@cfbender/cesium 0.7.0 → 0.7.2

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 CHANGED
@@ -36,7 +36,7 @@ Add to `~/.config/opencode/opencode.json`:
36
36
 
37
37
  ```json
38
38
  {
39
- "plugin": ["@cfbender/cesium"]
39
+ "plugin": ["@cfbender/cesium@latest"]
40
40
  }
41
41
  ```
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfbender/cesium",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Beautiful self-contained HTML artifacts from your opencode agent.",
5
5
  "keywords": [
6
6
  "agent",
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ import { createStyleguideTool } from "./tools/styleguide.ts";
12
12
  import { createCritiqueTool } from "./tools/critique.ts";
13
13
  import { createStopTool } from "./tools/stop.ts";
14
14
  import { generateBlockFieldReference } from "./prompt/field-reference.ts";
15
+ import { recordSessionModel } from "./session-model.ts";
15
16
 
16
17
  const rawFragment = await readFile(
17
18
  join(dirname(fileURLToPath(import.meta.url)), "prompt/system-fragment.md"),
@@ -37,6 +38,11 @@ export const CesiumPlugin: Plugin = async (ctx): Promise<Hooks> => {
37
38
  "experimental.chat.system.transform": async (_input, output) => {
38
39
  output.system.push(PROMPT_FRAGMENT);
39
40
  },
41
+ "chat.params": async (input, _output) => {
42
+ // Record the model resolved for this session so tool handlers can stamp
43
+ // it onto generated artifacts. Latest call wins (model can change mid-session).
44
+ recordSessionModel(input.sessionID, input.model.providerID, input.model.id);
45
+ },
40
46
  };
41
47
  };
42
48
 
@@ -942,7 +942,6 @@ export function getClientJs(): string {
942
942
  // Hide when popup opens (activePopup watcher via close/open hooks handled inline above)
943
943
  // Hide menu when selection is cleared or moves outside anchored content
944
944
  }
945
- }
946
945
 
947
946
  // ─── Verdict button wiring ───────────────────────────────────────────────
948
947
  function wireVerdictButtons() {
@@ -1133,13 +1133,37 @@ body { position: relative; }
1133
1133
  flex-direction: column;
1134
1134
  z-index: 50;
1135
1135
  }
