omp-config-crypt 0.9.9 → 0.9.11

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/README.md CHANGED
@@ -58,9 +58,9 @@ npx omp-config-crypt pull gist:<id> --pass "mysecret" --token "$GITHUB_TOKEN"
58
58
 
59
59
  # Conflict resolution: when local files differ from remote with no baseline
60
60
  # (initial-conflict-both-exist-different), default behavior aborts. Auto-resolve:
61
- # --strategy prefer-remote overwrite local with remote (typical fresh-machine pull)
62
- # --strategy prefer-local keep local files and adopt them as the new baseline
63
- npx omp-config-crypt pull gist:<id> --pass "mysecret" --token "$GITHUB_TOKEN" --strategy prefer-remote
61
+ # --mode remote overwrite local with remote (typical fresh-machine pull)
62
+ # --mode local keep local files and adopt them as the new baseline
63
+ npx omp-config-crypt pull gist:<id> --pass "mysecret" --token "$GITHUB_TOKEN" --mode remote
64
64
 
65
65
  # Keep every modelRoles leaf local (preset and top-level). Other conflicts still abort.
66
66
  npx omp-config-crypt pull gist:<id> --pass "mysecret" --token "$GITHUB_TOKEN" --local
@@ -98,8 +98,8 @@ Configuration exports include the installed `omp-config-crypt` source (excluding
98
98
  /config-push gist:new
99
99
  /config-push gist:<id>
100
100
  /config-push https://…
101
- /config-pull gist:<id> [--dry-run] [--force] [--local]
102
- /config-pull https://… [--dry-run] [--force] [--local]
101
+ /config-pull gist:<id> [--dry-run] [--force] [--mode remote|local] [--local]
102
+ /config-pull https://… [--dry-run] [--force] [--mode remote|local] [--local]
103
103
  /config-rollback
104
104
  /config-upgrade [--check]
105
105
  /config-doctor [gist:<id> | https://…]
package/bin/omp-sync.js CHANGED
@@ -60,7 +60,7 @@ Commands:
60
60
  pull <gist:id|url> Download and restore configs from Gist or HTTP URL
61
61
  (-f/--force adopts a differing remote namespace; local
62
62
  policy/state are backed up to .bak first)
63
- (--strategy prefer-remote|prefer-local auto-resolves
63
+ (--mode remote|local auto-resolves
64
64
  conflicts by taking remote or local side; default:
65
65
  report conflicts and abort)
66
66
  (--local keeps modelRoles leaves local and still
@@ -93,7 +93,7 @@ Options:
93
93
  --public Save as public (synced across machines via models.yml)
94
94
  -y, --yes Non-interactive mode (use defaults without prompting)
95
95
  -f, --force Force operations (pull: adopt differing remote namespace)
96
- --strategy <mode> Conflict resolution for pull: prefer-remote | prefer-local
96
+ --mode <mode> Conflict resolution for pull: remote | local
97
97
  --local Keep modelRoles leaves local; other conflicts still abort
98
98
  --profile <name> Target specific profile scene (e.g. dev, ops)
99
99
 
@@ -165,10 +165,12 @@ function parseCliArgs(argv) {
165
165
  options.nonInteractive = true;
166
166
  } else if (a === "-f" || a === "--force") {
167
167
  options.force = true;
168
- } else if (a === "--strategy") {
169
- options.strategy = args[++i];
170
- } else if (a.startsWith("--strategy=")) {
171
- options.strategy = a.slice(11);
168
+ } else if (a === "--mode" || a === "--strategy") {
169
+ const v = args[++i];
170
+ options.strategy = v === "remote" ? "prefer-remote" : v === "local" ? "prefer-local" : v;
171
+ } else if (a.startsWith("--mode=") || a.startsWith("--strategy=")) {
172
+ const v = a.startsWith("--mode=") ? a.slice(7) : a.slice(11);
173
+ options.strategy = v === "remote" ? "prefer-remote" : v === "local" ? "prefer-local" : v;
172
174
  } else if (a === "--local") {
173
175
  options.keepLocal = true;
174
176
  } else if (a === "--check") {
package/index.js CHANGED
@@ -918,12 +918,17 @@ export function extractDryRun(str) {
918
918
  keepLocal = true;
919
919
  continue;
920
920
  }
921
- if (token === "--strategy") {
921
+ if (token === "--mode" || token === "--strategy") {
922
922
  const value = tokens[++i];
923
923
  if (value === undefined || value.startsWith("-")) {
924
- throw new Error("--strategy requires a value: prefer-remote | prefer-local");
924
+ throw new Error((token === "--mode" ? "--mode" : "--strategy") + " requires a value: remote | local");
925
925
  }
926
- strategy = value;
926
+ strategy = value === "remote" ? "prefer-remote" : value === "local" ? "prefer-local" : value;
927
+ continue;
928
+ }
929
+ if (token.startsWith("--mode=")) {
930
+ const value = token.slice(7);
931
+ strategy = value === "remote" ? "prefer-remote" : value === "local" ? "prefer-local" : value;
927
932
  continue;
928
933
  }
929
934
  if (token.startsWith("--strategy=")) {
@@ -1175,7 +1180,7 @@ export default function (pi) {
1175
1180
  handler: async (args, ctx) => {
1176
1181
  const { dryRun, strategy, keepLocal, clean: src } = extractDryRun(args || "");
1177
1182
  if (!src) {
1178
- ctx.ui.notify("usage: /config-import <file.enc> [--dry-run] [--strategy prefer-remote|prefer-local]", "error");
1183
+ ctx.ui.notify("usage: /config-import <file.enc> [--dry-run] [--mode remote|local]", "error");
1179
1184
  return;
1180
1185
  }
1181
1186
  try {
@@ -1234,7 +1239,7 @@ export default function (pi) {
1234
1239
  }
1235
1240
  const { dryRun, force, strategy, keepLocal, clean: spec } = extractDryRun(args || "");
1236
1241
  if (!spec) {
1237
- ctx.ui.notify("usage: /config-pull gist:<id> | https://… [--dry-run] [--force] [--strategy prefer-remote|prefer-local] [--local]", "error");
1242
+ ctx.ui.notify("usage: /config-pull gist:<id> | https://… [--dry-run] [--force] [--mode remote|local] [--local]", "error");
1238
1243
  return;
1239
1244
  }
1240
1245
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-config-crypt",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "description": "Universal cross-platform encrypted portability for omp config, extensions, and instructions",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/preflight.js CHANGED
@@ -6,8 +6,9 @@
6
6
  */
7
7
  import fs from "node:fs";
8
8
  import path from "node:path";
9
- import { readSyncPolicy } from "./sync-policy.js";
10
- import { readSyncState, healSyncMetadata } from "./sync-plan.js";
9
+ import { readSyncPolicy, resolveResourceScope } from "./sync-policy.js";
10
+ import { readSyncState, healSyncMetadata, canonicalHash, SENTINEL_DELETED } from "./sync-plan.js";
11
+ import { inventoryResources, readResource, canonicalResourceValue } from "./sync-resources.js";
11
12
  import { resolveNpmCommand } from "./rehydrator.js";
12
13
  import { runUpgrade } from "./maintenance.js";
13
14
 
@@ -140,6 +141,40 @@ export async function runPreflight({
140
141
  checks.push({ id: "metadata", status: "fail", detail: `sync metadata not repairable: ${err.message}` });
141
142
  }
142
143
 
144
+ // local-drift: public resources whose local value no longer matches the baseline
145
+ // are the seeds of pull conflicts; surface them before a remote pull aborts.
146
+ try {
147
+ const policy = readSyncPolicy(root);
148
+ const state = readSyncState(root);
149
+ const inventory = inventoryResources(root);
150
+ const drifted = [];
151
+ for (const item of inventory) {
152
+ if (resolveResourceScope(item.id, policy, state, item).scope !== "public") continue;
153
+ const baselineHash = state.resources?.[item.id]?.hash;
154
+ if (!baselineHash || baselineHash === SENTINEL_DELETED) continue;
155
+ const readRes = readResource(root, item.id);
156
+ if (!readRes) {
157
+ drifted.push(`${item.id} (missing locally)`);
158
+ continue;
159
+ }
160
+ const localHash = canonicalHash(canonicalResourceValue(item.id, readRes.value, root));
161
+ if (localHash !== baselineHash) drifted.push(item.id);
162
+ }
163
+ const head = drifted.slice(0, 8);
164
+ const rest = drifted.length - head.length;
165
+ if (drifted.length === 0) {
166
+ checks.push({ id: "local-drift", status: "pass", detail: "no public resource drifted from baseline" });
167
+ } else {
168
+ checks.push({
169
+ id: "local-drift",
170
+ status: "warn",
171
+ detail: `${drifted.length} public resource(s) locally modified since last sync (may conflict on pull): ${head.join(", ")}${rest > 0 ? `, … +${rest} more` : ""}; run pull --dry-run or push to reconcile`,
172
+ });
173
+ }
174
+ } catch (err) {
175
+ checks.push({ id: "local-drift", status: "warn", detail: `drift check failed: ${err.message}` });
176
+ }
177
+
143
178
  // node-engine: informational gate against package.json engines (warn only).
144
179
  const nodeMajor = Number(process.versions.node.split(".")[0]);
145
180
  const floor = nodeEngineFloor();