UNPKG

@hasna/projects

Version:

High-level project management CLI, MCP server, SDK, and AI SDK agent loop for coding agents

85 lines • 5.3 kB
import { type ProjectRelation, type ProjectRelationKind, type ProjectRelationRow, type ProjectRelationSnapshot, type ProjectRelationView, type Workspace } from "../types/workspace.js"; export { PROJECT_RELATION_DEFAULT_MAX_ITEMS } from "../types/workspace.js"; /** `prr_` — the Projects-owned project-relation identity, sibling of `prl_`. */ export declare const PROJECT_RELATION_ID_PREFIX = "prr_"; /** * The ordered pair is the relation's identity: `(from, to)` hashes to one * stable `prr_` id, and the *declared relation* is that identity's value. * * This is the whole point of the chosen contract (A27-00022 Option A): changing * `related_to` to `parent_of` supersedes the pair's row, it does not mint a new * identifier. An id that moved when a user changed a word would dangle every * receipt, readback and reference taken before the change. The declared * `relation` is deliberately absent from this digest input, so the first and * every later version of the same ordered pair share one id. */ export declare function projectRelationId(fromProjectId: string, toProjectId: string): string; /** * Every relation endpoint must be a complete stable **Projects** identity. * * This is the C05 form rule applied to the relation's own endpoints: a Files * `prj_…` project reference, a Todos project id, a UUID from another authority, * a slug, a path or a name is refused by name, with the accepted form stated. * The failure is a local named refusal, never a not-found from a store lookup. */ export declare function assertProjectRelationEndpointId(value: string, label: string): string; export declare function normalizeProjectRelationKind(value: unknown, label?: string): ProjectRelationKind; export declare function projectRelationIsAcyclicKind(relation: ProjectRelationKind): boolean; /** A relation from a project to itself is refused before any store lookup. */ export declare function assertProjectRelationNotSelf(fromProjectId: string, toProjectId: string): void; /** * Both endpoints of a relation must resolve in the same tenant and must be * active. Tenancy in this registry is the store itself — every row a relation * can name is a `workspaces` row of the same database, which the foreign key * and this explicit resolution both enforce — so the check that can actually * fail is a missing, archived or deleted endpoint, and each one is named. */ export declare function assertProjectRelationEndpointActive(workspace: Workspace | null, label: string, projectId: string): Workspace; export declare function rowToProjectRelation(row: ProjectRelationRow): ProjectRelation; export interface ProjectRelationCounterpart { slug: string | null; name: string | null; status: string | null; } /** * Fold stored relations into the reading project's own two-sided view. A * relation is returned once from each side: `outbound` for the side that * declares it and `inbound` for the counterpart, with the relation kind in the * vocabulary both sides spell the same way (`related_to` reads identically in * both directions; `parent_of`/`depends_on` keep their declared direction). */ export declare function projectRelationViews(relations: readonly ProjectRelation[], selfProjectId: string, counterparts?: ReadonlyMap<string, ProjectRelationCounterpart>): ProjectRelationView[]; export declare function projectRelationViewKey(view: ProjectRelationView): string; /** * The digest of one project's complete two-sided relation view. It covers the * view (identity, direction, kind, version, counterpart), so a `supersede` * moves it and a re-read of an unchanged collection reproduces it byte for * byte. */ export declare function projectRelationsDigest(views: readonly ProjectRelationView[]): string; export declare function projectRelationSnapshot(project: Workspace, relations: ProjectRelationView[]): ProjectRelationSnapshot; export interface ProjectRelationEdge { from_project_id: string; to_project_id: string; relation: ProjectRelationKind; } /** * Refuse a relation that would close a cycle in the hierarchy. * * `parent_of` and `depends_on` are the two hierarchical kinds and they share ONE * graph: a mixed loop (`A parent_of B`, `B depends_on C`, `C parent_of A`) is a * hierarchy that contradicts itself, so it is refused exactly like a loop within * a single kind. `related_to` is a semantically free association, is never an * edge of this graph, and is therefore exempt. * * There is no "edge being replaced" parameter, and that is a property of the * walk rather than an omission: a supersede is judged in the graph with its own * head already removed, and the head is an edge out of `from`. The walk starts at * `to` and stops the first time it reaches `from`, so no simple path it can find * ever traverses an edge out of `from` — the replaced head cannot affect the * verdict. */ export declare function assertProjectRelationAcyclic(existing: readonly ProjectRelationEdge[], candidate: ProjectRelationEdge): void; /** The reachable path from `start` to `target` in a directed adjacency map, or null. */ export declare function findProjectRelationPath(adjacency: ReadonlyMap<string, readonly string[]>, start: string, target: string): string[] | null; //# sourceMappingURL=project-relations.d.ts.map