@encoredigitalgroup/opencode 0.2.9 → 0.2.11

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
@@ -90,3 +90,6 @@ bun install
90
90
  bun run check
91
91
  bun run pack:check
92
92
  ```
93
+
94
+ Run `bun run local:install` to build the plugin and switch the local OpenCode configuration to this checkout. Run `bun run local:uninstall` to restore
95
+ `@encoredigitalgroup/opencode@latest`. Both commands preserve the plugin's configured options.
@@ -0,0 +1,30 @@
1
+ import type { Rpc } from "@opencode/plugin";
2
+ import type { SkillMappings } from "../config";
3
+ export declare const planningConfigRpcID = "encoredigitalgroup.opencode-planning";
4
+ export type PlanningConfigRpcOutput = {
5
+ planDirectory: string;
6
+ skillMappings: SkillMappings;
7
+ };
8
+ type StandardValueSchema = Extract<Rpc.PortableValueSchema, {
9
+ "~standard": unknown;
10
+ }>;
11
+ type Typed<T> = {
12
+ "~standard": {
13
+ types?: {
14
+ input: T;
15
+ output: T;
16
+ };
17
+ };
18
+ };
19
+ type PlanningConfigRpcSchema<T> = StandardValueSchema & Typed<T>;
20
+ export declare const PlanningConfigRpc: {
21
+ id: string;
22
+ events: {};
23
+ methods: {
24
+ get: {
25
+ input: PlanningConfigRpcSchema<Record<string, never>>;
26
+ output: PlanningConfigRpcSchema<PlanningConfigRpcOutput>;
27
+ };
28
+ };
29
+ };
30
+ export {};
@@ -156,6 +156,44 @@ class ConfigLoader {
156
156
  }
157
157
  }
158
158
  }
159
+ // src/lib/PlanningConfigRpc.ts
160
+ var planningConfigRpcID = "encoredigitalgroup.opencode-planning";
161
+ function schema(check) {
162
+ return {
163
+ "~standard": {
164
+ version: 1,
165
+ vendor: "@encoredigitalgroup/opencode",
166
+ validate: (value) => {
167
+ const issue = check(value);
168
+ return issue === null ? { value } : { issues: [{ message: issue }] };
169
+ }
170
+ }
171
+ };
172
+ }
173
+ function checkEmptyObject(value) {
174
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0 ? null : "input must be an empty object";
175
+ }
176
+ function checkConfigOutput(value) {
177
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
178
+ return "output must be an object";
179
+ }
180
+ const config = value;
181
+ if (typeof config.planDirectory !== "string") {
182
+ return "output planDirectory must be a string";
183
+ }
184
+ return typeof config.skillMappings === "object" && config.skillMappings !== null && !Array.isArray(config.skillMappings) ? null : "output skillMappings must be an object";
185
+ }
186
+ var PlanningConfigRpc = {
187
+ id: planningConfigRpcID,
188
+ events: {},
189
+ methods: {
190
+ get: {
191
+ input: schema(checkEmptyObject),
192
+ output: schema(checkConfigOutput)
193
+ }
194
+ }
195
+ };
196
+
159
197
  // src/lib/SkillCommands.ts
160
198
  class SkillCommands {
161
199
  static getCommands(config) {
@@ -8420,7 +8458,7 @@ function findGitWorktreeRoot(startDir) {
8420
8458
 
8421
8459
  // src/lib/Quota/rpc.ts
8422
8460
  var QUOTA_RPC_ID = "slkiser.opencode-quota";
8423
- function schema(check) {
8461
+ function schema2(check) {
8424
8462
  return {
8425
8463
  "~standard": {
8426
8464
  version: 1,
@@ -8433,7 +8471,7 @@ function schema(check) {
8433
8471
  };
8434
8472
  }
8435
8473
  function eventSchema(check) {
8436
- return schema(check);
8474
+ return schema2(check);
8437
8475
  }
8438
8476
  function checkSessionInput(value) {
8439
8477
  if (!isRecord2(value))
@@ -8457,12 +8495,12 @@ var QuotaRpc = {
8457
8495
  },
8458
8496
  methods: {
8459
8497
  snapshot: {
8460
- input: schema(checkSessionInput),
8461
- output: schema(checkSnapshotOutput)
8498
+ input: schema2(checkSessionInput),
8499
+ output: schema2(checkSnapshotOutput)
8462
8500
  },
8463
8501
  refresh: {
8464
- input: schema(checkRefreshInput),
8465
- output: schema(checkSnapshotOutput)
8502
+ input: schema2(checkRefreshInput),
8503
+ output: schema2(checkSnapshotOutput)
8466
8504
  }
8467
8505
  }
8468
8506
  };
@@ -9524,30 +9562,43 @@ var server_default = Plugin2.define({
9524
9562
  const command = "feature-planning";
9525
9563
  const route = SkillCommands.getCommands(pluginConfig)[command];
9526
9564
  try {
9527
- const commandRegistration = await ctx.command.transform((commands) => {
9528
- commands.add({
9529
- name: command,
9530
- description: route.description,
9531
- execute: async (input) => {
9532
- const skills = await ctx.skill.list();
9533
- const skill = skills.data.find((candidate) => candidate.name === route.skill);
9534
- if (skill === undefined) {
9535
- throw new Error(`OpenCode skill "${route.skill}" is not available for /${command}.`);
9565
+ const configRegistration = await ctx.rpc.register(PlanningConfigRpc, {
9566
+ get: async () => ({
9567
+ planDirectory: pluginConfig.planDirectory,
9568
+ skillMappings: pluginConfig.skillMappings
9569
+ })
9570
+ });
9571
+ let commandRegistration;
9572
+ try {
9573
+ commandRegistration = await ctx.command.transform((commands) => {
9574
+ commands.add({
9575
+ name: command,
9576
+ description: route.description,
9577
+ execute: async (input) => {
9578
+ const skills = await ctx.skill.list();
9579
+ const skill = skills.data.find((candidate) => candidate.name === route.skill);
9580
+ if (skill === undefined) {
9581
+ throw new Error(`OpenCode skill "${route.skill}" is not available for /${command}.`);
9582
+ }
9583
+ await ctx.session.prompt({
9584
+ sessionID: input.sessionID,
9585
+ ...input.prompt,
9586
+ skills: [...input.prompt.skills ?? [], { id: skill.id }],
9587
+ delivery: input.delivery
9588
+ });
9536
9589
  }
9537
- await ctx.session.prompt({
9538
- sessionID: input.sessionID,
9539
- ...input.prompt,
9540
- skills: [...input.prompt.skills ?? [], { id: skill.id }],
9541
- delivery: input.delivery
9542
- });
9543
- }
9590
+ });
9544
9591
  });
9545
- });
9592
+ } catch (error) {
9593
+ await configRegistration.dispose();
9594
+ throw error;
9595
+ }
9546
9596
  let toolRegistration;
9547
9597
  try {
9548
9598
  toolRegistration = await TodoTracker.register(ctx, pluginConfig);
9549
9599
  } catch (error) {
9550
9600
  await commandRegistration.dispose();
9601
+ await configRegistration.dispose();
9551
9602
  throw error;
9552
9603
  }
9553
9604
  return async () => {
@@ -9558,7 +9609,11 @@ var server_default = Plugin2.define({
9558
9609
  await commandRegistration.dispose();
9559
9610
  }
9560
9611
  } finally {
9561
- await quotaCleanup?.();
9612
+ try {
9613
+ await configRegistration.dispose();
9614
+ } finally {
9615
+ await quotaCleanup?.();
9616
+ }
9562
9617
  }
9563
9618
  };
9564
9619
  } catch (error) {
@@ -1,3 +1,5 @@
1
1
  import { Plugin } from "@opencode/plugin/tui";
2
+ import { ConfigLoader } from "../config";
3
+ export declare function loadPickerConfig(context: Plugin.Context): Promise<ReturnType<typeof ConfigLoader.loadConfig>>;
2
4
  declare const _default: Plugin.Definition;
3
5
  export default _default;
package/dist/tui/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // src/tui/index.tsx
3
3
  import { Plugin as Plugin2 } from "@opencode/plugin/tui";
4
- import { fg, StyledText } from "@opentui/core";
4
+ import { fg as fg2, StyledText as StyledText2 } from "@opentui/core";
5
5
 
6
6
  // node_modules/solid-js/dist/solid.js
7
7
  var sharedConfig = {
@@ -987,6 +987,44 @@ class FilePickerCommands {
987
987
  }
988
988
  }
989
989
 
990
+ // src/lib/PlanningConfigRpc.ts
991
+ var planningConfigRpcID = "encoredigitalgroup.opencode-planning";
992
+ function schema(check) {
993
+ return {
994
+ "~standard": {
995
+ version: 1,
996
+ vendor: "@encoredigitalgroup/opencode",
997
+ validate: (value) => {
998
+ const issue = check(value);
999
+ return issue === null ? { value } : { issues: [{ message: issue }] };
1000
+ }
1001
+ }
1002
+ };
1003
+ }
1004
+ function checkEmptyObject(value) {
1005
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0 ? null : "input must be an empty object";
1006
+ }
1007
+ function checkConfigOutput(value) {
1008
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1009
+ return "output must be an object";
1010
+ }
1011
+ const config = value;
1012
+ if (typeof config.planDirectory !== "string") {
1013
+ return "output planDirectory must be a string";
1014
+ }
1015
+ return typeof config.skillMappings === "object" && config.skillMappings !== null && !Array.isArray(config.skillMappings) ? null : "output skillMappings must be an object";
1016
+ }
1017
+ var PlanningConfigRpc = {
1018
+ id: planningConfigRpcID,
1019
+ events: {},
1020
+ methods: {
1021
+ get: {
1022
+ input: schema(checkEmptyObject),
1023
+ output: schema(checkConfigOutput)
1024
+ }
1025
+ }
1026
+ };
1027
+
990
1028
  // src/lib/Quota/tui/index.tsx
991
1029
  import { Plugin } from "@opencode/plugin/tui";
992
1030
 
@@ -1009,7 +1047,7 @@ function finiteNumber(value) {
1009
1047
 
1010
1048
  // src/lib/Quota/rpc.ts
1011
1049
  var QUOTA_RPC_ID = "slkiser.opencode-quota";
1012
- function schema(check) {
1050
+ function schema2(check) {
1013
1051
  return {
1014
1052
  "~standard": {
1015
1053
  version: 1,
@@ -1022,7 +1060,7 @@ function schema(check) {
1022
1060
  };
1023
1061
  }
1024
1062
  function eventSchema(check) {
1025
- return schema(check);
1063
+ return schema2(check);
1026
1064
  }
1027
1065
  function checkSessionInput(value) {
1028
1066
  if (!isRecord(value))
@@ -1046,12 +1084,12 @@ var QuotaRpc = {
1046
1084
  },
1047
1085
  methods: {
1048
1086
  snapshot: {
1049
- input: schema(checkSessionInput),
1050
- output: schema(checkSnapshotOutput)
1087
+ input: schema2(checkSessionInput),
1088
+ output: schema2(checkSnapshotOutput)
1051
1089
  },
1052
1090
  refresh: {
1053
- input: schema(checkRefreshInput),
1054
- output: schema(checkSnapshotOutput)
1091
+ input: schema2(checkRefreshInput),
1092
+ output: schema2(checkSnapshotOutput)
1055
1093
  }
1056
1094
  }
1057
1095
  };
@@ -5858,6 +5896,9 @@ function clientSettings({
5858
5896
  return { values, fromFile, providers, custom };
5859
5897
  }
5860
5898
 
5899
+ // src/lib/Quota/tui/sidebar.tsx
5900
+ import { bg, bold, fg, StyledText } from "@opentui/core";
5901
+
5861
5902
  // src/lib/Quota/view/columns.ts
5862
5903
  var GRAPHEMES = new Intl.Segmenter("en", { granularity: "grapheme" });
5863
5904
  var WIDE = /^[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6\u{20000}-\u{3FFFD}]/u;
@@ -6495,78 +6536,92 @@ var MARKED_ROLES = new Set([
6495
6536
  "label",
6496
6537
  "statusName"
6497
6538
  ]);
6498
- function LineText(props) {
6499
- const theme = () => props.host.theme();
6500
- const color = (segment) => props.marked && MARKED_ROLES.has(segment.role) ? theme().text.action.primary.selected : segmentColor(theme(), props.host.display(), segment);
6501
- return /* @__PURE__ */ jsxs("text", {
6502
- wrapMode: "none",
6503
- selectable: false,
6504
- flexShrink: 0,
6505
- bg: props.marked ? theme().background.raised.high : undefined,
6506
- children: [
6507
- props.line.segments.length === 0 ? " " : null,
6508
- props.line.segments.map((segment) => /* @__PURE__ */ jsx("span", {
6509
- style: {
6510
- fg: color(segment),
6511
- bold: segment.bold === true
6512
- },
6513
- children: segment.text
6514
- }))
6515
- ]
6516
- });
6539
+ function segmentForeground(theme, settings, segment, marked) {
6540
+ return marked && MARKED_ROLES.has(segment.role) ? theme.text.action.primary.selected : segmentColor(theme, settings, segment);
6541
+ }
6542
+ function styledLine(line, host, marked) {
6543
+ const theme = host.theme();
6544
+ const settings = host.display();
6545
+ return new StyledText(line.segments.flatMap((segment) => {
6546
+ let chunk = fg(segmentForeground(theme, settings, segment, marked))(segment.text);
6547
+ if (segment.bold === true)
6548
+ chunk = bold(chunk);
6549
+ if (marked)
6550
+ chunk = bg(theme.background.raised.high)(chunk);
6551
+ return chunk;
6552
+ }));
6517
6553
  }
6518
6554
  function SidebarPanel(props) {
6519
6555
  const host = props.host;
6520
6556
  const stop = host.quota.watch(props.sessionID);
6521
6557
  onCleanup(stop);
6522
- const [snapshotRevision, setSnapshotRevision] = createSignal(0);
6523
- onCleanup(host.quota.subscribe(() => setSnapshotRevision((revision) => revision + 1)));
6524
- onMount(() => {
6525
- host.quota.refresh("poll", props.sessionID);
6526
- });
6527
6558
  onCleanup(host.editing.sidebarShown());
6528
6559
  const open = () => host.editing.panelOpen() ?? props.open();
6529
- const [width, setWidth] = createSignal(DEFAULT_SIDEBAR_WIDTH);
6530
- const [nowMs, setNowMs] = createSignal(Date.now());
6531
- const clock = setInterval(() => setNowMs(Date.now()), 60000);
6532
- onCleanup(() => clearInterval(clock));
6533
- const display = () => host.display();
6534
- const snapshot = () => {
6535
- snapshotRevision();
6536
- return host.quota.snapshot(props.sessionID);
6537
- };
6538
- const panel = createMemo(() => sidebarPanel(snapshot(), display(), { nowMs: nowMs(), width: width(), open: open() }));
6560
+ let width = DEFAULT_SIDEBAR_WIDTH;
6561
+ let nowMs = Date.now();
6539
6562
  const marked = () => host.editing.marked(open() ? "sidebar" : "collapsed");
6563
+ let heading;
6564
+ let body;
6565
+ const render = () => {
6566
+ const snapshot = host.quota.snapshot(props.sessionID);
6567
+ const panel = sidebarPanel(snapshot, host.display(), { nowMs, width, open: open() });
6568
+ if (heading)
6569
+ heading.content = new StyledText([bold(panel.title)]);
6570
+ if (!body)
6571
+ return;
6572
+ if (!snapshot) {
6573
+ body.content = "Loading quota\u2026";
6574
+ return;
6575
+ }
6576
+ body.content = new StyledText(panel.lines.flatMap((line, index) => [
6577
+ ...styledLine(line, host, line.id !== "" && line.id === marked()).chunks,
6578
+ ...index === panel.lines.length - 1 ? [] : [fg(host.theme().text.base)(`
6579
+ `)]
6580
+ ]));
6581
+ };
6582
+ onCleanup(host.quota.subscribe(render));
6583
+ const clock = setInterval(() => {
6584
+ nowMs = Date.now();
6585
+ render();
6586
+ }, 60000);
6587
+ onCleanup(() => clearInterval(clock));
6588
+ onMount(() => {
6589
+ render();
6590
+ host.quota.refresh("poll", props.sessionID);
6591
+ });
6540
6592
  return /* @__PURE__ */ jsx(Show, {
6541
- when: display().sidebar.show,
6593
+ when: host.display().sidebar.show,
6542
6594
  children: /* @__PURE__ */ jsxs("box", {
6543
6595
  flexDirection: "column",
6544
6596
  onSizeChange: function() {
6545
6597
  const measured = this.width;
6546
6598
  if (measured > 0)
6547
- queueMicrotask(() => setWidth(measured));
6599
+ queueMicrotask(() => {
6600
+ width = measured;
6601
+ render();
6602
+ });
6548
6603
  },
6549
6604
  children: [
6550
6605
  /* @__PURE__ */ jsx("text", {
6551
- fg: roleColor(host.theme(), display(), "title"),
6606
+ ref: (node) => {
6607
+ heading = node;
6608
+ },
6609
+ fg: roleColor(host.theme(), host.display(), "title"),
6552
6610
  wrapMode: "none",
6553
6611
  selectable: false,
6554
- onMouseDown: () => props.setOpen(!open()),
6555
- children: /* @__PURE__ */ jsx("b", {
6556
- children: panel().title
6557
- })
6612
+ onMouseDown: () => {
6613
+ props.setOpen(!open());
6614
+ queueMicrotask(render);
6615
+ },
6616
+ children: "Usage Meter"
6558
6617
  }),
6559
- /* @__PURE__ */ jsx(Show, {
6560
- when: snapshot(),
6561
- fallback: /* @__PURE__ */ jsx("text", {
6562
- fg: host.theme().text.muted,
6563
- children: "Loading quota\u2026"
6564
- }),
6565
- children: panel().lines.map((line) => /* @__PURE__ */ jsx(LineText, {
6566
- line,
6567
- host,
6568
- marked: line.id !== "" && line.id === marked()
6569
- }))
6618
+ /* @__PURE__ */ jsx("text", {
6619
+ ref: (node) => {
6620
+ body = node;
6621
+ },
6622
+ wrapMode: "none",
6623
+ selectable: false,
6624
+ content: "Loading..."
6570
6625
  })
6571
6626
  ]
6572
6627
  })
@@ -6936,14 +6991,31 @@ function PickerCommandLayer(props) {
6936
6991
  FilePickerCommands.register(props.context, props.config);
6937
6992
  return /* @__PURE__ */ jsx3(Fragment, {});
6938
6993
  }
6994
+ async function loadPickerConfig(context) {
6995
+ const fallback = ConfigLoader.loadConfig(context.options);
6996
+ try {
6997
+ const location = context.location ?? context.data.location.default();
6998
+ const config = await context.client.rpc(PlanningConfigRpc).get({}, {
6999
+ location: { directory: location.directory },
7000
+ signal: AbortSignal.timeout(5000)
7001
+ });
7002
+ return {
7003
+ ...fallback,
7004
+ planDirectory: config.planDirectory,
7005
+ skillMappings: config.skillMappings
7006
+ };
7007
+ } catch {
7008
+ return fallback;
7009
+ }
7010
+ }
6939
7011
  function TodoSidebar(props) {
6940
7012
  const todos = () => TodoTracker.sidebar(props.context.data.session.message.list(props.sessionID), props.context.data.session.status(props.sessionID) === "idle");
6941
7013
  const color = (status) => status === "in_progress" ? props.context.theme.text.feedback.warning.base : props.context.theme.text.muted;
6942
7014
  const line = (todo) => `${TodoTracker.marker(todo.status)} (${todo.priority}) ${todo.content}`;
6943
7015
  const plainContent = (items) => items.map(line).join(`
