@brainervirus/workit-opencode 8.15.1 → 8.16.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.
Files changed (2) hide show
  1. package/dist/plugin.js +65 -3
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -16086,6 +16086,54 @@ function evaluateClosure(requestedOutcome, view) {
16086
16086
  requirementIds: evaluations.map((item) => item.requirementId)
16087
16087
  });
16088
16088
  }
16089
+ var BRIEF_TEXT = 250;
16090
+ var BRIEF_BLOCKERS = 3;
16091
+ var BRIEF_OPEN = 8;
16092
+ var clip = (value) => {
16093
+ const fits = (text) => Buffer.byteLength(JSON.stringify(text)) <= BRIEF_TEXT;
16094
+ if (fits(value))
16095
+ return value;
16096
+ let length = Math.min(value.length, BRIEF_TEXT);
16097
+ while (length > 0 && !fits(`${value.slice(0, length)}…`))
16098
+ length -= 1;
16099
+ return `${value.slice(0, length)}…`;
16100
+ };
16101
+ function boundTaskSummary(summary) {
16102
+ const rules = new Map((summary.policy?.requirements ?? []).map((item) => [item.id, item]));
16103
+ const unmet = summary.requirements.filter((item) => item.status === "unsatisfied" || item.status === "unavailable");
16104
+ const { progress, closure } = summary;
16105
+ const next = progress.nextAction;
16106
+ const open = unmet.slice(0, BRIEF_OPEN).map((item) => ({
16107
+ dimension: rules.get(item.requirementId)?.dimension ?? "verification",
16108
+ before: rules.get(item.requirementId)?.before ?? "close",
16109
+ status: item.status
16110
+ }));
16111
+ const brief = {
16112
+ id: summary.id,
16113
+ revision: summary.revision,
16114
+ workspaceRevision: summary.workspaceRevision,
16115
+ updatedAt: summary.updatedAt,
16116
+ objective: clip(summary.objective),
16117
+ status: summary.status,
16118
+ closure: closure && {
16119
+ outcome: closure.outcome,
16120
+ at: closure.at,
16121
+ summary: clip(closure.summary)
16122
+ },
16123
+ progress: {
16124
+ summary: clip(progress.summary),
16125
+ nextAction: next && clip(next),
16126
+ blockers: progress.blockers.slice(0, BRIEF_BLOCKERS).map((item) => ({
16127
+ reason: clip(item.reason),
16128
+ dependentAction: clip(item.dependentAction)
16129
+ }))
16130
+ },
16131
+ requirements: { total: summary.requirements.length, unmet: unmet.length, open },
16132
+ truncated: false
16133
+ };
16134
+ brief.truncated = JSON.stringify(brief).includes("…") || progress.blockers.length > BRIEF_BLOCKERS || unmet.length > BRIEF_OPEN;
16135
+ return brief;
16136
+ }
16089
16137
 
16090
16138
  // packages/workit-core/src/core/methods.ts
16091
16139
  var METHODS = {
@@ -19514,6 +19562,15 @@ class WorkitCore {
19514
19562
  if (!parsed.ok)
19515
19563
  return parsed;
19516
19564
  const input = parsed.data;
19565
+ if (this.context.readOnlyChild) {
19566
+ if (input.action !== "inspect")
19567
+ return failure2("permission_denied", "child sessions can only inspect the task summary");
19568
+ const task = this.store.readTask(input.taskId);
19569
+ if (!task.ok)
19570
+ return task;
19571
+ const summary = this.summary(task.data);
19572
+ return summary.ok ? { ...summary, data: boundTaskSummary(summary.data) } : summary;
19573
+ }
19517
19574
  if ((this.context.workerId ?? null) !== null) {
19518
19575
  if (input.action !== "inspect" && input.action !== "list")
19519
19576
  return failure2("permission_denied", "helpers cannot control task lifecycle or scope");
@@ -24659,13 +24716,14 @@ var childMayRecord = (family, input) => {
24659
24716
  const action = fields(input).action;
24660
24717
  return family !== null && typeof action === "string" && CHILD_RECORDS[family]?.has(action) === true;
24661
24718
  };
24719
+ var childMayInspect = (family, input) => family === "task" && fields(input).action === "inspect";
24662
24720
  var childTaskMissing = (store, input) => {
24663
24721
  if (fields(input).taskId !== undefined)
24664
24722
  return false;
24665
24723
  const report = store.keyReport();
24666
24724
  return !report.ok || report.data.bound.length === 0;
24667
24725
  };
24668
- var childDenial = (identity) => `OpenCode child session has no validated Workit worker: as ${identity} it may only record evidence or findings (workit_evidence/workit_finding action "record") on an existing task; for anything else the lead assigns it a worker with workit_worker before launching it`;
24726
+ var childDenial = (identity) => `OpenCode child session has no validated Workit worker: as ${identity} it may only inspect the task summary (workit_task action "inspect") or record evidence or findings (workit_evidence/workit_finding action "record") on an existing task; for anything else the lead assigns it a worker with workit_worker before launching it`;
24669
24727
 
24670
24728
  // packages/workit-opencode/src/v2/shell.ts
24671
24729
  import path38 from "node:path";
@@ -25041,7 +25099,7 @@ var setup = async (ctx) => {
25041
25099
  }
25042
25100
  });
25043
25101
  const contextTool = createContextTool();
25044
- const runFamily = (family, input, session, store, workerId) => {
25102
+ const runFamily = (family, input, session, store, workerId, readOnlyChild = false) => {
25045
25103
  const parsed = parseAdvertisedOperation(family, input, "opencode");
25046
25104
  if (!parsed.ok)
25047
25105
  return parsed;
@@ -25052,6 +25110,7 @@ var setup = async (ctx) => {
25052
25110
  constraints: [],
25053
25111
  now: () => new Date().toISOString().replace(/\.\d{3}Z$/, "Z"),
25054
25112
  workerId,
25113
+ ...readOnlyChild ? { readOnlyChild } : {},
25055
25114
  nativeWorker: nativeWorkerFor(lifecycle.directChildren, session.id)
25056
25115
  });
25057
25116
  const run = core[family];
@@ -25079,8 +25138,11 @@ var setup = async (ctx) => {
25079
25138
  const identity = childSessionId(session.parentID, session.id);
25080
25139
  const lead = await sessionFacts(ctx, session.parentID);
25081
25140
  const directChild = lead !== null && lead.parentID === undefined && sameWorkspace(root, lead.directory);
25082
- if (!directChild || family === null || !childMayRecord(family, input))
25141
+ const inspecting = childMayInspect(family, input);
25142
+ if (!directChild || family === null || !(inspecting || childMayRecord(family, input)))
25083
25143
  return resultContent(failure2("permission_denied", childDenial(identity)));
25144
+ if (inspecting)
25145
+ return resultContent(runFamily(family, input, { ...session, id: identity }, store, null, true));
25084
25146
  if (childTaskMissing(store, input))
25085
25147
  return resultContent(failure2("not_found", "no task for this branch yet: the lead starts one (workit_task start) before a child records on it, or pass taskId"));
25086
25148
  return resultContent(runFamily(family, input, { ...session, id: identity }, store, null));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-opencode",
3
- "version": "8.15.1",
3
+ "version": "8.16.0",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "devDependencies": {
42
- "@brainervirus/workit-core": "^8.15.1",
42
+ "@brainervirus/workit-core": "^8.16.0",
43
43
  "@opencode/plugin": "2.0.18"
44
44
  },
45
45
  "engines": {