- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/init.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/init.ts?format=json
75 linesFirst import 89% · engine 8% · codex-capacity-chair 3%Last change codex-capacity-chair in version 143,
75 lines from 3 changes in 3 versions.
init0Start the project1// Create the project from its first files. Writes go through InitHost; today
2// the host is Project.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare4import { type AttrSet, buildBase, canonicalText, type ReadView } from "../../src/engine/index.ts";
6import { ProjectError } from "./project-error.ts";
engine25Read 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.Compare7import { configProblem, PROJECT_FILES, projectFileOf } from "./project-helpers.ts";
9import { clashInPaths } from "./spelling.ts";
10import { checkModes } from "./view-changes.ts";
12/** What creating the project needs from a Project. */
13export interface InitHost {
14 initialized(): boolean;
15 readonly whole: ProjectOptions["whole"];
16 wholeOut(
17 files: Readonly<Record<string, string | null>>,
18 blobs: Readonly<Record<string, string>>,
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare19 view: ReadView | undefined,
21 ): { files: Record<string, string | null>; blobs: Record<string, string> };
22 checkBlobs(blobs: unknown, files: object): Record<string, string>;
23 commit(entries: Entry[]): void;
24}
26/** Create the project from its first files. */
27export function init(
28 host: InitHost,
29 files: Readonly<Record<string, string>>,
30 time: number,
31 modes: Modes = {},
32 blobs: Readonly<Record<string, string>> = {},
33): { version: 0; skipped: string[] } {
34 if (host.initialized()) throw new ProjectError("already-initialized", "the project already exists");
35 if (typeof files !== "object" || files === null) throw new ProjectError("bad-request", "init needs {files}");
36 const clash = clashInPaths([...new Set([...Object.keys(files), ...Object.keys(blobs)])].toSorted());
37 if (clash) throw new ProjectError("bad-request", `init: ${clash} (#49)`);
engine25Read 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.Compare38 for (const name of PROJECT_FILES) {
39 const config = typeof files[name] === "string" ? configProblem(files[name]) : undefined;
40 if (config) throw new ProjectError("bad-request", `init: ${name} ${config}`);
41 }
43 // The project file being created says which paths are whole (#46).
engine25Read 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.Compare44 const config = projectFileOf(files)?.text;
46 files: Record<string, string>;
47 blobs: Record<string, string>;
48 });
49 }
50 const kept: Record<string, string> = {};
51 const attrs: AttrSet[] = [];
52 for (const [path, sha] of Object.entries(host.checkBlobs(blobs, files)).toSorted(([a], [b]) => (a < b ? -1 : 1))) {
53 attrs.push({ file: path, name: "blob", value: sha });
54 }
55 for (const path of Object.keys(files).toSorted()) {
56 checkPath(path);
57 const text = files[path];
58 if (typeof text !== "string") throw new ProjectError("bad-request", `${path}: file text must be a string`);
59 const canonical = canonicalText(text);
60 kept[path] = canonical;
61 // An empty file is kept by its exists attribute.
62 if (canonical === "" && typeof modes[path]?.link !== "string")
63 attrs.push({ file: path, name: "exists", value: "1" });
64 }
65 for (const path of Object.keys(checkModes(modes)).toSorted()) {
66 checkPath(path);
67 const m = modes[path]!;
68 if (m.exec === true) attrs.push({ file: path, name: "exec", value: "1" });
69 if (typeof m.link === "string") attrs.push({ file: path, name: "link", value: m.link });
70 }
71 const atom = buildBase(kept, { author: "init", message: "Start the project", time }, attrs);
72 const skipped: string[] = [];
73 host.commit([{ type: "init", atom, time }]);
74 return { version: 0, skipped };
75}