@revoengine/cli 1.0.31 → 1.0.34

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +152 -24
  3. package/dist/src/argument-contract.d.ts +17 -0
  4. package/dist/src/argument-contract.js +359 -0
  5. package/dist/src/automation-contract.generated.d.ts +56 -22
  6. package/dist/src/automation-contract.generated.js +68 -26
  7. package/dist/src/cli.js +15 -13
  8. package/dist/src/client.d.ts +34 -2
  9. package/dist/src/client.js +76 -13
  10. package/dist/src/commands/agents.js +5 -1
  11. package/dist/src/commands/auth.js +2 -0
  12. package/dist/src/commands/component.js +34 -17
  13. package/dist/src/commands/database-tables.js +15 -4
  14. package/dist/src/commands/database-views.js +5 -1
  15. package/dist/src/commands/endpoints.js +5 -1
  16. package/dist/src/commands/env.js +5 -1
  17. package/dist/src/commands/events.js +5 -1
  18. package/dist/src/commands/groups.js +5 -1
  19. package/dist/src/commands/info.js +2 -0
  20. package/dist/src/commands/job-templates.js +5 -1
  21. package/dist/src/commands/metadata.js +2 -0
  22. package/dist/src/commands/migrate.d.ts +2 -2
  23. package/dist/src/commands/migrate.js +33 -7
  24. package/dist/src/commands/project.js +19 -14
  25. package/dist/src/commands/request.js +2 -0
  26. package/dist/src/commands/role-groups.js +5 -1
  27. package/dist/src/commands/schedules.js +5 -1
  28. package/dist/src/commands/search.js +2 -0
  29. package/dist/src/commands/service-accounts.js +5 -1
  30. package/dist/src/commands/studio.js +2 -0
  31. package/dist/src/commands/terminal-browser-central-profile.d.ts +65 -0
  32. package/dist/src/commands/terminal-browser-central-profile.js +203 -0
  33. package/dist/src/commands/terminal-browser-human-input.d.ts +3 -1
  34. package/dist/src/commands/terminal-browser-human-input.js +3 -1
  35. package/dist/src/commands/terminal-browser-interaction.js +1 -1
  36. package/dist/src/commands/terminal-browser-live-protocol.d.ts +34 -2
  37. package/dist/src/commands/terminal-browser-live-protocol.js +28 -12
  38. package/dist/src/commands/terminal-browser-live-transport.d.ts +1 -0
  39. package/dist/src/commands/terminal-browser-live-transport.js +9 -5
  40. package/dist/src/commands/terminal-browser-live.d.ts +24 -3
  41. package/dist/src/commands/terminal-browser-live.js +199 -30
  42. package/dist/src/commands/terminal-browser-page-input.d.ts +4 -1
  43. package/dist/src/commands/terminal-browser-page-input.js +46 -1
  44. package/dist/src/commands/terminal-browser-profile-crypto.d.ts +30 -0
  45. package/dist/src/commands/terminal-browser-profile-crypto.js +101 -0
  46. package/dist/src/commands/terminal-browser-profile-import-runner.d.ts +31 -0
  47. package/dist/src/commands/terminal-browser-profile-import-runner.js +112 -0
  48. package/dist/src/commands/terminal-browser-profile-import.d.ts +28 -0
  49. package/dist/src/commands/terminal-browser-profile-import.js +125 -0
  50. package/dist/src/commands/terminal-browser-profile-import.protocol.d.ts +50 -0
  51. package/dist/src/commands/terminal-browser-profile-import.protocol.js +52 -0
  52. package/dist/src/commands/terminal-browser-profile-preferences.d.ts +1 -0
  53. package/dist/src/commands/terminal-browser-profile-preferences.js +16 -0
  54. package/dist/src/commands/terminal-browser-profile-sync.d.ts +14 -0
  55. package/dist/src/commands/terminal-browser-profile-sync.js +169 -0
  56. package/dist/src/commands/terminal-browser-profile-sync.protocol.d.ts +50 -0
  57. package/dist/src/commands/terminal-browser-profile-sync.protocol.js +19 -0
  58. package/dist/src/commands/terminal-browser-profile.d.ts +10 -1
  59. package/dist/src/commands/terminal-browser-profile.js +30 -4
  60. package/dist/src/commands/terminal-browser-recording.d.ts +39 -0
  61. package/dist/src/commands/terminal-browser-recording.js +74 -0
  62. package/dist/src/commands/terminal-browser-recording.protocol.d.ts +49 -0
  63. package/dist/src/commands/terminal-browser-recording.protocol.js +16 -0
  64. package/dist/src/commands/terminal-browser.d.ts +14 -1
  65. package/dist/src/commands/terminal-browser.js +98 -33
  66. package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
  67. package/dist/src/commands/terminal-file-descriptor.js +39 -0
  68. package/dist/src/commands/terminal-file.js +41 -6
  69. package/dist/src/commands/terminal-image.js +3 -31
  70. package/dist/src/commands/terminal-output-buffer.d.ts +18 -1
  71. package/dist/src/commands/terminal-output-buffer.js +95 -8
  72. package/dist/src/commands/terminal-process-group.d.ts +25 -0
  73. package/dist/src/commands/terminal-process-group.js +144 -0
  74. package/dist/src/commands/terminal.d.ts +3 -1
  75. package/dist/src/commands/terminal.js +366 -80
  76. package/dist/src/commands/tests.js +2 -0
  77. package/dist/src/component-lock.d.ts +15 -1
  78. package/dist/src/component-lock.js +96 -10
  79. package/dist/src/env-sync.js +12 -6
  80. package/dist/src/migration.d.ts +7 -0
  81. package/dist/src/migration.js +39 -21
  82. package/dist/src/planning-snapshot.d.ts +3 -0
  83. package/dist/src/planning-snapshot.js +60 -2
  84. package/dist/src/project.d.ts +1 -0
  85. package/dist/src/project.js +7 -8
  86. package/dist/src/resource-syncs/agent-sync.js +76 -24
  87. package/dist/src/resource-syncs/database-table-sync.d.ts +8 -1
  88. package/dist/src/resource-syncs/database-table-sync.js +66 -32
  89. package/dist/src/resource-syncs/database-view-sync.js +41 -28
  90. package/dist/src/resource-syncs/endpoint-sync.js +90 -18
  91. package/dist/src/resource-syncs/event-sync.js +33 -14
  92. package/dist/src/resource-syncs/group-sync.js +21 -11
  93. package/dist/src/resource-syncs/job-template-sync.js +98 -37
  94. package/dist/src/resource-syncs/role-group-sync.js +22 -11
  95. package/dist/src/resource-syncs/schedule-sync.js +26 -11
  96. package/dist/src/resource-syncs/service-account-sync.js +22 -11
  97. package/dist/src/reviewed-plan.js +3 -0
  98. package/dist/src/runtime-view.js +2 -18
  99. package/dist/src/sync-omit-command.d.ts +6 -0
  100. package/dist/src/sync-omit-command.js +49 -0
  101. package/dist/src/sync-omit-write-fence.d.ts +10 -0
  102. package/dist/src/sync-omit-write-fence.js +134 -0
  103. package/dist/src/sync-omit.d.ts +59 -0
  104. package/dist/src/sync-omit.js +469 -0
  105. package/dist/src/sync-output.d.ts +3 -3
  106. package/dist/src/ui.js +11 -5
  107. package/dist/src/update-notifier.d.ts +1 -1
  108. package/dist/src/update-notifier.js +2 -1
  109. package/dist/src/utils.js +46 -17
  110. package/dist/src/workspace-prune.js +11 -3
  111. package/dist/src/workspace-write-lock.d.ts +7 -0
  112. package/dist/src/workspace-write-lock.js +144 -0
  113. package/package.json +6 -5
