{"file":"worker/project/init.ts","version":318,"total":75,"from":1,"to":75,"lines":[{"n":1,"text":"// Create the project from its first files. Writes go through InitHost; today","atom":"a0","author":"init","version":0},{"n":2,"text":"// the host is Project.","atom":"a0","author":"init","version":0},{"n":3,"text":"","atom":"a0","author":"init","version":0},{"n":4,"text":"import { type AttrSet, buildBase, canonicalText, type ReadView } from \"../../src/engine/index.ts\";","atom":"a1340","author":"codex-capacity-chair","version":143},{"n":5,"text":"import { checkPath } from \"./path-rules.ts\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { ProjectError } from \"./project-error.ts\";","atom":"a0","author":"init","version":0},{"n":7,"text":"import { configProblem, PROJECT_FILES, projectFileOf } from \"./project-helpers.ts\";","atom":"a178","author":"engine","version":25},{"n":8,"text":"import type { Entry, Modes, ProjectOptions } from \"./project-types.ts\";","atom":"a0","author":"init","version":0},{"n":9,"text":"import { clashInPaths } from \"./spelling.ts\";","atom":"a0","author":"init","version":0},{"n":10,"text":"import { checkModes } from \"./view-changes.ts\";","atom":"a0","author":"init","version":0},{"n":11,"text":"","atom":"a0","author":"init","version":0},{"n":12,"text":"/** What creating the project needs from a Project. */","atom":"a0","author":"init","version":0},{"n":13,"text":"export interface InitHost {","atom":"a0","author":"init","version":0},{"n":14,"text":"\tinitialized(): boolean;","atom":"a0","author":"init","version":0},{"n":15,"text":"\treadonly whole: ProjectOptions[\"whole\"];","atom":"a0","author":"init","version":0},{"n":16,"text":"\twholeOut(","atom":"a0","author":"init","version":0},{"n":17,"text":"\t\tfiles: Readonly<Record<string, string | null>>,","atom":"a0","author":"init","version":0},{"n":18,"text":"\t\tblobs: Readonly<Record<string, string>>,","atom":"a0","author":"init","version":0},{"n":19,"text":"\t\tview: ReadView | undefined,","atom":"a1340","author":"codex-capacity-chair","version":143},{"n":20,"text":"\t\tconfig?: string,","atom":"a0","author":"init","version":0},{"n":21,"text":"\t): { files: Record<string, string | null>; blobs: Record<string, string> };","atom":"a0","author":"init","version":0},{"n":22,"text":"\tcheckBlobs(blobs: unknown, files: object): Record<string, string>;","atom":"a0","author":"init","version":0},{"n":23,"text":"\tcommit(entries: Entry[]): void;","atom":"a0","author":"init","version":0},{"n":24,"text":"}","atom":"a0","author":"init","version":0},{"n":25,"text":"","atom":"a0","author":"init","version":0},{"n":26,"text":"/** Create the project from its first files. */","atom":"a0","author":"init","version":0},{"n":27,"text":"export function init(","atom":"a0","author":"init","version":0},{"n":28,"text":"\thost: InitHost,","atom":"a0","author":"init","version":0},{"n":29,"text":"\tfiles: Readonly<Record<string, string>>,","atom":"a0","author":"init","version":0},{"n":30,"text":"\ttime: number,","atom":"a0","author":"init","version":0},{"n":31,"text":"\tmodes: Modes = {},","atom":"a0","author":"init","version":0},{"n":32,"text":"\tblobs: Readonly<Record<string, string>> = {},","atom":"a0","author":"init","version":0},{"n":33,"text":"): { version: 0; skipped: string[] } {","atom":"a0","author":"init","version":0},{"n":34,"text":"\tif (host.initialized()) throw new ProjectError(\"already-initialized\", \"the project already exists\");","atom":"a0","author":"init","version":0},{"n":35,"text":"\tif (typeof files !== \"object\" || files === null) throw new ProjectError(\"bad-request\", \"init needs {files}\");","atom":"a0","author":"init","version":0},{"n":36,"text":"\tconst clash = clashInPaths([...new Set([...Object.keys(files), ...Object.keys(blobs)])].toSorted());","atom":"a0","author":"init","version":0},{"n":37,"text":"\tif (clash) throw new ProjectError(\"bad-request\", `init: ${clash} (#49)`);","atom":"a0","author":"init","version":0},{"n":38,"text":"\tfor (const name of PROJECT_FILES) {","atom":"a178","author":"engine","version":25},{"n":39,"text":"\t\tconst config = typeof files[name] === \"string\" ? configProblem(files[name]) : undefined;","atom":"a178","author":"engine","version":25},{"n":40,"text":"\t\tif (config) throw new ProjectError(\"bad-request\", `init: ${name} ${config}`);","atom":"a178","author":"engine","version":25},{"n":41,"text":"\t}","atom":"a178","author":"engine","version":25},{"n":42,"text":"\tif (host.whole) {","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\t// The project file being created says which paths are whole (#46).","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\tconst config = projectFileOf(files)?.text;","atom":"a178","author":"engine","version":25},{"n":45,"text":"\t\t({ files, blobs } = host.wholeOut(files, blobs, undefined, config) as {","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t\tfiles: Record<string, string>;","atom":"a0","author":"init","version":0},{"n":47,"text":"\t\t\tblobs: Record<string, string>;","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\t});","atom":"a0","author":"init","version":0},{"n":49,"text":"\t}","atom":"a0","author":"init","version":0},{"n":50,"text":"\tconst kept: Record<string, string> = {};","atom":"a0","author":"init","version":0},{"n":51,"text":"\tconst attrs: AttrSet[] = [];","atom":"a0","author":"init","version":0},{"n":52,"text":"\tfor (const [path, sha] of Object.entries(host.checkBlobs(blobs, files)).toSorted(([a], [b]) => (a < b ? -1 : 1))) {","atom":"a0","author":"init","version":0},{"n":53,"text":"\t\tattrs.push({ file: path, name: \"blob\", value: sha });","atom":"a0","author":"init","version":0},{"n":54,"text":"\t}","atom":"a0","author":"init","version":0},{"n":55,"text":"\tfor (const path of Object.keys(files).toSorted()) {","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\tcheckPath(path);","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\tconst text = files[path];","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\tif (typeof text !== \"string\") throw new ProjectError(\"bad-request\", `${path}: file text must be a string`);","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\tconst canonical = canonicalText(text);","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\tkept[path] = canonical;","atom":"a0","author":"init","version":0},{"n":61,"text":"\t\t// An empty file is kept by its exists attribute.","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\tif (canonical === \"\" && typeof modes[path]?.link !== \"string\")","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t\tattrs.push({ file: path, name: \"exists\", value: \"1\" });","atom":"a0","author":"init","version":0},{"n":64,"text":"\t}","atom":"a0","author":"init","version":0},{"n":65,"text":"\tfor (const path of Object.keys(checkModes(modes)).toSorted()) {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\tcheckPath(path);","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\tconst m = modes[path]!;","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\tif (m.exec === true) attrs.push({ file: path, name: \"exec\", value: \"1\" });","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\tif (typeof m.link === \"string\") attrs.push({ file: path, name: \"link\", value: m.link });","atom":"a0","author":"init","version":0},{"n":70,"text":"\t}","atom":"a0","author":"init","version":0},{"n":71,"text":"\tconst atom = buildBase(kept, { author: \"init\", message: \"Start the project\", time }, attrs);","atom":"a0","author":"init","version":0},{"n":72,"text":"\tconst skipped: string[] = [];","atom":"a0","author":"init","version":0},{"n":73,"text":"\thost.commit([{ type: \"init\", atom, time }]);","atom":"a0","author":"init","version":0},{"n":74,"text":"\treturn { version: 0, skipped };","atom":"a0","author":"init","version":0},{"n":75,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a178","author":"engine","message":"","time":1791531853932,"timeIso":"2026-10-09T07:44:13.932Z","publish":{"draft":null,"version":25,"agent":"engine","message":"Read abso.json first, then avcs.json (abso 224, ask 238): one helper (projectFileIn) for the queue, files kept whole, reviewers and init; publish, init and git intake check both files the same way; when shared has both, abso.json counts and status says avcs.json is ignored (status answer projectFile, printed by abso status). .abso/ is kept out of projects like .avcs/. Old projects with only avcs.json work as before.","time":1791531874263,"timeIso":"2026-10-09T07:44:34.263Z"}},{"atom":"a1340","author":"codex-capacity-chair","message":"","time":1791854964720,"timeIso":"2026-10-13T01:29:24.720Z","publish":{"draft":null,"version":143,"agent":"codex-capacity-chair","message":"Add inactive disk projection provider and verified transactional readers (#16)","time":1791855032023,"timeIso":"2026-10-13T01:30:32.023Z"}}]}