Files
zopu-code/packages/backend/convex/artifactModel.ts
-Puter 224e98d0bc feat: add Convex project backend with generic storage and org-scoped authz
Schema:
- Cut projects table to {organizationId, name, description, createdAt, updatedAt}
- Add projectSources table with git source metadata and normalized URL index
- Add projectContextDocuments table with six canonical kinds, origin, revision
- Add by_organizationId index for project enumeration
- Remove all GitHub-specific fields (ownerId, provider, repoOwner, etc.)

Backend:
- Add requireCurrentOrganization and requireProjectMember authz helpers
- Migrate signals.ts authorizeProject to organizationId invariant check
- Update artifactModel: 8 operational artifacts (removed project/business/design.md)
- Add projectStore.ts with query/mutation/action store adapters
- Rewrite projects.ts to thin generic application calls
- Update projectIssues/projectArtifacts to use requireProjectMember
- Update projectEvents.test.ts and signals.test.ts for new project creation

All 33 backend tests pass.
2026-07-23 18:16:41 +05:30

72 lines
2.8 KiB
TypeScript

import { v } from "convex/values";
export const ARTIFACT_PATHS = [
"agent.md",
"work.md",
"steps.md",
"artifacts.md",
"signals.md",
"agent-manager.md",
"context.md",
"card.md",
] as const;
export type ArtifactPath = (typeof ARTIFACT_PATHS)[number];
export const artifactPath = v.union(
v.literal("agent.md"),
v.literal("work.md"),
v.literal("steps.md"),
v.literal("artifacts.md"),
v.literal("signals.md"),
v.literal("agent-manager.md"),
v.literal("context.md"),
v.literal("card.md")
);
export const createInitialArtifacts = (): readonly {
path: ArtifactPath;
content: string;
}[] => [
{
content:
"# Agent\n\n## Role\n\nOwn one project issue at a time. Read the project artifacts before editing code, ask a focused question when blocked, and support completion claims with command output.\n\n## Guardrails\n\n- Keep issue work isolated in its AgentOS workspace.\n- Update work.md, steps.md, artifacts.md, and context.md as facts change.\n- Never mark work complete without a relevant runtime check.\n",
path: "agent.md",
},
{
content:
"# Work\n\nNo issue has entered the agent queue yet. New issues are appended here by the control plane.\n",
path: "work.md",
},
{
content:
"# Steps\n\n1. Read the issue and project artifacts.\n2. Inspect the repository context.\n3. Ask for missing decisions only when work cannot continue safely.\n4. Implement the smallest complete change.\n5. Run the relevant command or scenario.\n6. Publish changed artifacts and the final signal.\n",
path: "steps.md",
},
{
content:
"# Artifacts\n\nThis file indexes concrete outputs from issue runs, including changed paths, command results, and preview links.\n",
path: "artifacts.md",
},
{
content:
"# Project events\n\nThe agent manager emits `issue.queued`, `agent.started`, `agent.needs-input`, `agent.completed`, and `agent.failed`. These are durable project events and drive the web status.\n",
path: "signals.md",
},
{
content:
"# Agent manager\n\n## State machine\n\n`open -> queued -> working -> completed`\n\nA blocked run moves from `working` to `needs-input`; a resumed run returns to `queued`. An unrecoverable run moves to `failed`.\n\nEach issue owns one Flue agent identity and one AgentOS actor key, so conversation and workspace state remain isolated.\n",
path: "agent-manager.md",
},
{
content:
"# Context\n\nCanonical project knowledge is staged under /workspace/context. Issue-specific facts belong below.\n",
path: "context.md",
},
{
content:
"# Project card\n\nThe web project workspace reads and writes Projects, context documents, artifacts, and issues through the generated Convex interface. Agent work uses the issue-scoped workspace and durable daemon commands.\n",
path: "card.md",
},
];