- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/switch-to.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/switch-to.ts?format=json
79 linesFirst import 94% · codex-capacity-chair 5% · rename 1%Last change codex-capacity-chair in version 143,
79 lines from 3 changes in 3 versions.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare1import { View } from "../../src/engine/index.ts";
3// SwitchHost; today the host is Project.
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare5import type { AtomId, Graph, ReadView } from "../../src/engine/index.ts";
7import { checkDraftName } from "./project-helpers.ts";
8import type { AgentState, Entry, SwitchAnswer, SyncAnswer } from "./project-types.ts";
9import { last, SHARED, type Space } from "./spaces.ts";
11/** What switching an agent's draft needs from a project. */
12export interface SwitchHost {
13 agent(name: string, entries: Entry[]): AgentState;
14 flush(entries: Entry[]): void;
15 readonly spaces: ReadonlyMap<string, Space>;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare16 agentView(agent: AgentState): ReadView;
18 version(): number;
19 apply(entry: Entry): void;
20 draft(agent: AgentState): readonly AtomId[];
21 setOf(space: Space): ReadonlySet<AtomId>;
codex-capacity-chair143Add inactive disk projection provider and verified transactional readers (#16)Compare22 changesSince(agent: AgentState, before: ReadView): SyncAnswer;
25/**
26 * Move the agent to a named draft, or back to shared with null. Its
27 * unpublished changes stay parked on the server in the space it leaves,
28 * and what it parked in the space it moves to comes back. Nothing is lost
29 * and nothing has to be published or stashed first. A new named draft
30 * starts on shared's newest version; with `carry`, the agent's current
31 * unpublished changes move into it instead of being parked. Answers like a
32 * sync: the files that change in its folder.
33 */
34export function switchTo(
35 host: SwitchHost,
36 agentName: string,
37 draftName: string | null,
38 time: number,
39 options: { carry?: boolean } = {},
40): SwitchAnswer {
41 const entries: Entry[] = [];
42 const agent = host.agent(agentName, entries);
43 const target = draftName === null ? SHARED : checkDraftName(draftName);
44 const carry = options.carry === true;
45 const name = target === SHARED ? null : target;
46 if (target === agent.space && !carry) {
47 host.flush(entries);
48 return { version: agent.base, files: {}, collisions: [], draft: name };
49 }
50 if (carry && host.spaces.has(target)) {
51 throw new ProjectError(
52 "bad-request",
53 `carrying changes starts a new named draft, and ${name ?? "shared"} already exists`,
54 );
55 }
56 const before = agent.synced ? host.agentView(agent) : new View(host.graph, []);
57 if (!host.spaces.has(target)) {
58 entries.push({ type: "space", name: target, agent: agent.name, time, sharedBase: host.version() });
59 host.apply(entries[entries.length - 1]!);
60 }
61 const space = host.spaces.get(target)!;
62 if (carry) {
63 const draft = host.draft(agent);
64 const into = new Set([...host.setOf(space), ...draft]);
65 for (const id of draft) {
66 if (host.graph.atom(id).deps.some((d) => !into.has(d))) {
67 throw new ProjectError(
68 "bad-request",
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing.
push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare69 `your unpushed changes build on changes that shared doesn't have yet (they're in draft ${agent.space}); push them there first, or switch without carrying`,
71 }
72 }
73 }
74 entries.push({ type: "switch", agent: agent.name, space: target, version: last(space), carry });
75 host.apply(entries[entries.length - 1]!);
76 const answer = host.changesSince(agent, before);
77 host.flush(entries);
78 return { ...answer, version: agent.base, draft: name };
79}