@memfork/cli 0.1.16 → 0.1.18

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/cli.js CHANGED
@@ -89,9 +89,9 @@ program
89
89
  .action(wrap((opts) => cmdCommit(opts)));
90
90
  program
91
91
  .command("merge <from> <into>")
92
- .description("propose a merge from one branch into another")
93
- .requiredOption("-r, --resolver <id>", "ResolverRef object ID")
94
- .option("--ttl <ms>", "TTL in milliseconds", parseInt, 86_400_000)
92
+ .description("merge memory from one branch into another")
93
+ .option("-r, --resolver <id>", "ResolverRef object ID (default: LastWriteWins, or MEMFORK_RESOLVER_ID env var)")
94
+ .option("--ttl <ms>", "proposal TTL in milliseconds", parseInt, 86_400_000)
95
95
  .action(wrap((from, into, opts) => cmdMerge(from, into, opts)));
96
96
  program
97
97
  .command("proposals")
@@ -20,7 +20,7 @@ export declare function cmdCommit(opts: {
20
20
  autoExtract?: boolean;
21
21
  }): Promise<void>;
22
22
  export declare function cmdMerge(from: string, into: string, opts: {
23
- resolver: string;
23
+ resolver?: string;
24
24
  ttl?: number;
25
25
  }): Promise<void>;
26
26
  export declare function cmdProposals(): Promise<void>;
@@ -126,20 +126,34 @@ export async function cmdCommit(opts) {
126
126
  }
127
127
  // ─── merge ────────────────────────────────────────────────────────────────────
128
128
  export async function cmdMerge(from, into, opts) {
129
- const { client } = await getClient();
130
- process.stdout.write(chalk.dim(`Proposing merge ${chalk.green(from)} → ${chalk.green(into)} … `));
131
- const digest = await client.proposeMerge({
132
- fromBranch: from,
133
- intoBranch: into,
134
- resolverId: opts.resolver,
135
- ttlMs: opts.ttl ?? 86_400_000,
136
- });
129
+ const cfg = resolveConfig();
130
+ const clientCfg = {
131
+ ...toClientConfig(cfg),
132
+ // --resolver flag overrides MEMFORK_RESOLVER_ID env var for this call
133
+ ...(opts.resolver ? { defaultResolverId: opts.resolver } : {}),
134
+ };
135
+ const client = await MemForksClient.connect(clientCfg);
136
+ const governed = !!(opts.resolver ?? process.env["MEMFORK_RESOLVER_ID"]);
137
+ process.stdout.write(chalk.dim(`Merging ${chalk.green(from)} → ${chalk.green(into)}`) +
138
+ chalk.dim(governed ? " (governed — awaiting resolver…)" : " (LWW — self-finalizing…)") +
139
+ " ");
140
+ const { digest, mergedCount, blobId, proposalId } = await client.merge(from, into);
137
141
  console.log(chalk.green("done"));
138
142
  console.log("");
139
- console.log(chalk.dim(` tx: ${digest}`));
143
+ console.log(chalk.dim(` facts merged: ${mergedCount}`));
144
+ if (blobId)
145
+ console.log(chalk.dim(` blob: ${blobId}`));
146
+ if (digest)
147
+ console.log(chalk.dim(` tx: ${digest}`));
148
+ if (proposalId)
149
+ console.log(chalk.dim(` proposal: ${proposalId}`));
140
150
  console.log("");
141
- console.log(chalk.dim("The resolver runtime will handle attestation and finalization automatically."));
142
- console.log(chalk.dim("Use `memfork proposals` to monitor progress."));
151
+ if (governed) {
152
+ console.log(chalk.dim("Resolver finalized. Use `memfork log --branch " + into + "` to verify."));
153
+ }
154
+ else {
155
+ console.log(chalk.dim("Merge anchor written on-chain. Use `memfork log --branch " + into + "` to verify."));
156
+ }
143
157
  console.log("");
144
158
  }
145
159
  // ─── proposals ────────────────────────────────────────────────────────────────
@@ -173,22 +173,36 @@ export async function autoProvision(opts) {
173
173
  });
174
174
  let treeId;
175
175
  let digest;
176
- try {
177
- ({ treeId, digest } = await memClient.initTree(accountId, opts.defaultBranch ?? "main"));
178
- }
179
- catch (e) {
180
- const msg = String(e);
181
- console.log(chalk.red("failed"));
182
- if (msg.includes("429") || msg.toLowerCase().includes("rate limit")) {
183
- throw new Error("Sponsor rate limit hit for init_tree (1/IP/day).\n" +
184
- "Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
185
- ` ${address}`);
176
+ // Retry once on a transient gas-coin version race: the sponsor refreshes its
177
+ // pool after the drip, but if initTree lands before that completes the
178
+ // fullnode may report a stale-object error. A short wait + retry clears it.
179
+ const maxAttempts = 2;
180
+ for (let attempt = 1;; attempt++) {
181
+ try {
182
+ ({ treeId, digest } = await memClient.initTree(accountId, opts.defaultBranch ?? "main"));
183
+ break;
186
184
  }
187
- if (msg.includes("Sponsor error: 404")) {
188
- throw new Error(`Sponsor endpoint not reachable (${sponsorEndpoint}).\n` +
189
- "Set MEMFORK_SPONSOR_URL to your sponsor base URL and retry.");
185
+ catch (e) {
186
+ const msg = String(e);
187
+ const isTransient = msg.includes("needs to be rebuilt") ||
188
+ msg.includes("unavailable for consumption") ||
189
+ msg.includes("object version");
190
+ if (isTransient && attempt < maxAttempts) {
191
+ await new Promise((r) => setTimeout(r, 1500));
192
+ continue;
193
+ }
194
+ console.log(chalk.red("failed"));
195
+ if (msg.includes("429") || msg.toLowerCase().includes("rate limit")) {
196
+ throw new Error("Sponsor rate limit hit for init_tree (1/IP/day).\n" +
197
+ "Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
198
+ ` ${address}`);
199
+ }
200
+ if (msg.includes("Sponsor error: 404")) {
201
+ throw new Error(`Sponsor endpoint not reachable (${sponsorEndpoint}).\n` +
202
+ "Set MEMFORK_SPONSOR_URL to your sponsor base URL and retry.");
203
+ }
204
+ throw new Error(`MemoryTree creation failed: ${msg}`);
190
205
  }
191
- throw new Error(`MemoryTree creation failed: ${msg}`);
192
206
  }
193
207
  if (!treeId) {
194
208
  throw new Error("MemoryTree creation returned no treeId — check sponsor logs.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memfork/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "MemForks CLI — init, commit, recall, merge, install plugins",
5
5
  "repository": {
6
6
  "type": "git",