6944
7016
  `);
6945
- const content = (items) => new StyledText(items.flatMap((todo, index) => [
6946
- fg(color(todo.status))(`${line(todo)}${index === items.length - 1 ? "" : `
7017
+ const content = (items) => new StyledText2(items.flatMap((todo, index) => [
7018
+ fg2(color(todo.status))(`${line(todo)}${index === items.length - 1 ? "" : `
6947
7019
  `}`)
6948
7020
  ]));
6949
7021
  let heading;
@@ -6989,11 +7061,12 @@ var tui_default2 = Plugin2.define({
6989
7061
  id: "@encoredigitalgroup/opencode",
6990
7062
  async setup(ctx) {
6991
7063
  const quotaCleanup = ctx.storage === undefined ? undefined : await tui_default.setup(ctx);
7064
+ const pickerConfig = await loadPickerConfig(ctx);
6992
7065
  const appSlot = ctx.ui.slot({
6993
7066
  append: "app",
6994
7067
  render: () => /* @__PURE__ */ jsx3(PickerCommandLayer, {
6995
7068
  context: ctx,
6996
- config: ConfigLoader.loadConfig(ctx.options)
7069
+ config: pickerConfig
6997
7070
  })
6998
7071
  });
6999
7072
  let sidebarSlot;
@@ -7024,5 +7097,6 @@ var tui_default2 = Plugin2.define({
7024
7097
  }
7025
7098
  });
7026
7099
  export {
7027
- tui_default2 as default
7100
+ tui_default2 as default,
7101
+ loadPickerConfig
7028
7102
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@encoredigitalgroup/opencode",
3
3
  "type": "module",
4
- "version": "0.2.9",
4
+ "version": "0.2.11",
5
5
  "description": "OpenCode planning pickers, a todo tracker, and a quota sidebar.",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -34,6 +34,8 @@
34
34
  "scripts": {
35
35
  "build": "rm -rf dist && bun build src/server/index.ts src/tui/index.tsx --outdir dist --target bun --external '@opencode/plugin' --external '@opencode/plugin/*' --external '@opentui/core' --external '@opentui/core/*' --external '@opentui/solid' --external '@opentui/solid/*' && tsc --emitDeclarationOnly",
36
36
  "check": "bun run typecheck && bun run build",
37
+ "local:install": "bun run build && bun tools/local-plugin.ts install",
38
+ "local:uninstall": "bun tools/local-plugin.ts uninstall",
37
39
  "pack:check": "bun pm pack --dry-run",
38
40
  "test": "bun test",
39
41
  "typecheck": "tsc --noEmit"