mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-06 05:49:12 +02:00
* fix(projects): add resource_count breadcrumb to project responses Closes #2087 `multica project get` previously returned project metadata with no signal that resources existed. Agents that fetched a project this way had no way to discover its attached resources without already knowing about `/api/projects/{id}/resources` or the on-disk `.multica/project/resources.json`. Rather than inline the full resource list into the parent payload (which conflates parent metadata with a child sub-collection and locks the resource_ref shape into the project endpoint's contract), this adds a scalar `resource_count` breadcrumb to ProjectResponse. The actual list stays at the dedicated sub-collection endpoint. Changes: - GetProjectResourceCounts :many — new batched sqlc query - ProjectResponse.ResourceCount populated in GetProject, ListProjects, SearchProjects, and the with-resources CreateProject echo - multica project get prints a stderr hint pointing at multica project resource list <id> when count > 0; the JSON on stdout stays parseable - Meta-skill (runtime_config.go) lists multica project get and multica project resource list in Available Commands so agents that read CLAUDE.md / AGENTS.md know about both paths Co-authored-by: multica-agent <github@multica.ai> * fix(projects): wire ResourceCount through Update + Create event payload Review feedback on #2118. - UpdateProject now reloads ResourceCount before responding/publishing. Previously a title- or status-only PUT served (and broadcast over WS) resource_count: 0 even when resources existed. - The with-resources CreateProject path sets resp.ResourceCount before the project:created publish, so the WS event payload matches the HTTP echo. The hand-rolled response map collapses to an embedded ProjectResponse + resources array — one source of truth for the serialized shape. - packages/core/types/project.ts: Project gains resource_count: number to keep the TS contract aligned with the server response. Tests: - TestProjectResourceCountBreadcrumb extends to assert UpdateProject preserves the breadcrumb. - TestCreateProjectWithResourcesEchoesCount asserts the create echo carries resource_count matching the attached resources. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: multica-agent <github@multica.ai>
37 lines
1.1 KiB
SQL
37 lines
1.1 KiB
SQL
-- name: ListProjectResources :many
|
|
SELECT * FROM project_resource
|
|
WHERE project_id = $1
|
|
ORDER BY position ASC, created_at ASC;
|
|
|
|
-- name: ListProjectResourcesForProjects :many
|
|
SELECT * FROM project_resource
|
|
WHERE project_id = ANY(sqlc.arg('project_ids')::uuid[])
|
|
ORDER BY project_id, position ASC, created_at ASC;
|
|
|
|
-- name: GetProjectResource :one
|
|
SELECT * FROM project_resource
|
|
WHERE id = $1;
|
|
|
|
-- name: GetProjectResourceInWorkspace :one
|
|
SELECT * FROM project_resource
|
|
WHERE id = $1 AND workspace_id = $2;
|
|
|
|
-- name: CreateProjectResource :one
|
|
INSERT INTO project_resource (
|
|
project_id, workspace_id, resource_type, resource_ref, label, position, created_by
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7
|
|
) RETURNING *;
|
|
|
|
-- name: DeleteProjectResource :exec
|
|
DELETE FROM project_resource WHERE id = $1;
|
|
|
|
-- name: CountProjectResources :one
|
|
SELECT count(*) FROM project_resource WHERE project_id = $1;
|
|
|
|
-- name: GetProjectResourceCounts :many
|
|
SELECT project_id, count(*)::bigint AS resource_count
|
|
FROM project_resource
|
|
WHERE project_id = ANY(sqlc.arg('project_ids')::uuid[])
|
|
GROUP BY project_id;
|