@@ -1,15 +1,17 @@
1
+ import { fenceSyncOmitWrites } from "./sync-omit-write-fence.js";
2
+ import { currentSyncOmitPolicy, syncBaselineHash, withoutSyncOmit } from "./sync-omit.js";
1
3
  import { AGENT_LAYOUT, buildAgentsPlan, pullAgentsToWorkspace, pushAgents } from "./resource-syncs/agent-sync.js";
2
4
  import { projectRepositoryItems, migrationItemOperation, BLOCKING_SCHEMA_STATUSES, schemaItemAction, viewItemIsBlocked, viewItemAction, componentItemAction, jobTemplateItemAction, endpointItemAction, scheduleItemAction, eventItemAction, groupItemAction, roleGroupItemAction, serviceAccountItemAction, } from "./migration-actions.js";
3
5
  import fs from 'node:fs';
4
6
  import { sameReviewedPlan } from "./reviewed-plan.js";
5
- import { applyWorkspacePrune, buildWorkspacePrunePlan, samePrunePlan } from "./workspace-prune.js";
7
+ import { applyWorkspacePrune, buildWorkspacePrunePlan, samePrunePlan, readPruneManifests } from "./workspace-prune.js";
6
8
  import { planIdentityMigration } from "./resource-syncs/identity-migration.js";
7
9
  import { SERVICE_ACCOUNTS_DIRECTORY, buildServiceAccountsPlan, pullServiceAccountsToWorkspace, pushServiceAccounts } from "./resource-syncs/service-account-sync.js";
8
10
  import os from 'node:os';
9
11
  import path from 'node:path';
10
12
  import { RevoClient } from "./client.js";
11
- import { planningSnapshot } from "./planning-snapshot.js";
12
- import { REVO_LOCK_FILE, readComponentLock } from "./component-lock.js";
13
+ import { planningSnapshot, planningSnapshotReviewHash, planningSnapshotVersions } from "./planning-snapshot.js";
14
+ import { REVO_LOCK_FILE, readComponentLock, hashStable } from "./component-lock.js";
13
15
  import { normalizeStableKeyValue } from "./resource-metadata.js";
14
16
  import { withHttpTraceContext } from "./http-trace.js";
15
17
  import { buildComponentPlan, pullAllComponents, pushAllComponents, } from "./commands/component.js";
