@workit-dev/pi 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.
package/dist/worker.js CHANGED
@@ -7434,7 +7434,8 @@ var workspaceConfigSchema = object({
7434
7434
  commitPolicy: workspaceCommitPolicySchema.optional().describe("The commit message rules."),
7435
7435
  defaultProfile: nonBlank.optional().describe("The profile used when none is named; must be a key of `profiles`."),
7436
7436
  profiles: record(nonBlank, workspaceProfileSchema).optional().describe("Named branch/commit policy variants of this workspace."),
7437
- releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning.")
7437
+ releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning."),
7438
+ 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.")
7438
7439
  }).passthrough().superRefine((workspace, context) => {
7439
7440
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
7440
7441
  context.addIssue({
@@ -8919,6 +8920,9 @@ var SCOPE_FIELDS = new Set([
8919
8920
  "youtrack"
8920
8921
  ]);
8921
8922
 
8923
+ // packages/workit-core/src/core/release-packages.ts
8924
+ var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
8925
+
8922
8926
  // packages/workit-core/src/hooks/raw-git.ts
8923
8927
  var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh", "ash", "mksh", "yash", "fish"]);
8924
8928
  var POWERSHELLS = new Set(["pwsh", "powershell"]);
package/dist/workit.js CHANGED
@@ -9195,7 +9195,8 @@ var workspaceConfigSchema = object({
9195
9195
  commitPolicy: workspaceCommitPolicySchema.optional().describe("The commit message rules."),
9196
9196
  defaultProfile: nonBlank.optional().describe("The profile used when none is named; must be a key of `profiles`."),
9197
9197
  profiles: record(nonBlank, workspaceProfileSchema).optional().describe("Named branch/commit policy variants of this workspace."),
9198
- releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning.")
9198
+ releaseTracks: record(nonBlank, releaseTrackSchema).optional().describe("Named release tracks: production and integration branches, naming and versioning."),
9199
+ 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.")
9199
9200
  }).passthrough().superRefine((workspace, context) => {
9200
9201
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
9201
9202
  context.addIssue({
@@ -9639,6 +9640,10 @@ var inheritedSetting = (cwd, dir, has) => {
9639
9640
  source: [selected, ...enclosing].find(has) ?? null
9640
9641
  };
9641
9642
  };
9643
+ var resolveRuntimeReleasePackages = (cwd, dir) => {
9644
+ const found = inheritedSetting(cwd, dir, (entry) => entry.releasePackages !== undefined);
9645
+ return found?.source ? { workspace: found.source.name, releasePackages: found.source.releasePackages } : null;
9646
+ };
9642
9647
  var workspaceTrailers = (cwd, dir) => {
9643
9648
  const found = inheritedSetting(cwd, dir, (entry) => typeof entry.trailers === "boolean");
9644
9649
  return {
@@ -9648,6 +9653,14 @@ var workspaceTrailers = (cwd, dir) => {
9648
9653
  };
9649
9654
  };
9650
9655
  var workspaceLiveSessionGuard = (cwd, dir) => inheritedSetting(cwd, dir, (entry) => typeof entry.liveSessionGuard === "boolean")?.source?.liveSessionGuard !== false;
9656
+ var changelogPathOf = (value) => {
9657
+ if (typeof value !== "string")
9658
+ return null;
9659
+ const parts = value.trim().replaceAll("\\", "/").split("/").filter((part) => part && part !== ".");
9660
+ if (!parts.length || value.trim().startsWith("/") || /^[A-Za-z]:/u.test(value.trim()))
9661
+ return null;
9662
+ return parts.includes("..") ? null : parts.join("/");
9663
+ };
9651
9664
  var modelSources = (cwd, dir) => {
9652
9665
  const out = [];
9653
9666
  try {
@@ -18929,6 +18942,69 @@ var SCOPE_FIELDS = new Set([
18929
18942
  "youtrack"
18930
18943
  ]);
18931
18944
 
18945
+ // packages/workit-core/src/core/release-packages.ts
18946
+ var KNOWN_FIELDS2 = new Set(["tagNamespace", "changelogPath"]);
18947
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18948
+ var NAMESPACE = /^[A-Za-z@][\w.@/+-]*$/u;
18949
+ var validTagNamespace = (value) => NAMESPACE.test(value) && !value.includes("..") && !value.includes("@{") && !value.includes("//") && !value.endsWith(".lock") && !/\d$/u.test(value);
18950
+ function readReleasePackages(raw) {
18951
+ const out = { packages: [], issues: [] };
18952
+ if (raw === undefined || raw === null)
18953
+ return out;
18954
+ if (!isRecord4(raw)) {
18955
+ out.issues.push("releasePackages is not an object; ignored");
18956
+ return out;
18957
+ }
18958
+ const seen = new Map;
18959
+ for (const [name, entry] of Object.entries(raw).toSorted(([a], [b]) => a < b ? -1 : 1)) {
18960
+ const label = `release package ${JSON.stringify(name)}`;
18961
+ if (!name.trim() || name.trim() !== name) {
18962
+ out.issues.push(`${label}: a blank or padded name; ignored`);
18963
+ continue;
18964
+ }
18965
+ if (!isRecord4(entry)) {
18966
+ out.issues.push(`${label} is not an object; ignored`);
18967
+ continue;
18968
+ }
18969
+ for (const key of Object.keys(entry))
18970
+ if (!KNOWN_FIELDS2.has(key))
18971
+ out.issues.push(`${label} ${key}: unknown field, ignored`);
18972
+ const tagNamespace = typeof entry.tagNamespace === "string" ? entry.tagNamespace.trim() : `${name}@`;
18973
+ if (!validTagNamespace(tagNamespace)) {
18974
+ out.issues.push(`${label} tagNamespace ${JSON.stringify(tagNamespace)}: not a tag prefix (a letter first, no trailing digit); the package is ignored`);
18975
+ continue;
18976
+ }
18977
+ const owner = seen.get(tagNamespace);
18978
+ if (owner) {
18979
+ out.issues.push(`${label} tagNamespace ${tagNamespace}: already ${owner}'s; ignored`);
18980
+ continue;
18981
+ }
18982
+ let changelogPath = null;
18983
+ if (entry.changelogPath !== undefined) {
18984
+ changelogPath = changelogPathOf(entry.changelogPath);
18985
+ if (!changelogPath)
18986
+ out.issues.push(`${label} changelogPath: not a repo-relative path; ignored`);
18987
+ }
18988
+ seen.set(tagNamespace, name);
18989
+ out.packages.push({ name, tagNamespace, changelogPath });
18990
+ }
18991
+ return out;
18992
+ }
18993
+ function workspaceReleasePackages(cwd, dir) {
18994
+ let raw;
18995
+ try {
18996
+ raw = resolveRuntimeReleasePackages(cwd, dir)?.releasePackages;
18997
+ } catch {
18998
+ return { packages: [], issues: [] };
18999
+ }
19000
+ return readReleasePackages(raw);
19001
+ }
19002
+ function packageOfTag(tag, packages) {
19003
+ 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];
19004
+ return pkg ? { pkg, version: tag.slice(pkg.tagNamespace.length) } : null;
19005
+ }
19006
+ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespace}<version>`);
19007
+
18932
19008
  // packages/workit-core/src/hooks/session-marker.ts
18933
19009
  import { createHash as createHash15 } from "node:crypto";
18934
19010
  import fs18 from "node:fs";
@@ -20771,15 +20847,20 @@ var guardedTarget = (dir, target) => {
20771
20847
  };
20772
20848
  var isTag = (facts, name) => facts.tags.has(name) && !facts.heads.has(name);
20773
20849
  var tagRefusal = (action, facts, dir) => {
20850
+ let packages;
20851
+ 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);
20774
20852
  const tags = [
20775
20853
  ...action.tags ?? [],
20776
- ...action.targets.filter((name) => name !== null && isTag(facts, name))
20854
+ ...action.targets.filter((name) => name !== null && isTag(facts, name)),
20855
+ ...unmade
20777
20856
  ];
20778
20857
  if (!tags.length && !action.allTags)
20779
20858
  return null;
20780
20859
  const shape = `${releaseTagPrefixOf(dir)}<version>`;
20860
+ const shapes = [shape, ...packageTagShapes(packages ?? workspaceReleasePackages(dir).packages)];
20781
20861
  const named = tags.length ? tags.join(" --release ") : shape;
20782
- 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")}).`;
20862
+ 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.` : "";
20863
+ 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}`;
20783
20864
  };
20784
20865
  var remoteHeads = (repo, remote) => {
20785
20866
  const listed = spawnSync16("git", ["ls-remote", "--heads", remote], {
@@ -24906,7 +24987,7 @@ var readText3 = (file) => {
24906
24987
  throw error;
24907
24988
  }
24908
24989
  };
24909
- var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
24990
+ var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
24910
24991
  function parseJsonc(text) {
24911
24992
  let out = "";
24912
24993
  for (let index = 0;index < text.length; index += 1) {
@@ -24980,12 +25061,12 @@ function claudeRules(cwd, env = process.env) {
24980
25061
  if (text === null)
24981
25062
  continue;
24982
25063
  const value = JSON.parse(text);
24983
- if (!isRecord4(value))
25064
+ if (!isRecord5(value))
24984
25065
  return "unreadable";
24985
25066
  const permissions = value.permissions;
24986
25067
  if (permissions === undefined)
24987
25068
  continue;
24988
- if (!isRecord4(permissions))
25069
+ if (!isRecord5(permissions))
24989
25070
  return "unreadable";
24990
25071
  for (const [key, bucket] of [
24991
25072
  ["deny", rules.deny],
@@ -25019,7 +25100,7 @@ var opencodePermission = (permission, rules) => {
25019
25100
  (permission === "allow" ? rules.allow : rules.deny).push("");
25020
25101
  return ["allow", "ask", "deny"].includes(permission);
25021
25102
  }
25022
- if (!isRecord4(permission))
25103
+ if (!isRecord5(permission))
25023
25104
  return false;
25024
25105
  for (const key of ["bash", "shell"]) {
25025
25106
  const value = permission[key];
@@ -25031,7 +25112,7 @@ var opencodePermission = (permission, rules) => {
25031
25112
  (value === "allow" ? rules.allow : rules.deny).push("");
25032
25113
  continue;
25033
25114
  }
25034
- if (!isRecord4(value))
25115
+ if (!isRecord5(value))
25035
25116
  return false;
25036
25117
  for (const [pattern, action] of Object.entries(value)) {
25037
25118
  if (action !== "allow" && action !== "ask" && action !== "deny")
@@ -25042,15 +25123,15 @@ var opencodePermission = (permission, rules) => {
25042
25123
  return true;
25043
25124
  };
25044
25125
  var opencodeConfig = (value, rules) => {
25045
- if (!isRecord4(value))
25126
+ if (!isRecord5(value))
25046
25127
  return false;
25047
25128
  if (!opencodePermission(value.permission, rules))
25048
25129
  return false;
25049
25130
  if (value.agent === undefined)
25050
25131
  return true;
25051
- if (!isRecord4(value.agent))
25132
+ if (!isRecord5(value.agent))
25052
25133
  return false;
25053
- return Object.values(value.agent).every((agent) => isRecord4(agent) && opencodePermission(agent.permission, rules));
25134
+ return Object.values(value.agent).every((agent) => isRecord5(agent) && opencodePermission(agent.permission, rules));
25054
25135
  };
25055
25136
  function opencodeRules(cwd, env = process.env) {
25056
25137
  const rules = EMPTY2();
@@ -25140,11 +25221,11 @@ function cursorRules(cwd, env = process.env) {
25140
25221
  if (text === null)
25141
25222
  continue;
25142
25223
  const value = JSON.parse(text);
25143
- if (!isRecord4(value))
25224
+ if (!isRecord5(value))
25144
25225
  return "unreadable";
25145
25226
  if (value.permissions === undefined)
25146
25227
  continue;
25147
- if (!isRecord4(value.permissions))
25228
+ if (!isRecord5(value.permissions))
25148
25229
  return "unreadable";
25149
25230
  for (const [key, bucket] of [
25150
25231
  ["deny", rules.deny],
@@ -25480,11 +25561,11 @@ var readJson = (file) => {
25480
25561
  return;
25481
25562
  }
25482
25563
  };
25483
- var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25564
+ var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25484
25565
  var stringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
25485
25566
  function machinePatterns(env) {
25486
25567
  const value = readJson(heavyCommandsFile(env));
25487
- return isRecord5(value) ? stringList(value.patterns) : [];
25568
+ return isRecord6(value) ? stringList(value.patterns) : [];
25488
25569
  }
25489
25570
  function repoPatterns(cwd) {
25490
25571
  return repoHeavyCommands(gitTop(cwd) ?? path38.resolve(cwd));
@@ -27817,7 +27898,7 @@ ${line}` };
27817
27898
  };
27818
27899
  var shellNudge = (input, command) => withContextLine(rawGitPre(input, command), shipNudge(input, command));
27819
27900
  // packages/workit-core/src/hooks/hosts/fields.ts
27820
- var isRecord6 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
27901
+ var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
27821
27902
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
27822
27903
  var SHELLS2 = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
27823
27904
  var WRITE_TOOLS = new Set([
@@ -27842,7 +27923,7 @@ var WRITE_TOOLS = new Set([
27842
27923
  var PATH_KEYS = ["file_path", "filePath", "notebook_path", "path", "target_file", "file"];
27843
27924
  var PATCH_HEADER = /^[ \t]*\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
27844
27925
  var writePaths = (input) => {
27845
- if (!isRecord6(input))
27926
+ if (!isRecord7(input))
27846
27927
  return [];
27847
27928
  const paths = PATH_KEYS.map((key) => input[key]).filter(nonEmpty2);
27848
27929
  for (const value of Object.values(input))
@@ -30969,9 +31050,9 @@ import { randomUUID as randomUUID5 } from "node:crypto";
30969
31050
  // packages/workit-pi/src/worker-protocol.ts
30970
31051
  var MAX_WORKER_LINE_BYTES = 64 * 1024;
30971
31052
  var MAX_WORKER_STDERR_BYTES = 64 * 1024;
30972
- var isRecord7 = (value) => typeof value === "object" && value !== null;
31053
+ var isRecord8 = (value) => typeof value === "object" && value !== null;
30973
31054
  var parseEvent2 = (value) => {
30974
- if (!isRecord7(value) || typeof value.type !== "string")
31055
+ if (!isRecord8(value) || typeof value.type !== "string")
30975
31056
  return null;
30976
31057
  if (value.type === "workit_worker_ready") {
30977
31058
  if (typeof value.workerId !== "string" || typeof value.sessionId !== "string")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",
@@ -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>`.