1136
- @media (max-width: 900px) {
1136
+ /* When annotate is active and viewport has room for page + rail side-by-side,
1137
+ shift .page leftward so its right edge (and the .cs-anchor-affordance-block
1138
+ button parked at right: 8px of each annotatable block) does not slide under
1139
+ the rail. Required viewport width: 1120 (page) + 24 (gap) + 280 (rail) +
1140
+ 24 (right gutter) = 1448px. */
1141
+ @media (min-width: 1448px) {
1142
+ body.cs-annotate-active .page,
1143
+ body:has(.cs-annotate-scaffold) .page {
1144
+ margin-right: 328px; /* rail width (280) + outer gutter (24) + inner gap (24) */
1145
+ margin-left: auto;
1146
+ }
1147
+ }
1148
+ /* Below 1448px, fall back to a static rail below content. The previous
1149
+ breakpoint at 900px left a wide intermediate zone where the absolute rail
1150
+ overlapped the right edge of .page and covered the per-block Comment button. */
1151
+ @media (max-width: 1447px) {
1137
1152
  .cs-comment-rail {
1138
1153
  position: static;
1139
1154
  width: 100%;
1140
1155
  max-height: none;
1141
1156
  margin-top: 24px;
1142
1157
  }
1158
+ /* In static-rail mode, bubbles flow naturally; positionBubbles() sets
1159
+ top: <px> which we override since bubbles should stack normally. */
1160
+ .cs-comment-rail .cs-comment-bubble {
1161
+ position: static;
1162
+ margin-bottom: 12px;
1163
+ }
1164
+ .cs-comment-rail .cs-comment-bubble::before {
1165
+ display: none;
1166
+ }
1143
1167
  }
1144
1168
  .cs-comment-bubble {
1145
1169
  position: absolute;
@@ -0,0 +1,23 @@
1
+ // Tracks the model in use per opencode session.
2
+ //
3
+ // opencode's `chat.params` hook fires before each LLM request with the resolved
4
+ // Model. We record `providerID/id` keyed by sessionID so that tool handlers
5
+ // (publish/ask/annotate) can stamp the generating model onto every artifact's
6
+ // metadata footer. The map is process-local and resets on plugin reload.
7
+
8
+ const sessionModels = new Map<string, string>();
9
+
10
+ export function recordSessionModel(sessionID: string, providerID: string, modelID: string): void {
11
+ if (!sessionID || !providerID || !modelID) return;
12
+ sessionModels.set(sessionID, `${providerID}/${modelID}`);
13
+ }
14
+
15
+ export function getSessionModel(sessionID: string | undefined | null): string | null {
16
+ if (!sessionID) return null;
17
+ return sessionModels.get(sessionID) ?? null;
18
+ }
19
+
20
+ /** Test-only: clear all recorded session models. */
21
+ export function resetSessionModels(): void {
22
+ sessionModels.clear();
23
+ }
@@ -26,6 +26,7 @@ import {
26
26
  type LifecycleConfig,
27
27
  } from "../server/lifecycle.ts";
28
28
  import { buildTerminalSummary, resolveDisplayHost } from "./publish.ts";
29
+ import { getSessionModel } from "../session-model.ts";
29
30
 
30
31
  export interface AnnotateToolOverrides {
31
32
  loadConfig?: () => CesiumConfig;
@@ -84,7 +85,7 @@ export function createAnnotateTool(
84
85
  tags: tool.schema.array(tool.schema.string()).optional(),
85
86
  expiresAt: tool.schema.string().optional(),
86
87
  },
87
- async execute(args, _context) {
88
+ async execute(args, context) {
88
89
  // 1. Validate top-level input shape
89
90
  const validation = validateAnnotateInput(args);
90
91
  if (!validation.ok) {
@@ -181,8 +182,8 @@ export function createAnnotateTool(
181
182
  summary: input.summary ?? null,
182
183
  tags: input.tags ?? [],
183
184
  createdAt: createdAt.toISOString(),
184
- model: null,
185
- sessionId: null,
185
+ model: getSessionModel(context.sessionID),
186
+ sessionId: context.sessionID ?? null,
186
187
  projectSlug: identity.slug,
187
188
  projectName: identity.name,
188
189
  cwd: ctx.directory,
package/src/tools/ask.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  type LifecycleConfig,
26
26
  } from "../server/lifecycle.ts";
27
27
  import { buildTerminalSummary, resolveDisplayHost } from "./publish.ts";
28
+ import { getSessionModel } from "../session-model.ts";
28
29
 
29
30
  export interface AskToolOverrides {
30
31
  loadConfig?: () => CesiumConfig;
@@ -106,7 +107,7 @@ export function createAskTool(
106
107
  expiresAt: tool.schema.string().optional(),
107
108
  requireAll: tool.schema.boolean().optional(),
108
109
  },
109
- async execute(args, _context) {
110
+ async execute(args, context) {
110
111
  // 1. Validate input
111
112
  const validation = validateAskInput(args);
112
113
  if (!validation.ok) {
@@ -193,8 +194,8 @@ export function createAskTool(
193
194
  summary: input.summary ?? null,
194
195
  tags: input.tags ?? [],
195
196
  createdAt: createdAt.toISOString(),
196
- model: null,
197
- sessionId: null,
197
+ model: getSessionModel(context.sessionID),
198
+ sessionId: context.sessionID ?? null,
198
199
  projectSlug: identity.slug,
199
200
  projectName: identity.name,
200
201
  cwd: ctx.directory,
@@ -31,6 +31,7 @@ import {
31
31
  type RunningInfo,
32
32
  type LifecycleConfig,
33
33
  } from "../server/lifecycle.ts";
34
+ import { getSessionModel } from "../session-model.ts";
34
35
 
35
36
  export interface PublishToolOverrides {
36
37
  loadConfig?: () => CesiumConfig;
@@ -107,7 +108,7 @@ export function createPublishTool(
107
108
  tags: tool.schema.array(tool.schema.string()).optional(),
108
109
  supersedes: tool.schema.string().optional(),
109
110
  },
110
- async execute(args, _context) {
111
+ async execute(args, context) {
111
112
  // 1. Validate input
112
113
  const validation = validatePublishInput(args);
113
114
  if (!validation.ok) {
@@ -190,8 +191,8 @@ export function createPublishTool(
190
191
  summary: input.summary ?? null,
191
192
  tags: input.tags ?? [],
192
193
  createdAt: createdAt.toISOString(),
193
- model: null,
194
- sessionId: null,
194
+ model: getSessionModel(context.sessionID),
195
+ sessionId: context.sessionID ?? null,
195
196
  projectSlug: identity.slug,
196
197
  projectName: identity.name,
197
198
  cwd: ctx.directory,