@@ -570,43 +572,43 @@ function combinePlan(input) {
570
572
  if (input.migrationInput.sourceMode === 'workspace') {
571
573
  const lock = readComponentLock(requireProject(input.migrationInput).projectRoot);
572
574
  const environment = targetKey(input.migrationInput);
573
- const baselineByKey = (entries, normalize = (key) => key) => {
574
- const baselines = new Map(Object.values(entries).map((entry) => [normalize(entry.stableKey), entry.environments[environment]?.remoteHash]));
575
+ const baselineByKey = (family, entries, normalize = (key) => key) => {
576
+ const baselines = new Map(Object.values(entries).map((entry) => [normalize(entry.stableKey), syncBaselineHash(family, entry.environments[environment])]));
575
577
  return (item) => item.stableKey ? baselines.get(normalize(item.stableKey)) : undefined;
576
578
  };
577
579
  if (input.databaseSchemas) {
578
- input.databaseSchemas = { ...input.databaseSchemas, items: projectRepositoryItems(input.databaseSchemas.items, schemaItemAction, (item) => item.stableKey ? lock.databaseSchemas[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
580
+ input.databaseSchemas = { ...input.databaseSchemas, items: projectRepositoryItems(input.databaseSchemas.items, schemaItemAction, (item) => item.stableKey ? syncBaselineHash('database-table', lock.databaseSchemas[item.stableKey]?.environments[environment]) : undefined) };
579
581
  }
580
582
  if (input.databaseViews) {
581
- input.databaseViews = { ...input.databaseViews, items: projectRepositoryItems(input.databaseViews.items, viewItemAction, (item) => item.stableKey ? lock.databaseViews[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
583
+ input.databaseViews = { ...input.databaseViews, items: projectRepositoryItems(input.databaseViews.items, viewItemAction, (item) => item.stableKey ? syncBaselineHash('database-view', lock.databaseViews[item.stableKey]?.environments[environment]) : undefined) };
582
584
  }
583
585
  if (input.components) {
584
586
  input.components = { ...input.components, items: projectRepositoryItems(input.components.items, componentItemAction, (item) => item.lockHash) };
585
587
  }
586
588
  for (const field of ['agentPlugins', 'agents']) {
587
589
  if (input[field])
588
- input[field] = { ...input[field], items: projectRepositoryItems(input[field].items, agentItemAction, baselineByKey(lock[field])) };
590
+ input[field] = { ...input[field], items: projectRepositoryItems(input[field].items, agentItemAction, baselineByKey(field === 'agents' ? 'agent' : 'agent-plugin', lock[field])) };
589
591
  }
590
592
  if (input.serviceAccounts) {
591
- input.serviceAccounts = { ...input.serviceAccounts, items: projectRepositoryItems(input.serviceAccounts.items, serviceAccountItemAction, baselineByKey(lock.serviceAccounts)) };
593
+ input.serviceAccounts = { ...input.serviceAccounts, items: projectRepositoryItems(input.serviceAccounts.items, serviceAccountItemAction, baselineByKey('service-account', lock.serviceAccounts)) };
592
594
  }
593
595
  if (input.jobTemplates) {
594
- input.jobTemplates = { ...input.jobTemplates, items: projectRepositoryItems(input.jobTemplates.items, jobTemplateItemAction, baselineByKey(lock.jobTemplates)) };
596
+ input.jobTemplates = { ...input.jobTemplates, items: projectRepositoryItems(input.jobTemplates.items, jobTemplateItemAction, baselineByKey('job-template', lock.jobTemplates)) };
595
597
  }
596
598
  if (input.endpoints) {
597
- input.endpoints = { ...input.endpoints, items: projectRepositoryItems(input.endpoints.items, endpointItemAction, (item) => item.stableKey ? lock.endpoints[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
599
+ input.endpoints = { ...input.endpoints, items: projectRepositoryItems(input.endpoints.items, endpointItemAction, (item) => item.stableKey ? syncBaselineHash('endpoint', lock.endpoints[item.stableKey]?.environments[environment]) : undefined) };
598
600
  }
599
601
  if (input.schedules) {
600
- input.schedules = { ...input.schedules, items: projectRepositoryItems(input.schedules.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : scheduleItemAction(item), (item) => item.stableKey ? lock.schedules[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
602
+ input.schedules = { ...input.schedules, items: projectRepositoryItems(input.schedules.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : scheduleItemAction(item), (item) => item.stableKey ? syncBaselineHash('schedule', lock.schedules[item.stableKey]?.environments[environment]) : undefined) };
601
603
  }
602
604
  if (input.events) {
603
- input.events = { ...input.events, items: projectRepositoryItems(input.events.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : eventItemAction(item), (item) => item.stableKey ? lock.events[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
605
+ input.events = { ...input.events, items: projectRepositoryItems(input.events.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : eventItemAction(item), (item) => item.stableKey ? syncBaselineHash('event', lock.events[item.stableKey]?.environments[environment]) : undefined) };
604
606
  }
605
607
  if (input.groups) {
606
- input.groups = { ...input.groups, items: projectRepositoryItems(input.groups.items, groupItemAction, baselineByKey(lock.groups)) };
608
+ input.groups = { ...input.groups, items: projectRepositoryItems(input.groups.items, groupItemAction, baselineByKey('group', lock.groups)) };
607
609
  }
608
610
  if (input.roleGroups) {
609
- input.roleGroups = { ...input.roleGroups, items: projectRepositoryItems(input.roleGroups.items, roleGroupItemAction, baselineByKey(lock.roleGroups, normalizeStableKeyValue)) };
611
+ input.roleGroups = { ...input.roleGroups, items: projectRepositoryItems(input.roleGroups.items, roleGroupItemAction, baselineByKey('role-group', lock.roleGroups, normalizeStableKeyValue)) };
610
612
  }
611
613
  }
612
614
  const phases = [
@@ -713,7 +715,7 @@ function combinePlan(input) {
713
715
  from: input.migrationInput.from,
714
716
  to: input.migrationInput.to,
715
717
  resources: selectedResources(input.migrationInput),
716
- policy: { ...migrationPolicy(input.migrationInput), mode: 'upsert', ...(input.migrationInput.activateAutomations ? { activateAutomations: true } : {}) },
718
+ policy: { ...migrationPolicy(input.migrationInput), mode: 'upsert', ...(currentSyncOmitPolicy().rules.length ? { omit: currentSyncOmitPolicy() } : {}), ...(input.migrationInput.activateAutomations ? { activateAutomations: true } : {}) },
717
719
  needsChanges: phases.some((phase) => phase.needsChanges),
718
720
  readyToMigrate: blockers.length === 0,
719
721
  verdict: phaseVerdict(blockers, warnings),
@@ -830,7 +832,8 @@ function migrationComponentIdentity(cwd) {
830
832
  }
831
833
  function componentCommandContext(input) {
832
834
  return {
833
- args: { _: ['component', input.operation], all: true, force: true, yes: true },
835
+ args: { _: ['component', input.operation], all: true,
836
+ ...(input.operation !== 'plan' ? { force: true, yes: true } : {}) },
834
837
  client: input.client,
835
838
  componentEnvironment: input.envName,
836
839
  componentIdentity: migrationComponentIdentity(input.cwd),
@@ -963,7 +966,7 @@ export async function pullResourcesToWorkspace(input) {
963
966
  };
964
967
  }
965
968
  async function pullSelectedResources(input) {
966
- return (await pullResourcesToWorkspace({
969
+ return (await withoutSyncOmit(() => pullResourcesToWorkspace({
967
970
  cwd: input.cwd,
968
971
  client: createEnvironmentClient(input.from),
969
972
  sourceKey: input.from,
@@ -971,7 +974,7 @@ async function pullSelectedResources(input) {
971
974
  resources: selectedResources(input),
972
975
  force: true,
973
976
  pruneOrphans: true,
974
- })).results;
977
+ }))).results;
975
978
  }
976
979
  function projectedComponentDependencies(plan) {
977
980
  return plan.items.flatMap((item) => {
@@ -1053,6 +1056,10 @@ function projectedDatabaseRecords(pull) {
1053
1056
  partition: manifest.partition,
1054
1057
  }));
1055
1058
  }
1059
+ function sourceOmitReviewHash(cwd, resources) {
1060
+ const manifests = readPruneManifests(cwd, resources);
1061
+ return hashStable(resources.map(resource => [resource, [...(manifests[resource]?.entries() || [])].sort(([left], [right]) => left.localeCompare(right))]));
1062
+ }
1056
1063
  async function planWorkspace(input) {
1057
1064
  const planStage = (stage, resource, environment, operation) => runMigrationStage(stage, resource, environment, operation, input.onProgress);
1058
1065
  const resources = selectedResources(input);
@@ -1200,6 +1207,11 @@ async function planWorkspace(input) {
1200
1207
  agents,
1201
1208
  });
1202
1209
  combined.reviewedPlanVersion = 1;
1210
+ if (currentSyncOmitPolicy().rules.length) {
1211
+ combined.omitTargetRevisionHash = planningSnapshotReviewHash(client);
1212
+ combined.omitSourceRevisionHash = sourceOmitReviewHash(input.cwd, resources);
1213
+ combined.omitTargetVersions = planningSnapshotVersions(client);
1214
+ }
1203
1215
  if (identities) {
1204
1216
  combined.identityOrder = identities.ordered.map(({ resource, stableKey }) => ({ resource, stableKey }));
1205
1217
  }
@@ -1302,14 +1314,20 @@ export async function runMigration(input) {
1302
1314
  from: input.from,
1303
1315
  to: input.to,
1304
1316
  resources,
1305
- policy: { ...migrationPolicy(input), mode: 'upsert', ...(input.activateAutomations ? { activateAutomations: true } : {}) },
1317
+ policy: { ...migrationPolicy(input), mode: 'upsert', ...(currentSyncOmitPolicy().rules.length ? { omit: currentSyncOmitPolicy() } : {}), ...(input.activateAutomations ? { activateAutomations: true } : {}) },
1306
1318
  sourcePull: pulls,
1307
1319
  plan: initialPlan,
1308
1320
  };
1309
1321
  if (!initialPlan.readyToMigrate) {
1310
1322
  return { ...base, verdict: 'blocked', results: [], phaseResults: {} };
1311
1323
  }
1312
- const targetClient = resolveTargetClient(input);
1324
+ const rawTargetClient = resolveTargetClient(input);
1325
+ const targetClient = currentSyncOmitPolicy().rules.length
1326
+ ? fenceSyncOmitWrites(rawTargetClient, initialPlan.omitTargetVersions || {}, () => {
1327
+ if (sourceOmitReviewHash(input.cwd, resources) !== initialPlan.omitSourceRevisionHash) {
1328
+ throw new Error('Workspace source changed after the deployment plan was reviewed; run plan again before writing.');
1329
+ }
1330
+ }) : rawTargetClient;
1313
1331
  const deployStage = (resource, operation) => runMigrationStage('target deploy', resource, targetLabel(input), operation, input.onProgress);
1314
1332
  const environmentKey = targetKey(input);
1315
1333
  const phaseResults = {};
@@ -1,2 +1,5 @@
1
1
  import type { RevoClient } from './client.ts';
2
+ import { type SyncOmitTargetVersions } from './sync-omit-write-fence.ts';
3
+ export declare function planningSnapshotVersions(client: RevoClient): SyncOmitTargetVersions;
4
+ export declare function planningSnapshotReviewHash(client: RevoClient): string;
2
5
  export declare function planningSnapshot(client: RevoClient): RevoClient;
@@ -1,8 +1,49 @@
1
+ import { hashStable } from "./component-lock.js";
2
+ import { syncTargetVersionRecords } from "./sync-omit-write-fence.js";
3
+ import { currentSyncOmitPolicy } from "./sync-omit.js";
4
+ const reviewVersions = new WeakMap();
5
+ export function planningSnapshotVersions(client) {
6
+ return { ...reviewVersions.get(client) };
7
+ }
8
+ function readFamily(method) {
9
+ if (/AgentPlugins?/.test(method))
10
+ return 'agent-plugin';
11
+ if (/Agents?/.test(method))
12
+ return 'agent';
13
+ if (/ServiceAccounts?|Accounts?/.test(method))
14
+ return 'service-account';
15
+ if (/RoleGroups?/.test(method))
16
+ return 'role-group';
17
+ if (/Groups?/.test(method))
18
+ return 'group';
19
+ if (/JobTemplates?/.test(method))
20
+ return 'job-template';
21
+ if (/Endpoints?/.test(method))
22
+ return 'endpoint';
23
+ if (/Schedules?/.test(method))
24
+ return 'schedule';
25
+ if (/Events?/.test(method))
26
+ return 'event';
27
+ if (/DatabaseViews?/.test(method))
28
+ return 'database-view';
29
+ if (/DatabaseSchemas?/.test(method))
30
+ return 'database-table';
31
+ // Historical/runtime component snapshots have their own revision namespace.
32
+ // Component writes retain the existing dedicated componentReview fence.
33
+ if (/^(getComponent|listAllComponents)$/.test(method))
34
+ return 'component';
35
+ return undefined;
36
+ }
37
+ export function planningSnapshotReviewHash(client) {
38
+ return hashStable(Object.entries(reviewVersions.get(client) || {}).sort(([left], [right]) => left.localeCompare(right)));
39
+ }
1
40
  // Only one planning pass owns this cache. Mutation/readback uses the original
2
41
  // client, and the next pass always starts empty. Never persist auth or row data.
3
42
  export function planningSnapshot(client) {
4
43
  const pending = new Map();
5
- return new Proxy(client, {
44
+ const versions = {};
45
+ const captureRevisions = currentSyncOmitPolicy().rules.length > 0;
46
+ const snapshot = new Proxy(client, {
6
47
  get(target, property) {
7
48
  const value = Reflect.get(target, property, target);
8
49
  if (typeof value !== 'function')
@@ -22,8 +63,25 @@ export function planningSnapshot(client) {
22
63
  request.catch(() => pending.delete(key));
23
64
  }
24
65
  // Planners annotate records. No consumer may mutate another's snapshot.
25
- return structuredClone(await request);
66
+ const result = await request;
67
+ const family = captureRevisions ? readFamily(property) : undefined;
68
+ if (family) {
69
+ const detailId = property.startsWith('get') && typeof args[0] === 'string' ? args[0] : undefined;
70
+ if (detailId && !Object.hasOwn(versions, `${family}:${detailId}`))
71
+ versions[`${family}:${detailId}`] = null;
72
+ for (const record of syncTargetVersionRecords(family, result, detailId)) {
73
+ const identity = `${family}:${record.id}`;
74
+ const previous = versions[identity];
75
+ if (previous != null && record.version != null && previous !== record.version)
76
+ throw new Error(`Target ${family} changed while planning; review a fresh deployment plan.`);
77
+ if (!Object.hasOwn(versions, identity) || record.version !== null)
78
+ versions[identity] = record.version;
79
+ }
80
+ }
81
+ return structuredClone(result);
26
82
  };
27
83
  },
28
84
  });
85
+ reviewVersions.set(snapshot, versions);
86
+ return snapshot;
29
87
  }
@@ -7,6 +7,7 @@ export declare const REVO_TYPES_FILE: string;
7
7
  export declare const REVO_TYPES_DEFINITIONS_FILE: string;
8
8
  export declare const REVO_METADATA_FILE: string;
9
9
  export declare const REVO_TYPES_GITIGNORE_ENTRY = ".revoengine/types/";
10
+ export declare const REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY = ".revoengine/workspace-write.lock/";
10
11
  export declare const REVO_DEBUG_JS_FILE: string;
11
12
  export declare const REVO_DEBUG_TS_FILE: string;
12
13
  export declare const REVO_DEBUG_INPUT_FILE: string;
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { readJsonFile } from "./utils.js";
3
+ import { readJsonFile, writeJsonFile } from "./utils.js";
4
4
  import { COMPONENT_IDENTITY_BY_ID, DEFAULT_COMPONENT_IDENTITY, DEFAULT_STABLE_KEY_NAME, normalizeComponentIdentityConfig, normalizeComponentIdentityMode, normalizeStableKeyName, } from "./resource-metadata.js";
5
5
  import { TRACK_ALL_RESOURCES, normalizeTrackedResources, } from "./tracked-resources.js";
6
6
  export const REVO_PROJECT_DIR = '.revoengine';
@@ -9,6 +9,7 @@ export const REVO_TYPES_FILE = path.join(REVO_TYPES_DIR, 'revo.editor.d.ts');
9
9
  export const REVO_TYPES_DEFINITIONS_FILE = path.join(REVO_TYPES_DIR, 'revo.editor.definitions.json');
10
10
  export const REVO_METADATA_FILE = path.join(REVO_PROJECT_DIR, 'revo.json');
11
11
  export const REVO_TYPES_GITIGNORE_ENTRY = '.revoengine/types/';
12
+ export const REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY = '.revoengine/workspace-write.lock/';
12
13
  export const REVO_DEBUG_JS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.js');
13
14
  export const REVO_DEBUG_TS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.ts');
14
15
  export const REVO_DEBUG_INPUT_FILE = path.join(REVO_PROJECT_DIR, 'debug_input.json');
@@ -198,10 +199,6 @@ function readResourceSelectionArgs(args) {
198
199
  }
199
200
  return values.length > 0 ? values : undefined;
200
201
  }
201
- function writeJsonFile(filePath, value) {
202
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
203
- fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
204
- }
205
202
  export function resolveProjectInvocation(args) {
206
203
  const projectArgs = args._.slice(1);
207
204
  const [first, second, ...rest] = projectArgs;
@@ -606,8 +603,9 @@ export function ensureProjectConfig(rootDir, typesInclude = REVO_TYPES_FILE) {
606
603
  }
607
604
  export function ensureProjectGitignore(rootDir) {
608
605
  const filePath = path.join(rootDir, '.gitignore');
606
+ const entries = [REVO_TYPES_GITIGNORE_ENTRY, REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY];
609
607
  if (!fs.existsSync(filePath)) {
610
- fs.writeFileSync(filePath, `${REVO_TYPES_GITIGNORE_ENTRY}\n`);
608
+ fs.writeFileSync(filePath, `${entries.join('\n')}\n`);
611
609
  return {
612
610
  filePath,
613
611
  action: 'created',
@@ -615,14 +613,15 @@ export function ensureProjectGitignore(rootDir) {
615
613
  }
616
614
  const raw = fs.readFileSync(filePath, 'utf8');
617
615
  const lines = raw.split(/\r?\n/);
618
- if (lines.some((line) => line.trim() === REVO_TYPES_GITIGNORE_ENTRY)) {
616
+ const missing = entries.filter(entry => !lines.some(line => line.trim() === entry));
617
+ if (!missing.length) {
619
618
  return {
620
619
  filePath,
621
620
  action: 'unchanged',
622
621
  };
623
622
  }
624
623
  const trimmed = raw.replace(/\s*$/, '');
625
- const next = trimmed ? `${trimmed}\n${REVO_TYPES_GITIGNORE_ENTRY}\n` : `${REVO_TYPES_GITIGNORE_ENTRY}\n`;
624
+ const next = `${trimmed ? `${trimmed}\n` : ''}${missing.join('\n')}\n`;
626
625
  fs.writeFileSync(filePath, next);
627
626
  return {
628
627
  filePath,
@@ -1,3 +1,4 @@
1
+ import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths } from "../sync-omit.js";
1
2
  import { componentRevisionByDigest, verifyComponentRuntime } from "../component-contract.js";
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
@@ -149,7 +150,7 @@ function comparableAgent(desired, current) {
149
150
  }
150
151
  export function hashPortableAgent(manifest) {
151
152
  const { owner, ...rest } = manifest;
152
- return hashStable({ ...rest, ...((owner && ['group', 'service-account', 'system'].includes(owner.type)) ? { owner } : {}) });
153
+ return hashSyncDefinition(manifest.kind, { ...rest, ...((owner && ['group', 'service-account', 'system'].includes(owner.type)) ? { owner } : {}) });
153
154
  }
154
155
  export function readWorkspaceAgents(cwd, family) {
155
156
  const { workspaceRoot } = requireProjectLayout(cwd, family);
@@ -312,35 +313,39 @@ export async function pullAgentsToWorkspace(input) {
312
313
  unique(entries);
313
314
  const existing = readWorkspaceAgents(input.cwd, input.family);
314
315
  unique(existing);
316
+ const { projectRoot } = requireProjectLayout(input.cwd, input.family);
317
+ const lock = readComponentLock(projectRoot);
318
+ const field = AGENT_LAYOUT[input.family][2];
315
319
  const paths = new Set();
316
- for (const { manifest } of entries) {
320
+ const writes = entries.map(({ manifest: incoming }) => {
321
+ const remoteHash = hashPortableAgent(incoming);
322
+ const local = existing.find(value => value.manifest.stableKey === incoming.stableKey);
323
+ const manifest = local ? preserveOmittedProperties(input.family, incoming, local.manifest) : incoming;
324
+ const sourceHash = withoutSyncOmit(() => hashPortableAgent(manifest));
317
325
  const filename = manifestPath(input.cwd, manifest);
318
326
  const key = pathIdentity(filename);
319
327
  if (paths.has(key))
320
328
  throw new Error('Agent manifest filesystem path collision.');
321
329
  paths.add(key);
322
- const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
323
- if (local && hashPortableAgent(local.manifest) !== hashPortableAgent(manifest) && !input.force)
324
- throw new Error(`Local ${input.family} "${manifest.stableKey}" differs; use --force to replace.`);
330
+ if (local && !input.force) {
331
+ const localHash = hashPortableAgent(local.manifest);
332
+ if (localHash !== remoteHash && localHash !== syncSourceBaselineHash(input.family, lock[field][manifest.stableKey]))
333
+ throw new Error(`Local ${input.family} "${manifest.stableKey}" differs; use --force to replace.`);
334
+ }
325
335
  if (fs.existsSync(filename) && (!local || pathIdentity(local.manifestPath) !== key))
326
336
  throw new Error('Agent manifest path is occupied by another resource.');
327
- }
328
- const { projectRoot } = requireProjectLayout(input.cwd, input.family);
329
- const lock = readComponentLock(projectRoot);
330
- const field = AGENT_LAYOUT[input.family][2];
331
- if (input.pruneOrphans && skipped.length && existing.some(local => !entries.some(e => e.manifest.stableKey === local.manifest.stableKey)))
337
+ return { manifest, local, filename, remoteHash, sourceHash };
338
+ });
339
+ if (input.pruneOrphans && skipped.length && existing.some(local => !entries.some(entry => entry.manifest.stableKey === local.manifest.stableKey)))
332
340
  throw new Error('Cannot prune local Agent manifests while source inventory contains unmanaged resources.');
333
341
  const pulled = [];
334
342
  const pruned = [];
335
- for (const { manifest } of entries) {
336
- const filename = manifestPath(input.cwd, manifest);
343
+ for (const { manifest, local, filename, remoteHash, sourceHash } of writes) {
337
344
  writePulledManifest({ filePath: filename, manifest, root: path.dirname(filename) });
338
- const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
339
345
  if (local && local.manifestPath !== filename)
340
346
  fs.unlinkSync(local.manifestPath);
341
- const hash = hashPortableAgent(manifest);
342
347
  const prior = lock[field][manifest.stableKey];
343
- lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: hash, environments: { ...prior?.environments, [input.envName]: { remoteHash: hash, syncedAt: new Date().toISOString() } } };
348
+ lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash, environments: { ...prior?.environments, [input.envName]: { remoteHash, syncedAt: new Date().toISOString() } } };
344
349
  pulled.push({ manifest, targetPath: path.relative(input.cwd, filename) });
345
350
  }
346
351
  if (input.pruneOrphans)
@@ -404,10 +409,46 @@ async function pluginPayload(input, definition, current, cache = new Map()) {
404
409
  }
405
410
  return result;
406
411
  }
412
+ function ownFields(value, fields) {
413
+ return Object.fromEntries(fields.filter(field => Object.hasOwn(value, field)).map(field => [field, value[field]]));
414
+ }
415
+ /** Raw shapes are used only in memory for ignored-path preservation, never exported or hashed as definitions. */
416
+ function rawAgentOmitShape(family, value) {
417
+ return {
418
+ ...ownFields(value, ['name', 'metadata']),
419
+ definition: family === 'agent-plugin'
420
+ ? { ...(isRecord(value.config) ? value.config : {}), ...ownFields(value, ['category', 'active']) }
421
+ : ownFields(value, ['desc', 'config', 'policy']),
422
+ };
423
+ }
424
+ function preserveRawAgentOmitPayload(input, payload, current) {
425
+ if (!current || omitPaths(input.family).length === 0)
426
+ return payload;
427
+ const shape = {
428
+ ...ownFields(payload, ['name', 'metadata']),
429
+ definition: input.family === 'agent-plugin'
430
+ ? Object.fromEntries(Object.entries(payload).filter(([field]) => field !== 'metadata'))
431
+ : ownFields(payload, ['desc', 'config', 'policy']),
432
+ };
433
+ const preserved = preserveOmittedProperties(input.family, shape, rawAgentOmitShape(input.family, current));
434
+ if (input.family === 'agent-plugin')
435
+ return { ...preserved.definition, ...ownFields(preserved, ['metadata']) };
436
+ const result = { ...payload };
437
+ const sections = [[preserved, ['name', 'metadata']], [preserved.definition, ['desc', 'config', 'policy']]];
438
+ for (const [source, fields] of sections) {
439
+ for (const field of fields) {
440
+ if (Object.hasOwn(source, field))
441
+ result[field] = source[field];
442
+ else
443
+ delete result[field];
444
+ }
445
+ }
446
+ return result;
447
+ }
407
448
  async function writePayload(input, manifest, current) {
408
449
  const cache = new Map();
409
450
  if (manifest.kind === 'agent-plugin')
410
- return { ...await pluginPayload(input, manifest.definition, isRecord(current?.config) ? current.config : undefined, cache), category: manifest.definition.category ?? null, metadata: manifest.metadata };
451
+ return preserveRawAgentOmitPayload(input, { ...await pluginPayload(input, manifest.definition, isRecord(current?.config) ? current.config : undefined, cache), category: manifest.definition.category ?? null, metadata: manifest.metadata }, current);
411
452
  if (manifest.executionPrincipal?.kind === 'service-account') {
412
453
  const id = await resolveKey(input, 'service-account', manifest.executionPrincipal.stableKey, cache);
413
454
  if ((await input.client.getServiceAccount(id)).platformAccess !== true)
@@ -435,7 +476,7 @@ async function writePayload(input, manifest, current) {
435
476
  replacement.plugins = [];
436
477
  result[field] = replacement;
437
478
  }
438
- return result;
479
+ return preserveRawAgentOmitPayload(input, result, current);
439
480
  }
440
481
  async function verifyPluginComponents(input, manifest, cache, projected) {
441
482
  const definitions = manifest.kind === 'agent-plugin' ? [manifest.definition]
@@ -511,10 +552,15 @@ export async function buildAgentsPlan(input) {
511
552
  }
512
553
  }
513
554
  const slugs = new Set();
514
- for (const { manifest } of locals) {
555
+ for (const local of locals) {
556
+ let manifest = local.manifest;
515
557
  const item = { name: manifest.name, stableKey: manifest.stableKey, status: 'collision' };
516
558
  plan.items.push(item);
517
559
  try {
560
+ const target = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
561
+ const current = target ? await agentManifestFromRecord(input, target) : null;
562
+ if (current)
563
+ manifest = preserveOmittedProperties(input.family, manifest, current);
518
564
  validate(manifest, input);
519
565
  if (input.family === 'agent-plugin') {
520
566
  const slug = String(manifest.definition.id);
@@ -522,7 +568,6 @@ export async function buildAgentsPlan(input) {
522
568
  throw new Error(`Duplicate local plugin slug "${slug}".`);
523
569
  slugs.add(slug);
524
570
  }
525
- const target = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
526
571
  if (target && input.family === 'agent-plugin' && target.pluginSlug !== manifest.definition.id)
527
572
  throw new Error('Plugin slug is immutable; target Stable Key belongs to a different slug.');
528
573
  const nameCollision = values.some(v => v !== target && (input.family === 'agent-plugin' ? v.pluginSlug === manifest.definition.id : String(v.name).trim().toLowerCase() === manifest.name.trim().toLowerCase()));
@@ -560,13 +605,12 @@ export async function buildAgentsPlan(input) {
560
605
  const mcp = manifest.definition.mcpServer;
561
606
  if (isRecord(mcp))
562
607
  requireMcpAuthentication(mcp, isRecord(target?.config) ? target.config.mcpServer : undefined);
563
- const current = target ? await agentManifestFromRecord(input, target) : null;
564
608
  // Human ownership stays local and cannot create drift.
565
609
  if (current && manifest.owner?.type === 'manual-user')
566
610
  current.owner = manifest.owner;
567
611
  item.desiredHash = hashPortableAgent(manifest);
568
612
  item.currentHash = current ? hashPortableAgent(current) : undefined;
569
- item.baselineHash = lock[manifest.stableKey]?.environments[input.envName]?.remoteHash;
613
+ item.baselineHash = syncBaselineHash(input.family, lock[manifest.stableKey]?.environments[input.envName]);
570
614
  item.status = !target ? 'create' : item.desiredHash === item.currentHash ? 'clean' : !item.baselineHash ? 'missing-lock' : item.currentHash === item.baselineHash ? 'safe-update' : item.desiredHash === item.baselineHash ? 'remote-changed' : 'conflict';
571
615
  if (current && item.desiredHash !== item.currentHash) {
572
616
  item.changedFields = Object.keys(manifest).filter(k => hashStable(manifest[k]) !== hashStable(current[k]));
@@ -614,10 +658,11 @@ export async function pushAgents(input) {
614
658
  const current = target ? await agentManifestFromRecord(input, target) : null;
615
659
  if ((current ? hashPortableAgent(comparableAgent(manifest, current)) : undefined) !== item.currentHash)
616
660
  throw new Error('Target definition changed after planning.');
617
- await verifyPluginComponents(input, manifest, new Map());
661
+ const effectiveManifest = current ? preserveOmittedProperties(input.family, manifest, current) : manifest;
662
+ await verifyPluginComponents(input, effectiveManifest, new Map());
618
663
  let written = target;
619
664
  if (item.desiredHash !== item.currentHash) {
620
- const payload = await writePayload(input, manifest, target);
665
+ const payload = await writePayload(input, effectiveManifest, target);
621
666
  if (target && !Number.isInteger(target.version))
622
667
  throw new Error('Target version is required.');
623
668
  if (target) {
@@ -633,11 +678,18 @@ export async function pushAgents(input) {
633
678
  const readback = await agentManifestFromRecord(input, verified);
634
679
  if (!readback || hashPortableAgent(comparableAgent(manifest, readback)) !== item.desiredHash)
635
680
  throw new Error('Portable readback differs; baseline not recorded.');
681
+ if (!target && !withoutSyncOmit(() => hashPortableAgent(comparableAgent(manifest, readback)) === hashPortableAgent(manifest)))
682
+ throw new Error('Created resource did not initialize the complete source definition.');
683
+ if (current)
684
+ assertOmittedPropertiesPreserved(input.family, current, readback);
685
+ if (target && omitPaths(input.family).length > 0) {
686
+ assertOmittedPropertiesPreserved(input.family, rawAgentOmitShape(input.family, target), rawAgentOmitShape(input.family, verified));
687
+ }
636
688
  const { projectRoot } = requireProjectLayout(input.cwd, input.family);
637
689
  const lock = readComponentLock(projectRoot);
638
690
  const field = AGENT_LAYOUT[input.family][2];
639
691
  const prior = lock[field][manifest.stableKey];
640
- lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: item.desiredHash, environments: { ...prior?.environments, [input.envName]: { remoteHash: item.desiredHash, syncedAt: new Date().toISOString() } } };
692
+ lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: withoutSyncOmit(() => hashPortableAgent(manifest)), environments: { ...prior?.environments, [input.envName]: { remoteHash: item.desiredHash, syncedAt: new Date().toISOString() } } };
641
693
  writeComponentLock(projectRoot, lock);
642
694
  output.status = 'deployed';
643
695
  }
@@ -83,7 +83,12 @@ export type DatabaseSchemaMigrationPolicy = {
83
83
  export type DatabaseSchemaPushResult = {
84
84
  stableKey: string;
85
85
  action: 'create' | 'update' | 'reconcile' | 'delete' | 'skipped';
86
- status: 'deployed' | 'skipped' | 'failed' | 'write-unverified';
86
+ status: 'deployed' | 'accepted' | 'skipped' | 'failed' | 'write-unverified';
87
+ operation?: {
88
+ accepted: true;
89
+ jobId: string;
90
+ status: string;
91
+ };
87
92
  targetPath: string;
88
93
  reason?: string;
89
94
  error?: string;
@@ -123,6 +128,8 @@ export declare function pushDatabaseSchemas(input: {
123
128
  pruneOrphans?: boolean;
124
129
  pruneOrphansConfirmed?: boolean;
125
130
  migrationPolicy?: DatabaseSchemaMigrationPolicy;
131
+ async?: boolean;
132
+ idempotencyKey?: string;
126
133
  }): Promise<{
127
134
  plan: DatabaseSchemasPlan;
128
135
  results: DatabaseSchemaPushResult[];