omo-memory 0.1.1 → 0.1.3
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 +16 -0
- package/dist/cli.js +10 -1
- package/dist/hookTemplates.js +151 -0
- package/dist/hooks.js +156 -0
- package/dist/mcp.js +1 -1
- package/docs/adapter-integration.md +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ After the package is published to npm, use the same package for CLI and MCP:
|
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
34
|
npx -y omo-memory init
|
|
35
|
+
npx -y omo-memory hooks install --host all
|
|
35
36
|
npx -y omo-memory session bootstrap --host codex --adapter lazycodex --limit 5
|
|
36
37
|
npx -y omo-memory recent --limit 5
|
|
37
38
|
npx -y omo-memory mcp
|
|
@@ -64,6 +65,21 @@ grok mcp add omo-memory -- npx -y omo-memory mcp
|
|
|
64
65
|
|
|
65
66
|
Both hosts use `~/.omo/memory/state.sqlite` by default. The `host` value is recorded when an adapter calls `memory_start_session`, not by installing separate servers.
|
|
66
67
|
|
|
68
|
+
## Passive setup
|
|
69
|
+
|
|
70
|
+
Install passive skills/rules/hooks with:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npx -y omo-memory hooks install --host all
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This installs:
|
|
77
|
+
|
|
78
|
+
- Codex: `~/.codex/skills/omo-memory/SKILL.md` plus a global `~/.codex/AGENTS.md` lifecycle rule.
|
|
79
|
+
- Grok: `~/.grok/skills/omo-memory/SKILL.md`, a global `~/.grok/AGENTS.md` lifecycle rule, and a `~/.grok/hooks/` SessionStart hook.
|
|
80
|
+
|
|
81
|
+
Codex currently exposes MCP and global instruction surfaces, but not a standalone user hook add command like Grok. The Codex passive behavior is therefore rule/skill-driven; Grok additionally gets an executable SessionStart hook.
|
|
82
|
+
|
|
67
83
|
## Session bootstrap
|
|
68
84
|
|
|
69
85
|
Adapters should call the bootstrap tool at the beginning of each host session:
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
+
import { installHooks } from "./hooks.js";
|
|
3
4
|
import { bootstrapSession, doctorReport, exportMemory, initMemory, purgeMemory, recentEvents, recordEvent, startSession, writeHandoff } from "./memory.js";
|
|
4
5
|
import { runMcpServer } from "./mcp.js";
|
|
5
6
|
async function main(argv) {
|
|
@@ -29,6 +30,9 @@ function runCommand(command, subcommand, rest) {
|
|
|
29
30
|
const args = [subcommand, ...rest].filter((value) => value !== undefined);
|
|
30
31
|
return { ok: true, ...purgeMemory({ yes: args.includes("--yes") }) };
|
|
31
32
|
}
|
|
33
|
+
if (command === "hooks" && subcommand === "install") {
|
|
34
|
+
return { ok: true, ...installHooks({ host: parseHookInstallHost(readFlag(rest, "--host") ?? "all") }) };
|
|
35
|
+
}
|
|
32
36
|
if (command === "session" && subcommand === "start") {
|
|
33
37
|
const host = parseHost(readFlag(rest, "--host") ?? "unknown");
|
|
34
38
|
const adapter = readFlag(rest, "--adapter") ?? "unknown";
|
|
@@ -73,6 +77,11 @@ function parseHost(value) {
|
|
|
73
77
|
return value;
|
|
74
78
|
fail("--host must be one of codex, opencode, grok, unknown");
|
|
75
79
|
}
|
|
80
|
+
function parseHookInstallHost(value) {
|
|
81
|
+
if (value === "codex" || value === "grok" || value === "all")
|
|
82
|
+
return value;
|
|
83
|
+
fail("--host must be one of codex, grok, all");
|
|
84
|
+
}
|
|
76
85
|
function readPositiveIntFlag(args, name, defaultValue) {
|
|
77
86
|
return parsePositiveInt(readFlag(args, name) ?? String(defaultValue), name);
|
|
78
87
|
}
|
|
@@ -86,7 +95,7 @@ function fail(message) {
|
|
|
86
95
|
throw new Error(message);
|
|
87
96
|
}
|
|
88
97
|
function printHelp() {
|
|
89
|
-
process.stdout.write(`OMO Memory\n\nCommands:\n omo-memory init\n omo-memory doctor\n omo-memory export\n omo-memory purge --yes\n omo-memory session start --host <codex|opencode|grok|unknown> --adapter <name>\n omo-memory session bootstrap --host <codex|opencode|grok|unknown> --adapter <name> [--limit <n>]\n omo-memory event record --type <type> --summary <text> [--session-id <id>]\n omo-memory recent [--limit <n>]\n omo-memory handoff write (--summary <text> | --summary-file <path>) [--session-id <id>]\n omo-memory mcp\n`);
|
|
98
|
+
process.stdout.write(`OMO Memory\n\nCommands:\n omo-memory init\n omo-memory doctor\n omo-memory export\n omo-memory purge --yes\n omo-memory hooks install --host <codex|grok|all>\n omo-memory session start --host <codex|opencode|grok|unknown> --adapter <name>\n omo-memory session bootstrap --host <codex|opencode|grok|unknown> --adapter <name> [--limit <n>]\n omo-memory event record --type <type> --summary <text> [--session-id <id>]\n omo-memory recent [--limit <n>]\n omo-memory handoff write (--summary <text> | --summary-file <path>) [--session-id <id>]\n omo-memory mcp\n`);
|
|
90
99
|
}
|
|
91
100
|
main(process.argv.slice(2)).catch((error) => {
|
|
92
101
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const CODEX_MARKETPLACE = "islee23520";
|
|
2
|
+
export const CODEX_PLUGIN = "omo-memory";
|
|
3
|
+
export const CODEX_SKILL = `---
|
|
4
|
+
name: omo-memory
|
|
5
|
+
description: Use OMO Memory as the shared local memory ledger across Codex, Grok, and OpenCode. Trigger when starting non-trivial workspace work, needing prior session context, recording decisions, QA evidence, task state, handoffs, or using the omo-memory MCP tools.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# OMO Memory
|
|
9
|
+
|
|
10
|
+
Use the \`omo-memory\` MCP server as the shared local memory ledger across Codex, Grok, and OpenCode.
|
|
11
|
+
|
|
12
|
+
## Session Start
|
|
13
|
+
|
|
14
|
+
At the beginning of non-trivial workspace work, call \`memory_bootstrap_session\` with:
|
|
15
|
+
|
|
16
|
+
- \`host\`: \`codex\`
|
|
17
|
+
- \`adapter\`: \`lazycodex\`
|
|
18
|
+
- \`limit\`: \`5\`
|
|
19
|
+
|
|
20
|
+
Read \`recentEvents\` before changing files. Keep the returned \`sessionId\` for the turn/session.
|
|
21
|
+
|
|
22
|
+
## During Work
|
|
23
|
+
|
|
24
|
+
Record durable, concise facts with \`memory_record_event\` and the active \`sessionId\`: decisions, QA evidence, task state, blockers, and handoff-worthy facts.
|
|
25
|
+
|
|
26
|
+
Use \`memory_write_handoff\` for explicit handoff summaries.
|
|
27
|
+
|
|
28
|
+
## Privacy
|
|
29
|
+
|
|
30
|
+
Never store full transcripts, API keys, tokens, \`.env\` contents, auth files, cookies, bearer headers, or raw secret-bearing logs. Store summaries and evidence references only.
|
|
31
|
+
`;
|
|
32
|
+
export const GROK_SKILL = CODEX_SKILL.replace("Codex, Grok", "Grok, Codex")
|
|
33
|
+
.replace("- `host`: `codex`", "- `host`: `grok`")
|
|
34
|
+
.replace("- `adapter`: `lazycodex`", "- `adapter`: `lfg`");
|
|
35
|
+
export const CODEX_AGENTS_BLOCK = `### OMO Memory lifecycle
|
|
36
|
+
|
|
37
|
+
When the \`omo-memory\` MCP server is available, use it as the shared local memory ledger for Codex/Grok/OpenCode work.
|
|
38
|
+
|
|
39
|
+
At the beginning of a non-trivial workspace session, call \`memory_bootstrap_session\` with:
|
|
40
|
+
|
|
41
|
+
- \`host\`: \`codex\`
|
|
42
|
+
- \`adapter\`: \`lazycodex\`
|
|
43
|
+
- \`limit\`: \`5\`
|
|
44
|
+
|
|
45
|
+
Read the returned \`recentEvents\` before making changes. Keep the returned \`sessionId\` for this session.
|
|
46
|
+
|
|
47
|
+
During work, record concise durable state with \`memory_record_event\` using that \`sessionId\`: decisions, task state, QA evidence, important blockers, and handoff-worthy facts. Use \`memory_write_handoff\` only for explicit handoff summaries. Do not store full transcripts, API keys, tokens, \`.env\` contents, auth files, cookies, bearer headers, or raw secret-bearing logs.`;
|
|
48
|
+
export const GROK_AGENTS_BLOCK = CODEX_AGENTS_BLOCK.replace("- `host`: `codex`", "- `host`: `grok`").replace("- `adapter`: `lazycodex`", "- `adapter`: `lfg`");
|
|
49
|
+
export const SESSION_BOOTSTRAP_SCRIPT = `#!/usr/bin/env node
|
|
50
|
+
import { spawnSync } from "node:child_process";
|
|
51
|
+
|
|
52
|
+
const host = process.env["OMO_MEMORY_HOST"] ?? "codex";
|
|
53
|
+
const adapter = process.env["OMO_MEMORY_ADAPTER"] ?? "lazycodex";
|
|
54
|
+
const limit = process.env["OMO_MEMORY_LIMIT"] ?? "5";
|
|
55
|
+
|
|
56
|
+
const result = spawnSync("npx", ["-y", "omo-memory", "session", "bootstrap", "--host", host, "--adapter", adapter, "--limit", limit], {
|
|
57
|
+
encoding: "utf8",
|
|
58
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
59
|
+
timeout: 5000
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (result.status !== 0) {
|
|
63
|
+
process.stdout.write("OMO Memory: bootstrap unavailable; continue without blocking the session.\\n");
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const payload = JSON.parse(result.stdout);
|
|
69
|
+
const recentEvents = Array.isArray(payload.recentEvents) ? payload.recentEvents : [];
|
|
70
|
+
process.stdout.write(\`OMO Memory sessionId: \${payload.sessionId}\\n\`);
|
|
71
|
+
if (recentEvents.length === 0) {
|
|
72
|
+
process.stdout.write("OMO Memory recentEvents: none for this project.\\n");
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
process.stdout.write("OMO Memory recentEvents:\\n");
|
|
76
|
+
for (const event of recentEvents.slice(0, Number(limit))) {
|
|
77
|
+
process.stdout.write(\`- \${event.type}: \${event.summary}\\n\`);
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
81
|
+
process.stdout.write(\`OMO Memory: bootstrap returned unreadable output; \${detail}\\n\`);
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
export const GROK_HOOK_SCRIPT = SESSION_BOOTSTRAP_SCRIPT.replace('?? "codex"', '?? "grok"').replace('?? "lazycodex"', '?? "lfg"');
|
|
85
|
+
export const CODEX_PLUGIN_JSON = `{
|
|
86
|
+
"name": "omo-memory",
|
|
87
|
+
"version": "0.1.3",
|
|
88
|
+
"description": "Session-start OMO Memory bootstrap hook for Codex.",
|
|
89
|
+
"author": "islee23520",
|
|
90
|
+
"homepage": "https://github.com/islee23520/omo-memory",
|
|
91
|
+
"repository": "https://github.com/islee23520/omo-memory",
|
|
92
|
+
"license": "MIT",
|
|
93
|
+
"keywords": ["codex", "hooks", "memory", "mcp"],
|
|
94
|
+
"skills": "./skills/",
|
|
95
|
+
"hooks": "./hooks/hooks.json",
|
|
96
|
+
"interface": {
|
|
97
|
+
"displayName": "OMO Memory",
|
|
98
|
+
"shortDescription": "Bootstraps local shared memory at Codex session start.",
|
|
99
|
+
"longDescription": "OMO Memory records concise local session state and loads recent project memory through the omo-memory CLI and MCP server.",
|
|
100
|
+
"developerName": "islee23520",
|
|
101
|
+
"category": "Developer Tools",
|
|
102
|
+
"capabilities": ["Hooks", "MCP Tools", "Workflow"],
|
|
103
|
+
"websiteURL": "https://github.com/islee23520/omo-memory",
|
|
104
|
+
"privacyPolicyURL": "https://github.com/islee23520/omo-memory#privacy",
|
|
105
|
+
"termsOfServiceURL": "https://github.com/islee23520/omo-memory#license",
|
|
106
|
+
"defaultPrompt": [
|
|
107
|
+
"Use OMO Memory to load recent project memory before non-trivial workspace work.",
|
|
108
|
+
"Record durable decisions, task state, QA evidence, blockers, and handoffs without storing secrets or full transcripts."
|
|
109
|
+
],
|
|
110
|
+
"brandColor": "#0F766E",
|
|
111
|
+
"screenshots": []
|
|
112
|
+
},
|
|
113
|
+
"capabilities": []
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
export const CODEX_HOOKS_JSON = `{
|
|
117
|
+
"hooks": {
|
|
118
|
+
"SessionStart": [
|
|
119
|
+
{
|
|
120
|
+
"hooks": [
|
|
121
|
+
{
|
|
122
|
+
"type": "command",
|
|
123
|
+
"command": "node \\"\${PLUGIN_ROOT}/scripts/omo-memory-session.mjs\\"",
|
|
124
|
+
"timeout": 5,
|
|
125
|
+
"description": "omo-memory session bootstrap",
|
|
126
|
+
"statusMessage": "OMO Memory: loading recent session memory"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
export const GROK_HOOKS_JSON = `{
|
|
135
|
+
"hooks": {
|
|
136
|
+
"SessionStart": [
|
|
137
|
+
{
|
|
138
|
+
"hooks": [
|
|
139
|
+
{
|
|
140
|
+
"type": "command",
|
|
141
|
+
"command": "node \\"{{HOME}}/.grok/hooks/omo-memory-session.mjs\\"",
|
|
142
|
+
"timeout": 5,
|
|
143
|
+
"description": "omo-memory session bootstrap",
|
|
144
|
+
"statusMessage": "OMO Memory: loading recent session memory"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { CODEX_AGENTS_BLOCK, CODEX_HOOKS_JSON, CODEX_MARKETPLACE, CODEX_PLUGIN, CODEX_PLUGIN_JSON, CODEX_SKILL, GROK_AGENTS_BLOCK, GROK_HOOK_SCRIPT, GROK_HOOKS_JSON, GROK_SKILL, SESSION_BOOTSTRAP_SCRIPT, } from "./hookTemplates.js";
|
|
5
|
+
const BLOCK_START = "<!-- omo-memory:start -->";
|
|
6
|
+
const BLOCK_END = "<!-- omo-memory:end -->";
|
|
7
|
+
export function installHooks(input) {
|
|
8
|
+
const home = process.env["OMO_MEMORY_INSTALL_HOME"] ?? homedir();
|
|
9
|
+
return { home, installed: targetsFor(input.host).map((target) => installTarget(target, home)) };
|
|
10
|
+
}
|
|
11
|
+
function targetsFor(host) {
|
|
12
|
+
if (host === "all")
|
|
13
|
+
return ["codex", "grok"];
|
|
14
|
+
return [host];
|
|
15
|
+
}
|
|
16
|
+
function installTarget(host, home) {
|
|
17
|
+
if (host === "codex")
|
|
18
|
+
return installCodex(home);
|
|
19
|
+
return installGrok(home);
|
|
20
|
+
}
|
|
21
|
+
function installCodex(home) {
|
|
22
|
+
const skillPath = join(home, ".codex", "skills", "omo-memory", "SKILL.md");
|
|
23
|
+
const agentsPath = join(home, ".codex", "AGENTS.md");
|
|
24
|
+
const marketplacePath = join(home, ".codex", "local-marketplaces", CODEX_MARKETPLACE);
|
|
25
|
+
const marketplaceJsonPath = join(marketplacePath, "marketplace.json");
|
|
26
|
+
const agentsMarketplaceJsonPath = join(marketplacePath, ".agents", "plugins", "marketplace.json");
|
|
27
|
+
const pluginRoot = join(marketplacePath, "plugins", CODEX_PLUGIN);
|
|
28
|
+
const pluginJsonPath = join(pluginRoot, ".codex-plugin", "plugin.json");
|
|
29
|
+
const pluginSkillPath = join(pluginRoot, "skills", "omo-memory", "SKILL.md");
|
|
30
|
+
const hookJsonPath = join(pluginRoot, "hooks", "hooks.json");
|
|
31
|
+
const hookScriptPath = join(pluginRoot, "scripts", "omo-memory-session.mjs");
|
|
32
|
+
const configPath = join(home, ".codex", "config.toml");
|
|
33
|
+
writeText(skillPath, CODEX_SKILL);
|
|
34
|
+
upsertAgentsBlock(agentsPath, CODEX_AGENTS_BLOCK);
|
|
35
|
+
writeText(pluginJsonPath, CODEX_PLUGIN_JSON);
|
|
36
|
+
writeText(pluginSkillPath, CODEX_SKILL);
|
|
37
|
+
writeText(hookJsonPath, CODEX_HOOKS_JSON);
|
|
38
|
+
writeText(hookScriptPath, SESSION_BOOTSTRAP_SCRIPT);
|
|
39
|
+
chmodSync(hookScriptPath, 0o755);
|
|
40
|
+
upsertMarketplace(marketplaceJsonPath, { withInterface: false });
|
|
41
|
+
upsertMarketplace(agentsMarketplaceJsonPath, { withInterface: true });
|
|
42
|
+
upsertCodexConfig(configPath, marketplacePath);
|
|
43
|
+
return {
|
|
44
|
+
host: "codex",
|
|
45
|
+
files: [skillPath, agentsPath, pluginJsonPath, pluginSkillPath, hookJsonPath, hookScriptPath, marketplaceJsonPath, agentsMarketplaceJsonPath, configPath],
|
|
46
|
+
notes: [
|
|
47
|
+
"Codex MCP still needs `codex mcp add omo-memory -- npx -y omo-memory mcp` if it is not already present.",
|
|
48
|
+
"Codex plugin hooks are installed through the local islee23520 marketplace and enabled in ~/.codex/config.toml.",
|
|
49
|
+
"Codex may ask to trust the new hook command on first execution unless hook trust has already been granted.",
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function installGrok(home) {
|
|
54
|
+
const skillPath = join(home, ".grok", "skills", "omo-memory", "SKILL.md");
|
|
55
|
+
const agentsPath = join(home, ".grok", "AGENTS.md");
|
|
56
|
+
const hookScriptPath = join(home, ".grok", "hooks", "omo-memory-session.mjs");
|
|
57
|
+
const hookJsonPath = join(home, ".grok", "hooks", "omo-memory-hooks.json");
|
|
58
|
+
writeText(skillPath, GROK_SKILL);
|
|
59
|
+
upsertAgentsBlock(agentsPath, GROK_AGENTS_BLOCK);
|
|
60
|
+
writeText(hookScriptPath, GROK_HOOK_SCRIPT);
|
|
61
|
+
chmodSync(hookScriptPath, 0o755);
|
|
62
|
+
writeText(hookJsonPath, GROK_HOOKS_JSON.replace("{{HOME}}", home));
|
|
63
|
+
return {
|
|
64
|
+
host: "grok",
|
|
65
|
+
files: [skillPath, agentsPath, hookScriptPath, hookJsonPath],
|
|
66
|
+
notes: ["Grok discovers ~/.grok/skills and ~/.grok/hooks; run grok inspect to verify discovery."],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function writeText(path, text) {
|
|
70
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
71
|
+
writeFileSync(path, text, "utf8");
|
|
72
|
+
}
|
|
73
|
+
function upsertMarketplace(path, input) {
|
|
74
|
+
const marketplace = readMarketplace(path, input.withInterface);
|
|
75
|
+
const plugins = marketplace.plugins.filter((plugin) => plugin.name !== CODEX_PLUGIN);
|
|
76
|
+
const omoMemory = marketplacePlugin(input.withInterface);
|
|
77
|
+
const next = { ...marketplace, plugins: [...plugins, omoMemory] };
|
|
78
|
+
writeText(path, `${JSON.stringify(next, null, 2)}\n`);
|
|
79
|
+
}
|
|
80
|
+
function readMarketplace(path, withInterface) {
|
|
81
|
+
if (!existsSync(path))
|
|
82
|
+
return defaultMarketplace(withInterface);
|
|
83
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
84
|
+
if (!isMarketplace(parsed))
|
|
85
|
+
return defaultMarketplace(withInterface);
|
|
86
|
+
return parsed;
|
|
87
|
+
}
|
|
88
|
+
function defaultMarketplace(withInterface) {
|
|
89
|
+
return {
|
|
90
|
+
name: CODEX_MARKETPLACE,
|
|
91
|
+
...(withInterface ? { interface: { displayName: CODEX_MARKETPLACE } } : {}),
|
|
92
|
+
plugins: [],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function marketplacePlugin(withPolicy) {
|
|
96
|
+
return {
|
|
97
|
+
name: CODEX_PLUGIN,
|
|
98
|
+
source: { source: "local", path: "./plugins/omo-memory" },
|
|
99
|
+
...(withPolicy ? { policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" }, category: "Developer Tools" } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function isMarketplace(value) {
|
|
103
|
+
if (!isRecord(value) || value["name"] !== CODEX_MARKETPLACE || !Array.isArray(value["plugins"]))
|
|
104
|
+
return false;
|
|
105
|
+
return value["plugins"].every(isMarketplacePlugin);
|
|
106
|
+
}
|
|
107
|
+
function isMarketplacePlugin(value) {
|
|
108
|
+
if (!isRecord(value) || typeof value["name"] !== "string" || !isRecord(value["source"]))
|
|
109
|
+
return false;
|
|
110
|
+
const source = value["source"];
|
|
111
|
+
return source["source"] === "local" && typeof source["path"] === "string";
|
|
112
|
+
}
|
|
113
|
+
function isRecord(value) {
|
|
114
|
+
return typeof value === "object" && value !== null;
|
|
115
|
+
}
|
|
116
|
+
function upsertCodexConfig(path, marketplacePath) {
|
|
117
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
118
|
+
const withHooks = ensureTomlKey(existing, "[features]", "plugin_hooks = true");
|
|
119
|
+
const withMarketplace = ensureTomlTable(withHooks, `[marketplaces.${CODEX_MARKETPLACE}]`, `source_type = "local"\nsource = "${escapeTomlString(marketplacePath)}"`);
|
|
120
|
+
writeText(path, ensureTomlTable(withMarketplace, `[plugins."${CODEX_PLUGIN}@${CODEX_MARKETPLACE}"]`, "enabled = true"));
|
|
121
|
+
}
|
|
122
|
+
function ensureTomlKey(text, table, keyValue) {
|
|
123
|
+
if (text.includes(keyValue))
|
|
124
|
+
return text;
|
|
125
|
+
if (!text.includes(table))
|
|
126
|
+
return appendTomlTable(text, table, keyValue);
|
|
127
|
+
const start = text.indexOf(table);
|
|
128
|
+
const nextTable = text.indexOf("\n[", start + table.length);
|
|
129
|
+
const insertAt = nextTable === -1 ? text.length : nextTable;
|
|
130
|
+
return `${text.slice(0, insertAt).trimEnd()}\n${keyValue}\n${text.slice(insertAt).trimStart()}`;
|
|
131
|
+
}
|
|
132
|
+
function ensureTomlTable(text, table, body) {
|
|
133
|
+
if (text.includes(table))
|
|
134
|
+
return text;
|
|
135
|
+
return appendTomlTable(text, table, body);
|
|
136
|
+
}
|
|
137
|
+
function appendTomlTable(text, table, body) {
|
|
138
|
+
const prefix = text.trimEnd();
|
|
139
|
+
const separator = prefix.length === 0 ? "" : "\n\n";
|
|
140
|
+
return `${prefix}${separator}${table}\n${body}\n`;
|
|
141
|
+
}
|
|
142
|
+
function escapeTomlString(value) {
|
|
143
|
+
return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
144
|
+
}
|
|
145
|
+
function upsertAgentsBlock(path, block) {
|
|
146
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
147
|
+
const wrapped = `${BLOCK_START}\n${block}\n${BLOCK_END}`;
|
|
148
|
+
const start = existing.indexOf(BLOCK_START);
|
|
149
|
+
const end = existing.indexOf(BLOCK_END);
|
|
150
|
+
if (start !== -1 && end > start) {
|
|
151
|
+
writeText(path, `${existing.slice(0, start)}${wrapped}${existing.slice(end + BLOCK_END.length)}`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const separator = existing.trim().length === 0 ? "" : "\n\n";
|
|
155
|
+
writeText(path, `${existing.trimEnd()}${separator}${wrapped}\n`);
|
|
156
|
+
}
|
package/dist/mcp.js
CHANGED
|
@@ -3,7 +3,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { bootstrapSession, exportMemory, initMemory, memoryPaths, purgeMemory, PurgeConfirmationError, recentEvents, recordEvent, resolveProjectContext, startSession, writeHandoff } from "./memory.js";
|
|
5
5
|
export async function runMcpServer() {
|
|
6
|
-
const server = new McpServer({ name: "omo-memory", version: "0.1.
|
|
6
|
+
const server = new McpServer({ name: "omo-memory", version: "0.1.2" });
|
|
7
7
|
server.registerTool("memory_init", {
|
|
8
8
|
title: "Initialize OMO Memory",
|
|
9
9
|
description: "Create or migrate the local OMO memory SQLite database.",
|
|
@@ -27,6 +27,7 @@ After npm publish, adapters and users can invoke the packaged CLI directly:
|
|
|
27
27
|
|
|
28
28
|
```sh
|
|
29
29
|
npx -y omo-memory init
|
|
30
|
+
npx -y omo-memory hooks install --host all
|
|
30
31
|
npx -y omo-memory session bootstrap --host codex --adapter lazycodex --limit 5
|
|
31
32
|
npx -y omo-memory session start --host codex --adapter lazycodex
|
|
32
33
|
npx -y omo-memory session start --host grok --adapter lfg
|
|
@@ -82,6 +83,22 @@ grok mcp add omo-memory -- npx -y omo-memory mcp
|
|
|
82
83
|
|
|
83
84
|
Register the same MCP server in every host that needs memory access. Do not create separate Codex/Grok schemas or databases; host identity belongs in `memory_start_session` metadata.
|
|
84
85
|
|
|
86
|
+
## Passive Hook Install
|
|
87
|
+
|
|
88
|
+
Install host-side passive behavior with:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
npx -y omo-memory hooks install --host all
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Supported `--host` values:
|
|
95
|
+
|
|
96
|
+
- `codex`: installs `~/.codex/skills/omo-memory/SKILL.md` and an idempotent OMO Memory block in `~/.codex/AGENTS.md`.
|
|
97
|
+
- `grok`: installs `~/.grok/skills/omo-memory/SKILL.md`, an idempotent OMO Memory block in `~/.grok/AGENTS.md`, and `~/.grok/hooks/omo-memory-hooks.json` plus its SessionStart script.
|
|
98
|
+
- `all`: installs both.
|
|
99
|
+
|
|
100
|
+
The installer is idempotent and replaces only the marked `omo-memory` block in AGENTS files.
|
|
101
|
+
|
|
85
102
|
## Session Bootstrap Flow
|
|
86
103
|
|
|
87
104
|
At the beginning of a Codex, OpenCode, or Grok adapter session, call `memory_bootstrap_session` instead of separately calling `memory_start_session` and `memory_recent_events`.
|