@memfork/cli 0.1.45 → 0.1.47

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
@@ -85,6 +85,7 @@ program
85
85
  .requiredOption("-m, --message <msg>", "commit message")
86
86
  .option("-b, --branch <name>", "branch (default: current git branch)")
87
87
  .option("-f, --facts <facts...>", "one or more fact strings")
88
+ .option("--tool <tool>", "tool that wrote this commit: codex | cursor | sdk")
88
89
  .option("--from-response <text>", "extract facts from a full response text")
89
90
  .option("--auto-extract", "use LLM to extract durable facts (requires --from-response)")
90
91
  .option("--file <path>", "attach a file as a Walrus artifact (repeatable). Requires artifacts.enabled = true in config.", (v, acc) => [...acc, v], [])
@@ -125,8 +125,10 @@ export async function cmdDoctor() {
125
125
  process.exit(1);
126
126
  }
127
127
  // ── 5. MemoryTree on-chain ──────────────────────────────────────────────────
128
+ let treeOwner;
128
129
  try {
129
130
  const tree = await client.getTree();
131
+ treeOwner = tree.owner;
130
132
  checks.push({
131
133
  label: "MemoryTree on-chain",
132
134
  status: "ok",
@@ -141,7 +143,72 @@ export async function cmdDoctor() {
141
143
  fix: "Check the treeId in .memfork/config.json or run `memfork init`",
142
144
  });
143
145
  }
144
- // ── 6. Signer balance (warn if low) ─────────────────────────────────────────
146
+ // ── 6. Signer role (owner vs delegate) ──────────────────────────────────────
147
+ const signerAddr = client.keypair.toSuiAddress();
148
+ if (treeOwner) {
149
+ if (signerAddr === treeOwner) {
150
+ checks.push({
151
+ label: "Signer role",
152
+ status: "ok",
153
+ detail: `owner (${signerAddr.slice(0, 10)}…)`,
154
+ });
155
+ }
156
+ else {
157
+ // Look for a DelegateCap owned by this signer for this tree.
158
+ try {
159
+ if (!cfg.packageId)
160
+ throw new Error("packageId unknown");
161
+ const capType = `${cfg.packageId}::tree::DelegateCap`;
162
+ const owned = await client.suiClient.getOwnedObjects({
163
+ owner: signerAddr,
164
+ filter: { StructType: capType },
165
+ options: { showContent: true },
166
+ });
167
+ const cap = owned.data.find((o) => {
168
+ if (!o.data?.content || o.data.content.dataType !== "moveObject")
169
+ return false;
170
+ const f = o.data.content.fields;
171
+ return f["tree_id"] === cfg.treeId && !f["revoked"];
172
+ });
173
+ if (cap && cap.data?.content && cap.data.content.dataType === "moveObject") {
174
+ const f = cap.data.content.fields;
175
+ const raw = Number(f["permissions"] ?? 0);
176
+ const labels = [];
177
+ if (raw & 0x01)
178
+ labels.push("READ");
179
+ if (raw & 0x02)
180
+ labels.push("WRITE");
181
+ if (raw & 0x04)
182
+ labels.push("FORK");
183
+ if (raw & 0x08)
184
+ labels.push("MERGE");
185
+ if (raw & 0x10)
186
+ labels.push("PROPOSE");
187
+ checks.push({
188
+ label: "Signer role",
189
+ status: "ok",
190
+ detail: `delegate · ${labels.join(" · ") || "no permissions"} (${signerAddr.slice(0, 10)}…)`,
191
+ });
192
+ }
193
+ else {
194
+ checks.push({
195
+ label: "Signer role",
196
+ status: "warn",
197
+ detail: `no delegate cap found for this tree (${signerAddr.slice(0, 10)}…)`,
198
+ fix: "Ask the tree owner to run: memfork grant --agent " + signerAddr,
199
+ });
200
+ }
201
+ }
202
+ catch {
203
+ checks.push({
204
+ label: "Signer role",
205
+ status: "skip",
206
+ detail: "could not query delegate cap",
207
+ });
208
+ }
209
+ }
210
+ }
211
+ // ── 7. Signer balance (warn if low) ─────────────────────────────────────────
145
212
  try {
146
213
  const addr = client.keypair.toSuiAddress();
147
214
  const balance = await client.suiClient.getBalance({ owner: addr });
@@ -157,7 +224,7 @@ export async function cmdDoctor() {
157
224
  catch {
158
225
  checks.push({ label: "Signer balance", status: "skip", detail: "could not fetch" });
159
226
  }
160
- // ── 7. MemWal reachable ──────────────────────────────────────────────────────
227
+ // ── 8. MemWal reachable ──────────────────────────────────────────────────────
161
228
  try {
162
229
  const resp = await fetch(cfg.memwalRelayer + "/health", { signal: AbortSignal.timeout(5000) });
163
230
  checks.push({
@@ -175,7 +242,7 @@ export async function cmdDoctor() {
175
242
  fix: "Check your network. MemWal read/write will be unavailable.",
176
243
  });
177
244
  }
178
- // ── 8. Artifact storage (optional) ──────────────────────────────────────────
245
+ // ── 9. Artifact storage (optional) ──────────────────────────────────────────
179
246
  if (cfg.artifacts.enabled) {
180
247
  // Artifacts require WAL tokens. Fetch the signer's WAL coin balance.
181
248
  // The WAL package ID is identical on mainnet and testnet.
@@ -16,6 +16,7 @@ export declare function cmdCommit(opts: {
16
16
  branch?: string;
17
17
  message: string;
18
18
  facts?: string[];
19
+ tool?: string;
19
20
  fromResponse?: string;
20
21
  autoExtract?: boolean;
21
22
  /**
@@ -155,6 +155,7 @@ export async function cmdCommit(opts) {
155
155
  const { blobId, artifacts: refs } = await client.commit(branch, {
156
156
  facts,
157
157
  message: opts.message,
158
+ ...(opts.tool ? { tool: opts.tool } : {}),
158
159
  ...(artifacts.length > 0 ? { artifacts } : {}),
159
160
  });
160
161
  const out = { blobId, branch, artifacts: refs };
@@ -242,6 +242,19 @@ async function handleApiHistory(res, url) {
242
242
  message: facts?.length ? facts[0] : `commit ${entry.blob_id.slice(0, 8)}`,
243
243
  delta: payload["delta"] ?? {},
244
244
  ...(artifacts?.length ? { artifacts } : {}),
245
+ // author is stored as base64-encoded bytes; decode to 0x-prefixed hex address.
246
+ ...(payload["author"] ? {
247
+ author: (() => {
248
+ try {
249
+ const hex = Buffer.from(String(payload["author"]), "base64").toString("hex");
250
+ return `0x${hex}`;
251
+ }
252
+ catch {
253
+ return undefined;
254
+ }
255
+ })(),
256
+ } : {}),
257
+ ...(payload["tool"] ? { tool: payload["tool"] } : {}),
245
258
  }];
246
259
  });
247
260
  commits.sort((a, b) => a.ts_ms - b.ts_ms);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memfork/cli",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "MemForks CLI — init, commit, recall, merge, install plugins",
5
5
  "repository": {
6
6
  "type": "git",