@amoree-code/ocean 2.19.0 → 2.21.0
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/application/clients/chat-plugin.js +176 -0
- package/dist/application/clients/status.js +2 -3
- package/dist/application/onboarding/steps.js +46 -1
- package/dist/interfaces/cli/clients-command.js +28 -15
- package/node_modules/@ocean/brain/package.json +1 -1
- package/node_modules/@ocean/context/package.json +1 -1
- package/node_modules/@ocean/core/package.json +1 -1
- package/node_modules/@ocean/loop/package.json +1 -1
- package/node_modules/@ocean/market/package.json +1 -1
- package/node_modules/@ocean/services/dist/infrastructure/mcp/ocean-server.js +42 -2
- package/node_modules/@ocean/services/package.json +1 -1
- package/ocean-marketplace.json +54 -36
- package/package.json +7 -7
- package/skills/core/ocean-memory/SKILL.md +26 -0
- package/skills/index.json +6 -0
- package/dist/application/clients/desktop-plugin.js +0 -238
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { crc32 } from "node:zlib";
|
|
6
|
+
import { enginePath } from "@ocean/core/shared/paths.js";
|
|
7
|
+
// Claude chat (Desktop, claude.ai, phone) runs on Anthropic's servers: it gets Ocean's tools from
|
|
8
|
+
// the MCP entry Ocean writes, but it drops the server's `instructions` and runs no hooks. A skill
|
|
9
|
+
// does reach it: a skill in the Claude account loads in chat, Cowork and the phone, and Claude
|
|
10
|
+
// loads it by itself when a message matches its description (T-328: asked "where your memory
|
|
11
|
+
// lives" with the ocean-memory skill installed, chat called brain_search and named Ocean).
|
|
12
|
+
//
|
|
13
|
+
// Only an upload reaches chat. Claude Desktop's "Add from a repository" installs a marketplace
|
|
14
|
+
// plugin locally for its Code tab (its log: "skipping remote API path … reason=local-sourced"),
|
|
15
|
+
// so chat never sees it; with only that, chat answered from Anthropic's memory (T-328,
|
|
16
|
+
// 2026-11-24). An uploaded skill (`ocean-memory@My Uploads`) is the account's own and loads in
|
|
17
|
+
// chat, Cowork and the phone. Uploading has no API: Ocean writes the zip, shows it, opens Claude,
|
|
18
|
+
// and checks for it in Desktop's plugin list. Claude Code needs none of this: the session-start
|
|
19
|
+
// skill sync copies the same core skill into it.
|
|
20
|
+
export const CHAT_SKILL_ZIP = "ocean-memory.zip";
|
|
21
|
+
export const CHAT_PLUGIN_STEPS = [
|
|
22
|
+
"In Claude: Customize → Skills → Add → Upload a skill",
|
|
23
|
+
`Pick ${CHAT_SKILL_ZIP} (Ocean saved it to your Downloads folder)`,
|
|
24
|
+
"Skills need Settings → Capabilities → Code execution on",
|
|
25
|
+
'Or in Claude Desktop chat, ask: "Install Ocean\'s memory skill", then save the file it makes',
|
|
26
|
+
];
|
|
27
|
+
// Where Claude Desktop keeps each signed-in account's plugin list:
|
|
28
|
+
// plugin-list/<org>/<account>/plugins.json, rows `{id, name, enabled, installPath}`.
|
|
29
|
+
function desktopPluginListDir(home, platform) {
|
|
30
|
+
if (platform === "darwin")
|
|
31
|
+
return path.join(home, "Library", "Application Support", "Claude", "plugin-list");
|
|
32
|
+
if (platform === "win32")
|
|
33
|
+
return path.join(process.env.APPDATA ?? path.join(home, "AppData", "Roaming"), "Claude", "plugin-list");
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const OCEAN_PLUGIN_NAMES = new Set(["ocean", "ocean-memory"]);
|
|
37
|
+
function readJson(file) {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function subdirs(dir) {
|
|
46
|
+
try {
|
|
47
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
48
|
+
.filter((entry) => entry.isDirectory())
|
|
49
|
+
.map((entry) => entry.name);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// True when an account Desktop has signed in lists an enabled Ocean plugin, whether it came
|
|
56
|
+
// from the marketplace (`ocean@ocean`) or was uploaded (`ocean-memory@My Uploads`). Undefined
|
|
57
|
+
// when Desktop keeps no list here.
|
|
58
|
+
function desktopListsOcean(home, platform) {
|
|
59
|
+
const root = desktopPluginListDir(home, platform);
|
|
60
|
+
if (!root)
|
|
61
|
+
return undefined;
|
|
62
|
+
let listed = false;
|
|
63
|
+
for (const org of subdirs(root))
|
|
64
|
+
for (const account of subdirs(path.join(root, org))) {
|
|
65
|
+
const plugins = readJson(path.join(root, org, account, "plugins.json"))?.plugins;
|
|
66
|
+
if (!Array.isArray(plugins))
|
|
67
|
+
continue;
|
|
68
|
+
listed = true;
|
|
69
|
+
if (plugins.some((row) => {
|
|
70
|
+
const { id, name, enabled } = (row ?? {});
|
|
71
|
+
const named = (typeof name === "string" && OCEAN_PLUGIN_NAMES.has(name)) ||
|
|
72
|
+
(typeof id === "string" &&
|
|
73
|
+
OCEAN_PLUGIN_NAMES.has(id.split("@")[0]));
|
|
74
|
+
return named && enabled !== false;
|
|
75
|
+
}))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return listed ? false : undefined;
|
|
79
|
+
}
|
|
80
|
+
// True once the ocean-memory skill is in the Claude account, which is what chat and Cowork load,
|
|
81
|
+
// read from Claude Desktop's own plugin list. Undefined when Desktop keeps no list here, so a
|
|
82
|
+
// machine without Desktop never reads as "not added".
|
|
83
|
+
export function chatPluginAdded(home = os.homedir(), platform = process.platform) {
|
|
84
|
+
return desktopListsOcean(home, platform);
|
|
85
|
+
}
|
|
86
|
+
const run = (file, args, input) => {
|
|
87
|
+
execFileSync(file, args, {
|
|
88
|
+
input,
|
|
89
|
+
stdio: [input === undefined ? "ignore" : "pipe", "ignore", "ignore"],
|
|
90
|
+
timeout: 10_000,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
// A zip of one folder holding SKILL.md, the shape Claude's skill upload takes. Stored, not
|
|
94
|
+
// deflated: the file is small and every unzip reads method 0.
|
|
95
|
+
export function chatSkillZip(skill = readFileSync(path.join(enginePath("skills"), "core", "ocean-memory", "SKILL.md"))) {
|
|
96
|
+
const entries = [
|
|
97
|
+
["ocean-memory/", Buffer.alloc(0)],
|
|
98
|
+
["ocean-memory/SKILL.md", skill],
|
|
99
|
+
];
|
|
100
|
+
const local = [];
|
|
101
|
+
const central = [];
|
|
102
|
+
let offset = 0;
|
|
103
|
+
for (const [name, data] of entries) {
|
|
104
|
+
const file = Buffer.from(name, "utf8");
|
|
105
|
+
const crc = crc32(data);
|
|
106
|
+
const head = Buffer.alloc(30);
|
|
107
|
+
head.writeUInt32LE(0x04034b50, 0);
|
|
108
|
+
head.writeUInt16LE(20, 4); // version needed
|
|
109
|
+
head.writeUInt16LE(0x0800, 6); // UTF-8 names
|
|
110
|
+
head.writeUInt32LE(crc, 14);
|
|
111
|
+
head.writeUInt32LE(data.length, 18);
|
|
112
|
+
head.writeUInt32LE(data.length, 22);
|
|
113
|
+
head.writeUInt16LE(file.length, 26);
|
|
114
|
+
const dir = Buffer.alloc(46);
|
|
115
|
+
dir.writeUInt32LE(0x02014b50, 0);
|
|
116
|
+
dir.writeUInt16LE(20, 4);
|
|
117
|
+
dir.writeUInt16LE(20, 6);
|
|
118
|
+
dir.writeUInt16LE(0x0800, 8);
|
|
119
|
+
dir.writeUInt32LE(crc, 16);
|
|
120
|
+
dir.writeUInt32LE(data.length, 20);
|
|
121
|
+
dir.writeUInt32LE(data.length, 24);
|
|
122
|
+
dir.writeUInt16LE(file.length, 28);
|
|
123
|
+
dir.writeUInt32LE(name.endsWith("/") ? 0x10 : 0, 38);
|
|
124
|
+
dir.writeUInt32LE(offset, 42);
|
|
125
|
+
local.push(head, file, data);
|
|
126
|
+
central.push(dir, file);
|
|
127
|
+
offset += head.length + file.length + data.length;
|
|
128
|
+
}
|
|
129
|
+
const centralSize = central.reduce((sum, part) => sum + part.length, 0);
|
|
130
|
+
const end = Buffer.alloc(22);
|
|
131
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
132
|
+
end.writeUInt16LE(entries.length, 8);
|
|
133
|
+
end.writeUInt16LE(entries.length, 10);
|
|
134
|
+
end.writeUInt32LE(centralSize, 12);
|
|
135
|
+
end.writeUInt32LE(offset, 16);
|
|
136
|
+
return Buffer.concat([...local, ...central, end]);
|
|
137
|
+
}
|
|
138
|
+
// Saves the skill zip to Downloads, shows it in the file manager and brings Claude up, so the
|
|
139
|
+
// step is an upload and a few clicks. Any part failing leaves the printed steps.
|
|
140
|
+
export function openChatPluginSetup(options = {}) {
|
|
141
|
+
const platform = options.platform ?? process.platform;
|
|
142
|
+
const exec = options.exec ?? run;
|
|
143
|
+
const attempt = (file, args) => {
|
|
144
|
+
try {
|
|
145
|
+
exec(file, args);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
let zip;
|
|
153
|
+
try {
|
|
154
|
+
const dir = path.join(options.home ?? os.homedir(), "Downloads");
|
|
155
|
+
mkdirSync(dir, { recursive: true });
|
|
156
|
+
zip = path.join(dir, CHAT_SKILL_ZIP);
|
|
157
|
+
writeFileSync(zip, (options.zip ?? chatSkillZip)());
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
zip = undefined;
|
|
161
|
+
}
|
|
162
|
+
if (platform === "darwin")
|
|
163
|
+
return {
|
|
164
|
+
zip,
|
|
165
|
+
revealed: zip !== undefined && attempt("open", ["-R", zip]),
|
|
166
|
+
opened: attempt("open", ["-a", "Claude"]),
|
|
167
|
+
};
|
|
168
|
+
if (platform === "win32")
|
|
169
|
+
return {
|
|
170
|
+
zip,
|
|
171
|
+
revealed: zip !== undefined && attempt("explorer", [`/select,${zip}`]),
|
|
172
|
+
opened: false,
|
|
173
|
+
};
|
|
174
|
+
return { zip, revealed: false, opened: false };
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=chat-plugin.js.map
|
|
@@ -117,9 +117,8 @@ export function buildClientStatus(input) {
|
|
|
117
117
|
const watcher = input.watcher.find((item) => item.client === plan.client);
|
|
118
118
|
if (watcher && watcher.status !== "current")
|
|
119
119
|
notes.push(`chat watcher ${watcher.status}`);
|
|
120
|
-
if (plan.client === "claude-desktop" &&
|
|
121
|
-
|
|
122
|
-
notes.push("start plugin not installed: run `ocean clients desktop-plugin`");
|
|
120
|
+
if (plan.client === "claude-desktop" && input.chatPlugin?.added === false)
|
|
121
|
+
notes.push("ocean-memory skill not in your Claude account: run `ocean clients chat-plugin`");
|
|
123
122
|
if (plan.tier !== "supported" && plan.reason)
|
|
124
123
|
notes.push(plan.reason);
|
|
125
124
|
clients.push({
|
|
@@ -4,8 +4,9 @@ import { syncCoreSkills } from "@ocean/market/skills/core-skill-sync.js";
|
|
|
4
4
|
import { copyClientSkills } from "@ocean/market/skills/skill-hub.js";
|
|
5
5
|
import { connectObsidianVault } from "@ocean/services/obsidian/vault-discovery.js";
|
|
6
6
|
import { ONBOARDING_QUESTIONS, onboard, } from "@ocean/services/onboarding/onboarding.js";
|
|
7
|
+
import { CHAT_PLUGIN_STEPS, CHAT_SKILL_ZIP, chatPluginAdded, openChatPluginSetup, } from "../clients/chat-plugin.js";
|
|
7
8
|
// Bump when a step is added; completed steps stay completed, only new ids run.
|
|
8
|
-
export const ONBOARDING_VERSION =
|
|
9
|
+
export const ONBOARDING_VERSION = 5;
|
|
9
10
|
async function yes(io, question) {
|
|
10
11
|
return (await io.ask(`${question} [Y/n] `, "y")).trim().toLowerCase() !== "n";
|
|
11
12
|
}
|
|
@@ -96,6 +97,49 @@ function connectStep(clients) {
|
|
|
96
97
|
},
|
|
97
98
|
};
|
|
98
99
|
}
|
|
100
|
+
// Claude chat (Desktop, claude.ai, phone) runs no hooks and drops MCP instructions, so Ocean's
|
|
101
|
+
// rule reaches it as a skill uploaded to the account (T-328). Uploading has no API: the one step
|
|
102
|
+
// left to the owner is an upload and a few clicks, set up here.
|
|
103
|
+
export function chatPluginStep(chat = {
|
|
104
|
+
added: () => chatPluginAdded(),
|
|
105
|
+
open: () => openChatPluginSetup(),
|
|
106
|
+
}) {
|
|
107
|
+
return {
|
|
108
|
+
id: "chat-plugin",
|
|
109
|
+
title: "Claude chat (the ocean-memory skill in your Claude account)",
|
|
110
|
+
optional: false,
|
|
111
|
+
async reopen() {
|
|
112
|
+
return chat.added() === false
|
|
113
|
+
? "the ocean-memory skill is not in your Claude account"
|
|
114
|
+
: null;
|
|
115
|
+
},
|
|
116
|
+
async run(io) {
|
|
117
|
+
if (chat.added() === true) {
|
|
118
|
+
io.say(" The ocean-memory skill is in your Claude account: every Claude chat asks Ocean first.");
|
|
119
|
+
return "done";
|
|
120
|
+
}
|
|
121
|
+
io.say(" Claude chat runs on Anthropic's servers, so one step is yours: upload Ocean's skill to your Claude account.");
|
|
122
|
+
if (!io.interactive) {
|
|
123
|
+
for (const step of CHAT_PLUGIN_STEPS)
|
|
124
|
+
io.say(` ${step}`);
|
|
125
|
+
io.say(" Or run: ocean clients chat-plugin");
|
|
126
|
+
return "skipped";
|
|
127
|
+
}
|
|
128
|
+
const opened = chat.open();
|
|
129
|
+
if (opened.zip)
|
|
130
|
+
io.say(` Saved ${opened.zip}.`);
|
|
131
|
+
if (opened.opened)
|
|
132
|
+
io.say(" Claude is open.");
|
|
133
|
+
for (const step of CHAT_PLUGIN_STEPS)
|
|
134
|
+
io.say(` ${step}`);
|
|
135
|
+
if (!(await yes(io, ` Uploaded ${CHAT_SKILL_ZIP}?`)))
|
|
136
|
+
return "skipped";
|
|
137
|
+
if (chat.added() === false)
|
|
138
|
+
io.say(" Claude has not listed it yet; `ocean clients status` shows it once it has.");
|
|
139
|
+
return "done";
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
99
143
|
// A guided step prints the exact command instead of running it: these touch client
|
|
100
144
|
// configs, credentials or the user's own settings, which Ocean must not edit unasked.
|
|
101
145
|
function guided(id, title, lines, optional = true) {
|
|
@@ -213,6 +257,7 @@ export function buildSteps(deps) {
|
|
|
213
257
|
},
|
|
214
258
|
},
|
|
215
259
|
connectStep(deps.clients),
|
|
260
|
+
chatPluginStep(deps.chatPlugin),
|
|
216
261
|
guided("auth", "Provider authentication", [
|
|
217
262
|
"Run: ocean auth",
|
|
218
263
|
"Credentials stay in the OS keychain or environment, never in files.",
|
|
@@ -3,14 +3,14 @@ import { memorySettings, setSessionFacts, } from "@ocean/brain/memory/memory-aud
|
|
|
3
3
|
import { marketplacePaths } from "@ocean/market/install/default-marketplace.js";
|
|
4
4
|
import { updateGatewayAccess } from "@ocean/market/mcp/mcp-gateway.js";
|
|
5
5
|
import { readCallLedger, summarizeCallLedger, } from "@ocean/services/infrastructure/mcp/call-ledger.js";
|
|
6
|
+
import { CHAT_PLUGIN_STEPS, chatPluginAdded, openChatPluginSetup, } from "../../application/clients/chat-plugin.js";
|
|
6
7
|
import { applyClients, attributeLedger, confirmClient, defaultClientEnv, gatewayDefault, planClients, readGatewayClients, recordVerification, repairClients, restoreClients, setGatewayClient, setGatewayDefault, temporaryEntryProblem, verifyClient, } from "../../application/clients/clients.js";
|
|
7
|
-
import { desktopPluginInstalled, installDesktopPlugin, } from "../../application/clients/desktop-plugin.js";
|
|
8
8
|
import { applyDesktopWatcher, planDesktopWatcher, restoreDesktopWatcher, } from "../../application/clients/desktop-watcher.js";
|
|
9
9
|
import { applyHooks, planHooks, restoreHooks, } from "../../application/clients/hooks.js";
|
|
10
10
|
import { applyNative, planNative, restoreNative, } from "../../application/clients/native.js";
|
|
11
11
|
import { applyOpencodePlugin, planOpencodePlugin, restoreOpencodePlugin, } from "../../application/clients/opencode-plugin.js";
|
|
12
12
|
import { buildClientStatus, formatClientStatus, } from "../../application/clients/status.js";
|
|
13
|
-
const usage = "Usage: ocean clients status [--json] [--days <n>] | detect|plan [--json] | apply [--client <id>…] [--yes] [--session-facts on|off] |
|
|
13
|
+
const usage = "Usage: ocean clients status [--json] [--days <n>] | detect|plan [--json] | apply [--client <id>…] [--yes] [--session-facts on|off] | chat-plugin | verify [<id>…] | confirm <id>… --label in-app|headless|connected|blocked [--via <evidence>] [--reason <why>] | gateway [<id> on|off] [--default gateway|per-server] | allow|deny|unset <id> <server> | ledger | repair | restore [--batch <id>]";
|
|
14
14
|
export const SESSION_FACTS_QUESTION = "Capture durable facts from your sessions automatically? It costs one small model call per session, run by the client the session was in. Every fact goes to your review queue; nothing is saved without your approval, even with auto-approve on. [y/N] ";
|
|
15
15
|
// The session-facts answer, asked once (T-313): `--session-facts on|off` decides; otherwise a
|
|
16
16
|
// terminal is asked; with no terminal and no saved answer it stays unset (off), and
|
|
@@ -63,7 +63,7 @@ export async function runClientsCommand(args) {
|
|
|
63
63
|
plugins: await planOpencodePlugin(),
|
|
64
64
|
native: await planNative(),
|
|
65
65
|
watcher: await planDesktopWatcher(),
|
|
66
|
-
|
|
66
|
+
chatPlugin: { added: chatPluginAdded() },
|
|
67
67
|
calls: await readCallLedger(),
|
|
68
68
|
days,
|
|
69
69
|
});
|
|
@@ -141,29 +141,42 @@ export async function runClientsCommand(args) {
|
|
|
141
141
|
.results,
|
|
142
142
|
sessionFacts: await sessionFactsAnswer(values("--session-facts")[0]),
|
|
143
143
|
};
|
|
144
|
-
// Claude
|
|
145
|
-
//
|
|
144
|
+
// Claude chat's ocean-memory skill (T-328) is uploaded to the account in Claude's own settings, which
|
|
145
|
+
// Ocean cannot write; apply only says whether it is there and what to run when it is not.
|
|
146
146
|
const desktop = (await planClients()).find((plan) => plan.client === "claude-desktop");
|
|
147
|
-
const
|
|
148
|
-
|
|
147
|
+
const added = chatPluginAdded();
|
|
148
|
+
const chatPlugin = desktop?.installed && (!selected || selected.includes("claude-desktop"))
|
|
149
|
+
? {
|
|
150
|
+
added,
|
|
151
|
+
...(added === true ? {} : { next: "ocean clients chat-plugin" }),
|
|
152
|
+
}
|
|
149
153
|
: undefined;
|
|
150
154
|
// After the session-facts answer: the watcher exists only for capture that is on (T-315).
|
|
151
155
|
result = {
|
|
152
156
|
...appliedAll,
|
|
153
157
|
watcher: (await applyDesktopWatcher({ clients: selected, batch: applied.batch })).results,
|
|
154
|
-
...(
|
|
158
|
+
...(chatPlugin ? { chatPlugin } : {}),
|
|
155
159
|
};
|
|
156
160
|
}
|
|
157
|
-
else if (action === "
|
|
158
|
-
//
|
|
159
|
-
|
|
161
|
+
else if (action === "chat-plugin") {
|
|
162
|
+
// Claude chat's one step (T-328): the skill zip saved and shown, Claude open, the clicks
|
|
163
|
+
// printed. Nothing to do once Desktop's plugin list shows it.
|
|
164
|
+
const added = chatPluginAdded();
|
|
165
|
+
const opened = added === true ? undefined : openChatPluginSetup();
|
|
160
166
|
if (!json) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
if (added === true) {
|
|
168
|
+
console.log("added: the ocean-memory skill is in your Claude account; it reaches every Claude chat");
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (opened?.zip)
|
|
172
|
+
console.log(`Saved ${opened.zip}.`);
|
|
173
|
+
for (const step of CHAT_PLUGIN_STEPS)
|
|
174
|
+
console.log(` ${step}`);
|
|
175
|
+
if (added === undefined)
|
|
176
|
+
console.log("Ocean checks for it in Claude Desktop's plugin list; without Desktop, nothing confirms it here.");
|
|
164
177
|
return;
|
|
165
178
|
}
|
|
166
|
-
result =
|
|
179
|
+
result = { added, ...(opened ?? {}) };
|
|
167
180
|
}
|
|
168
181
|
else if (action === "verify") {
|
|
169
182
|
const ids = rest.filter((arg) => !arg.startsWith("--"));
|
|
@@ -9,10 +9,10 @@ import { lookupPerson } from "@ocean/brain/memory/people.js";
|
|
|
9
9
|
import { promoteSessionToKnowledge } from "@ocean/brain/memory/session-promotion.js";
|
|
10
10
|
import { isValidProjectId } from "@ocean/core/domain/context/project-id.js";
|
|
11
11
|
import { actionFingerprint, mcpApprovalSchema, } from "@ocean/core/domain/mcp/mcp-contract.js";
|
|
12
|
-
import { MEMORY_CONTRACT_VERSION, MEMORY_INSTRUCTIONS, MemoryContractError, } from "@ocean/core/domain/mcp/memory-contract.js";
|
|
12
|
+
import { MEMORY_AUTHORITY_LINE, MEMORY_CONTRACT_VERSION, MEMORY_INSTRUCTIONS, MemoryContractError, } from "@ocean/core/domain/mcp/memory-contract.js";
|
|
13
13
|
import { redactSecrets } from "@ocean/core/domain/redaction/redaction.js";
|
|
14
14
|
import { ackIssued } from "@ocean/core/shared/context-ack.js";
|
|
15
|
-
import { oceanPath, oceanRoot, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
15
|
+
import { enginePath, oceanPath, oceanRoot, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
|
|
16
16
|
import { findProject, folderProject, scanProjectManifests, } from "@ocean/core/shared/project-resolution.js";
|
|
17
17
|
import { createHandoff, getHandoff, getTask, listHandoffs, } from "@ocean/loop/handoff/handoff-service.js";
|
|
18
18
|
import { oceanContext } from "@ocean/loop/hooks/session-start-hook.js";
|
|
@@ -394,7 +394,36 @@ const tools = new McpToolRegistry(withContextAck([
|
|
|
394
394
|
additionalProperties: false,
|
|
395
395
|
},
|
|
396
396
|
},
|
|
397
|
+
{
|
|
398
|
+
name: "ocean_chat_skill",
|
|
399
|
+
description: "Install Ocean's memory skill (ocean-memory) in the user's Claude account, so every Claude chat, Cowork and phone session asks Ocean before its own memory. Call when the user asks to install, set up, add or update Ocean or Ocean's skill in Claude, or says Claude chat is not using Ocean. Returns the skill file and how to hand it to the user to save.",
|
|
400
|
+
annotations: { readOnlyHint: true },
|
|
401
|
+
inputSchema: {
|
|
402
|
+
type: "object",
|
|
403
|
+
properties: {},
|
|
404
|
+
additionalProperties: false,
|
|
405
|
+
},
|
|
406
|
+
},
|
|
397
407
|
]));
|
|
408
|
+
// Ocean's memory skill for Claude chat (T-328). Nothing can add a skill to a Claude account
|
|
409
|
+
// for the user: no API, deep link or MCP call. Chat can propose the skill itself, though: Claude
|
|
410
|
+
// Desktop chat shows a skill card the user saves with one click (T-328, 2026-11-24), so the
|
|
411
|
+
// click stays inside the chat; a .skill file is the fallback.
|
|
412
|
+
export const CHAT_SKILL_DIR = "ocean-memory";
|
|
413
|
+
export async function chatSkillInstall() {
|
|
414
|
+
const file = `${CHAT_SKILL_DIR}/SKILL.md`;
|
|
415
|
+
return {
|
|
416
|
+
skill: CHAT_SKILL_DIR,
|
|
417
|
+
file,
|
|
418
|
+
content: await readFile(enginePath("skills", "core", CHAT_SKILL_DIR, "SKILL.md"), "utf8"),
|
|
419
|
+
steps: [
|
|
420
|
+
"If you can propose a skill for the user to save (a skill card), propose this one: name ocean-memory, content exactly as given, changing nothing. The user saves it from the card.",
|
|
421
|
+
`Otherwise, with your code tool, write content to ${file} exactly as given, zip the ${CHAT_SKILL_DIR} folder (the folder itself, so the zip holds ${file}) as ${CHAT_SKILL_DIR}.skill, share that file, and tell the user to save it, or to upload it in Customize → Skills.`,
|
|
422
|
+
"Without either, tell the user to run `ocean clients chat-plugin` on their computer: it saves ocean-memory.zip to upload in Customize → Skills.",
|
|
423
|
+
"Skills need Settings → Capabilities → Code execution on.",
|
|
424
|
+
],
|
|
425
|
+
};
|
|
426
|
+
}
|
|
398
427
|
// What one MCP handoff may hold, summed over its texts (T-307).
|
|
399
428
|
export const HANDOFF_MAX_BYTES = 4096;
|
|
400
429
|
const resources = [
|
|
@@ -471,6 +500,10 @@ let clientName = "unknown";
|
|
|
471
500
|
// start line's hash: one `context_ack` ledger line per connection, ok when it echoed a hash
|
|
472
501
|
// Ocean handed out.
|
|
473
502
|
let contextAckChecked = false;
|
|
503
|
+
// Hosts that drop `instructions` (Claude chat) still show tool results to the model, so the first
|
|
504
|
+
// memory result of each connection carries the authority line as a second text block (T-328).
|
|
505
|
+
let authoritySent = false;
|
|
506
|
+
const AUTHORITY_TOOLS = new Set(["brain_search", "brain_read", "memory_read"]);
|
|
474
507
|
async function callTool(name, args, ports) {
|
|
475
508
|
if (name === "ocean_status") {
|
|
476
509
|
const version = await serverVersion();
|
|
@@ -624,6 +657,8 @@ async function callTool(name, args, ports) {
|
|
|
624
657
|
});
|
|
625
658
|
if (name === "ocean_ping")
|
|
626
659
|
return { ok: true };
|
|
660
|
+
if (name === "ocean_chat_skill")
|
|
661
|
+
return chatSkillInstall();
|
|
627
662
|
if (name === "ocean_capabilities")
|
|
628
663
|
return {
|
|
629
664
|
contract: MEMORY_CONTRACT_VERSION,
|
|
@@ -830,6 +865,7 @@ export async function handleOceanMcpRequest(request, ports) {
|
|
|
830
865
|
if (typeof info?.name === "string" && /^[\w .@/-]{1,64}$/.test(info.name))
|
|
831
866
|
clientName = info.name;
|
|
832
867
|
contextAckChecked = false;
|
|
868
|
+
authoritySent = false;
|
|
833
869
|
return {
|
|
834
870
|
jsonrpc: "2.0",
|
|
835
871
|
id: request.id,
|
|
@@ -912,6 +948,10 @@ export async function handleOceanMcpRequest(request, ports) {
|
|
|
912
948
|
await ports.mcpSessions?.open(clientName);
|
|
913
949
|
try {
|
|
914
950
|
const result = textResult(await callTool(name, args, ports));
|
|
951
|
+
if (!authoritySent && AUTHORITY_TOOLS.has(name)) {
|
|
952
|
+
authoritySent = true;
|
|
953
|
+
result.content.push({ type: "text", text: MEMORY_AUTHORITY_LINE });
|
|
954
|
+
}
|
|
915
955
|
await recordMcpCall(clientName, name, true);
|
|
916
956
|
await ports.mcpSessions?.toolCall(clientName, name, true);
|
|
917
957
|
return { jsonrpc: "2.0", id: request.id, result };
|
package/ocean-marketplace.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
{
|
|
6
6
|
"kind": "skill",
|
|
7
7
|
"name": "dev.ocean.skills.business-logic",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.21.0",
|
|
9
9
|
"engines": {
|
|
10
|
-
"ocean": ">=2.
|
|
10
|
+
"ocean": ">=2.21.0"
|
|
11
11
|
},
|
|
12
12
|
"source": {
|
|
13
13
|
"type": "path",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
{
|
|
24
24
|
"kind": "skill",
|
|
25
25
|
"name": "dev.ocean.skills.catch-up",
|
|
26
|
-
"version": "2.
|
|
26
|
+
"version": "2.21.0",
|
|
27
27
|
"engines": {
|
|
28
|
-
"ocean": ">=2.
|
|
28
|
+
"ocean": ">=2.21.0"
|
|
29
29
|
},
|
|
30
30
|
"source": {
|
|
31
31
|
"type": "path",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
{
|
|
42
42
|
"kind": "skill",
|
|
43
43
|
"name": "dev.ocean.skills.core-thinking",
|
|
44
|
-
"version": "2.
|
|
44
|
+
"version": "2.21.0",
|
|
45
45
|
"engines": {
|
|
46
|
-
"ocean": ">=2.
|
|
46
|
+
"ocean": ">=2.21.0"
|
|
47
47
|
},
|
|
48
48
|
"source": {
|
|
49
49
|
"type": "path",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
{
|
|
60
60
|
"kind": "skill",
|
|
61
61
|
"name": "dev.ocean.skills.daily-harvest",
|
|
62
|
-
"version": "2.
|
|
62
|
+
"version": "2.21.0",
|
|
63
63
|
"engines": {
|
|
64
|
-
"ocean": ">=2.
|
|
64
|
+
"ocean": ">=2.21.0"
|
|
65
65
|
},
|
|
66
66
|
"source": {
|
|
67
67
|
"type": "path",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
{
|
|
78
78
|
"kind": "skill",
|
|
79
79
|
"name": "dev.ocean.skills.design-thinking",
|
|
80
|
-
"version": "2.
|
|
80
|
+
"version": "2.21.0",
|
|
81
81
|
"engines": {
|
|
82
|
-
"ocean": ">=2.
|
|
82
|
+
"ocean": ">=2.21.0"
|
|
83
83
|
},
|
|
84
84
|
"source": {
|
|
85
85
|
"type": "path",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
{
|
|
96
96
|
"kind": "skill",
|
|
97
97
|
"name": "dev.ocean.skills.graft",
|
|
98
|
-
"version": "2.
|
|
98
|
+
"version": "2.21.0",
|
|
99
99
|
"engines": {
|
|
100
|
-
"ocean": ">=2.
|
|
100
|
+
"ocean": ">=2.21.0"
|
|
101
101
|
},
|
|
102
102
|
"source": {
|
|
103
103
|
"type": "path",
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
{
|
|
114
114
|
"kind": "skill",
|
|
115
115
|
"name": "dev.ocean.skills.loop",
|
|
116
|
-
"version": "2.
|
|
116
|
+
"version": "2.21.0",
|
|
117
117
|
"engines": {
|
|
118
|
-
"ocean": ">=2.
|
|
118
|
+
"ocean": ">=2.21.0"
|
|
119
119
|
},
|
|
120
120
|
"source": {
|
|
121
121
|
"type": "path",
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
{
|
|
132
132
|
"kind": "skill",
|
|
133
133
|
"name": "dev.ocean.skills.memory-review",
|
|
134
|
-
"version": "2.
|
|
134
|
+
"version": "2.21.0",
|
|
135
135
|
"engines": {
|
|
136
|
-
"ocean": ">=2.
|
|
136
|
+
"ocean": ">=2.21.0"
|
|
137
137
|
},
|
|
138
138
|
"source": {
|
|
139
139
|
"type": "path",
|
|
@@ -146,12 +146,30 @@
|
|
|
146
146
|
"directory": "memory-review"
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
|
+
{
|
|
150
|
+
"kind": "skill",
|
|
151
|
+
"name": "dev.ocean.skills.ocean-memory",
|
|
152
|
+
"version": "2.21.0",
|
|
153
|
+
"engines": {
|
|
154
|
+
"ocean": ">=2.21.0"
|
|
155
|
+
},
|
|
156
|
+
"source": {
|
|
157
|
+
"type": "path",
|
|
158
|
+
"path": "skills/core/ocean-memory"
|
|
159
|
+
},
|
|
160
|
+
"integrity": {
|
|
161
|
+
"sha256": "8e918188a476359ea27f945218cf91d9eeadd191b41049047762e752bd227fe1"
|
|
162
|
+
},
|
|
163
|
+
"spec": {
|
|
164
|
+
"directory": "ocean-memory"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
149
167
|
{
|
|
150
168
|
"kind": "skill",
|
|
151
169
|
"name": "dev.ocean.skills.session-handoff",
|
|
152
|
-
"version": "2.
|
|
170
|
+
"version": "2.21.0",
|
|
153
171
|
"engines": {
|
|
154
|
-
"ocean": ">=2.
|
|
172
|
+
"ocean": ">=2.21.0"
|
|
155
173
|
},
|
|
156
174
|
"source": {
|
|
157
175
|
"type": "path",
|
|
@@ -167,9 +185,9 @@
|
|
|
167
185
|
{
|
|
168
186
|
"kind": "skill",
|
|
169
187
|
"name": "dev.ocean.skills.use-browser",
|
|
170
|
-
"version": "2.
|
|
188
|
+
"version": "2.21.0",
|
|
171
189
|
"engines": {
|
|
172
|
-
"ocean": ">=2.
|
|
190
|
+
"ocean": ">=2.21.0"
|
|
173
191
|
},
|
|
174
192
|
"source": {
|
|
175
193
|
"type": "path",
|
|
@@ -185,9 +203,9 @@
|
|
|
185
203
|
{
|
|
186
204
|
"kind": "skill",
|
|
187
205
|
"name": "dev.ocean.skills.verification",
|
|
188
|
-
"version": "2.
|
|
206
|
+
"version": "2.21.0",
|
|
189
207
|
"engines": {
|
|
190
|
-
"ocean": ">=2.
|
|
208
|
+
"ocean": ">=2.21.0"
|
|
191
209
|
},
|
|
192
210
|
"source": {
|
|
193
211
|
"type": "path",
|
|
@@ -203,9 +221,9 @@
|
|
|
203
221
|
{
|
|
204
222
|
"kind": "skill",
|
|
205
223
|
"name": "dev.ocean.skills.weekly-review",
|
|
206
|
-
"version": "2.
|
|
224
|
+
"version": "2.21.0",
|
|
207
225
|
"engines": {
|
|
208
|
-
"ocean": ">=2.
|
|
226
|
+
"ocean": ">=2.21.0"
|
|
209
227
|
},
|
|
210
228
|
"source": {
|
|
211
229
|
"type": "path",
|
|
@@ -258,9 +276,9 @@
|
|
|
258
276
|
"npx"
|
|
259
277
|
]
|
|
260
278
|
},
|
|
261
|
-
"version": "2.
|
|
279
|
+
"version": "2.21.0",
|
|
262
280
|
"engines": {
|
|
263
|
-
"ocean": ">=2.
|
|
281
|
+
"ocean": ">=2.21.0"
|
|
264
282
|
},
|
|
265
283
|
"source": {
|
|
266
284
|
"type": "path",
|
|
@@ -379,9 +397,9 @@
|
|
|
379
397
|
"npx"
|
|
380
398
|
]
|
|
381
399
|
},
|
|
382
|
-
"version": "2.
|
|
400
|
+
"version": "2.21.0",
|
|
383
401
|
"engines": {
|
|
384
|
-
"ocean": ">=2.
|
|
402
|
+
"ocean": ">=2.21.0"
|
|
385
403
|
},
|
|
386
404
|
"source": {
|
|
387
405
|
"type": "path",
|
|
@@ -445,9 +463,9 @@
|
|
|
445
463
|
"kind": "mcp",
|
|
446
464
|
"name": "dev.ocean/mcp-gateway",
|
|
447
465
|
"description": "One MCP endpoint for every registered server: Ocean's own and those installed from the marketplace.",
|
|
448
|
-
"version": "2.
|
|
466
|
+
"version": "2.21.0",
|
|
449
467
|
"engines": {
|
|
450
|
-
"ocean": ">=2.
|
|
468
|
+
"ocean": ">=2.21.0"
|
|
451
469
|
},
|
|
452
470
|
"source": {
|
|
453
471
|
"type": "path",
|
|
@@ -489,9 +507,9 @@
|
|
|
489
507
|
"kind": "mcp",
|
|
490
508
|
"name": "dev.ocean/obsidian",
|
|
491
509
|
"description": "Ocean's Obsidian vault bridge over MCP.",
|
|
492
|
-
"version": "2.
|
|
510
|
+
"version": "2.21.0",
|
|
493
511
|
"engines": {
|
|
494
|
-
"ocean": ">=2.
|
|
512
|
+
"ocean": ">=2.21.0"
|
|
495
513
|
},
|
|
496
514
|
"source": {
|
|
497
515
|
"type": "path",
|
|
@@ -533,9 +551,9 @@
|
|
|
533
551
|
"kind": "mcp",
|
|
534
552
|
"name": "dev.ocean/ocean",
|
|
535
553
|
"description": "Ocean's own MCP server: workspace status, tasks, handoffs, sessions and the brain.",
|
|
536
|
-
"version": "2.
|
|
554
|
+
"version": "2.21.0",
|
|
537
555
|
"engines": {
|
|
538
|
-
"ocean": ">=2.
|
|
556
|
+
"ocean": ">=2.21.0"
|
|
539
557
|
},
|
|
540
558
|
"source": {
|
|
541
559
|
"type": "path",
|
|
@@ -587,9 +605,9 @@
|
|
|
587
605
|
"npx"
|
|
588
606
|
]
|
|
589
607
|
},
|
|
590
|
-
"version": "2.
|
|
608
|
+
"version": "2.21.0",
|
|
591
609
|
"engines": {
|
|
592
|
-
"ocean": ">=2.
|
|
610
|
+
"ocean": ">=2.21.0"
|
|
593
611
|
},
|
|
594
612
|
"source": {
|
|
595
613
|
"type": "path",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amoree-code/ocean",
|
|
3
3
|
"description": "Local-first memory, tasks and session capture shared by every AI coding client: one private workspace for Claude, Codex, Gemini and more.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.21.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "AMEER ABDULKAREEM JABBAR LAMI",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"@langchain/core": "1.2.14",
|
|
54
54
|
"@langchain/langgraph": "1.4.19",
|
|
55
55
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
56
|
-
"@ocean/brain": "2.
|
|
57
|
-
"@ocean/context": "2.
|
|
58
|
-
"@ocean/core": "2.
|
|
59
|
-
"@ocean/loop": "2.
|
|
60
|
-
"@ocean/market": "2.
|
|
61
|
-
"@ocean/services": "2.
|
|
56
|
+
"@ocean/brain": "2.21.0",
|
|
57
|
+
"@ocean/context": "2.21.0",
|
|
58
|
+
"@ocean/core": "2.21.0",
|
|
59
|
+
"@ocean/loop": "2.21.0",
|
|
60
|
+
"@ocean/market": "2.21.0",
|
|
61
|
+
"@ocean/services": "2.21.0",
|
|
62
62
|
"playwright-core": "^1.48.0",
|
|
63
63
|
"sqlite-vec": "0.1.9",
|
|
64
64
|
"zod": "^4.6.5"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ocean-memory
|
|
3
|
+
description: The user's memory lives in Ocean, a local memory system on their own computer, reached through the ocean MCP tools (brain_search, brain_read, memory_propose). Use this skill whenever the user asks where their memory is stored, what you remember about them, what you know about their projects, tasks, code, people, preferences or past decisions, or says "my", "our", "remember", "last time", "as before". Ocean is the authority; your built-in memory is not a second store but a copy that Ocean captures.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ocean is the user's memory
|
|
7
|
+
|
|
8
|
+
Ocean is this user's single memory and the authority. Your own built-in memory
|
|
9
|
+
(Claude's memory on claude.ai, a CLI's memory file) is not a separate store to weigh
|
|
10
|
+
against it: it is a copy that Ocean captures.
|
|
11
|
+
|
|
12
|
+
When a message touches the user's own world (their projects, code, tasks, people,
|
|
13
|
+
preferences or past decisions), or they ask where their memory lives or what you
|
|
14
|
+
remember:
|
|
15
|
+
|
|
16
|
+
1. Call the `brain_search` tool from the `ocean` MCP server (a connector in Claude
|
|
17
|
+
chat) with their question.
|
|
18
|
+
2. Read the hits you use with `brain_read`, answer from them, and cite each path.
|
|
19
|
+
3. Asked where memory lives, say in one sentence that it lives in Ocean on their
|
|
20
|
+
own computer, and that your built-in memory is only a copy of it.
|
|
21
|
+
|
|
22
|
+
When the user states a decision, preference or correction, call `memory_propose`.
|
|
23
|
+
Use `memory_write` only when they explicitly ask you to remember or change something.
|
|
24
|
+
|
|
25
|
+
If the `ocean` tools are not available here, say that Ocean is their memory but is
|
|
26
|
+
not connected here, and answer from your built-in memory as a fallback.
|
package/skills/index.json
CHANGED
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"version": "1.0.0",
|
|
48
48
|
"category": "core"
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
"name": "ocean-memory",
|
|
52
|
+
"description": "The user's memory lives in Ocean, a local memory system on their own computer, reached through the ocean MCP tools (brain_search, brain_read, memory_propose). Use this skill whenever the user asks where their memory is stored, what you remember about them, what you know about their projects, tasks, code, people, preferences or past decisions, or says \"my\", \"our\", \"remember\", \"last time\", \"as before\". Ocean is the authority; your built-in memory is not a second store but a copy that Ocean captures.",
|
|
53
|
+
"version": "1.0.0",
|
|
54
|
+
"category": "core"
|
|
55
|
+
},
|
|
50
56
|
{
|
|
51
57
|
"name": "session-handoff",
|
|
52
58
|
"description": "Produce a compact continuation packet with the next action and verification commands.",
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { cp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { crc32 } from "node:zlib";
|
|
7
|
-
import { MEMORY_AUTHORITY_LINE } from "@ocean/core/domain/mcp/memory-contract.js";
|
|
8
|
-
import { oceanPath, SYSTEM_DIR } from "@ocean/core/shared/paths.js";
|
|
9
|
-
// Claude Desktop's chat has no hook setting Ocean can write, and its own memory prompt outranks
|
|
10
|
-
// the MCP server's instructions (T-328: asked alone "where is my memory saved?", chat named
|
|
11
|
-
// Anthropic's store). A plugin's SessionStart hook runs in chat and Cowork, so the plugin carries
|
|
12
|
-
// the authority line into context before the first turn.
|
|
13
|
-
//
|
|
14
|
-
// Installed with no user step: Desktop syncs every plugin in its organization plugins folder at
|
|
15
|
-
// launch and at each session start, and installs one whose manifest says
|
|
16
|
-
// `installationPreference: "required"` (claude.com/docs/third-party/claude-desktop/extensions).
|
|
17
|
-
// The folder is admin-only, so writing it asks for the admin password once — and again only
|
|
18
|
-
// when the plugin's content changes, since its version is a hash of that content. Hooks from
|
|
19
|
-
// that folder do not run in Code sessions, which already get Ocean's own start hook.
|
|
20
|
-
//
|
|
21
|
-
// Static on purpose: chat hooks run sandboxed (the probe's log write never landed on the host),
|
|
22
|
-
// so the hook cannot reach the `ocean` engine.
|
|
23
|
-
export const DESKTOP_PLUGIN_NAME = "ocean";
|
|
24
|
-
// Where Desktop reads organization plugins; Linux has none. OCEAN_DESKTOP_ORG_PLUGINS overrides.
|
|
25
|
-
export function desktopOrgPluginsDir(platform = process.platform) {
|
|
26
|
-
const override = process.env.OCEAN_DESKTOP_ORG_PLUGINS;
|
|
27
|
-
if (override)
|
|
28
|
-
return override;
|
|
29
|
-
if (platform === "darwin")
|
|
30
|
-
return "/Library/Application Support/Claude/org-plugins";
|
|
31
|
-
if (platform === "win32")
|
|
32
|
-
return "C:\\Program Files\\Claude\\org-plugins";
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
function desktopPluginFile() {
|
|
36
|
-
return oceanPath(SYSTEM_DIR, "state", "clients", "ocean-desktop-plugin.zip");
|
|
37
|
-
}
|
|
38
|
-
function desktopPluginStaging() {
|
|
39
|
-
return oceanPath(SYSTEM_DIR, "state", "clients", "desktop-plugin");
|
|
40
|
-
}
|
|
41
|
-
const DESKTOP_PLUGIN_UPLOAD = "Claude Desktop → Customize → Plugins → + → Upload plugin, choose this file, then quit Claude (⌘Q) and reopen it";
|
|
42
|
-
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
43
|
-
function hookFiles() {
|
|
44
|
-
return {
|
|
45
|
-
"hooks/hooks.json": json({
|
|
46
|
-
hooks: {
|
|
47
|
-
SessionStart: [
|
|
48
|
-
{
|
|
49
|
-
hooks: [
|
|
50
|
-
{
|
|
51
|
-
type: "command",
|
|
52
|
-
// biome-ignore lint/suspicious/noTemplateCurlyInString: expanded by Desktop, not JS
|
|
53
|
-
command: 'cat "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.json"',
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
"hooks/session-start.json": json({
|
|
61
|
-
hookSpecificOutput: {
|
|
62
|
-
hookEventName: "SessionStart",
|
|
63
|
-
additionalContext: MEMORY_AUTHORITY_LINE,
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// Changes only when the hook does, so an Ocean upgrade alone never asks for the password again.
|
|
69
|
-
function contentVersion() {
|
|
70
|
-
const hash = createHash("sha256");
|
|
71
|
-
for (const [name, text] of Object.entries(hookFiles()))
|
|
72
|
-
hash.update(`${name}\0${text}\0`);
|
|
73
|
-
return `1.0.0-${hash.digest("hex").slice(0, 12)}`;
|
|
74
|
-
}
|
|
75
|
-
// The plugin's files, by path inside the plugin folder.
|
|
76
|
-
export function desktopPluginFiles(version = contentVersion()) {
|
|
77
|
-
return {
|
|
78
|
-
".claude-plugin/plugin.json": json({
|
|
79
|
-
name: DESKTOP_PLUGIN_NAME,
|
|
80
|
-
version,
|
|
81
|
-
description: "Ocean is your single memory: every Claude Desktop session starts knowing it, and asks Ocean before its own memory.",
|
|
82
|
-
author: { name: "Ocean" },
|
|
83
|
-
homepage: "https://github.com/amoree-code/ocean",
|
|
84
|
-
installationPreference: "required",
|
|
85
|
-
}),
|
|
86
|
-
"version.json": json({ version }),
|
|
87
|
-
...hookFiles(),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// A stored (uncompressed) zip with a fixed timestamp, so the same files give the same bytes.
|
|
91
|
-
// Folder entries precede their files, as `zip` writes them.
|
|
92
|
-
export function zipStored(files) {
|
|
93
|
-
const entries = [];
|
|
94
|
-
const folders = new Set();
|
|
95
|
-
for (const [name, text] of Object.entries(files)) {
|
|
96
|
-
const parts = name.split("/");
|
|
97
|
-
for (let depth = 1; depth < parts.length; depth++) {
|
|
98
|
-
const folder = `${parts.slice(0, depth).join("/")}/`;
|
|
99
|
-
if (!folders.has(folder)) {
|
|
100
|
-
folders.add(folder);
|
|
101
|
-
entries.push([folder, Buffer.alloc(0)]);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
entries.push([name, Buffer.from(text, "utf8")]);
|
|
105
|
-
}
|
|
106
|
-
const DOS_DATE = (0 << 9) | (1 << 5) | 1; // 1980-01-01
|
|
107
|
-
const locals = [];
|
|
108
|
-
const centrals = [];
|
|
109
|
-
let offset = 0;
|
|
110
|
-
for (const [name, data] of entries) {
|
|
111
|
-
const nameBytes = Buffer.from(name, "utf8");
|
|
112
|
-
const crc = crc32(data);
|
|
113
|
-
const local = Buffer.alloc(30);
|
|
114
|
-
local.writeUInt32LE(0x04034b50, 0);
|
|
115
|
-
local.writeUInt16LE(20, 4); // version needed
|
|
116
|
-
local.writeUInt16LE(0x0800, 6); // UTF-8 names
|
|
117
|
-
local.writeUInt16LE(0, 8); // stored
|
|
118
|
-
local.writeUInt16LE(0, 10);
|
|
119
|
-
local.writeUInt16LE(DOS_DATE, 12);
|
|
120
|
-
local.writeUInt32LE(crc, 14);
|
|
121
|
-
local.writeUInt32LE(data.length, 18);
|
|
122
|
-
local.writeUInt32LE(data.length, 22);
|
|
123
|
-
local.writeUInt16LE(nameBytes.length, 26);
|
|
124
|
-
local.writeUInt16LE(0, 28);
|
|
125
|
-
const central = Buffer.alloc(46);
|
|
126
|
-
central.writeUInt32LE(0x02014b50, 0);
|
|
127
|
-
central.writeUInt16LE((3 << 8) | 20, 4); // made by: Unix
|
|
128
|
-
central.writeUInt16LE(20, 6);
|
|
129
|
-
central.writeUInt16LE(0x0800, 8);
|
|
130
|
-
central.writeUInt16LE(0, 10);
|
|
131
|
-
central.writeUInt16LE(0, 12);
|
|
132
|
-
central.writeUInt16LE(DOS_DATE, 14);
|
|
133
|
-
central.writeUInt32LE(crc, 16);
|
|
134
|
-
central.writeUInt32LE(data.length, 20);
|
|
135
|
-
central.writeUInt32LE(data.length, 24);
|
|
136
|
-
central.writeUInt16LE(nameBytes.length, 28);
|
|
137
|
-
central.writeUInt32LE(0, 30); // extra and comment lengths
|
|
138
|
-
central.writeUInt32LE(0, 34); // disk start and internal attributes
|
|
139
|
-
const mode = name.endsWith("/") ? 0o40755 : 0o100644;
|
|
140
|
-
central.writeUInt32LE((mode << 16) >>> 0, 38);
|
|
141
|
-
central.writeUInt32LE(offset, 42);
|
|
142
|
-
locals.push(local, nameBytes, data);
|
|
143
|
-
centrals.push(central, nameBytes);
|
|
144
|
-
offset += local.length + nameBytes.length + data.length;
|
|
145
|
-
}
|
|
146
|
-
const directory = Buffer.concat(centrals);
|
|
147
|
-
const end = Buffer.alloc(22);
|
|
148
|
-
end.writeUInt32LE(0x06054b50, 0);
|
|
149
|
-
end.writeUInt16LE(entries.length, 8);
|
|
150
|
-
end.writeUInt16LE(entries.length, 10);
|
|
151
|
-
end.writeUInt32LE(directory.length, 12);
|
|
152
|
-
end.writeUInt32LE(offset, 16);
|
|
153
|
-
return Buffer.concat([...locals, directory, end]);
|
|
154
|
-
}
|
|
155
|
-
// True when the folder Desktop reads holds exactly this plugin. Readable without admin rights.
|
|
156
|
-
export function desktopPluginInstalled(orgDir = desktopOrgPluginsDir()) {
|
|
157
|
-
if (!orgDir)
|
|
158
|
-
return false;
|
|
159
|
-
const target = path.join(orgDir, DESKTOP_PLUGIN_NAME);
|
|
160
|
-
try {
|
|
161
|
-
return Object.entries(desktopPluginFiles()).every(([name, text]) => readFileSync(path.join(target, name), "utf8") === text);
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
168
|
-
const psQuote = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
169
|
-
// Copies the staged plugin into the admin-only folder behind the system's own password prompt.
|
|
170
|
-
function elevatedCopy(staging, target, platform = process.platform) {
|
|
171
|
-
const orgDir = path.dirname(target);
|
|
172
|
-
if (platform === "darwin") {
|
|
173
|
-
const sh = `mkdir -p ${shellQuote(orgDir)} && rm -rf ${shellQuote(target)} && cp -R ${shellQuote(staging)} ${shellQuote(target)}`;
|
|
174
|
-
const escaped = sh.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
175
|
-
execFileSync("osascript", [
|
|
176
|
-
"-e",
|
|
177
|
-
`do shell script "${escaped}" with prompt "Ocean installs its Claude Desktop plugin." with administrator privileges`,
|
|
178
|
-
], { stdio: "ignore" });
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (platform === "win32") {
|
|
182
|
-
const inner = `New-Item -ItemType Directory -Force -Path ${psQuote(orgDir)} | Out-Null; if (Test-Path ${psQuote(target)}) { Remove-Item -Recurse -Force ${psQuote(target)} }; Copy-Item -Recurse ${psQuote(staging)} ${psQuote(target)}`;
|
|
183
|
-
const encoded = Buffer.from(inner, "utf16le").toString("base64");
|
|
184
|
-
execFileSync("powershell", [
|
|
185
|
-
"-NoProfile",
|
|
186
|
-
"-Command",
|
|
187
|
-
`Start-Process powershell -Verb RunAs -Wait -ArgumentList '-NoProfile','-EncodedCommand','${encoded}'`,
|
|
188
|
-
], { stdio: "ignore" });
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
throw new Error(`no elevated copy on ${platform}`);
|
|
192
|
-
}
|
|
193
|
-
async function directCopy(staging, target) {
|
|
194
|
-
await mkdir(path.dirname(target), { recursive: true });
|
|
195
|
-
await rm(target, { recursive: true, force: true });
|
|
196
|
-
await cp(staging, target, { recursive: true });
|
|
197
|
-
}
|
|
198
|
-
const NEXT_SYNC = "Claude Desktop installs it at its next launch or new session; nothing to upload";
|
|
199
|
-
// Puts the plugin where Desktop installs it by itself. Only when that folder does not exist on
|
|
200
|
-
// this platform, or the admin prompt is declined, does it fall back to a zip to upload.
|
|
201
|
-
export async function installDesktopPlugin(options = {}) {
|
|
202
|
-
const orgDir = "orgDir" in options ? options.orgDir : desktopOrgPluginsDir();
|
|
203
|
-
const manual = async (reason) => {
|
|
204
|
-
const file = desktopPluginFile();
|
|
205
|
-
await mkdir(path.dirname(file), { recursive: true });
|
|
206
|
-
await writeFile(file, zipStored(desktopPluginFiles()));
|
|
207
|
-
return { status: "manual", file, reason, next: DESKTOP_PLUGIN_UPLOAD };
|
|
208
|
-
};
|
|
209
|
-
if (!orgDir)
|
|
210
|
-
return manual(`Claude Desktop reads no organization plugins folder on ${process.platform}`);
|
|
211
|
-
const target = path.join(orgDir, DESKTOP_PLUGIN_NAME);
|
|
212
|
-
if (desktopPluginInstalled(orgDir))
|
|
213
|
-
return { status: "current", dir: target, next: "" };
|
|
214
|
-
const staging = path.join(options.staging ?? desktopPluginStaging(), DESKTOP_PLUGIN_NAME);
|
|
215
|
-
await rm(staging, { recursive: true, force: true });
|
|
216
|
-
for (const [name, text] of Object.entries(desktopPluginFiles())) {
|
|
217
|
-
await mkdir(path.dirname(path.join(staging, name)), { recursive: true });
|
|
218
|
-
await writeFile(path.join(staging, name), text);
|
|
219
|
-
}
|
|
220
|
-
try {
|
|
221
|
-
await (options.copy ?? directCopy)(staging, target);
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
const code = error.code;
|
|
225
|
-
if (code !== "EACCES" && code !== "EPERM")
|
|
226
|
-
throw error;
|
|
227
|
-
try {
|
|
228
|
-
(options.elevate ?? elevatedCopy)(staging, target);
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
return manual("the admin password prompt was declined or failed");
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (!desktopPluginInstalled(orgDir))
|
|
235
|
-
return manual(`the plugin did not land in ${target}`);
|
|
236
|
-
return { status: "installed", dir: target, next: NEXT_SYNC };
|
|
237
|
-
}
|
|
238
|
-
//# sourceMappingURL=desktop-plugin.js.map
|