Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 153 to 318

Compare

+44 −41 in 3 places
Lines 20–27 at 318 (were 20–26 at 153)
2020// that defines it (project.ts, #definitionCore).
2121
2222import type { LineId, ReadView } from "../../src/engine/index.ts";
23−import { codeOfLines, holdsNoCode, isCommonName } from "./names.ts";
23+import { withDefinitionCode } from "./definition-code.ts";
24+import { holdsNoCode, isCommonName } from "./names.ts";
2425
2526export interface Definition {
2627 readonly name: string;
Lines 122–149 at 318 (were 121–147 at 153)
121122function definitionsInFile(view: ReadView, file: string, keepCommon = false): Definition[] {
122123 if (holdsNoCode(file) || !view.hasFile(file)) return [];
123124 const out: Definition[] = [];
124− const visible = view.lines(file);
125− const code = codeOfLines(visible.map((l) => l.text));
126− for (let i = 0; i < code.length; i++) {
127− // Only top-level declarations: what another file can import. Locals,
128− // parameters and methods are indented.
129− if (/^\s/.test(code[i]!)) continue;
130− const found = defineAt(code, i);
131− if (!found || (!keepCommon && (found.name.length < 3 || isCommonName(found.name)))) continue;
132− out.push({
133− name: found.name,
134− file,
135− start: i,
136− end: found.end,
137− lines: visible.slice(i, found.end).map((l) => l.id),
138− text: visible
139− .slice(i, found.end)
140− .map((l) => l.text)
141− .join("\n"),
142− });
143− }
144− return out;
125+ const visible = view.buildLines(file);
126+ return withDefinitionCode(view, visible, (code) => {
127+ for (let i = 0; i < code.length; i++) {
128+ // Only top-level declarations: what another file can import. Locals,
129+ // parameters and methods are indented.
130+ if (/^\s/.test(code[i]!)) continue;
131+ const found = defineAt(code, i);
132+ if (!found || (!keepCommon && (found.name.length < 3 || isCommonName(found.name)))) continue;
133+ out.push({
134+ name: found.name,
135+ file,
136+ start: i,
137+ end: found.end,
138+ lines: visible.slice(i, found.end).map((l) => l.id),
139+ text: visible
140+ .slice(i, found.end)
141+ .map((l) => l.text)
142+ .join("\n"),
143+ });
144+ }
145+ return out;
146+ });
145147}
146148
147149/**
Lines 157–182 at 318 (were 155–179 at 153)
155157 const count = new Map<string, number>();
156158 for (const d of all) count.set(d.name, (count.get(d.name) ?? 0) + 1);
157159 if (![...count.values()].some((n) => n > 1)) return out;
158− const visible = view.lines(file);
159− const code = codeOfLines(visible.map((l) => l.text));
160− for (const d of all) {
161− if (count.get(d.name)! < 2) continue;
162− const end = Math.max(d.end, wholeBlockEnd(code, d.start));
163− const whole: Definition = {
164− ...d,
165− end,
166− lines: visible.slice(d.start, end).map((l) => l.id),
167− text: visible
168− .slice(d.start, end)
169− .map((l) => l.text)
170− .join("\n"),
171− };
172− const list = out.get(d.name);
173− if (list) list.push(whole);
174− else out.set(d.name, [whole]);
175− }
176− return out;
160+ const visible = view.buildLines(file);
161+ return withDefinitionCode(view, visible, (code) => {
162+ for (const d of all) {
163+ if (count.get(d.name)! < 2) continue;
164+ const end = Math.max(d.end, wholeBlockEnd(code, d.start));
165+ const whole: Definition = {
166+ ...d,
167+ end,
168+ lines: visible.slice(d.start, end).map((l) => l.id),
169+ text: visible
170+ .slice(d.start, end)
171+ .map((l) => l.text)
172+ .join("\n"),
173+ };
174+ const list = out.get(d.name);
175+ if (list) list.push(whole);
176+ else out.set(d.name, [whole]);
177+ }
178+ return out;
179+ });
177180}
178181
179182/**
MCP
compare on this site's /mcp
CLI
abso diff 153 318 worker/project/definitions.ts --json
JSON
/christopher/abso-core/compare/153..318?file=worker%2Fproject%2Fdefinitions.ts&format=json