mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 00:10:49 +08:00
* Prepare versioned project edits locally and skip recursive preview mounts * Preserve validation details on locally prepared composition drops * Prepare Studio edits from one ordered local working copy * Chain editable media references to their preceding Studio writes --------- Co-authored-by: lefarcen <935902669@qq.com>
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
// Node CLI shipped with each Studio build. Project reads and authenticated writes stay with the host Agent.
|
|
import { projectEditInputs } from '../packages/edit-core/project-inputs.ts';
|
|
import { prepareFileEdits, type ObservedEditFile } from '../packages/edit-core/prepare-file-edits.ts';
|
|
import { editRequestSchema, editSchemaDefinitions } from '../packages/edit-core/schema.ts';
|
|
import type { EditRequest } from '../packages/edit-core/commands.ts';
|
|
import { validateInput } from '../shared/phase1-tools.ts';
|
|
|
|
async function main() {
|
|
const chunks = [];
|
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
const input = JSON.parse(Buffer.concat(chunks).toString('utf8')) as { edit: EditRequest; files?: ObservedEditFile[] };
|
|
validateInput(editRequestSchema, input.edit, 'edit', 'edit', editSchemaDefinitions);
|
|
if (!input.files) {
|
|
const { requested } = projectEditInputs(input.edit);
|
|
return { inputs: Array.from(requested, ([path, kind]) => ({ path, kind })) };
|
|
}
|
|
const textEdits = await prepareFileEdits(input.edit, input.files);
|
|
return textEdits.files.length ? { textEdits } : { changed: false };
|
|
}
|
|
main().then(result => process.stdout.write(JSON.stringify(result) + '\n')).catch(error => {
|
|
process.stderr.write(String(error.message ?? error) + '\n');
|
|
process.exitCode = 1;
|
|
});
|