Download packages/knowledge-fabric/src/ConsolidationService.ts from AnthropicallyHuggingFaces/ProjectOS: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/ProjectOS/resolve/main/packages/knowledge-fabric/src/ConsolidationService.ts
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/ProjectOS/packages/knowledge-fabric/src/ConsolidationService.ts
-
curl -L -o ConsolidationService.ts https://huggingface.co/spaces/AnthropicallyHuggingFaces/ProjectOS/resolve/main/packages/knowledge-fabric/src/ConsolidationService.ts
1.57 kB
| import type { DatabaseSync } from 'node:sqlite'; | |
| import { CanonService } from './CanonService.js'; | |
| import { FrontierService } from './FrontierService.js'; | |
| export type ConsolidationInput = { | |
| projectId: string; | |
| title: string; | |
| body: string; | |
| sourceEntryIds: string[]; | |
| createdBy?: string; | |
| }; | |
| export class ConsolidationService { | |
| private readonly canon: CanonService; | |
| private readonly frontier: FrontierService; | |
| constructor(db: DatabaseSync) { | |
| this.canon = new CanonService(db); | |
| this.frontier = new FrontierService(db); | |
| } | |
| prepare(input: ConsolidationInput) { | |
| const title = input.title.trim(); | |
| const body = input.body.trim(); | |
| const sourceEntryIds = [...new Set(input.sourceEntryIds)]; | |
| if (!title || !body) throw new Error('A consolidation needs a title and reviewed content.'); | |
| if (!sourceEntryIds.length) throw new Error('A consolidation needs at least one source canon entry.'); | |
| const sources = sourceEntryIds.map((id) => this.canon.get(id)); | |
| if (sources.some((entry) => !entry || entry.status !== 'active' || entry.projectId !== input.projectId)) { | |
| throw new Error('Every consolidation source must be an active canon entry in the same project.'); | |
| } | |
| return this.frontier.create({ | |
| projectId: input.projectId, | |
| domain: 'knowledge-consolidation', | |
| itemType: 'research', | |
| title, | |
| description: body, | |
| rationale: 'Prepared from reviewed canon sources; pending logic and governance review.', | |
| metadata: { sourceEntryIds, createdBy: input.createdBy ?? null } | |
| }); | |
| } | |
| } | |