opencode-work-context 0.4.13 → 0.4.15
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/package.json +1 -1
- package/plugin/attention.js +21 -19
- package/src/core.js +1 -1
- package/src/tool-definitions.js +2 -1
package/package.json
CHANGED
package/plugin/attention.js
CHANGED
|
@@ -272,25 +272,29 @@ const currentSessionId = (api) => api?.route?.current?.name === "session"
|
|
|
272
272
|
: undefined;
|
|
273
273
|
const linkedSessionIds = (snapshot) => new Set((snapshot?.data?.workspaces || []).flatMap((workspace) =>
|
|
274
274
|
(workspace.sessions || []).map((session) => session.opencode_session_id).filter(Boolean)));
|
|
275
|
+
const visibleSessionRecords = (snapshot, sessionId) => (snapshot?.workspaces || []).flatMap((workspace) => {
|
|
276
|
+
const visibleStages = new Set((workspace.stages || [])
|
|
277
|
+
.filter((stage) => stage.status !== "archived")
|
|
278
|
+
.map((stage) => stage.id));
|
|
279
|
+
return (workspace.sessions || [])
|
|
280
|
+
.filter((session) => session.opencode_session_id === sessionId && visibleStages.has(session.stage))
|
|
281
|
+
.map((session) => ({ workspace, session }));
|
|
282
|
+
});
|
|
275
283
|
const notificationContexts = (snapshot, sessionId, reason) => {
|
|
276
284
|
const contexts = [];
|
|
277
285
|
const seen = new Set();
|
|
278
|
-
for (const workspace of snapshot
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
stageTitle: stage.title,
|
|
291
|
-
reason,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
286
|
+
for (const { workspace, session } of visibleSessionRecords(snapshot, sessionId)) {
|
|
287
|
+
const key = `${workspace.id}:${session.stage}`;
|
|
288
|
+
if (seen.has(key)) continue;
|
|
289
|
+
const stage = workspace.stages.find((item) => item.id === session.stage);
|
|
290
|
+
seen.add(key);
|
|
291
|
+
contexts.push({
|
|
292
|
+
workspaceId: workspace.id,
|
|
293
|
+
workspaceTitle: workspace.title,
|
|
294
|
+
stageId: stage.id,
|
|
295
|
+
stageTitle: stage.title,
|
|
296
|
+
reason,
|
|
297
|
+
});
|
|
294
298
|
}
|
|
295
299
|
return contexts;
|
|
296
300
|
};
|
|
@@ -359,9 +363,7 @@ export const createAttentionTuiController = ({ api, projectRoot, read = readWork
|
|
|
359
363
|
const current = currentSessionId(api);
|
|
360
364
|
for (const attention of engine.list()) {
|
|
361
365
|
if (attention.sessionId === current) continue;
|
|
362
|
-
const records = (snapshot
|
|
363
|
-
.filter((session) => session.opencode_session_id === attention.sessionId)
|
|
364
|
-
.map((session) => ({ workspace, session })));
|
|
366
|
+
const records = visibleSessionRecords(snapshot, attention.sessionId);
|
|
365
367
|
if (records.some(matches)) bySession.set(attention.sessionId, attention);
|
|
366
368
|
}
|
|
367
369
|
const items = [...bySession.values()];
|
package/src/core.js
CHANGED
|
@@ -111,7 +111,7 @@ export class WorkContext {
|
|
|
111
111
|
workspace = normalizeWorkspaceId(workspace);
|
|
112
112
|
const dir = path.join(this.storage.workspaceDir(workspace), "stages");
|
|
113
113
|
if (!fs.existsSync(dir)) fail(ERROR_CODES.NOT_FOUND, "Workspace not found");
|
|
114
|
-
const stages = fs.readdirSync(dir).filter((file) => /^\d{2}\.md$/.test(file)).map((file) => {
|
|
114
|
+
const stages = fs.readdirSync(dir).filter((file) => /^\d{2}\.md$/.test(file)).sort().map((file) => {
|
|
115
115
|
const stage = this.storage.readStage(workspace, file.slice(0, 2)).data;
|
|
116
116
|
return { ...stage, description: stage.goal };
|
|
117
117
|
});
|
package/src/tool-definitions.js
CHANGED
|
@@ -9,7 +9,8 @@ const tool = Object.assign((definition) => definition, { schema: z });
|
|
|
9
9
|
|
|
10
10
|
const run = (fn) => async (args, context) => {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
12
|
+
const projectRoot = context.worktree === "/" ? context.directory : (context.worktree || context.directory);
|
|
13
|
+
const result = await fn(contextFor(projectRoot, context.sessionID), args, context);
|
|
13
14
|
try { await context.metadata({ title: "work-context", metadata: { result } }); } catch {}
|
|
14
15
|
return { output: JSON.stringify(result), metadata: result };
|
|
15
16
|
} catch (error) {
|