@brainervirus/workit-mcp 1.3.0 → 1.3.1

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/index.js +73 -36
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -20755,7 +20755,47 @@ function operationJsonSchema(family) {
20755
20755
  return toJSONSchema(operationSchemas[family], { target: "draft-2020-12" });
20756
20756
  }
20757
20757
  var OPERATION_SCHEMA_DEPTH = 1;
20758
- var canonicalFieldsDescription = (fields) => `Canonical object fields: ${fields.join(", ")}. Workit validates the complete nested value.`;
20758
+ var schemaShapeDescription = (value, depth = 0) => {
20759
+ if (!value || typeof value !== "object")
20760
+ return "value";
20761
+ const schema = value;
20762
+ if (Array.isArray(schema.oneOf) || Array.isArray(schema.anyOf)) {
20763
+ const options = Array.isArray(schema.oneOf) ? schema.oneOf : schema.anyOf;
20764
+ return `(${options.map((option) => schemaShapeDescription(option, depth)).join("|")})`;
20765
+ }
20766
+ if (schema.const !== undefined)
20767
+ return `=${JSON.stringify(schema.const)}`;
20768
+ if (Array.isArray(schema.enum))
20769
+ return `[${schema.enum.map(String).join("|")}]`;
20770
+ const type = Array.isArray(schema.type) ? schema.type.join("/") : schema.type;
20771
+ if (type === "array")
20772
+ return `arr<${schemaShapeDescription(schema.items, depth)}>`;
20773
+ if (type === "object" && schema.properties && typeof schema.properties === "object") {
20774
+ if (depth >= 2)
20775
+ return "obj";
20776
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
20777
+ const properties = schema.properties;
20778
+ const fields = Object.entries(properties).map(([name, child]) => `${name}${required.has(name) ? "!" : ""}:${schemaShapeDescription(child, depth + 1)}`);
20779
+ return `obj{${fields.join(",")}}`;
20780
+ }
20781
+ if (typeof type !== "string")
20782
+ return "?";
20783
+ return type.split("/").map((part) => ({ string: "str", boolean: "bool", number: "num", null: "null" })[part] ?? part).join("|");
20784
+ };
20785
+ var canonicalFieldsDescription = (value) => {
20786
+ if (Array.isArray(value))
20787
+ return `Canonical object fields: ${value.join(", ")}. Workit validates the complete nested value.`;
20788
+ const isZodType = (schema) => ("_zod" in schema) && typeof schema._zod === "object";
20789
+ const schema = isZodType(value) ? toJSONSchema(value, { target: "draft-2020-12" }) : value;
20790
+ if (!schema.properties || typeof schema.properties !== "object") {
20791
+ const variants = Array.isArray(schema.oneOf) ? schema.oneOf : Array.isArray(schema.anyOf) ? schema.anyOf : null;
20792
+ return variants ? `Canonical shapes: ${variants.map((variant) => schemaShapeDescription(variant)).join(" | ")}. Full nested value is validated.` : "Canonical nested value; Workit validates the complete value.";
20793
+ }
20794
+ const properties = schema.properties;
20795
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
20796
+ const fields = Object.entries(properties).map(([name, child]) => `${name}${required.has(name) ? "!" : ""}:${schemaShapeDescription(child)}`);
20797
+ return `Fields (! required): ${fields.join(", ")}. Full nested value is validated.`;
20798
+ };
20759
20799
  function boundedOperationJsonSchema(family, maxDepth = OPERATION_SCHEMA_DEPTH, stringifiedObjects = false) {
20760
20800
  const tolerate = (projected) => {
20761
20801
  if (!stringifiedObjects)
@@ -20779,9 +20819,10 @@ function boundedOperationJsonSchema(family, maxDepth = OPERATION_SCHEMA_DEPTH, s
20779
20819
  return node;
20780
20820
  const record = node;
20781
20821
  if (record.properties && typeof record.properties === "object") {
20782
- const fields = Object.keys(record.properties);
20822
+ const properties = record.properties;
20823
+ const fields = Object.keys(properties);
20783
20824
  if (currentDepth >= maxDepth || fields.length === 0) {
20784
- const description = stringifiedObjects ? `${canonicalFieldsDescription(fields)} A JSON-encoded string is also accepted.` : canonicalFieldsDescription(fields);
20825
+ const description = stringifiedObjects ? `${canonicalFieldsDescription(record)} A JSON-encoded string is also accepted.` : canonicalFieldsDescription(record);
20785
20826
  return tolerate({ type: "object", description });
20786
20827
  }
20787
20828
  return tolerate({
@@ -23073,6 +23114,28 @@ var canonicalGlob = (glob) => {
23073
23114
  const real = realpathOf(prefix.replace(/\/+$/, "") || "/");
23074
23115
  return real + (prefix.endsWith("/") ? "/" : "") + rest;
23075
23116
  };
23117
+ var globSpecificity = (glob) => glob.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0 && !/[*?[\]{]/.test(segment)).length;
23118
+ var selectWorkspaceMatch = (matches, cwd, workspaceName) => {
23119
+ if (workspaceName !== undefined) {
23120
+ const named = matches.filter((entry) => entry.name === workspaceName);
23121
+ if (named.length === 1)
23122
+ return named[0];
23123
+ if (named.length > 1)
23124
+ throw new Error(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
23125
+ if (matches.length > 0) {
23126
+ throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
23127
+ }
23128
+ throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
23129
+ }
23130
+ if (matches.length < 2)
23131
+ return matches[0];
23132
+ const highestSpecificity = Math.max(...matches.map((entry) => globSpecificity(entry.glob)));
23133
+ const mostSpecific = matches.filter((entry) => globSpecificity(entry.glob) === highestSpecificity);
23134
+ if (mostSpecific.length > 1) {
23135
+ throw new Error(`ambiguous workspace for ${cwd}; choose one of: ${mostSpecific.map((entry) => entry.name).join(", ")}`);
23136
+ }
23137
+ return mostSpecific[0];
23138
+ };
23076
23139
  var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
23077
23140
  const result = readWorkspacesResult(dir);
23078
23141
  if (result.status === "malformed" || result.status === "invalid")
@@ -23092,20 +23155,7 @@ var resolveWorkspaceFrom = (cwd, dir, workspaceName) => {
23092
23155
  if (matched)
23093
23156
  matches.push(ws);
23094
23157
  }
23095
- if (workspaceName !== undefined) {
23096
- const selected = matches.find((ws) => ws.name === workspaceName);
23097
- if (!selected && matches.length > 0) {
23098
- const matchingNames = matches.map((ws) => ws.name);
23099
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matchingNames.join(", ")}`);
23100
- }
23101
- if (selected)
23102
- return selected;
23103
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
23104
- }
23105
- if (matches.length > 1) {
23106
- throw new Error(`ambiguous workspace for ${cwd}; choose one of: ${matches.map((ws) => ws.name).join(", ")}`);
23107
- }
23108
- return matches[0] ?? null;
23158
+ return selectWorkspaceMatch(matches, cwd, workspaceName) ?? null;
23109
23159
  };
23110
23160
  var runtimeWorkspacePolicySchema = (kind) => {
23111
23161
  const key = kind === "branch" ? "branchPolicy" : kind === "commit" ? "commitPolicy" : "vcs";
@@ -23162,21 +23212,7 @@ var resolveRuntimeWorkspaceCandidate = (cwd, kind) => {
23162
23212
  return targets.some((target) => matchWorkspace(glob, target) || canonical !== glob && matchWorkspace(canonical, target));
23163
23213
  });
23164
23214
  const workspaceName = process.env.WORKFLOW_WORKSPACE_NAME?.trim() || undefined;
23165
- let selected;
23166
- if (workspaceName) {
23167
- const named = matches.filter((entry) => entry.name === workspaceName);
23168
- if (named.length === 1)
23169
- selected = named[0];
23170
- else if (named.length > 1)
23171
- throw new Error(`ambiguous workspace ${JSON.stringify(workspaceName)} for ${cwd}`);
23172
- else if (matches.length)
23173
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}; matching choices: ${matches.map((entry) => entry.name).join(", ")}`);
23174
- else
23175
- throw new Error(`workspace ${JSON.stringify(workspaceName)} does not match ${cwd}`);
23176
- } else if (matches.length > 1)
23177
- throw new Error(`ambiguous workspace for ${cwd}; choose one of: ${matches.map((entry) => entry.name).join(", ")}`);
23178
- else
23179
- selected = matches[0];
23215
+ const selected = selectWorkspaceMatch(matches, cwd, workspaceName);
23180
23216
  if (!selected)
23181
23217
  return null;
23182
23218
  const policy = runtimeWorkspacePolicySchema(kind).safeParse(selected);
@@ -25105,6 +25141,7 @@ function resolveRequirements(input) {
25105
25141
  dependentAction: null,
25106
25142
  acceptanceAllowed: false
25107
25143
  }));
25144
+ const independentBehaviorReview = input.preferences?.thorough === true || input.assessment.consequences.some((consequence) => ["security", "data", "public_contract", "operations"].includes(consequence.area));
25108
25145
  if (signals.behaviorChange.value === true)
25109
25146
  requirements.push(requirement({
25110
25147
  ruleId: "behavioral-verification",
@@ -25116,14 +25153,14 @@ function resolveRequirements(input) {
25116
25153
  dependentAction: null,
25117
25154
  acceptanceAllowed: false
25118
25155
  }), requirement({
25119
- ruleId: "fresh-context-review",
25156
+ ruleId: independentBehaviorReview ? "fresh-context-review" : "self-review",
25120
25157
  dimension: "review",
25121
25158
  scope,
25122
- reason: "A non-mechanical behavior change requires fresh-context review.",
25123
- satisfaction: "A separate review context examines the current candidate and records its result.",
25159
+ reason: independentBehaviorReview ? "Consequential behavior or the thorough preference requires fresh-context review." : "Bounded behavior changes use self-review unless consequential risks or trusted rules require more.",
25160
+ satisfaction: independentBehaviorReview ? "A separate review context examines the current candidate and records its result." : "The lead reviews the resulting diff and records the relevant scope and checks.",
25124
25161
  before: "close",
25125
25162
  dependentAction: null,
25126
- acceptanceAllowed: false
25163
+ acceptanceAllowed: !independentBehaviorReview
25127
25164
  }));
25128
25165
  else if (signals.mechanicalLowRisk.value === true)
25129
25166
  requirements.push(requirement({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-mcp",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
5
  "description": "Workit shared MCP transport for the eight task and policy operation families",
6
6
  "keywords": [
@@ -42,7 +42,7 @@
42
42
  "build": "bun scripts/build.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@brainervirus/workit-core": "^1.3.0",
45
+ "@brainervirus/workit-core": "^1.3.1",
46
46
  "@modelcontextprotocol/sdk": "1.30.0",
47
47
  "zod": "4.5.4"
48
48
  },