@memfork/cli 0.1.49 → 0.1.51
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/branch.d.ts +20 -0
- package/dist/branch.js +37 -0
- package/dist/cli.js +1 -0
- package/dist/commands/ops.d.ts +1 -0
- package/dist/commands/ops.js +4 -2
- package/dist/commands/ui-server.js +10 -7
- package/dist/config.d.ts +4 -0
- package/dist/config.js +1 -0
- package/package.json +2 -2
- package/plugins/codex/plugins/memforks/.codex-plugin/plugin.json +1 -1
package/dist/branch.d.ts
CHANGED
|
@@ -28,6 +28,26 @@
|
|
|
28
28
|
* than writing memory into a bogus namespace literally named "HEAD".
|
|
29
29
|
*/
|
|
30
30
|
export declare function gitBranch(cwd?: string): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Read `git config user.name`, or undefined when unset / not in a repo.
|
|
33
|
+
* Used as the automatic default display name for commit authorship.
|
|
34
|
+
*/
|
|
35
|
+
export declare function gitUserName(cwd?: string): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the display name to attribute a commit to.
|
|
38
|
+
*
|
|
39
|
+
* Precedence (highest wins):
|
|
40
|
+
* 1. explicit — the `--author` flag
|
|
41
|
+
* 2. MEMFORK_AUTHOR — env override
|
|
42
|
+
* 3. configAuthor — `author` from .memfork/config.json (persistent persona)
|
|
43
|
+
* 4. git config user.name
|
|
44
|
+
* 5. undefined — caller falls back to the on-chain signer address
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveAuthor(opts?: {
|
|
47
|
+
explicit?: string;
|
|
48
|
+
configAuthor?: string;
|
|
49
|
+
cwd?: string;
|
|
50
|
+
}): string | undefined;
|
|
31
51
|
export interface BranchSources {
|
|
32
52
|
/** --branch / --from flag (highest priority). */
|
|
33
53
|
explicit?: string;
|
package/dist/branch.js
CHANGED
|
@@ -44,6 +44,43 @@ export function gitBranch(cwd = process.cwd()) {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Read `git config user.name`, or undefined when unset / not in a repo.
|
|
49
|
+
* Used as the automatic default display name for commit authorship.
|
|
50
|
+
*/
|
|
51
|
+
export function gitUserName(cwd = process.cwd()) {
|
|
52
|
+
try {
|
|
53
|
+
const out = execSync("git config user.name", {
|
|
54
|
+
encoding: "utf8",
|
|
55
|
+
cwd,
|
|
56
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
57
|
+
}).trim();
|
|
58
|
+
return out || undefined;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the display name to attribute a commit to.
|
|
66
|
+
*
|
|
67
|
+
* Precedence (highest wins):
|
|
68
|
+
* 1. explicit — the `--author` flag
|
|
69
|
+
* 2. MEMFORK_AUTHOR — env override
|
|
70
|
+
* 3. configAuthor — `author` from .memfork/config.json (persistent persona)
|
|
71
|
+
* 4. git config user.name
|
|
72
|
+
* 5. undefined — caller falls back to the on-chain signer address
|
|
73
|
+
*/
|
|
74
|
+
export function resolveAuthor(opts = {}) {
|
|
75
|
+
const clean = (s) => {
|
|
76
|
+
const t = s?.trim();
|
|
77
|
+
return t ? t : undefined;
|
|
78
|
+
};
|
|
79
|
+
return (clean(opts.explicit) ??
|
|
80
|
+
clean(process.env["MEMFORK_AUTHOR"]) ??
|
|
81
|
+
clean(opts.configAuthor) ??
|
|
82
|
+
clean(gitUserName(opts.cwd)));
|
|
83
|
+
}
|
|
47
84
|
/**
|
|
48
85
|
* Pure precedence resolver — no I/O. Exposed separately so the precedence
|
|
49
86
|
* rules can be unit-tested exhaustively without a git repo or env mutation.
|
package/dist/cli.js
CHANGED
|
@@ -96,6 +96,7 @@ program
|
|
|
96
96
|
.option("-b, --branch <name>", "branch (default: current git branch)")
|
|
97
97
|
.option("-f, --facts <facts...>", "one or more fact strings")
|
|
98
98
|
.option("--tool <tool>", "tool that wrote this commit: codex | cursor | sdk")
|
|
99
|
+
.option("--author <name>", "display name for the author (default: git user.name)")
|
|
99
100
|
.option("--from-response <text>", "extract facts from a full response text")
|
|
100
101
|
.option("--auto-extract", "use LLM to extract durable facts (requires --from-response)")
|
|
101
102
|
.option("--file <path>", "attach a file as a Walrus artifact (repeatable). Requires artifacts.enabled = true in config.", (v, acc) => [...acc, v], [])
|
package/dist/commands/ops.d.ts
CHANGED
package/dist/commands/ops.js
CHANGED
|
@@ -7,7 +7,7 @@ import fs from "node:fs";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
import { resolveConfig, toClientConfig, readProjectConfig, writeProjectConfig, MEMWAL_CONSTANTS, } from "../config.js";
|
|
10
|
-
import { resolveBranch } from "../branch.js";
|
|
10
|
+
import { resolveBranch, resolveAuthor } from "../branch.js";
|
|
11
11
|
import { MemForksClient } from "@memfork/core";
|
|
12
12
|
// ─── Shared helpers ───────────────────────────────────────────────────────────
|
|
13
13
|
async function getClient() {
|
|
@@ -116,6 +116,7 @@ export async function cmdRecall(query, opts) {
|
|
|
116
116
|
export async function cmdCommit(opts) {
|
|
117
117
|
const { client, cfg } = await getClient();
|
|
118
118
|
const branch = resolveBranch({ explicit: opts.branch, configDefault: cfg.defaultBranch });
|
|
119
|
+
const authorName = resolveAuthor({ explicit: opts.author, configAuthor: cfg.author });
|
|
119
120
|
let facts = opts.facts ?? [];
|
|
120
121
|
// --from-response + --auto-extract: stub for LLM extraction
|
|
121
122
|
// In production this calls the configured LLM to distil durable facts.
|
|
@@ -152,10 +153,11 @@ export async function cmdCommit(opts) {
|
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
|
-
const { blobId, artifacts: refs } = await client.commit(branch, {
|
|
156
|
+
const { blobId, artifacts: refs = [] } = await client.commit(branch, {
|
|
156
157
|
facts,
|
|
157
158
|
message: opts.message,
|
|
158
159
|
...(opts.tool ? { tool: opts.tool } : {}),
|
|
160
|
+
...(authorName ? { authorName } : {}),
|
|
159
161
|
...(artifacts.length > 0 ? { artifacts } : {}),
|
|
160
162
|
});
|
|
161
163
|
const out = { blobId, branch, artifacts: refs };
|
|
@@ -242,18 +242,21 @@ 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
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
// Prefer the human display name; fall back to the signer address (stored
|
|
246
|
+
// as base64-encoded bytes → 0x-prefixed hex).
|
|
247
|
+
author: (() => {
|
|
248
|
+
if (payload["author_name"])
|
|
249
|
+
return String(payload["author_name"]);
|
|
250
|
+
if (payload["author"]) {
|
|
248
251
|
try {
|
|
249
|
-
|
|
250
|
-
return `0x${hex}`;
|
|
252
|
+
return `0x${Buffer.from(String(payload["author"]), "base64").toString("hex")}`;
|
|
251
253
|
}
|
|
252
254
|
catch {
|
|
253
255
|
return undefined;
|
|
254
256
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
+
}
|
|
258
|
+
return undefined;
|
|
259
|
+
})(),
|
|
257
260
|
...(payload["tool"] ? { tool: payload["tool"] } : {}),
|
|
258
261
|
}];
|
|
259
262
|
});
|
package/dist/config.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export interface ProjectConfig {
|
|
|
43
43
|
network?: 'testnet' | 'mainnet' | 'devnet' | 'localnet';
|
|
44
44
|
/** Default branch name. Default: "main". */
|
|
45
45
|
defaultBranch?: string;
|
|
46
|
+
/** Display name attributed to commits (e.g. "Dev A"). Falls back to git user / signer. */
|
|
47
|
+
author?: string;
|
|
46
48
|
/** Override Sui RPC URL. */
|
|
47
49
|
rpcUrl?: string;
|
|
48
50
|
/** Override package ID (post-upgrade). */
|
|
@@ -88,6 +90,8 @@ export interface ResolvedConfig {
|
|
|
88
90
|
memwalRelayer: string;
|
|
89
91
|
network: 'testnet' | 'mainnet' | 'devnet' | 'localnet';
|
|
90
92
|
defaultBranch: string;
|
|
93
|
+
/** Display name attributed to commits. Undefined when no override is set. */
|
|
94
|
+
author?: string;
|
|
91
95
|
rpcUrl?: string;
|
|
92
96
|
packageId?: string;
|
|
93
97
|
sponsorUrl?: string;
|
package/dist/config.js
CHANGED
|
@@ -188,6 +188,7 @@ export function resolveConfig(opts = {}) {
|
|
|
188
188
|
defaultRelayer(network),
|
|
189
189
|
network,
|
|
190
190
|
defaultBranch: project?.defaultBranch ?? 'main',
|
|
191
|
+
author: env['MEMFORK_AUTHOR'] ?? project?.author,
|
|
191
192
|
rpcUrl: env['MEMFORK_RPC_URL'] ?? project?.rpcUrl,
|
|
192
193
|
packageId: env['MEMFORK_PACKAGE_ID'] ?? project?.packageId,
|
|
193
194
|
sponsorUrl: env['MEMFORK_SPONSOR_URL'] ??
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memfork/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "MemForks CLI — init, commit, recall, merge, install plugins",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@inquirer/prompts": "^8.5.2",
|
|
38
|
-
"@memfork/core": "^0.1.
|
|
38
|
+
"@memfork/core": "^0.1.14",
|
|
39
39
|
"chalk": "^5.6.2",
|
|
40
40
|
"commander": "^15.0.0"
|
|
41
41
|
},
|