@digi4care/omo-slim-decision-layer 0.2.3 → 0.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.
package/README.md CHANGED
@@ -27,6 +27,16 @@ Built as a companion plugin for
27
27
  - **Traceability** — typed links (`refines`, `depends_on`, `constrains`,
28
28
  `relates_to`) between records, with queries for orphans and reverse lookup.
29
29
 
30
+ ## Compatibility
31
+
32
+ One package, two registration paths, sharing the same register and tool logic:
33
+
34
+ - **v1** (`@opencode-ai/plugin` 1.x): the default export provides a v1 `server`
35
+ that registers the nine tools and the `command.execute.before` hook.
36
+ - **v2** (`@opencode/plugin` 2.x): the same default export also provides a v2
37
+ `setup` that registers the tools via `ctx.tool.transform` and injects the
38
+ prompt via `ctx.session.hook('prompt')`.
39
+
30
40
  ## Agent tools
31
41
 
32
42
  | Tool | Purpose |
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
- declare const _default: {
2
+ declare const pluginModule: {
3
3
  id: string;
4
4
  server: Plugin;
5
+ setup: (ctx: import("./v2/setup").V2Context) => Promise<void>;
5
6
  };
6
- export default _default;
7
+ export default pluginModule;
package/dist/index.js CHANGED
@@ -4307,6 +4307,55 @@ function createDecisionTools() {
4307
4307
  };
4308
4308
  }
4309
4309
 
4310
+ // src/v2/setup.ts
4311
+ import { z as z5 } from "zod";
4312
+ var INTERVIEW_MARKER = "You are running an interview q&a session for the user inside their repository";
4313
+ var SENTINEL2 = "<!-- decision-layer:inject v1 -->";
4314
+ function isRecord(value) {
4315
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4316
+ }
4317
+ function createV2Setup() {
4318
+ return async (ctx) => {
4319
+ const projectDir = ctx.location.directory;
4320
+ const tools = createDecisionTools();
4321
+ await ctx.tool.transform((editor) => {
4322
+ for (const [name, definition] of Object.entries(tools)) {
4323
+ editor.add({
4324
+ name,
4325
+ description: definition.description,
4326
+ input: z5.object(definition.args),
4327
+ execute: async (input, toolContext) => {
4328
+ const v1Context = {
4329
+ ...isRecord(toolContext) ? toolContext : {},
4330
+ worktree: projectDir,
4331
+ directory: projectDir
4332
+ };
4333
+ const result = await definition.execute(input, v1Context);
4334
+ return { content: result };
4335
+ }
4336
+ });
4337
+ }
4338
+ });
4339
+ await ctx.session.hook("prompt", async (event) => {
4340
+ try {
4341
+ if (!isRecord(event))
4342
+ return;
4343
+ const prompt = event.prompt;
4344
+ if (!isRecord(prompt) || typeof prompt.text !== "string")
4345
+ return;
4346
+ if (!prompt.text.includes(INTERVIEW_MARKER))
4347
+ return;
4348
+ if (prompt.text.includes(SENTINEL2))
4349
+ return;
4350
+ prompt.text = `${prompt.text}
4351
+
4352
+ ${SENTINEL2}
4353
+ ${DECISION_DISCIPLINE_PROMPT}`;
4354
+ } catch {}
4355
+ });
4356
+ };
4357
+ }
4358
+
4310
4359
  // src/index.ts
4311
4360
  var DecisionLayer = async () => {
4312
4361
  const hooks = {
@@ -4315,10 +4364,12 @@ var DecisionLayer = async () => {
4315
4364
  };
4316
4365
  return hooks;
4317
4366
  };
4318
- var src_default = {
4367
+ var pluginModule = {
4319
4368
  id: "omo-slim-decision-layer",
4320
- server: DecisionLayer
4369
+ server: DecisionLayer,
4370
+ setup: createV2Setup()
4321
4371
  };
4372
+ var src_default = pluginModule;
4322
4373
  export {
4323
4374
  src_default as default
4324
4375
  };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * v2 registration path, next to the v1 `server` export.
3
+ *
4
+ * Differences that matter for v2 (verified against @opencode/plugin 2.0.29):
5
+ * - tools are registered via `ctx.tool.transform` with a full input schema
6
+ * (zod object) instead of a raw args shape;
7
+ * - the tool context has no `worktree`/`directory`, so the project root is
8
+ * captured from `ctx.location.directory` at setup time and closed over;
9
+ * - the interview injection uses `ctx.session.hook('prompt')` and mutates the
10
+ * outgoing prompt instead of appending to `command.execute.before` parts.
11
+ */
12
+ interface V2TransformEditor {
13
+ add: (tool: unknown) => void;
14
+ }
15
+ export interface V2Context {
16
+ location: {
17
+ directory: string;
18
+ };
19
+ tool: {
20
+ transform: (callback: (editor: V2TransformEditor) => void) => Promise<unknown>;
21
+ };
22
+ session: {
23
+ hook: (name: string, callback: (event: unknown) => Promise<void> | void) => Promise<unknown>;
24
+ };
25
+ }
26
+ export declare function createV2Setup(): (ctx: V2Context) => Promise<void>;
27
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digi4care/omo-slim-decision-layer",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Git-native decision register for OpenCode: typed records (REQ/CONSTRAINT/ASSUMPTION/DEC), owner ratification and traceability, as a companion plugin for oh-my-opencode-slim",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,6 +64,7 @@
64
64
  "devDependencies": {
65
65
  "@biomejs/biome": "2.5.15",
66
66
  "@opencode-ai/plugin": "1.18.35",
67
+ "@opencode/plugin": "^2.0.29",
67
68
  "bun-types": "^1.4.2",
68
69
  "typescript": "^7.0.2"
69
70
  },