@workit-dev/opencode 2.3.0 → 2.4.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.
@@ -37,3 +37,11 @@ into the trunk instead, its body the release notes (draft and approve them
37
37
  first, as in step 3). Once it merges, tag the merge and run
38
38
  `workit git push --release <tag>`: it publishes the forge release with the
39
39
  same notes (under `review`, only the approved draft).
40
+
41
+ ## Release package
42
+
43
+ A workspace `releasePackages` entry, after the workspace release finished:
44
+ `workit release package <name> <version>` tags `<name>@<version>` on the
45
+ release commit (`--at <ref>`), pushes it, creates its forge release (not
46
+ Latest; `--latest` only when asked) and verifies it. Notes:
47
+ `workit release notes draft <name>@<version>`.
package/dist/plugin.js CHANGED
@@ -9524,7 +9524,8 @@ var workspaceConfigSchema = object({
9524
9524
  commitPolicy: workspaceCommitPolicySchema.optional().describe("The commit message rules."),
9525
9525
  defaultProfile: nonBlank.optional().describe("The profile used when none is named; must be a key of `profiles`."),
9526
9526
  profiles: record(nonBlank, workspaceProfileSchema).optional().describe("Named branch/commit policy variants of this workspace."),
9527
- releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning.")
9527
+ releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning."),
9528
+ releasePackages: unknown().optional().describe("Packages released from this repository's own release line under their own tag namespace (`pkg-a@0.1.0`): keyed by package name, each `{ tagNamespace?, changelogPath? }` (default namespace `<name>@`). `workit release package <name> <version>` tags and publishes one.")
9528
9529
  }).passthrough().superRefine((workspace, context) => {
9529
9530
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
9530
9531
  context.addIssue({
@@ -9968,7 +9969,19 @@ var inheritedSetting = (cwd, dir, has) => {
9968
9969
  source: [selected, ...enclosing].find(has) ?? null
9969
9970
  };
9970
9971
  };
9972
+ var resolveRuntimeReleasePackages = (cwd, dir) => {
9973
+ const found = inheritedSetting(cwd, dir, (entry) => entry.releasePackages !== undefined);
9974
+ return found?.source ? { workspace: found.source.name, releasePackages: found.source.releasePackages } : null;
9975
+ };
9971
9976
  var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
9977
+ var changelogPathOf = (value) => {
9978
+ if (typeof value !== "string")
9979
+ return null;
9980
+ const parts = value.trim().replaceAll("\\", "/").split("/").filter((part) => part && part !== ".");
9981
+ if (!parts.length || value.trim().startsWith("/") || /^[A-Za-z]:/u.test(value.trim()))
9982
+ return null;
9983
+ return parts.includes("..") ? null : parts.join("/");
9984
+ };
9972
9985
  var modelSources = (cwd, dir) => {
9973
9986
  const out = [];
9974
9987
  try {
@@ -19078,6 +19091,69 @@ var SCOPE_FIELDS = new Set([
19078
19091
  "youtrack"
19079
19092
  ]);
19080
19093
 
19094
+ // packages/workit-core/src/core/release-packages.ts
19095
+ var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
19096
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
19097
+ var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
19098
+ var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
19099
+ function readReleasePackages(raw) {
19100
+ const out = { packages: [], issues: [] };
19101
+ if (raw === undefined || raw === null)
19102
+ return out;
19103
+ if (!isRecord4(raw)) {
19104
+ out.issues.push("releasePackages is not an object; ignored");
19105
+ return out;
19106
+ }
19107
+ const seen = new Map;
19108
+ for (const [name, entry] of Object.entries(raw).toSorted(([a], [b]) => a < b ? -1 : 1)) {
19109
+ const label = `release package ${JSON.stringify(name)}`;
19110
+ if (!name.trim() || name.trim() !== name) {
19111
+ out.issues.push(`${label}: a blank or padded name; ignored`);
19112
+ continue;
19113
+ }
19114
+ if (!isRecord4(entry)) {
19115
+ out.issues.push(`${label} is not an object; ignored`);
19116
+ continue;
19117
+ }
19118
+ for (const key of Object.keys(entry))
19119
+ if (!KNOWN_FIELDS2.has(key))
19120
+ out.issues.push(`${label} ${key}: unknown field, ignored`);
19121
+ const tagNamespace = typeof entry.tagNamespace === "string" ? entry.tagNamespace.trim() : `${name}@`;
19122
+ if (!validTagNamespace(tagNamespace)) {
19123
+ out.issues.push(`${label} tagNamespace ${JSON.stringify(tagNamespace)}: not a tag prefix (a letter first, no trailing digit); the package is ignored`);
19124
+ continue;
19125
+ }
19126
+ const owner = seen.get(tagNamespace);
19127
+ if (owner) {
19128
+ out.issues.push(`${label} tagNamespace ${tagNamespace}: already ${owner}'s; ignored`);
19129
+ continue;
19130
+ }
19131
+ let changelogPath = null;
19132
+ if (entry.changelogPath !== undefined) {
19133
+ changelogPath = changelogPathOf(entry.changelogPath);
19134
+ if (!changelogPath)
19135
+ out.issues.push(`${label} changelogPath: not a repo-relative path; ignored`);
19136
+ }
19137
+ seen.set(tagNamespace, name);
19138
+ out.packages.push({ name, tagNamespace, changelogPath });
19139
+ }
19140
+ return out;
19141
+ }
19142
+ function workspaceReleasePackages(cwd, dir) {
19143
+ let raw;
19144
+ try {
19145
+ raw = resolveRuntimeReleasePackages(cwd, dir)?.releasePackages;
19146
+ } catch {
19147
+ return { packages: [], issues: [] };
19148
+ }
19149
+ return readReleasePackages(raw);
19150
+ }
19151
+ function packageOfTag(tag, packages) {
19152
+ const pkg = packages.filter((entry) => tag.startsWith(entry.tagNamespace) && /^\d/u.test(tag.slice(entry.tagNamespace.length))).toSorted((a, b) => b.tagNamespace.length - a.tagNamespace.length)[0];
19153
+ return pkg ? { pkg, version: tag.slice(pkg.tagNamespace.length) } : null;
19154
+ }
19155
+ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespace}<version>`);
19156
+
19081
19157
  // packages/workit-core/src/hooks/session-marker.ts
19082
19158
  import { createHash as createHash16 } from "node:crypto";
19083
19159
  import fs19 from "node:fs";
@@ -20898,15 +20974,20 @@ var guardedTarget = (dir, target) => {
20898
20974
  };
20899
20975
  var isTag = (facts, name) => facts.tags.has(name) && !facts.heads.has(name);
20900
20976
  var tagRefusal = (action, facts, dir) => {
20977
+ let packages;
20978
+ const unmade = action.targets.filter((name) => name !== null && /\d/u.test(name) && !facts.tags.has(name) && !facts.heads.has(name) && packageOfTag(name, packages ??= workspaceReleasePackages(dir).packages) !== null);
20901
20979
  const tags = [
20902
20980
  ...action.tags ?? [],
20903
- ...action.targets.filter((name) => name !== null && isTag(facts, name))
20981
+ ...action.targets.filter((name) => name !== null && isTag(facts, name)),
20982
+ ...unmade
20904
20983
  ];
20905
20984
  if (!tags.length && !action.allTags)
20906
20985
  return null;
20907
20986
  const shape = `${releaseTagPrefixOf(dir)}<version>`;
20987
+ const shapes = [shape, ...packageTagShapes(packages ?? workspaceReleasePackages(dir).packages)];
20908
20988
  const named = tags.length ? tags.join(" --release ") : shape;
20909
- return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shape} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).`;
20989
+ const create = unmade.length ? ` ${unmade.join(", ")} is not a tag here yet: create it first with ${quote(`git tag -a ${unmade[0]} -m '<notes>' <release commit>`)}, or let ${quote("workit release package <name> <version>")} tag, push and publish it.` : "";
20990
+ return `workit: raw ${quote(`git push${action.allTags ? " --tags" : ""}`)} of ${tags.length ? `tag ${tags.join(", ")}` : "tags"} bypasses the release grant. Push a release tag with ${quote(`workit git push --release ${named}`)} (${shapes.join(", ")} tags whose commit the production branch already has; a tag never moves), under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}).${create}`;
20910
20991
  };
20911
20992
  var remoteHeads = (repo, remote) => {
20912
20993
  const listed = spawnSync16("git", ["ls-remote", "--heads", remote], {
@@ -25014,7 +25095,7 @@ var readText3 = (file) => {
25014
25095
  throw error;
25015
25096
  }
25016
25097
  };
25017
- var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25098
+ var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25018
25099
  function parseJsonc(text) {
25019
25100
  let out = "";
25020
25101
  for (let index = 0;index < text.length; index += 1) {
@@ -25088,12 +25169,12 @@ function claudeRules(cwd, env = process.env) {
25088
25169
  if (text === null)
25089
25170
  continue;
25090
25171
  const value = JSON.parse(text);
25091
- if (!isRecord4(value))
25172
+ if (!isRecord5(value))
25092
25173
  return "unreadable";
25093
25174
  const permissions = value.permissions;
25094
25175
  if (permissions === undefined)
25095
25176
  continue;
25096
- if (!isRecord4(permissions))
25177
+ if (!isRecord5(permissions))
25097
25178
  return "unreadable";
25098
25179
  for (const [key, bucket] of [
25099
25180
  ["deny", rules.deny],
@@ -25127,7 +25208,7 @@ var opencodePermission = (permission, rules) => {
25127
25208
  (permission === "allow" ? rules.allow : rules.deny).push("");
25128
25209
  return ["allow", "ask", "deny"].includes(permission);
25129
25210
  }
25130
- if (!isRecord4(permission))
25211
+ if (!isRecord5(permission))
25131
25212
  return false;
25132
25213
  for (const key of ["bash", "shell"]) {
25133
25214
  const value = permission[key];
@@ -25139,7 +25220,7 @@ var opencodePermission = (permission, rules) => {
25139
25220
  (value === "allow" ? rules.allow : rules.deny).push("");
25140
25221
  continue;
25141
25222
  }
25142
- if (!isRecord4(value))
25223
+ if (!isRecord5(value))
25143
25224
  return false;
25144
25225
  for (const [pattern, action] of Object.entries(value)) {
25145
25226
  if (action !== "allow" && action !== "ask" && action !== "deny")
@@ -25150,15 +25231,15 @@ var opencodePermission = (permission, rules) => {
25150
25231
  return true;
25151
25232
  };
25152
25233
  var opencodeConfig = (value, rules) => {
25153
- if (!isRecord4(value))
25234
+ if (!isRecord5(value))
25154
25235
  return false;
25155
25236
  if (!opencodePermission(value.permission, rules))
25156
25237
  return false;
25157
25238
  if (value.agent === undefined)
25158
25239
  return true;
25159
- if (!isRecord4(value.agent))
25240
+ if (!isRecord5(value.agent))
25160
25241
  return false;
25161
- return Object.values(value.agent).every((agent) => isRecord4(agent) && opencodePermission(agent.permission, rules));
25242
+ return Object.values(value.agent).every((agent) => isRecord5(agent) && opencodePermission(agent.permission, rules));
25162
25243
  };
25163
25244
  function opencodeRules(cwd, env = process.env) {
25164
25245
  const rules = EMPTY2();
@@ -25248,11 +25329,11 @@ function cursorRules(cwd, env = process.env) {
25248
25329
  if (text === null)
25249
25330
  continue;
25250
25331
  const value = JSON.parse(text);
25251
- if (!isRecord4(value))
25332
+ if (!isRecord5(value))
25252
25333
  return "unreadable";
25253
25334
  if (value.permissions === undefined)
25254
25335
  continue;
25255
- if (!isRecord4(value.permissions))
25336
+ if (!isRecord5(value.permissions))
25256
25337
  return "unreadable";
25257
25338
  for (const [key, bucket] of [
25258
25339
  ["deny", rules.deny],
@@ -25588,11 +25669,11 @@ var readJson = (file) => {
25588
25669
  return;
25589
25670
  }
25590
25671
  };
25591
- var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25672
+ var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25592
25673
  var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
25593
25674
  function machinePatterns(env) {
25594
25675
  const value = readJson(heavyCommandsFile(env));
25595
- return isRecord5(value) ? stringList(value.patterns) : [];
25676
+ return isRecord6(value) ? stringList(value.patterns) : [];
25596
25677
  }
25597
25678
  function repoPatterns(cwd) {
25598
25679
  return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
@@ -30410,7 +30491,7 @@ function normalizePattern(raw) {
30410
30491
  return { error: "has unbalanced or nested braces" };
30411
30492
  return { pattern };
30412
30493
  }
30413
- var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
30494
+ var isRecord8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
30414
30495
  function findCycle(slices) {
30415
30496
  const byId = new Map(slices.map((slice) => [slice.id, slice]));
30416
30497
  const state = new Map;
@@ -30496,7 +30577,7 @@ function fanoutsDir(cwd) {
30496
30577
  return { ok: true, data: path53.join(root.value.root, "fanouts") };
30497
30578
  }
30498
30579
  function parseStored(raw) {
30499
- if (!isRecord7(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
30580
+ if (!isRecord8(raw) || typeof raw.name !== "string" || typeof raw.trunk !== "string")
30500
30581
  return null;
30501
30582
  if (!Array.isArray(raw.slices))
30502
30583
  return null;
@@ -30513,7 +30594,7 @@ function parseStored(raw) {
30513
30594
  });
30514
30595
  const slices = [];
30515
30596
  for (const item of raw.slices) {
30516
- if (!isRecord7(item) || typeof item.id !== "string" || typeof item.branch !== "string")
30597
+ if (!isRecord8(item) || typeof item.id !== "string" || typeof item.branch !== "string")
30517
30598
  return null;
30518
30599
  slices.push({
30519
30600
  id: item.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.0.18",
44
- "@workit-dev/core": "^2.3.0"
44
+ "@workit-dev/core": "^2.4.1"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"