@encoredigitalgroup/opencode 0.2.10 → 0.2.12

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) {
@@ -308,15 +346,22 @@ class TodoTrackerEnforcement {
308
346
  return existing;
309
347
  }
310
348
  const state = trackerStateFromMessages(await this.context.session.context({ sessionID }));
349
+ const current = this.states.get(sessionID);
350
+ if (current !== undefined) {
351
+ return current;
352
+ }
311
353
  this.states.set(sessionID, state);
312
354
  return state;
313
355
  }
314
- async requireTrackerRefresh(sessionID) {
356
+ async requireTrackerRefresh(sessionID, completedAt) {
315
357
  const state = await this.stateFor(sessionID);
316
- if (state.kind === "tracked") {
358
+ if (state.kind === "tracked" && state.refreshedAt < completedAt) {
317
359
  state.refreshRequired = true;
318
360
  }
319
361
  }
362
+ recordTrackerUpdate(sessionID, todos) {
363
+ this.states.set(sessionID, stateFromTodoResult({ todos }, JSON.stringify(todos)));
364
+ }
320
365
  async register(enforceRefresh) {
321
366
  let before;
322
367
  let after;
@@ -383,7 +428,7 @@ class TodoTrackerEnforcement {
383
428
  }
384
429
  const session = await this.context.session.get({ sessionID: event.data.sessionID });
385
430
  if (session.parentID !== undefined) {
386
- await this.requireTrackerRefresh(session.parentID);
431
+ await this.requireTrackerRefresh(session.parentID, event.created);
387
432
  }
388
433
  }
389
434
  } catch (error) {
@@ -416,26 +461,28 @@ class TodoTracker {
416
461
  return [...todos.slice(0, -1), { ...finalTodo, status: "completed" }];
417
462
  }
418
463
  static async register(context, config) {
464
+ const enforcement = new TodoTrackerEnforcement(context);
419
465
  const tool = await context.tool.transform((tools) => {
420
466
  tools.add({
421
467
  name: todoTrackerName,
422
468
  description: todoTrackerDescription,
423
469
  input: todoTrackerInput,
424
470
  options: { codemode: false },
425
- async execute(input) {
471
+ async execute(input, executionContext) {
426
472
  if (!isTodoTrackerInput(input)) {
427
473
  throw new Error("Invalid todotracker input.");
428
474
  }
475
+ enforcement.recordTrackerUpdate(executionContext.sessionID, input.todos);
429
476
  return { content: JSON.stringify(input.todos), metadata: { todos: input.todos } };
430
477
  }
431
478
  });
432
479
  });
433
480
  try {
434
- const enforcement = await new TodoTrackerEnforcement(context).register(config.enforceTodoTracker);
481
+ const registration = await enforcement.register(config.enforceTodoTracker);
435
482
  return {
436
483
  dispose: async () => {
437
484
  try {
438
- await enforcement.dispose();
485
+ await registration.dispose();
439
486
  } finally {
440
487
  await tool.dispose();
441
488
  }
@@ -8420,7 +8467,7 @@ function findGitWorktreeRoot(startDir) {
8420
8467
 
8421
8468
  // src/lib/Quota/rpc.ts
8422
8469
  var QUOTA_RPC_ID = "slkiser.opencode-quota";
8423
- function schema(check) {
8470
+ function schema2(check) {
8424
8471
  return {
8425
8472
  "~standard": {
8426
8473
  version: 1,
@@ -8433,7 +8480,7 @@ function schema(check) {
8433
8480
  };
8434
8481
  }
8435
8482
  function eventSchema(check) {
8436
- return schema(check);
8483
+ return schema2(check);
8437
8484
  }
8438
8485
  function checkSessionInput(value) {
8439
8486
  if (!isRecord2(value))
@@ -8457,12 +8504,12 @@ var QuotaRpc = {
8457
8504
  },
8458
8505
  methods: {
8459
8506
  snapshot: {
8460
- input: schema(checkSessionInput),
8461
- output: schema(checkSnapshotOutput)
8507
+ input: schema2(checkSessionInput),
8508
+ output: schema2(checkSnapshotOutput)
8462
8509
  },
8463
8510
  refresh: {
8464
- input: schema(checkRefreshInput),
8465
- output: schema(checkSnapshotOutput)
8511
+ input: schema2(checkRefreshInput),
8512
+ output: schema2(checkSnapshotOutput)
8466
8513
  }
8467
8514
  }
8468
8515
  };
@@ -9524,30 +9571,43 @@ var server_default = Plugin2.define({
9524
9571
  const command = "feature-planning";
9525
9572
  const route = SkillCommands.getCommands(pluginConfig)[command];
9526
9573
  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}.`);
9574
+ const configRegistration = await ctx.rpc.register(PlanningConfigRpc, {
9575
+ get: async () => ({
9576
+ planDirectory: pluginConfig.planDirectory,
9577
+ skillMappings: pluginConfig.skillMappings
9578
+ })
9579
+ });
9580
+ let commandRegistration;
9581
+ try {
9582
+ commandRegistration = await ctx.command.transform((commands) => {
9583
+ commands.add({
9584
+ name: command,
9585
+ description: route.description,
9586
+ execute: async (input) => {
9587
+ const skills = await ctx.skill.list();
9588
+ const skill = skills.data.find((candidate) => candidate.name === route.skill);
9589
+ if (skill === undefined) {
9590
+ throw new Error(`OpenCode skill "${route.skill}" is not available for /${command}.`);
9591
+ }
9592
+ await ctx.session.prompt({
9593
+ sessionID: input.sessionID,
9594
+ ...input.prompt,
9595
+ skills: [...input.prompt.skills ?? [], { id: skill.id }],
9596
+ delivery: input.delivery
9597
+ });
9536
9598
  }
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
- }
9599
+ });
9544
9600
  });
9545
- });
9601
+ } catch (error) {
9602
+ await configRegistration.dispose();
9603
+ throw error;
9604
+ }
9546
9605
  let toolRegistration;
9547
9606
  try {
9548
9607
  toolRegistration = await TodoTracker.register(ctx, pluginConfig);
9549
9608
  } catch (error) {
9550
9609
  await commandRegistration.dispose();
9610
+ await configRegistration.dispose();
9551
9611
  throw error;
9552
9612
  }
9553
9613
  return async () => {
@@ -9558,7 +9618,11 @@ var server_default = Plugin2.define({
9558
9618
  await commandRegistration.dispose();
9559
9619
  }
9560
9620
  } finally {
9561
- await quotaCleanup?.();
9621
+ try {
9622
+ await configRegistration.dispose();
9623
+ } finally {
9624
+ await quotaCleanup?.();
9625
+ }
9562
9626
  }
9563
9627
  };
9564
9628
  } 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
@@ -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
  };
@@ -6807,15 +6845,22 @@ class TodoTrackerEnforcement {
6807
6845
  return existing;
6808
6846
  }
6809
6847
  const state = trackerStateFromMessages(await this.context.session.context({ sessionID }));
6848
+ const current = this.states.get(sessionID);
6849
+ if (current !== undefined) {
6850
+ return current;
6851
+ }
6810
6852
  this.states.set(sessionID, state);
6811
6853
  return state;
6812
6854
  }
6813
- async requireTrackerRefresh(sessionID) {
6855
+ async requireTrackerRefresh(sessionID, completedAt) {
6814
6856
  const state = await this.stateFor(sessionID);
6815
- if (state.kind === "tracked") {
6857
+ if (state.kind === "tracked" && state.refreshedAt < completedAt) {
6816
6858
  state.refreshRequired = true;
6817
6859
  }
6818
6860
  }
6861
+ recordTrackerUpdate(sessionID, todos) {
6862
+ this.states.set(sessionID, stateFromTodoResult({ todos }, JSON.stringify(todos)));
6863
+ }
6819
6864
  async register(enforceRefresh) {
6820
6865
  let before;
6821
6866
  let after;
@@ -6882,7 +6927,7 @@ class TodoTrackerEnforcement {
6882
6927
  }
6883
6928
  const session = await this.context.session.get({ sessionID: event.data.sessionID });
6884
6929
  if (session.parentID !== undefined) {
6885
- await this.requireTrackerRefresh(session.parentID);
6930
+ await this.requireTrackerRefresh(session.parentID, event.created);
6886
6931
  }
6887
6932
  }
6888
6933
  } catch (error) {
@@ -6915,26 +6960,28 @@ class TodoTracker {
6915
6960
  return [...todos.slice(0, -1), { ...finalTodo, status: "completed" }];
6916
6961
  }
6917
6962
  static async register(context, config) {
6963
+ const enforcement = new TodoTrackerEnforcement(context);
6918
6964
  const tool = await context.tool.transform((tools) => {
6919
6965
  tools.add({
6920
6966
  name: todoTrackerName,
6921
6967
  description: todoTrackerDescription,
6922
6968
  input: todoTrackerInput,
6923
6969
  options: { codemode: false },
6924
- async execute(input) {
6970
+ async execute(input, executionContext) {
6925
6971
  if (!isTodoTrackerInput(input)) {
6926
6972
  throw new Error("Invalid todotracker input.");
6927
6973
  }
6974
+ enforcement.recordTrackerUpdate(executionContext.sessionID, input.todos);
6928
6975
  return { content: JSON.stringify(input.todos), metadata: { todos: input.todos } };
6929
6976
  }
6930
6977
  });
6931
6978
  });
6932
6979
  try {
6933
- const enforcement = await new TodoTrackerEnforcement(context).register(config.enforceTodoTracker);
6980
+ const registration = await enforcement.register(config.enforceTodoTracker);
6934
6981
  return {
6935
6982
  dispose: async () => {
6936
6983
  try {
6937
- await enforcement.dispose();
6984
+ await registration.dispose();
6938
6985
  } finally {
6939
6986
  await tool.dispose();
6940
6987
  }
@@ -6953,6 +7000,23 @@ function PickerCommandLayer(props) {
6953
7000
  FilePickerCommands.register(props.context, props.config);
6954
7001
  return /* @__PURE__ */ jsx3(Fragment, {});
6955
7002
  }
7003
+ async function loadPickerConfig(context) {
7004
+ const fallback = ConfigLoader.loadConfig(context.options);
7005
+ try {
7006
+ const location = context.location ?? context.data.location.default();
7007
+ const config = await context.client.rpc(PlanningConfigRpc).get({}, {
7008
+ location: { directory: location.directory },
7009
+ signal: AbortSignal.timeout(5000)
7010
+ });
7011
+ return {
7012
+ ...fallback,
7013
+ planDirectory: config.planDirectory,
7014
+ skillMappings: config.skillMappings
7015
+ };
7016
+ } catch {
7017
+ return fallback;
7018
+ }
7019
+ }
6956
7020
  function TodoSidebar(props) {
6957
7021
  const todos = () => TodoTracker.sidebar(props.context.data.session.message.list(props.sessionID), props.context.data.session.status(props.sessionID) === "idle");
6958
7022
  const color = (status) => status === "in_progress" ? props.context.theme.text.feedback.warning.base : props.context.theme.text.muted;
@@ -7006,11 +7070,12 @@ var tui_default2 = Plugin2.define({
7006
7070
  id: "@encoredigitalgroup/opencode",
7007
7071
  async setup(ctx) {
7008
7072
  const quotaCleanup = ctx.storage === undefined ? undefined : await tui_default.setup(ctx);
7073
+ const pickerConfig = await loadPickerConfig(ctx);
7009
7074
  const appSlot = ctx.ui.slot({
7010
7075
  append: "app",
7011
7076
  render: () => /* @__PURE__ */ jsx3(PickerCommandLayer, {
7012
7077
  context: ctx,
7013
- config: ConfigLoader.loadConfig(ctx.options)
7078
+ config: pickerConfig
7014
7079
  })
7015
7080
  });
7016
7081
  let sidebarSlot;
@@ -7041,5 +7106,6 @@ var tui_default2 = Plugin2.define({
7041
7106
  }
7042
7107
  });
7043
7108
  export {
7044
- tui_default2 as default
7109
+ tui_default2 as default,
7110
+ loadPickerConfig
7045
7111
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@encoredigitalgroup/opencode",
3
3
  "type": "module",
4
- "version": "0.2.10",
4
+ "version": "0.2.12",
5
5
  "description": "OpenCode planning pickers, a todo tracker, and a quota sidebar.",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -22,18 +22,20 @@
22
22
  "solid-js": "1.9.12"
23
23
  },
24
24
  "devDependencies": {
25
- "@opencode/cli": "2.1.4",
26
- "@opencode/client": "2.1.4",
27
- "@opencode/plugin": "2.1.4",
25
+ "@opencode/cli": "2.3.0",
26
+ "@opencode/client": "2.3.0",
27
+ "@opencode/plugin": "2.3.0",
28
28
  "@opentui/core": "0.5.14",
29
29
  "@types/node": "^22.20.5",
30
30
  "@types/bun": "1.4.0",
31
- "tsfmt": "^0.3.0-beta9",
31
+ "tsfmt": "0.3.0-beta15",
32
32
  "typescript": "5.8.2"
33
33
  },
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"