@amoree-code/ocean 2.2.3 → 2.3.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.
@@ -10,6 +10,7 @@ import { boundProjectManifest } from "@ocean/loop/hooks/session-start-hook.js";
10
10
  import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
11
11
  import { authorizeRun } from "@ocean/loop/runs/run-authorization.js";
12
12
  import { finalizeSession } from "@ocean/loop/sessions/session-closeout.js";
13
+ import { resolveSessionTask } from "@ocean/loop/tasks/session-task.js";
13
14
  import { authAdapter, authLogin, authStatus, } from "../../application/auth/auth-orchestrator.js";
14
15
  import { defaultAuthDeps } from "../../composition/runtime.js";
15
16
  import { redactRuntimeText } from "../../infrastructure/observability/runtime-logger.js";
@@ -72,7 +73,10 @@ export async function intercept(command, args, options = {}) {
72
73
  store.create({
73
74
  sessionId,
74
75
  title: options.title ?? `${provider.id} session`,
75
- taskId: options.taskId ?? null,
76
+ taskId: options.taskId ??
77
+ (await resolveSessionTask(workingDirectory, projectResolution.status === "bound"
78
+ ? projectResolution.projectId
79
+ : null)),
76
80
  handoffId: options.handoffId ?? null,
77
81
  provider: provider.id,
78
82
  providerSessionId: null,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/brain",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/context",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/core",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -3,6 +3,7 @@ import { stat } from "node:fs/promises";
3
3
  import readline from "node:readline";
4
4
  import { finalizeSession } from "../sessions/session-closeout.js";
5
5
  import { sessionProjectId } from "../sessions/session-projects.js";
6
+ import { resolveSessionTask } from "../tasks/session-task.js";
6
7
  // Gemini CLI, Qwen Code and Cursor fire a session-end event too (T-307); their transcript
7
8
  // formats are not read, so their sessions are recorded from metadata alone.
8
9
  export const SESSION_END_CLIENTS = [
@@ -151,8 +152,10 @@ export async function ensureHookSession(store, sessionId, client, cwd) {
151
152
  const existing = store.get(sessionId);
152
153
  if (existing)
153
154
  return existing;
155
+ const projectId = await sessionProjectId(cwd);
154
156
  store.create({
155
157
  sessionId,
158
+ taskId: await resolveSessionTask(cwd, projectId),
156
159
  provider: client,
157
160
  providerSessionId: sessionId,
158
161
  parentSessionId: null,
@@ -160,7 +163,7 @@ export async function ensureHookSession(store, sessionId, client, cwd) {
160
163
  profileIdentity: "",
161
164
  workingDirectory: cwd,
162
165
  resumeData: null,
163
- projectId: await sessionProjectId(cwd),
166
+ projectId,
164
167
  });
165
168
  store.updateStatus(sessionId, "running");
166
169
  return store.get(sessionId);
@@ -11,6 +11,7 @@ import { getHandoff } from "../handoff/handoff-service.js";
11
11
  import { emitHook } from "../hooks/lifecycle-hooks.js";
12
12
  import { finalizeSession } from "../sessions/session-closeout.js";
13
13
  import { sessionProjectId } from "../sessions/session-projects.js";
14
+ import { resolveSessionTask } from "../tasks/session-task.js";
14
15
  import { assemblePrompt, formatActiveLessons, formatProfileContract, formatSkillIndex, PROMOTED_SKILL_MAX_BYTES, readDirectoriesOutside, } from "./prompt-assembly.js";
15
16
  import { authorizeRun } from "./run-authorization.js";
16
17
  import { runToolLoop } from "./tool-loop.js";
@@ -20,8 +21,10 @@ export async function runAgent(request, deps) {
20
21
  const handoff = request.handoffId
21
22
  ? await getHandoff(request.handoffId, deps.openStore)
22
23
  : null;
24
+ const projectId = await sessionProjectId(request.cwd);
23
25
  const effectiveTaskId = request.taskId ??
24
- (typeof handoff?.taskId === "string" ? handoff.taskId : null);
26
+ (typeof handoff?.taskId === "string" ? handoff.taskId : null) ??
27
+ (await resolveSessionTask(request.cwd, projectId));
25
28
  const clientHome = deps.resolveClientHome(profile);
26
29
  executionPolicy(profile, request.cwd);
27
30
  // A completion client returns text and touches nothing, so it is read-only by construction.
@@ -59,7 +62,7 @@ export async function runAgent(request, deps) {
59
62
  profileIdentity: profileIdentity(profile),
60
63
  workingDirectory: request.cwd,
61
64
  resumeData: null,
62
- projectId: await sessionProjectId(request.cwd),
65
+ projectId,
63
66
  });
64
67
  if (request.runContract) {
65
68
  if (request.runContract.sessionId !== sessionId) {
@@ -0,0 +1,130 @@
1
+ import { readdir, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parseTaskId, taskIdSpellings, } from "@ocean/core/domain/tasks/task-id.js";
4
+ import { parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
5
+ import { BRAIN_RECORD_DIRS, CHARTER_DIR, listProjectDirs, oceanPath, oceanRoot, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
6
+ import { CLAIM_TTL_MS } from "./claim-task.js";
7
+ // Task-id-shaped tokens in a branch name: `t318`, `t-318`, `cws-003`, `cws3`.
8
+ export function branchTaskTokens(branch) {
9
+ const tokens = new Set();
10
+ for (const match of branch.matchAll(/(?:^|[/_.-])([a-z][a-z0-9]{0,5}?)-?(\d{1,6})(?=$|[/_.-])/gi)) {
11
+ const parsed = parseTaskId(`${match[1]}-${match[2]}`);
12
+ if (parsed)
13
+ tokens.add(`${parsed.prefix}-${parsed.number}`);
14
+ }
15
+ return [...tokens];
16
+ }
17
+ const sameTask = (token, id) => taskIdSpellings(token).some((spelling) => spelling.toUpperCase() === id.toUpperCase());
18
+ const inside = (dir, parent) => {
19
+ const relative = path.relative(parent, dir);
20
+ return (relative === "" ||
21
+ (!relative.startsWith("..") && !path.isAbsolute(relative)));
22
+ };
23
+ export function taskForSession(input) {
24
+ const now = (input.now ?? new Date()).getTime();
25
+ const live = input.candidates.filter((task) => task.state !== "cancelled");
26
+ // 1. The task's own folder.
27
+ const home = live.filter((task) => task.dir && inside(input.cwd, task.dir));
28
+ if (home.length === 1)
29
+ return home[0].id;
30
+ // 2. The branch, where the directory can hold code.
31
+ const codeDir = !(input.noCodeDirs ?? []).some((dir) => inside(input.cwd, dir));
32
+ const tokens = input.branch && codeDir ? branchTaskTokens(input.branch) : [];
33
+ const named = live.filter((task) => tokens.some((token) => sameTask(token, task.id)));
34
+ const inProject = named.filter((task) => task.project === input.projectId);
35
+ const byBranch = inProject.length ? inProject : named;
36
+ // One task, not one id: T-5 in two projects is two tasks.
37
+ if (new Set(byBranch.map((task) => `${task.project}/${task.id}`)).size === 1)
38
+ return byBranch[0].id;
39
+ if (byBranch.length > 1)
40
+ return null;
41
+ // 3. A live claim on a path holding the working directory.
42
+ const claimed = live.filter((task) => task.claim &&
43
+ now - Date.parse(task.claim.at) <= CLAIM_TTL_MS &&
44
+ task.claim.paths.some((entry) => inside(input.cwd, path.join(input.root, entry))));
45
+ return claimed.length === 1 ? claimed[0].id : null;
46
+ }
47
+ // The branch checked out at `cwd`, read from .git/HEAD (a worktree's `.git` file points at its
48
+ // own HEAD); null when detached or outside a repository. No git process is started.
49
+ export async function gitBranchAt(cwd) {
50
+ let dir = path.resolve(cwd);
51
+ for (;;) {
52
+ const dotGit = path.join(dir, ".git");
53
+ let gitDir = null;
54
+ try {
55
+ const text = await readFile(dotGit, "utf8");
56
+ const pointer = /^gitdir:\s*(.+)$/m.exec(text)?.[1]?.trim();
57
+ if (pointer)
58
+ gitDir = path.resolve(dir, pointer);
59
+ }
60
+ catch (error) {
61
+ const code = error.code;
62
+ if (code === "EISDIR")
63
+ gitDir = dotGit;
64
+ else if (code !== "ENOENT" && code !== "ENOTDIR")
65
+ return null;
66
+ }
67
+ if (gitDir) {
68
+ const head = await readFile(path.join(gitDir, "HEAD"), "utf8").catch(() => "");
69
+ return /^ref:\s*refs\/heads\/(.+)$/m.exec(head)?.[1]?.trim() ?? null;
70
+ }
71
+ const parent = path.dirname(dir);
72
+ if (parent === dir)
73
+ return null;
74
+ dir = parent;
75
+ }
76
+ }
77
+ // Every task folder in every project (archive/ excluded), with its state and claim.
78
+ export async function sessionTaskCandidates() {
79
+ const candidates = [];
80
+ for (const { id: project, dir } of listProjectDirs()) {
81
+ const root = oceanPath(dir, "tasks");
82
+ let entries;
83
+ try {
84
+ entries = await readdir(root);
85
+ }
86
+ catch {
87
+ continue;
88
+ }
89
+ for (const entry of entries) {
90
+ if (entry === "archive")
91
+ continue;
92
+ const source = await readFile(path.join(root, entry, "task.md"), "utf8").catch(() => "");
93
+ if (!source)
94
+ continue;
95
+ const fields = parseFrontmatter(source);
96
+ const paths = (fields.claimed_paths?.match(/^\[(.*)\]$/)?.[1] ?? "")
97
+ .split(",")
98
+ .map((item) => item.trim().replace(/^\.\//, "").replace(/\/+$/, ""))
99
+ .filter(Boolean);
100
+ candidates.push({
101
+ dir: path.join(root, entry),
102
+ id: fields.id || entry,
103
+ project,
104
+ state: fields.state ?? "",
105
+ claim: fields.claimed_by && fields.claimed_at
106
+ ? { at: fields.claimed_at, paths }
107
+ : null,
108
+ });
109
+ }
110
+ }
111
+ return candidates;
112
+ }
113
+ // What every session-creating path calls when no task was named. Never throws: a session is
114
+ // still recorded when the workspace cannot be read.
115
+ export async function resolveSessionTask(cwd, projectId) {
116
+ try {
117
+ return taskForSession({
118
+ cwd,
119
+ branch: await gitBranchAt(cwd),
120
+ projectId,
121
+ candidates: await sessionTaskCandidates(),
122
+ root: oceanRoot(),
123
+ noCodeDirs: [...BRAIN_RECORD_DIRS, SYSTEM_DIR, CHARTER_DIR].map((dir) => oceanPath(dir)),
124
+ });
125
+ }
126
+ catch {
127
+ return null;
128
+ }
129
+ }
130
+ //# sourceMappingURL=session-task.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/loop",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/market",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocean/services",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -5,9 +5,9 @@
5
5
  {
6
6
  "kind": "skill",
7
7
  "name": "dev.ocean.skills.business-logic",
8
- "version": "2.2.3",
8
+ "version": "2.3.0",
9
9
  "engines": {
10
- "ocean": ">=2.2.3"
10
+ "ocean": ">=2.3.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.2.3",
26
+ "version": "2.3.0",
27
27
  "engines": {
28
- "ocean": ">=2.2.3"
28
+ "ocean": ">=2.3.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.2.3",
44
+ "version": "2.3.0",
45
45
  "engines": {
46
- "ocean": ">=2.2.3"
46
+ "ocean": ">=2.3.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.2.3",
62
+ "version": "2.3.0",
63
63
  "engines": {
64
- "ocean": ">=2.2.3"
64
+ "ocean": ">=2.3.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.2.3",
80
+ "version": "2.3.0",
81
81
  "engines": {
82
- "ocean": ">=2.2.3"
82
+ "ocean": ">=2.3.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.2.3",
98
+ "version": "2.3.0",
99
99
  "engines": {
100
- "ocean": ">=2.2.3"
100
+ "ocean": ">=2.3.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.2.3",
116
+ "version": "2.3.0",
117
117
  "engines": {
118
- "ocean": ">=2.2.3"
118
+ "ocean": ">=2.3.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.2.3",
134
+ "version": "2.3.0",
135
135
  "engines": {
136
- "ocean": ">=2.2.3"
136
+ "ocean": ">=2.3.0"
137
137
  },
138
138
  "source": {
139
139
  "type": "path",
@@ -149,9 +149,9 @@
149
149
  {
150
150
  "kind": "skill",
151
151
  "name": "dev.ocean.skills.session-handoff",
152
- "version": "2.2.3",
152
+ "version": "2.3.0",
153
153
  "engines": {
154
- "ocean": ">=2.2.3"
154
+ "ocean": ">=2.3.0"
155
155
  },
156
156
  "source": {
157
157
  "type": "path",
@@ -167,9 +167,9 @@
167
167
  {
168
168
  "kind": "skill",
169
169
  "name": "dev.ocean.skills.use-browser",
170
- "version": "2.2.3",
170
+ "version": "2.3.0",
171
171
  "engines": {
172
- "ocean": ">=2.2.3"
172
+ "ocean": ">=2.3.0"
173
173
  },
174
174
  "source": {
175
175
  "type": "path",
@@ -185,9 +185,9 @@
185
185
  {
186
186
  "kind": "skill",
187
187
  "name": "dev.ocean.skills.verification",
188
- "version": "2.2.3",
188
+ "version": "2.3.0",
189
189
  "engines": {
190
- "ocean": ">=2.2.3"
190
+ "ocean": ">=2.3.0"
191
191
  },
192
192
  "source": {
193
193
  "type": "path",
@@ -203,9 +203,9 @@
203
203
  {
204
204
  "kind": "skill",
205
205
  "name": "dev.ocean.skills.weekly-review",
206
- "version": "2.2.3",
206
+ "version": "2.3.0",
207
207
  "engines": {
208
- "ocean": ">=2.2.3"
208
+ "ocean": ">=2.3.0"
209
209
  },
210
210
  "source": {
211
211
  "type": "path",
@@ -247,9 +247,9 @@
247
247
  "npx"
248
248
  ]
249
249
  },
250
- "version": "2.2.3",
250
+ "version": "2.3.0",
251
251
  "engines": {
252
- "ocean": ">=2.2.3"
252
+ "ocean": ">=2.3.0"
253
253
  },
254
254
  "source": {
255
255
  "type": "path",
@@ -299,9 +299,9 @@
299
299
  "kind": "mcp",
300
300
  "name": "dev.ocean/mcp-gateway",
301
301
  "description": "One MCP endpoint for every registered server: Ocean's own and those installed from the marketplace.",
302
- "version": "2.2.3",
302
+ "version": "2.3.0",
303
303
  "engines": {
304
- "ocean": ">=2.2.3"
304
+ "ocean": ">=2.3.0"
305
305
  },
306
306
  "source": {
307
307
  "type": "path",
@@ -343,9 +343,9 @@
343
343
  "kind": "mcp",
344
344
  "name": "dev.ocean/obsidian",
345
345
  "description": "Ocean's Obsidian vault bridge over MCP.",
346
- "version": "2.2.3",
346
+ "version": "2.3.0",
347
347
  "engines": {
348
- "ocean": ">=2.2.3"
348
+ "ocean": ">=2.3.0"
349
349
  },
350
350
  "source": {
351
351
  "type": "path",
@@ -387,9 +387,9 @@
387
387
  "kind": "mcp",
388
388
  "name": "dev.ocean/ocean",
389
389
  "description": "Ocean's own MCP server: workspace status, tasks, handoffs, sessions and the brain.",
390
- "version": "2.2.3",
390
+ "version": "2.3.0",
391
391
  "engines": {
392
- "ocean": ">=2.2.3"
392
+ "ocean": ">=2.3.0"
393
393
  },
394
394
  "source": {
395
395
  "type": "path",
@@ -441,9 +441,9 @@
441
441
  "npx"
442
442
  ]
443
443
  },
444
- "version": "2.2.3",
444
+ "version": "2.3.0",
445
445
  "engines": {
446
- "ocean": ">=2.2.3"
446
+ "ocean": ">=2.3.0"
447
447
  },
448
448
  "source": {
449
449
  "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.2.3",
4
+ "version": "2.3.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.2.3",
57
- "@ocean/context": "2.2.3",
58
- "@ocean/core": "2.2.3",
59
- "@ocean/loop": "2.2.3",
60
- "@ocean/market": "2.2.3",
61
- "@ocean/services": "2.2.3",
56
+ "@ocean/brain": "2.3.0",
57
+ "@ocean/context": "2.3.0",
58
+ "@ocean/core": "2.3.0",
59
+ "@ocean/loop": "2.3.0",
60
+ "@ocean/market": "2.3.0",
61
+ "@ocean/services": "2.3.0",
62
62
  "playwright-core": "^1.48.0",
63
63
  "sqlite-vec": "0.1.9",
64
64
  "zod": "^4.6.5"