@agentshouse/kit 0.2.1-ccffb3f637815 → 0.2.1-cd423aab3dbcc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/scripts.js CHANGED
@@ -5,6 +5,7 @@ import { rmSync } from 'node:fs';
5
5
  import { mkdir, rm, writeFile } from 'node:fs/promises';
6
6
  import { constants } from 'node:os';
7
7
  import { join } from 'node:path';
8
+ import { openRunBridge } from './bridge.js';
8
9
  import { loginPath, onLoginPath } from './clis.js';
9
10
  import { kitHome } from './home.js';
10
11
  import { childEnvironment } from './relay.js';
@@ -133,10 +134,14 @@ class KeptOutput {
133
134
  export class Scripts {
134
135
  calls;
135
136
  send;
137
+ house;
138
+ copies;
136
139
  runs = new Map();
137
- constructor(calls, send) {
140
+ constructor(calls, send, house, copies) {
138
141
  this.calls = calls;
139
142
  this.send = send;
143
+ this.house = house;
144
+ this.copies = copies;
140
145
  }
141
146
  start(call) {
142
147
  void this.calls.carry(call.input_id, () => this.run(call.input_id, planned(call)));
@@ -178,6 +183,8 @@ export class Scripts {
178
183
  const run = {
179
184
  plan,
180
185
  input: null,
186
+ bridge: null,
187
+ closed: new AbortController(),
181
188
  output,
182
189
  process: null,
183
190
  pipes: [],
@@ -197,6 +204,7 @@ export class Scripts {
197
204
  }
198
205
  finally {
199
206
  this.runs.delete(id);
207
+ run.bridge?.close();
200
208
  if (run.input !== null)
201
209
  await rm(run.input, { force: true });
202
210
  }
@@ -211,11 +219,18 @@ export class Scripts {
211
219
  return failed(plan, NO_BASH);
212
220
  const path = await loginPath();
213
221
  await run.sized.promise;
214
- if (plan.function !== null)
222
+ if (plan.function !== null) {
215
223
  run.input = await inputFile(plan.function.input);
224
+ run.bridge = await openRunBridge(this.house, this.copies, id, run.closed.signal);
225
+ }
216
226
  if (run.ended !== null)
217
227
  return run.ended;
218
- const environment = { ...childEnvironment(), PATH: path, ...(run.input === null ? {} : { HOUSE_INPUT: run.input }) };
228
+ const environment = {
229
+ ...childEnvironment(),
230
+ ...run.bridge?.env,
231
+ PATH: path,
232
+ ...(run.input === null ? {} : { HOUSE_INPUT: run.input }),
233
+ };
219
234
  if (plan.terminal === null) {
220
235
  ({ exited } = await this.piped(plan.script, shell, environment, run));
221
236
  }
@@ -234,7 +249,7 @@ export class Scripts {
234
249
  }
235
250
  }
236
251
  catch (error) {
237
- return failed(plan, causeOf(error));
252
+ return run.ended ?? failed(plan, causeOf(error));
238
253
  }
239
254
  let timedOut = false;
240
255
  // House sends a function run's time cap in seconds, and a run still going at its cap ends with its process group and the output pipes it holds.
@@ -285,6 +300,7 @@ export class Scripts {
285
300
  return;
286
301
  this.waited(run, null);
287
302
  run.ended = result;
303
+ run.closed.abort();
288
304
  run.sized.resolve();
289
305
  this.stop(run);
290
306
  }
package/dist/settings.js CHANGED
@@ -2,21 +2,27 @@ import { constants } from 'node:fs';
2
2
  import { access, mkdir, readdir, rm, stat } from 'node:fs/promises';
3
3
  import { dirname, isAbsolute, join, resolve } from 'node:path';
4
4
  import { house } from './api.js';
5
- import { earlierPrefix, enrolled, kitHome, readDisconnected, oneFolder, readConfiguration, readEnrolment, readHome, storedConfiguration, workspaceRoot, writeConfiguration, writeHome, } from './home.js';
5
+ import { KIT_RELEASE } from './clis.js';
6
+ import { LocalCopies } from './copies.js';
7
+ import { earlierPrefix, enrolled, houseFolder, kitHome, readDisconnected, oneFolder, readConfiguration, readEnrolment, readHome, storedConfiguration, workspaceRoot, writeConfiguration, writeHome, } from './home.js';
6
8
  import { askOwner, holdOwner } from './owner.js';
7
9
  import { placeSkillSet } from './skills.js';
8
10
  import { followRoot, merged, present, within } from './workspace.js';
9
- const FOLDERS = ['agents', 'local-copies'];
11
+ const FOLDERS = ['agents', 'rooms'];
10
12
  const RECORDS = join('local-copies', 'rooms');
11
13
  const MOVE = 'workspace-move.json';
12
14
  const WORKING = 'an Agent is working; change the workspace once its turn ends';
13
- const LOGGED_OUT = "Kit is logged out, so it cannot tell which Agents' folders their owners chose; run kit login, then change its workspace";
15
+ const UNCHOSEN = "Kit is logged out, so it cannot tell which Agents' folders their owners chose";
16
+ const LOGGED_OUT = `${UNCHOSEN}; run kit login, then change its workspace`;
14
17
  export const SETTINGS_USAGE = 'usage: kit settings [skills on|off | workspace <absolute path>]';
15
18
  export async function enrolledRoutes() {
16
19
  if (enrolled())
17
20
  return (await house.act('agents/desired/list', {})).routes;
18
21
  return (await readDisconnected()) === null ? [] : null;
19
22
  }
23
+ export async function launchDirectories() {
24
+ return ((await enrolledRoutes()) ?? []).map(({ working_directory }) => resolve(working_directory));
25
+ }
20
26
  const IDLE = { working: () => false, end: () => undefined, routes: enrolledRoutes };
21
27
  export async function heldSettings() {
22
28
  return { skills: (await readConfiguration()).skills, workspace: workspaceRoot() };
@@ -25,23 +31,15 @@ function records() {
25
31
  return join(kitHome(), RECORDS);
26
32
  }
27
33
  function placing(kept) {
28
- return (source, entry) => {
29
- if ((dirname(source) === records() && entry.isFile()) || kept.includes(source))
34
+ return (source) => {
35
+ if (kept.includes(source))
30
36
  return 'stays';
31
- return [records(), ...kept].some((folder) => within(folder, source)) ? 'opens' : 'moves';
37
+ return kept.some((folder) => within(folder, source)) ? 'opens' : 'moves';
32
38
  };
33
39
  }
34
40
  function causeOf(error) {
35
41
  return error instanceof Error ? error.message : String(error);
36
42
  }
37
- async function recordsOnly(folder) {
38
- const entries = await readdir(folder);
39
- if (entries.some((name) => name !== 'rooms'))
40
- return false;
41
- if (entries.length === 0)
42
- return true;
43
- return (await readdir(join(folder, 'rooms'), { withFileTypes: true })).every((entry) => entry.isFile());
44
- }
45
43
  async function writable(root) {
46
44
  for (let at = root;; at = dirname(at)) {
47
45
  const found = await stat(at).catch((error) => {
@@ -68,8 +66,6 @@ async function refusedRoot(from, to) {
68
66
  const held = join(to, name);
69
67
  if ((await present(held)) === null)
70
68
  continue;
71
- if (name === 'local-copies' && to === kitHome() && (await recordsOnly(held)))
72
- continue;
73
69
  return `${to} already holds ${held}`;
74
70
  }
75
71
  return null;
@@ -113,6 +109,72 @@ export async function resumeWorkspaceMove() {
113
109
  if (failure !== null)
114
110
  process.stderr.write(`kit: the workspace could not be moved to ${move.to}: ${failure}\n`);
115
111
  }
112
+ export const HOUSE_NOT_KITS = `${houseFolder()} holds what is not Kit's; move it elsewhere, then run this command again`;
113
+ async function free(folder, from) {
114
+ if ((await present(folder)) !== null) {
115
+ const held = await stat(folder).catch(() => null);
116
+ if (held === null || !held.isDirectory() || (await readdir(folder)).length > 0)
117
+ return false;
118
+ }
119
+ return (await refusedRoot(from, folder)) === null;
120
+ }
121
+ async function earlierLayout(root) {
122
+ const copies = await readdir(join(root, RECORDS), { withFileTypes: true }).catch(() => []);
123
+ if (copies.some((entry) => entry.isDirectory() && !entry.name.startsWith('.')))
124
+ return true;
125
+ return root === kitHome() && (await present(join(root, 'agents'))) !== null && (await present(join(root, 'rooms'))) === null;
126
+ }
127
+ export async function houseRoot() {
128
+ if (await earlierLayout(kitHome()))
129
+ return kitHome();
130
+ return (await free(houseFolder(), kitHome())) ? houseFolder() : null;
131
+ }
132
+ function chosenFolders(routes, from) {
133
+ const agents = join(from, 'agents');
134
+ const roots = [agents, join(from, 'rooms'), join(from, RECORDS)];
135
+ return routes
136
+ .filter(({ agent_id, working_directory }) => resolve(working_directory) !== join(agents, agent_id))
137
+ .map(({ working_directory }) => resolve(working_directory))
138
+ .filter((folder) => roots.some((root) => folder.startsWith(`${root}/`)));
139
+ }
140
+ export async function moveIntoHouse(copies) {
141
+ if (earlierPrefix() !== null)
142
+ return null;
143
+ const stored = await storedConfiguration();
144
+ const from = stored.workspace ?? kitHome();
145
+ if (!(await earlierLayout(from))) {
146
+ if (stored.workspace !== undefined)
147
+ return null;
148
+ const root = await houseRoot();
149
+ if (root === null)
150
+ throw new Error(HOUSE_NOT_KITS);
151
+ await writeConfiguration({ ...stored, workspace: root });
152
+ return null;
153
+ }
154
+ if (stored.workspace === undefined)
155
+ await writeConfiguration({ ...stored, workspace: from });
156
+ const routes = await enrolledRoutes().catch((error) => {
157
+ process.stderr.write(`kit: the workspace stays at ${from} and moves at the next start: ${causeOf(error)}\n`);
158
+ return undefined;
159
+ });
160
+ if (routes === undefined)
161
+ return null;
162
+ if (routes === null) {
163
+ process.stderr.write(`kit: the workspace stays at ${from} and moves at the next start: ${UNCHOSEN}; run kit login\n`);
164
+ return null;
165
+ }
166
+ const chosen = chosenFolders(routes, from);
167
+ const to = from === kitHome() && (await free(houseFolder(), from)) ? houseFolder() : from;
168
+ const laid = await copies.laidOut(join(from, RECORDS), join(from, 'rooms'), chosen);
169
+ if (to === from)
170
+ return laid.moved ? `Kit ${KIT_RELEASE} laid out its workspace ${from}; its supervisor starts it again` : null;
171
+ const move = { from, to, kept: [...chosen, ...laid.kept] };
172
+ await writeHome(MOVE, move);
173
+ const failure = await finished(move);
174
+ if (failure === null)
175
+ return `Kit ${KIT_RELEASE} moved its workspace to ${to}; its supervisor starts it there`;
176
+ return `the workspace could not be moved to ${to}: ${failure}; it stays at ${from} and its supervisor starts Kit again`;
177
+ }
116
178
  async function changeSkills(on) {
117
179
  const stored = await storedConfiguration();
118
180
  await writeConfiguration({ ...stored, skills: on });
@@ -137,13 +199,7 @@ export async function applySettings(change, kit) {
137
199
  const routes = await kit.routes();
138
200
  if (routes === null)
139
201
  return { refused: LOGGED_OUT, ended: false };
140
- const agents = join(from, 'agents');
141
- const copies = join(from, 'local-copies');
142
- const kept = routes
143
- .filter(({ agent_id, working_directory }) => resolve(working_directory) !== join(agents, agent_id))
144
- .map(({ working_directory }) => resolve(working_directory))
145
- .filter((folder) => folder.startsWith(`${agents}/`) || folder.startsWith(`${copies}/`));
146
- move = { from, to, kept };
202
+ move = { from, to, kept: chosenFolders(routes, from) };
147
203
  }
148
204
  }
149
205
  if (move !== null) {
@@ -173,6 +229,9 @@ async function appliedHere(change) {
173
229
  const lock = await holdOwner();
174
230
  try {
175
231
  await resumeWorkspaceMove();
232
+ const copies = new LocalCopies(house, launchDirectories);
233
+ await copies.load();
234
+ await moveIntoHouse(copies);
176
235
  return await applySettings(change, IDLE);
177
236
  }
178
237
  finally {
package/dist/workspace.js CHANGED
@@ -18,7 +18,7 @@ async function listed(path) {
18
18
  }));
19
19
  return shown.sort();
20
20
  }
21
- async function moved(source, target) {
21
+ export async function moved(source, target) {
22
22
  try {
23
23
  await rename(source, target);
24
24
  return;
@@ -43,6 +43,13 @@ async function moved(source, target) {
43
43
  await rename(copy, target);
44
44
  await rm(source, { recursive: true, force: true });
45
45
  }
46
+ export async function keptName(path) {
47
+ for (let count = 1;; count++) {
48
+ const name = `${path} (kept)${count === 1 ? '' : ` ${count}`}`;
49
+ if ((await present(name)) === null)
50
+ return name;
51
+ }
52
+ }
46
53
  export async function merged(from, to, placed = () => 'moves') {
47
54
  const found = await present(from);
48
55
  if (found === null || !found.isDirectory())
@@ -86,6 +93,9 @@ function rewritten(value, from, to, kept) {
86
93
  }
87
94
  return value;
88
95
  }
96
+ export function rerooted(value, from, to) {
97
+ return rewritten(value, from, to, []);
98
+ }
89
99
  export async function followRoot(records, from, to, kept = []) {
90
100
  if (from === to)
91
101
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-ccffb3f637815",
3
+ "version": "0.2.1-cd423aab3dbcc",
4
4
  "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,10 +25,9 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@agentclientprotocol/sdk": "2.4.0",
28
- "@agentshouse/kit-wire": "0.1.0-caf9c7b612dda",
29
- "@agentshouse/mdmodel": "0.1.0-c420026daf4fc",
28
+ "@agentshouse/kit-wire": "0.1.0-ceea7707b3282",
30
29
  "@agentshouse/session-content": "0.1.0-c560e48c9bea3",
31
- "@agentshouse/skills": "0.1.0-cc1f045bb51fa",
30
+ "@agentshouse/skills": "0.1.0-cbfeca43f4f64",
32
31
  "@lydell/node-pty": "1.2.0-beta.15",
33
32
  "micromark": "4.0.2",
34
33
  "smol-toml": "1.9.1",
package/dist/git-main.js DELETED
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn, spawnSync } from 'node:child_process';
3
- import { accessSync, constants, mkdtempSync, realpathSync, rmSync, statSync } from 'node:fs';
4
- import { request } from 'node:http';
5
- import { constants as system } from 'node:os';
6
- import { delimiter, dirname, join } from 'node:path';
7
- import { localCopies } from './git.js';
8
- import { kitHome } from './home.js';
9
- const VALUED = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--attr-source', '--super-prefix']);
10
- const READS = new Set([
11
- 'blame',
12
- 'branch',
13
- 'cat-file',
14
- 'check-ignore',
15
- 'config',
16
- 'describe',
17
- 'diff',
18
- 'fetch',
19
- 'for-each-ref',
20
- 'grep',
21
- 'help',
22
- 'log',
23
- 'ls-files',
24
- 'ls-tree',
25
- 'reflog',
26
- 'remote',
27
- 'rev-list',
28
- 'rev-parse',
29
- 'shortlog',
30
- 'show',
31
- 'show-ref',
32
- 'status',
33
- 'tag',
34
- 'version',
35
- ]);
36
- const RELAYED = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT'];
37
- function nativeGit() {
38
- const shim = join(kitHome(), 'shim');
39
- for (const directory of (process.env.PATH ?? '').split(delimiter)) {
40
- if (directory === '')
41
- continue;
42
- try {
43
- if (realpathSync(directory) === realpathSync(shim))
44
- continue;
45
- const candidate = join(directory, 'git');
46
- if (!statSync(candidate).isFile())
47
- continue;
48
- accessSync(candidate, constants.X_OK);
49
- return candidate;
50
- }
51
- catch { }
52
- }
53
- return null;
54
- }
55
- function captured(git, args, { input, index } = {}) {
56
- const ran = spawnSync(git, args, {
57
- input,
58
- stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'ignore'],
59
- maxBuffer: Infinity,
60
- env: { ...process.env, LC_ALL: 'C', ...(index === undefined ? {} : { GIT_INDEX_FILE: index }) },
61
- });
62
- return ran.status === 0 ? ran.stdout.toString('utf8') : null;
63
- }
64
- function delegated(git, args) {
65
- return new Promise((resolve) => {
66
- const child = spawn(git, args, { stdio: 'inherit' });
67
- const relay = (signal) => child.kill(signal);
68
- for (const signal of RELAYED)
69
- process.on(signal, relay);
70
- const settle = (outcome) => {
71
- for (const signal of RELAYED)
72
- process.off(signal, relay);
73
- resolve(outcome);
74
- };
75
- child.once('error', (error) => {
76
- process.stderr.write(`git: ${error.message}\n`);
77
- settle({ status: 127, signal: null });
78
- });
79
- child.once('close', (status, signal) => settle({ status, signal }));
80
- });
81
- }
82
- function merged(git, copy, common) {
83
- const staged = (captured(git, [...copy, 'ls-files', '--stage', '-z']) ?? '').split('\0');
84
- const input = staged.filter((entry) => /^\d+ [0-9a-f]+ 0\t/.test(entry)).map((entry) => `${entry}\0`).join('');
85
- const scratch = mkdtempSync(join(common, 'house-index-'));
86
- try {
87
- const index = join(scratch, 'index');
88
- captured(git, [...copy, 'update-index', '-z', '--index-info'], { input, index });
89
- return captured(git, [...copy, 'write-tree'], { index })?.trim();
90
- }
91
- finally {
92
- rmSync(scratch, { recursive: true, force: true });
93
- }
94
- }
95
- function moved(git, copy, before) {
96
- const renames = ['diff-index', '--cached', '-z', '--name-status', '--find-renames=100%', '--diff-filter=R', before];
97
- const fields = (captured(git, [...copy, ...renames]) ?? '').split('\0');
98
- const moves = [];
99
- for (let at = 0; at + 2 < fields.length; at += 3)
100
- moves.push({ from: fields[at + 1], to: fields[at + 2] });
101
- return moves;
102
- }
103
- function reported(socketPath, body) {
104
- return new Promise((resolve) => {
105
- const sent = request({ socketPath, path: '/git/observed', method: 'POST' }, (answer) => {
106
- answer.resume();
107
- answer.on('end', resolve);
108
- });
109
- sent.on('error', () => resolve());
110
- sent.end(JSON.stringify(body));
111
- });
112
- }
113
- async function observed(git, args) {
114
- let index = 0;
115
- while (index < args.length && args[index].startsWith('-'))
116
- index += VALUED.has(args[index]) ? 2 : 1;
117
- const globals = args.slice(0, index);
118
- const name = args[index];
119
- const bridge = process.env.HOUSE_BRIDGE;
120
- if (bridge === undefined || name === undefined || READS.has(name))
121
- return delegated(git, args);
122
- const located = captured(git, [...globals, 'rev-parse', '--path-format=absolute', '--git-common-dir', '--show-toplevel']);
123
- const [common, worktree] = located?.split('\n') ?? [];
124
- if (common === undefined || worktree === undefined || !dirname(common).startsWith(`${localCopies()}/`)) {
125
- return delegated(git, args);
126
- }
127
- const copy = [...globals, '-C', worktree];
128
- const before = name === 'mv' ? merged(git, copy, common) : undefined;
129
- const outcome = await delegated(git, args);
130
- const moves = before !== undefined && outcome.status === 0 ? moved(git, copy, before) : [];
131
- await reported(bridge, { common, worktree, moves });
132
- return outcome;
133
- }
134
- const git = nativeGit();
135
- if (git === null) {
136
- process.stderr.write('git: no installed Git found on PATH\n');
137
- process.exitCode = 127;
138
- }
139
- else {
140
- observed(git, process.argv.slice(2)).then(({ status, signal }) => {
141
- if (signal === null) {
142
- process.exitCode = status ?? 1;
143
- return;
144
- }
145
- process.exitCode = 128 + system.signals[signal];
146
- process.kill(process.pid, signal);
147
- });
148
- }
@@ -1,27 +0,0 @@
1
- import { ATTACHMENT_REFERENCE_PREFIX, DOCUMENT_REFERENCE_PREFIX, REVISION_REFERENCE_PREFIX } from '@agentshouse/mdmodel';
2
- import { isDocument } from './binaries.js';
3
- const OLD_REVISION = 'fr_';
4
- const OLD_ENTRY = 'af_';
5
- const REVISION_BASES = new Set(['replace', 'remove', 'rename', 'upload']);
6
- function renamed(value, path) {
7
- if (value?.startsWith(OLD_REVISION))
8
- return `${REVISION_REFERENCE_PREFIX}${value.slice(OLD_REVISION.length)}`;
9
- if (value?.startsWith(OLD_ENTRY)) {
10
- return `${isDocument(path) ? DOCUMENT_REFERENCE_PREFIX : ATTACHMENT_REFERENCE_PREFIX}${value.slice(OLD_ENTRY.length)}`;
11
- }
12
- return value;
13
- }
14
- export function renameOldReferences(record) {
15
- const held = JSON.stringify(record);
16
- for (const manifest of Object.values(record.manifests ?? {})) {
17
- for (const [path, revision] of Object.entries(manifest.files))
18
- manifest.files[path] = renamed(revision, path);
19
- }
20
- for (const change of record.push?.changes ?? []) {
21
- if (REVISION_BASES.has(change.op) && typeof change.base === 'string')
22
- change.base = renamed(change.base, change.path);
23
- }
24
- for (const written of record.push?.written ?? [])
25
- written.revision = renamed(written.revision, written.path);
26
- return JSON.stringify(record) !== held;
27
- }
package/dist/translate.js DELETED
@@ -1,52 +0,0 @@
1
- import { apply, definitionAt, HOUSE_TYPED_PATHS, parse, serialize, } from '@agentshouse/mdmodel';
2
- function same(left, right) {
3
- return JSON.stringify(left) === JSON.stringify(right);
4
- }
5
- function applied(document, changes, definition) {
6
- const result = apply(document, changes, definition);
7
- return result.outcome === 'applied' ? serialize(result.document) : null;
8
- }
9
- export function readDocument(content, file, model) {
10
- const definitions = definitionAt(model, file, HOUSE_TYPED_PATHS);
11
- const parsed = parse(content, file, definitions);
12
- if (!parsed.ok)
13
- return null;
14
- const { document } = parsed;
15
- const definition = definitions(document.type);
16
- return definition !== undefined || document.type === undefined ? { document, definition } : null;
17
- }
18
- function components(path, before, after, text, definition) {
19
- const edits = [];
20
- const changes = [];
21
- if (before.preamble !== after.preamble) {
22
- edits.push({ op: 'replace_preamble', path, base: before.preamble, content: after.preamble });
23
- changes.push({ kind: 'preamble', value: after.preamble, prior: before.preamble });
24
- }
25
- for (const name of new Set([...Object.keys(before.fields), ...Object.keys(after.fields)])) {
26
- const prior = before.fields[name];
27
- const value = after.fields[name];
28
- if (same(prior, value))
29
- continue;
30
- if (value === undefined)
31
- return null;
32
- edits.push({ op: 'set_field', path, field: name, ...(prior === undefined ? {} : { base: prior }), value });
33
- changes.push({ kind: 'field', name, value, prior });
34
- }
35
- for (const name of new Set([...Object.keys(before.sections), ...Object.keys(after.sections)])) {
36
- const prior = before.sections[name];
37
- const value = after.sections[name];
38
- if (prior === value)
39
- continue;
40
- if (prior === undefined || value === undefined)
41
- return null;
42
- edits.push({ op: 'replace_section', path, section: name, base: prior, content: value });
43
- changes.push({ kind: 'section', name, value, prior });
44
- }
45
- return edits.length > 0 && applied(before, changes, definition) === text ? edits : null;
46
- }
47
- export function changed(path, file, base, before, after, model) {
48
- const prior = readDocument(before, file, model);
49
- const next = readDocument(after, file, model);
50
- const structured = prior !== null && next !== null ? components(path, prior.document, next.document, after, prior.definition) : null;
51
- return structured ?? [{ op: 'replace', path, base, content: after }];
52
- }