@workit-dev/pi 2.26.1 → 2.27.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 (3) hide show
  1. package/dist/worker.js +101 -108
  2. package/dist/workit.js +425 -134
  3. package/package.json +1 -1
package/dist/worker.js CHANGED
@@ -4961,11 +4961,6 @@ if (!globalConfig.localeError)
4961
4961
  config(en_default());
4962
4962
  if (!globalConfig.memoizer)
4963
4963
  config({ memoizer: memoizer() });
4964
- var described = (schema, description) => {
4965
- const copy = schema.clone();
4966
- globalRegistry.add(copy, { description });
4967
- return copy;
4968
- };
4969
4964
 
4970
4965
  // packages/workit-core/src/core/task-contract.ts
4971
4966
  var OPERATION_FAMILIES = [
@@ -6424,25 +6419,25 @@ var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must
6424
6419
  var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
6425
6420
  var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
6426
6421
  var workspaceBranchPolicySchema = strictObject({
6427
- preset: described(branchPreset, "The branch model: gitflow, github-flow, trunk-based or custom (allowed/protected set by hand)."),
6428
- developBranch: described(optional(nonBlank), "The integration branch gitflow uses (default develop)."),
6429
- prefixes: described(optional(looseObject({
6422
+ preset: branchPreset,
6423
+ developBranch: optional(nonBlank),
6424
+ prefixes: optional(looseObject({
6430
6425
  feature: nonBlank,
6431
6426
  bugfix: nonBlank,
6432
6427
  release: nonBlank,
6433
6428
  hotfix: nonBlank
6434
- })), "The branch prefix per kind (feature/, bugfix/, release/, hotfix/)."),
6435
- allowed: described(optional(array(nonBlank)), "Branch name globs a new branch must match (`feature/*`)."),
6436
- protected: described(optional(array(nonBlank)), "Branches nobody commits or pushes to directly."),
6437
- integration: described(optional(_enum(["pr", "merge"])), "How work reaches its base: `pr` (default) opens a PR, `merge` merges locally.")
6429
+ })),
6430
+ allowed: optional(array(nonBlank)),
6431
+ protected: optional(array(nonBlank)),
6432
+ integration: optional(_enum(["pr", "merge"]))
6438
6433
  });
6439
6434
  var workspaceCommitPolicySchema = strictObject({
6440
- preset: described(commitPreset, "The commit message flavor, e.g. conventional."),
6441
- pattern: described(optional(string2()), "A regular expression every commit subject must match.")
6435
+ preset: commitPreset,
6436
+ pattern: optional(string2())
6442
6437
  });
6443
6438
  var workspaceProfileSchema = strictObject({
6444
- branchPolicy: described(optional(workspaceBranchPolicySchema), "This profile's branch policy."),
6445
- commitPolicy: described(optional(workspaceCommitPolicySchema), "This profile's commit policy.")
6439
+ branchPolicy: optional(workspaceBranchPolicySchema),
6440
+ commitPolicy: optional(workspaceCommitPolicySchema)
6446
6441
  }).check(refine((profile) => profile.branchPolicy !== undefined || profile.commitPolicy !== undefined, { message: "a profile must define branchPolicy or commitPolicy" }));
6447
6442
  var versionSourceSchema = discriminatedUnion("kind", [
6448
6443
  strictObject({
@@ -6454,22 +6449,22 @@ var versionSourceSchema = discriminatedUnion("kind", [
6454
6449
  strictObject({ kind: literal("manual") })
6455
6450
  ]);
6456
6451
  var releaseTrackSchema = looseObject({
6457
- strategy: described(optional(branchPreset), "The branch model this track follows."),
6458
- productionBranch: described(nonBlank, "The branch releases land on (main)."),
6459
- integrationBranch: described(nonBlank, "The branch work integrates into (develop)."),
6460
- naming: described(optional(looseObject({
6452
+ strategy: optional(branchPreset),
6453
+ productionBranch: nonBlank,
6454
+ integrationBranch: nonBlank,
6455
+ naming: optional(looseObject({
6461
6456
  feature: optional(nonBlank),
6462
6457
  release: optional(nonBlank),
6463
6458
  hotfix: optional(nonBlank)
6464
- })), "Branch name templates per kind, e.g. `feature/{name}`."),
6465
- baseBranch: described(optional(nonBlank), "The branch new work starts from."),
6466
- mergeBackBranches: described(optional(array(nonBlank)), "Branches a finished release or hotfix is merged back into."),
6467
- pullRequestTarget: described(optional(nonBlank), "The branch PRs target."),
6468
- tagNamespace: described(optional(string2()), "A prefix for this track's release tags."),
6469
- versionSource: described(optional(versionSourceSchema), "Where the version comes from: package-json, git-tag or manual."),
6470
- requiredChecks: described(optional(array(nonBlank)), "CI checks that must pass before a release."),
6471
- critical: described(optional(array(nonBlank)), "Fields an older Workit must not ignore: when one is unknown or malformed, Workit fails closed."),
6472
- releaseNotes: described(optional(unknown()), "This track's release notes mode, over the workspace's `releaseNotes`.")
6459
+ })),
6460
+ baseBranch: optional(nonBlank),
6461
+ mergeBackBranches: optional(array(nonBlank)),
6462
+ pullRequestTarget: optional(nonBlank),
6463
+ tagNamespace: optional(string2()),
6464
+ versionSource: optional(versionSourceSchema),
6465
+ requiredChecks: optional(array(nonBlank)),
6466
+ critical: optional(array(nonBlank)),
6467
+ releaseNotes: optional(unknown())
6473
6468
  }).check(superRefine((track, context) => {
6474
6469
  for (const [field, values] of [
6475
6470
  ["mergeBackBranches", track.mergeBackBranches ?? []],
@@ -6491,67 +6486,67 @@ var releaseTrackSchema = looseObject({
6491
6486
  });
6492
6487
  }
6493
6488
  }));
6494
- var modelRoles = described(optional(unknown()), "Per role (decider, implementer, verifier, reviewer, explore, babysit, default for a general-purpose spawn): a model name, `{ model, effort }`, or one of those per host (claude_code, opencode, codex, codex_cli, codex_desktop, cursor, pi, default). The implementer takes one per tier (mundane, standard, hard).");
6489
+ var modelRoles = optional(unknown());
6495
6490
  var workspaceConfigSchema = looseObject({
6496
- name: described(nonBlank, "The workspace's unique name."),
6497
- glob: described(nonBlank, "The directories this entry covers, an absolute path glob with * and ** (`/home/you/work/**`); the narrowest match wins."),
6498
- vcs: described(optional(looseObject({
6499
- provider: described(_enum(["gitlab", "github"]), "The forge: github or gitlab."),
6500
- defaultTargetBranch: described(optional(nonBlank), "The branch PRs target by default."),
6501
- tokenFile: described(optional(nonBlank), "A file holding the forge token for this workspace."),
6502
- account: described(optional(nonBlank), "The forge login delivery runs as; grants need it to reach the forge."),
6503
- host: described(optional(unknown()), "A self-hosted forge's host name.")
6504
- })), "The forge this workspace's repositories live on."),
6505
- autoApprove: described(optional(union([boolean2(), array(nonBlank)])), "Legacy (≤4.x) standing approvals, read once as autonomy grants; use `autonomy`."),
6506
- defaultEndpoint: described(optional(unknown()), "Where an unnamed request stops: commit (default), pr, green or merged. Set with `workit grant set`, like grants."),
6507
- verification: described(optional(_enum(["proportional", "self", "independent"])), "How a normal-risk behavior change is verified: proportional (default), self or independent. Set with `workit grant set`, like grants."),
6508
- delegation: described(optional(unknown()), "Who does the work: `inline-first` (default) keeps the lead working itself and refuses a slice without a reason to delegate; `lead-orchestrates` allows slices without one."),
6509
- changelog: described(optional(unknown()), "The Keep a Changelog step before a PR opens: `off` (default), `update` (an existing CHANGELOG.md needs an Unreleased entry from a user-facing PR) or `create` (the entry is required, creating the file). `workit pr create` enforces it."),
6510
- docs: described(optional(unknown()), "The docs refresh the ship skill does before a PR opens: `off` (default) or `when-user-facing`."),
6511
- changelogPath: described(optional(unknown()), "Where the changelog lives, repo-relative: one path or glob, or a list (a monorepo with one changelog per package; any of them satisfies the gate). Default CHANGELOG.md at the repo root."),
6512
- prTemplate: described(optional(unknown()), "Which template a PR description fills: `auto` (default: the repo's GitHub/GitLab template, else Workit's), `repo` (the repo's, refused when it has none), `workit` (Workit's Summary/Evidence/Merge danger) or a repo-relative path to one `.md` file."),
6513
- releaseNotes: described(optional(unknown()), "The release notes `workit release finish` publishes on the forge release: `auto` (default: the draft when there is one, else the notes built from the version's changelog section), `off` (no forge release) or `review` (finish refuses until `workit release notes approve`). A release track overrides it."),
6514
- trailers: described(optional(boolean2()), "Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
6515
- deleteBranch: described(optional(boolean2()), "Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
6516
- cleanup: described(optional(unknown()), "What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
6517
- feedback: described(optional(unknown()), '`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
6518
- liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
6519
- shared: described(optional(boolean2()), "Whether this workspace's repos are shared with a team that must not see Workit named (default false): `workit pr create` and `workit pr edit` then warn, never block, when the PR title, body or a new doc names it."),
6520
- fanout: described(optional(looseObject({
6521
- tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
6522
- deps: described(optional(unknown()), "How `workit fanout worktree create` gives a slice worktree node_modules: `install` (default: its own frozen install of its lockfile) or `link` (links into the main checkout's installed packages, for a repo too slow to install per slice). `--deps` overrides it."),
6523
- installTimeout: described(optional(unknown()), "How long the own install may run before its process tree is killed and the worktree is linked instead: a duration such as `90s` or `10m` (default `5m`). `--install-timeout` overrides it.")
6524
- })), "Fanout settings."),
6525
- models: described(optional(looseObject({ roles: modelRoles })), "Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
6526
- resources: described(optional(unknown()), "Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
6527
- remotes: described(optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))), "Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
6528
- externalRepos: described(optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))), "Repositories outside this workspace's own forge owners that `workit issue create|comment|close --repo` may write to: `owner/name`, or `owner/*` for a whole owner. Only the user changes it, in their own terminal."),
6529
- additiveRiskPaths: described(optional(array(nonBlank)), "Risk-path globs whose purely additive edits follow the review lane of the rest of the diff. Only the user sets it; it counts only while sealed."),
6530
- autonomy: described(optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
6491
+ name: nonBlank,
6492
+ glob: nonBlank,
6493
+ vcs: optional(looseObject({
6494
+ provider: _enum(["gitlab", "github"]),
6495
+ defaultTargetBranch: optional(nonBlank),
6496
+ tokenFile: optional(nonBlank),
6497
+ account: optional(nonBlank),
6498
+ host: optional(unknown())
6499
+ })),
6500
+ autoApprove: optional(union([boolean2(), array(nonBlank)])),
6501
+ defaultEndpoint: optional(unknown()),
6502
+ verification: optional(_enum(["proportional", "self", "independent"])),
6503
+ delegation: optional(unknown()),
6504
+ changelog: optional(unknown()),
6505
+ docs: optional(unknown()),
6506
+ changelogPath: optional(unknown()),
6507
+ prTemplate: optional(unknown()),
6508
+ releaseNotes: optional(unknown()),
6509
+ trailers: optional(boolean2()),
6510
+ deleteBranch: optional(boolean2()),
6511
+ cleanup: optional(unknown()),
6512
+ feedback: optional(unknown()),
6513
+ liveSessionGuard: optional(boolean2()),
6514
+ shared: optional(boolean2()),
6515
+ fanout: optional(looseObject({
6516
+ tierModels: optional(unknown()),
6517
+ deps: optional(unknown()),
6518
+ installTimeout: optional(unknown())
6519
+ })),
6520
+ models: optional(looseObject({ roles: modelRoles })),
6521
+ resources: optional(unknown()),
6522
+ remotes: optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
6523
+ externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
6524
+ additiveRiskPaths: optional(array(nonBlank)),
6525
+ autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
6531
6526
  kind,
6532
- described(optional(union([boolean2(), literal("verified")])), `The ${kind} grant: true, false, or "verified" (only after a verdict).`)
6533
- ])))), "Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
6534
- youtrack: described(optional(looseObject({
6535
- baseUrl: described(optional(nonBlank), "This workspace's YouTrack URL."),
6536
- link_issues: described(optional(boolean2()), "Legacy alias of `issues: { provider: youtrack, link: true }`."),
6537
- writes: described(optional(_enum(["ask", "auto"])), "ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1."),
6538
- autoHosts: described(optional(array(nonBlank)), "With writes auto: the only YouTrack hosts (`acme.youtrack.cloud`) a write may reach without asking. A raw ytrack write must name one with --host; a write elsewhere asks. Only the user widens it, in their own terminal (`workit workspace seal`).")
6539
- })), "YouTrack settings for this workspace."),
6540
- issues: described(optional(looseObject({
6541
- provider: described(optional(_enum(["github", "gitlab", "youtrack"])), "The issue tracker PRs link to."),
6542
- link: described(optional(boolean2()), "Derive the issue from the branch name."),
6543
- relation: described(optional(unknown()), "How a PR names its issue: `closes` (default) or `refs`."),
6544
- backlink: described(optional(boolean2()), "Post the PR URL on each linked issue after the PR is opened."),
6545
- link_on_pr: described(optional(boolean2()), "Legacy alias of `link`."),
6546
- repo: described(optional(unknown()), "The GitHub/GitLab repository (owner/name) that holds the issues; default the PR's own."),
6547
- host: described(optional(unknown()), "That repository's host; default the PR's host, or the tracker's public one.")
6548
- })), "The issue tracker PRs link to (any forge with any tracker)."),
6549
- branchPolicy: described(optional(workspaceBranchPolicySchema), "Which branches may be created and which are protected."),
6550
- commitPolicy: described(optional(workspaceCommitPolicySchema), "The commit message rules."),
6551
- defaultProfile: described(optional(nonBlank), "The profile used when none is named; must be a key of `profiles`."),
6552
- profiles: described(optional(record(nonBlank, workspaceProfileSchema)), "Named branch/commit policy variants of this workspace."),
6553
- releaseTracks: described(optional(record(nonBlank, releaseTrackSchema)), "Named release tracks: production and integration branches, naming and versioning."),
6554
- releasePackages: described(optional(unknown()), "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.")
6527
+ optional(union([boolean2(), literal("verified")]))
6528
+ ])))),
6529
+ youtrack: optional(looseObject({
6530
+ baseUrl: optional(nonBlank),
6531
+ link_issues: optional(boolean2()),
6532
+ writes: optional(_enum(["ask", "auto"])),
6533
+ autoHosts: optional(array(nonBlank))
6534
+ })),
6535
+ issues: optional(looseObject({
6536
+ provider: optional(_enum(["github", "gitlab", "youtrack"])),
6537
+ link: optional(boolean2()),
6538
+ relation: optional(unknown()),
6539
+ backlink: optional(boolean2()),
6540
+ link_on_pr: optional(boolean2()),
6541
+ repo: optional(unknown()),
6542
+ host: optional(unknown())
6543
+ })),
6544
+ branchPolicy: optional(workspaceBranchPolicySchema),
6545
+ commitPolicy: optional(workspaceCommitPolicySchema),
6546
+ defaultProfile: optional(nonBlank),
6547
+ profiles: optional(record(nonBlank, workspaceProfileSchema)),
6548
+ releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
6549
+ releasePackages: optional(unknown())
6555
6550
  }).check(superRefine((workspace, context) => {
6556
6551
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
6557
6552
  context.addIssue({
@@ -6562,11 +6557,11 @@ var workspaceConfigSchema = looseObject({
6562
6557
  }
6563
6558
  }));
6564
6559
  var workspacesFileSchema = looseObject({
6565
- workspaces: described(optional(array(workspaceConfigSchema)), "Workspace entries, each mapping a path glob to its forge, policies and grants."),
6566
- models: described(optional(looseObject({ roles: modelRoles })), "The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false)."),
6567
- feedback: described(optional(looseObject({
6568
- account: described(optional(nonBlank), "The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
6569
- })), "`workit feedback` defaults for every workspace.")
6560
+ workspaces: optional(array(workspaceConfigSchema)),
6561
+ models: optional(looseObject({ roles: modelRoles })),
6562
+ feedback: optional(looseObject({
6563
+ account: optional(nonBlank)
6564
+ }))
6570
6565
  }).check(superRefine((file, context) => {
6571
6566
  const names = new Set;
6572
6567
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -9950,19 +9945,6 @@ var PI_DESCRIPTOR = {
9950
9945
  ]
9951
9946
  };
9952
9947
 
9953
- // packages/workit-core/src/hooks/write-gate.ts
9954
- import path14 from "node:path";
9955
-
9956
- // packages/workit-core/src/core/live-session.ts
9957
- import { spawnSync as spawnSync8 } from "node:child_process";
9958
- var LIVE_SESSION_TTL_MS = 15 * 60000;
9959
- var liveProbe = {
9960
- platform: process.platform,
9961
- run: (args) => spawnSync8("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
9962
- start: (pid) => processStartOf(pid)
9963
- };
9964
- var PIDS = new Map;
9965
-
9966
9948
  // packages/workit-core/src/hooks/windows-reads.ts
9967
9949
  var READ_CMDLETS = new Set([
9968
9950
  "foreach-object",
@@ -9989,7 +9971,19 @@ var READ_CMDLETS = new Set([
9989
9971
  "pop-location",
9990
9972
  "help"
9991
9973
  ]);
9992
- var LOADER_ENV = /^(?:GIT_\w*|PAGER|EDITOR|VISUAL|PATH|LD_\w*|DYLD_\w*|NODE_OPTIONS|PYTHON\w*|BASH_ENV|ENV|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB))$/i;
9974
+
9975
+ // packages/workit-core/src/hooks/write-gate.ts
9976
+ import path14 from "node:path";
9977
+
9978
+ // packages/workit-core/src/core/live-session.ts
9979
+ import { spawnSync as spawnSync8 } from "node:child_process";
9980
+ var LIVE_SESSION_TTL_MS = 15 * 60000;
9981
+ var liveProbe = {
9982
+ platform: process.platform,
9983
+ run: (args) => spawnSync8("ps", args, { encoding: "utf8", timeout: 2000 }).stdout ?? "",
9984
+ start: (pid) => processStartOf(pid)
9985
+ };
9986
+ var PIDS = new Map;
9993
9987
 
9994
9988
  // packages/workit-core/src/hooks/write-gate.ts
9995
9989
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
@@ -10026,7 +10020,6 @@ var PUSHD2 = new Set(["pushd", "push-location"]);
10026
10020
  var POPD2 = new Set(["popd", "pop-location"]);
10027
10021
  var UNKNOWN_DIR = path14.resolve(path14.parse(process.cwd()).root, ".workit-unknown-dir");
10028
10022
  var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
10029
- var POSIX_LOADER = new RegExp(LOADER_ENV.source);
10030
10023
  var REBINDS_ANY = new Set([
10031
10024
  "source",
10032
10025
  ".",
package/dist/workit.js CHANGED
@@ -5374,11 +5374,6 @@ if (!globalConfig.localeError)
5374
5374
  config(en_default());
5375
5375
  if (!globalConfig.memoizer)
5376
5376
  config({ memoizer: memoizer() });
5377
- var described = (schema, description) => {
5378
- const copy = schema.clone();
5379
- globalRegistry.add(copy, { description });
5380
- return copy;
5381
- };
5382
5377
 
5383
5378
  // packages/workit-core/src/core/scope-glob.ts
5384
5379
  var GLOB = /[*?[\]{}]/u;
@@ -8378,25 +8373,25 @@ var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must
8378
8373
  var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
8379
8374
  var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
8380
8375
  var workspaceBranchPolicySchema = strictObject({
8381
- preset: described(branchPreset, "The branch model: gitflow, github-flow, trunk-based or custom (allowed/protected set by hand)."),
8382
- developBranch: described(optional(nonBlank), "The integration branch gitflow uses (default develop)."),
8383
- prefixes: described(optional(looseObject({
8376
+ preset: branchPreset,
8377
+ developBranch: optional(nonBlank),
8378
+ prefixes: optional(looseObject({
8384
8379
  feature: nonBlank,
8385
8380
  bugfix: nonBlank,
8386
8381
  release: nonBlank,
8387
8382
  hotfix: nonBlank
8388
- })), "The branch prefix per kind (feature/, bugfix/, release/, hotfix/)."),
8389
- allowed: described(optional(array(nonBlank)), "Branch name globs a new branch must match (`feature/*`)."),
8390
- protected: described(optional(array(nonBlank)), "Branches nobody commits or pushes to directly."),
8391
- integration: described(optional(_enum(["pr", "merge"])), "How work reaches its base: `pr` (default) opens a PR, `merge` merges locally.")
8383
+ })),
8384
+ allowed: optional(array(nonBlank)),
8385
+ protected: optional(array(nonBlank)),
8386
+ integration: optional(_enum(["pr", "merge"]))
8392
8387
  });
8393
8388
  var workspaceCommitPolicySchema = strictObject({
8394
- preset: described(commitPreset, "The commit message flavor, e.g. conventional."),
8395
- pattern: described(optional(string2()), "A regular expression every commit subject must match.")
8389
+ preset: commitPreset,
8390
+ pattern: optional(string2())
8396
8391
  });
8397
8392
  var workspaceProfileSchema = strictObject({
8398
- branchPolicy: described(optional(workspaceBranchPolicySchema), "This profile's branch policy."),
8399
- commitPolicy: described(optional(workspaceCommitPolicySchema), "This profile's commit policy.")
8393
+ branchPolicy: optional(workspaceBranchPolicySchema),
8394
+ commitPolicy: optional(workspaceCommitPolicySchema)
8400
8395
  }).check(refine((profile) => profile.branchPolicy !== undefined || profile.commitPolicy !== undefined, { message: "a profile must define branchPolicy or commitPolicy" }));
8401
8396
  var versionSourceSchema = discriminatedUnion("kind", [
8402
8397
  strictObject({
@@ -8408,22 +8403,22 @@ var versionSourceSchema = discriminatedUnion("kind", [
8408
8403
  strictObject({ kind: literal("manual") })
8409
8404
  ]);
8410
8405
  var releaseTrackSchema = looseObject({
8411
- strategy: described(optional(branchPreset), "The branch model this track follows."),
8412
- productionBranch: described(nonBlank, "The branch releases land on (main)."),
8413
- integrationBranch: described(nonBlank, "The branch work integrates into (develop)."),
8414
- naming: described(optional(looseObject({
8406
+ strategy: optional(branchPreset),
8407
+ productionBranch: nonBlank,
8408
+ integrationBranch: nonBlank,
8409
+ naming: optional(looseObject({
8415
8410
  feature: optional(nonBlank),
8416
8411
  release: optional(nonBlank),
8417
8412
  hotfix: optional(nonBlank)
8418
- })), "Branch name templates per kind, e.g. `feature/{name}`."),
8419
- baseBranch: described(optional(nonBlank), "The branch new work starts from."),
8420
- mergeBackBranches: described(optional(array(nonBlank)), "Branches a finished release or hotfix is merged back into."),
8421
- pullRequestTarget: described(optional(nonBlank), "The branch PRs target."),
8422
- tagNamespace: described(optional(string2()), "A prefix for this track's release tags."),
8423
- versionSource: described(optional(versionSourceSchema), "Where the version comes from: package-json, git-tag or manual."),
8424
- requiredChecks: described(optional(array(nonBlank)), "CI checks that must pass before a release."),
8425
- critical: described(optional(array(nonBlank)), "Fields an older Workit must not ignore: when one is unknown or malformed, Workit fails closed."),
8426
- releaseNotes: described(optional(unknown()), "This track's release notes mode, over the workspace's `releaseNotes`.")
8413
+ })),
8414
+ baseBranch: optional(nonBlank),
8415
+ mergeBackBranches: optional(array(nonBlank)),
8416
+ pullRequestTarget: optional(nonBlank),
8417
+ tagNamespace: optional(string2()),
8418
+ versionSource: optional(versionSourceSchema),
8419
+ requiredChecks: optional(array(nonBlank)),
8420
+ critical: optional(array(nonBlank)),
8421
+ releaseNotes: optional(unknown())
8427
8422
  }).check(superRefine((track, context) => {
8428
8423
  for (const [field, values] of [
8429
8424
  ["mergeBackBranches", track.mergeBackBranches ?? []],
@@ -8445,67 +8440,67 @@ var releaseTrackSchema = looseObject({
8445
8440
  });
8446
8441
  }
8447
8442
  }));
8448
- var modelRoles = described(optional(unknown()), "Per role (decider, implementer, verifier, reviewer, explore, babysit, default for a general-purpose spawn): a model name, `{ model, effort }`, or one of those per host (claude_code, opencode, codex, codex_cli, codex_desktop, cursor, pi, default). The implementer takes one per tier (mundane, standard, hard).");
8443
+ var modelRoles = optional(unknown());
8449
8444
  var workspaceConfigSchema = looseObject({
8450
- name: described(nonBlank, "The workspace's unique name."),
8451
- glob: described(nonBlank, "The directories this entry covers, an absolute path glob with * and ** (`/home/you/work/**`); the narrowest match wins."),
8452
- vcs: described(optional(looseObject({
8453
- provider: described(_enum(["gitlab", "github"]), "The forge: github or gitlab."),
8454
- defaultTargetBranch: described(optional(nonBlank), "The branch PRs target by default."),
8455
- tokenFile: described(optional(nonBlank), "A file holding the forge token for this workspace."),
8456
- account: described(optional(nonBlank), "The forge login delivery runs as; grants need it to reach the forge."),
8457
- host: described(optional(unknown()), "A self-hosted forge's host name.")
8458
- })), "The forge this workspace's repositories live on."),
8459
- autoApprove: described(optional(union([boolean2(), array(nonBlank)])), "Legacy (≤4.x) standing approvals, read once as autonomy grants; use `autonomy`."),
8460
- defaultEndpoint: described(optional(unknown()), "Where an unnamed request stops: commit (default), pr, green or merged. Set with `workit grant set`, like grants."),
8461
- verification: described(optional(_enum(["proportional", "self", "independent"])), "How a normal-risk behavior change is verified: proportional (default), self or independent. Set with `workit grant set`, like grants."),
8462
- delegation: described(optional(unknown()), "Who does the work: `inline-first` (default) keeps the lead working itself and refuses a slice without a reason to delegate; `lead-orchestrates` allows slices without one."),
8463
- changelog: described(optional(unknown()), "The Keep a Changelog step before a PR opens: `off` (default), `update` (an existing CHANGELOG.md needs an Unreleased entry from a user-facing PR) or `create` (the entry is required, creating the file). `workit pr create` enforces it."),
8464
- docs: described(optional(unknown()), "The docs refresh the ship skill does before a PR opens: `off` (default) or `when-user-facing`."),
8465
- changelogPath: described(optional(unknown()), "Where the changelog lives, repo-relative: one path or glob, or a list (a monorepo with one changelog per package; any of them satisfies the gate). Default CHANGELOG.md at the repo root."),
8466
- prTemplate: described(optional(unknown()), "Which template a PR description fills: `auto` (default: the repo's GitHub/GitLab template, else Workit's), `repo` (the repo's, refused when it has none), `workit` (Workit's Summary/Evidence/Merge danger) or a repo-relative path to one `.md` file."),
8467
- releaseNotes: described(optional(unknown()), "The release notes `workit release finish` publishes on the forge release: `auto` (default: the draft when there is one, else the notes built from the version's changelog section), `off` (no forge release) or `review` (finish refuses until `workit release notes approve`). A release track overrides it."),
8468
- trailers: described(optional(boolean2()), "Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
8469
- deleteBranch: described(optional(boolean2()), "Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
8470
- cleanup: described(optional(unknown()), "What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
8471
- feedback: described(optional(unknown()), '`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
8472
- liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
8473
- shared: described(optional(boolean2()), "Whether this workspace's repos are shared with a team that must not see Workit named (default false): `workit pr create` and `workit pr edit` then warn, never block, when the PR title, body or a new doc names it."),
8474
- fanout: described(optional(looseObject({
8475
- tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
8476
- deps: described(optional(unknown()), "How `workit fanout worktree create` gives a slice worktree node_modules: `install` (default: its own frozen install of its lockfile) or `link` (links into the main checkout's installed packages, for a repo too slow to install per slice). `--deps` overrides it."),
8477
- installTimeout: described(optional(unknown()), "How long the own install may run before its process tree is killed and the worktree is linked instead: a duration such as `90s` or `10m` (default `5m`). `--install-timeout` overrides it.")
8478
- })), "Fanout settings."),
8479
- models: described(optional(looseObject({ roles: modelRoles })), "Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
8480
- resources: described(optional(unknown()), "Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
8481
- remotes: described(optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))), "Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
8482
- externalRepos: described(optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))), "Repositories outside this workspace's own forge owners that `workit issue create|comment|close --repo` may write to: `owner/name`, or `owner/*` for a whole owner. Only the user changes it, in their own terminal."),
8483
- additiveRiskPaths: described(optional(array(nonBlank)), "Risk-path globs whose purely additive edits follow the review lane of the rest of the diff. Only the user sets it; it counts only while sealed."),
8484
- autonomy: described(optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
8445
+ name: nonBlank,
8446
+ glob: nonBlank,
8447
+ vcs: optional(looseObject({
8448
+ provider: _enum(["gitlab", "github"]),
8449
+ defaultTargetBranch: optional(nonBlank),
8450
+ tokenFile: optional(nonBlank),
8451
+ account: optional(nonBlank),
8452
+ host: optional(unknown())
8453
+ })),
8454
+ autoApprove: optional(union([boolean2(), array(nonBlank)])),
8455
+ defaultEndpoint: optional(unknown()),
8456
+ verification: optional(_enum(["proportional", "self", "independent"])),
8457
+ delegation: optional(unknown()),
8458
+ changelog: optional(unknown()),
8459
+ docs: optional(unknown()),
8460
+ changelogPath: optional(unknown()),
8461
+ prTemplate: optional(unknown()),
8462
+ releaseNotes: optional(unknown()),
8463
+ trailers: optional(boolean2()),
8464
+ deleteBranch: optional(boolean2()),
8465
+ cleanup: optional(unknown()),
8466
+ feedback: optional(unknown()),
8467
+ liveSessionGuard: optional(boolean2()),
8468
+ shared: optional(boolean2()),
8469
+ fanout: optional(looseObject({
8470
+ tierModels: optional(unknown()),
8471
+ deps: optional(unknown()),
8472
+ installTimeout: optional(unknown())
8473
+ })),
8474
+ models: optional(looseObject({ roles: modelRoles })),
8475
+ resources: optional(unknown()),
8476
+ remotes: optional(array(nonBlank.check(refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")))),
8477
+ externalRepos: optional(array(nonBlank.check(_regex(/^[\w-]+(?:\/\w[\w.-]*)*\/(?:\w[\w.-]*|\*)$/u, "is owner/name, group/project or owner/* on the checkout's forge host, without the host")))),
8478
+ additiveRiskPaths: optional(array(nonBlank)),
8479
+ autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
8485
8480
  kind,
8486
- described(optional(union([boolean2(), literal("verified")])), `The ${kind} grant: true, false, or "verified" (only after a verdict).`)
8487
- ])))), "Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
8488
- youtrack: described(optional(looseObject({
8489
- baseUrl: described(optional(nonBlank), "This workspace's YouTrack URL."),
8490
- link_issues: described(optional(boolean2()), "Legacy alias of `issues: { provider: youtrack, link: true }`."),
8491
- writes: described(optional(_enum(["ask", "auto"])), "ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1."),
8492
- autoHosts: described(optional(array(nonBlank)), "With writes auto: the only YouTrack hosts (`acme.youtrack.cloud`) a write may reach without asking. A raw ytrack write must name one with --host; a write elsewhere asks. Only the user widens it, in their own terminal (`workit workspace seal`).")
8493
- })), "YouTrack settings for this workspace."),
8494
- issues: described(optional(looseObject({
8495
- provider: described(optional(_enum(["github", "gitlab", "youtrack"])), "The issue tracker PRs link to."),
8496
- link: described(optional(boolean2()), "Derive the issue from the branch name."),
8497
- relation: described(optional(unknown()), "How a PR names its issue: `closes` (default) or `refs`."),
8498
- backlink: described(optional(boolean2()), "Post the PR URL on each linked issue after the PR is opened."),
8499
- link_on_pr: described(optional(boolean2()), "Legacy alias of `link`."),
8500
- repo: described(optional(unknown()), "The GitHub/GitLab repository (owner/name) that holds the issues; default the PR's own."),
8501
- host: described(optional(unknown()), "That repository's host; default the PR's host, or the tracker's public one.")
8502
- })), "The issue tracker PRs link to (any forge with any tracker)."),
8503
- branchPolicy: described(optional(workspaceBranchPolicySchema), "Which branches may be created and which are protected."),
8504
- commitPolicy: described(optional(workspaceCommitPolicySchema), "The commit message rules."),
8505
- defaultProfile: described(optional(nonBlank), "The profile used when none is named; must be a key of `profiles`."),
8506
- profiles: described(optional(record(nonBlank, workspaceProfileSchema)), "Named branch/commit policy variants of this workspace."),
8507
- releaseTracks: described(optional(record(nonBlank, releaseTrackSchema)), "Named release tracks: production and integration branches, naming and versioning."),
8508
- releasePackages: described(optional(unknown()), "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.")
8481
+ optional(union([boolean2(), literal("verified")]))
8482
+ ])))),
8483
+ youtrack: optional(looseObject({
8484
+ baseUrl: optional(nonBlank),
8485
+ link_issues: optional(boolean2()),
8486
+ writes: optional(_enum(["ask", "auto"])),
8487
+ autoHosts: optional(array(nonBlank))
8488
+ })),
8489
+ issues: optional(looseObject({
8490
+ provider: optional(_enum(["github", "gitlab", "youtrack"])),
8491
+ link: optional(boolean2()),
8492
+ relation: optional(unknown()),
8493
+ backlink: optional(boolean2()),
8494
+ link_on_pr: optional(boolean2()),
8495
+ repo: optional(unknown()),
8496
+ host: optional(unknown())
8497
+ })),
8498
+ branchPolicy: optional(workspaceBranchPolicySchema),
8499
+ commitPolicy: optional(workspaceCommitPolicySchema),
8500
+ defaultProfile: optional(nonBlank),
8501
+ profiles: optional(record(nonBlank, workspaceProfileSchema)),
8502
+ releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
8503
+ releasePackages: optional(unknown())
8509
8504
  }).check(superRefine((workspace, context) => {
8510
8505
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
8511
8506
  context.addIssue({
@@ -8516,11 +8511,11 @@ var workspaceConfigSchema = looseObject({
8516
8511
  }
8517
8512
  }));
8518
8513
  var workspacesFileSchema = looseObject({
8519
- workspaces: described(optional(array(workspaceConfigSchema)), "Workspace entries, each mapping a path glob to its forge, policies and grants."),
8520
- models: described(optional(looseObject({ roles: modelRoles })), "The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false)."),
8521
- feedback: described(optional(looseObject({
8522
- account: described(optional(nonBlank), "The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
8523
- })), "`workit feedback` defaults for every workspace.")
8514
+ workspaces: optional(array(workspaceConfigSchema)),
8515
+ models: optional(looseObject({ roles: modelRoles })),
8516
+ feedback: optional(looseObject({
8517
+ account: optional(nonBlank)
8518
+ }))
8524
8519
  }).check(superRefine((file, context) => {
8525
8520
  const names = new Set;
8526
8521
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -20389,12 +20384,20 @@ var POWERSHELL_PARAMETERS = [
20389
20384
  { name: "workingdirectory", min: 2, aliases: ["wd"], kind: "value" }
20390
20385
  ];
20391
20386
  var powershellRun = (words, stdin) => {
20387
+ const { script, opaque, dir } = powershellParameters(words, stdin);
20388
+ return {
20389
+ script: script !== null && dir !== undefined ? `Set-Location -LiteralPath '${dir.replaceAll("'", "''")}'; ${script}` : script,
20390
+ opaque
20391
+ };
20392
+ };
20393
+ var powershellParameters = (words, stdin) => {
20392
20394
  const host = /powershell/i.test(words[0] ?? "") ? "powershell" : "pwsh";
20393
20395
  let opaque = false;
20396
+ let dir;
20394
20397
  for (let index = 1;index < words.length; index++) {
20395
20398
  const word = words[index];
20396
20399
  if (!/^[-/]/.test(word))
20397
- return host === "powershell" ? { script: words.slice(index).join(" "), opaque } : { script: null, opaque: true };
20400
+ return host === "powershell" ? { script: words.slice(index).join(" "), opaque, dir } : { script: null, opaque: true };
20398
20401
  const [, key = "", glued] = /^(?:--?|\/)([^:=]*)(?:[:=](.*))?$/s.exec(word) ?? [];
20399
20402
  const flag = key.toLowerCase();
20400
20403
  const matches = POWERSHELL_PARAMETERS.filter((parameter) => (parameter.host ?? host) === host && flag !== "" && (parameter.aliases?.includes(flag) || flag.length >= parameter.min && parameter.name.startsWith(flag)));
@@ -20402,13 +20405,19 @@ var powershellRun = (words, stdin) => {
20402
20405
  opaque = true;
20403
20406
  continue;
20404
20407
  }
20405
- const [{ kind }] = matches;
20408
+ const [{ kind, name }] = matches;
20406
20409
  const value = glued ?? words[index + 1];
20410
+ if (name === "workingdirectory")
20411
+ dir = value;
20407
20412
  if (kind === "info")
20408
20413
  return { script: null, opaque: opaque || index < words.length - 1 };
20409
20414
  if (kind === "encoded") {
20410
20415
  try {
20411
- return { script: Buffer.from(value ?? "", "base64").toString("utf16le"), opaque: true };
20416
+ return {
20417
+ script: Buffer.from(value ?? "", "base64").toString("utf16le"),
20418
+ opaque: true,
20419
+ dir
20420
+ };
20412
20421
  } catch {
20413
20422
  return { script: null, opaque: true };
20414
20423
  }
@@ -20416,15 +20425,17 @@ var powershellRun = (words, stdin) => {
20416
20425
  if (kind === "args")
20417
20426
  return {
20418
20427
  script: value ?? null,
20419
- opaque: opaque || glued !== undefined || value === undefined
20428
+ opaque: opaque || glued !== undefined || value === undefined,
20429
+ dir
20420
20430
  };
20421
20431
  if (kind === "script") {
20422
20432
  if (value === "-")
20423
- return { script: stdin ?? null, opaque: true };
20433
+ return { script: stdin ?? null, opaque: true, dir };
20424
20434
  const rest = glued === undefined ? words.slice(index + 1) : [glued, ...words.slice(index + 1)];
20425
20435
  return {
20426
20436
  script: rest.join(" ") || null,
20427
- opaque: opaque || glued !== undefined || !rest.length
20437
+ opaque: opaque || glued !== undefined || !rest.length,
20438
+ dir
20428
20439
  };
20429
20440
  }
20430
20441
  opaque ||= kind === "opaque";
@@ -27729,7 +27740,9 @@ var KEYWORDS2 = /^(?:if|elseif|else|switch|while|do|until|for|foreach|try|catch|
27729
27740
  var WINDOWS_WRITERS = /^(?:xcopy|robocopy|attrib|icacls|cacls|takeown|compact|cipher|expand|extrac32|makecab|fsutil|reg|regedit|setx|schtasks|msiexec|certutil|bitsadmin|replace|subst|mountvol|format|diskpart|wsl|cscript|wscript|mshta|rundll32|regsvr32|call)$/;
27730
27741
  var READ_METHODS = /^(?:trim(?:start|end)?|split|contains(?:key|value)?|startswith|endswith|substring|(?:last)?indexof(?:any)?|to(?:lower|upper)(?:invariant)?|tostring|tochararray|pad(?:left|right)|equals|compareto|gettype|gethashcode|normalize|where)$/i;
27731
27742
  var READ_MEMBERS = /^(?:name|fullname|basename|extension|length|count|directory|directoryname|parent|root|exists|mode|lastwritetime(?:utc)?|creationtime(?:utc)?|lastaccesstime(?:utc)?|attributes|linktype|target|pspath|pschildname|path|line|linenumber|filename|matches|value|key|keys|values|id|processname|source|definition|version)$/i;
27732
- var LOADER_ENV = /^(?:GIT_\w*|PAGER|EDITOR|VISUAL|PATH|LD_\w*|DYLD_\w*|NODE_OPTIONS|PYTHON\w*|BASH_ENV|ENV|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB))$/i;
27743
+ var LOADER_ENV = /^(?:GIT_\w*|SSH_ASKPASS(?:_REQUIRE)?|PAGER|EDITOR|VISUAL|PATH|PATHEXT|PSModulePath|LD_\w*|DYLD_\w*|NODE_OPTIONS|NODE_PATH|BUN_OPTIONS|npm_config_\w*|PYTHON\w*|BASH_ENV|ENV|PROMPT_COMMAND|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB)|RUSTC_(?:WORKSPACE_)?WRAPPER|CARGO_\w*|JAVA_TOOL_OPTIONS|_JAVA_OPTIONS|JDK_JAVA_OPTIONS|DOTNET_STARTUP_HOOKS|COMPLUS_\w*|CORECLR_\w*)$/i;
27744
+ var GIT_CONFIG_ENV2 = /^(?:HOME|USERPROFILE|HOMEDRIVE|HOMEPATH|XDG_\w+|LESS\w*)$/i;
27745
+ var EXEMPT_LOADER = /^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/;
27733
27746
  var CMD_VAR = /%[^%\s]+%|![^!\s]+!/;
27734
27747
  var NULL_SINK = /^(?:\$null|nul|\/dev\/null)$/i;
27735
27748
  var pwshCode = (text) => {
@@ -27782,7 +27795,7 @@ var powershellTextWriter = (text) => {
27782
27795
  if (statics)
27783
27796
  return `${statics[1]}::${statics[2]}`;
27784
27797
  for (const [, name] of code.matchAll(/\$\{?env:(\w+)\}?\s*[-+]?=/gi))
27785
- if (LOADER_ENV.test(name))
27798
+ if (LOADER_ENV.test(name) || GIT_CONFIG_ENV2.test(name))
27786
27799
  return `$env:${name} =`;
27787
27800
  for (const [, name] of code.matchAll(/\.([A-Za-z_]\w*)\(/g))
27788
27801
  if (!READ_METHODS.test(name))
@@ -28098,7 +28111,7 @@ var WRAPPERS3 = {
28098
28111
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
28099
28112
  var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
28100
28113
  var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
28101
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts)$/.test(path42.relative(canonical5(resolveStateDir()), canonical5(file)));
28114
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(path42.relative(canonical5(resolveStateDir()), canonical5(file)));
28102
28115
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
28103
28116
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move(?:_into)?|copy(?:2|file|tree|File|_into)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|f?truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
28104
28117
  var SPAWNS = /getattr|Reflect|getOwnPropertyDescriptor|FileIO|\.copy\s*\((?!\s*\))|utime|ch(?:mod|own)|\.delete\s*\(\s*\)|(?:PYTHON|NODE_)\w*\+?=|-r\b|--(?:require|import|env-file|[\w-]*loader)|\b(?:exec\w*|eval|(?:unlink|rename|remove)\w*)\b|\]\s*\(/;
@@ -28856,14 +28869,13 @@ var commandWords = (words) => {
28856
28869
  start++;
28857
28870
  return words.slice(start);
28858
28871
  };
28859
- var POSIX_LOADER = new RegExp(LOADER_ENV.source);
28860
28872
  var loaderAssignment = (words) => {
28861
28873
  for (const word of words) {
28862
28874
  const name = /^(\w+)\+?=/.exec(word)?.[1];
28863
- if (/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/.test(word))
28875
+ if (EXEMPT_LOADER.test(word))
28864
28876
  continue;
28865
28877
  if (name !== undefined) {
28866
- if (POSIX_LOADER.test(name))
28878
+ if (LOADER_ENV.test(name))
28867
28879
  return word.split("=")[0];
28868
28880
  } else if (!DECLARERS.has(word) && word !== "env" && !word.startsWith("-"))
28869
28881
  return;
@@ -29473,7 +29485,7 @@ var globbed = (cwd, target, state, configs) => {
29473
29485
  };
29474
29486
  let roots = [];
29475
29487
  try {
29476
- roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$|verdicts$)/.test(name));
29488
+ roots = readdirSync5(state).filter((name) => /^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name));
29477
29489
  } catch {}
29478
29490
  return [
29479
29491
  ...roots.map((name) => path42.join(state, name)).filter((root) => hit(root, true)),
@@ -29498,8 +29510,8 @@ var guardedInodes = (state, configs) => {
29498
29510
  for (const name of CONFIG_FILES)
29499
29511
  add(path42.join(dir, name), "grants");
29500
29512
  for (const name of readdirSync5(state))
29501
- if (/^(?:issued|approvals$|verdicts$)/.test(name))
29502
- add(path42.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" ? "ledger" : "issued");
29513
+ if (/^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name))
29514
+ add(path42.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" || name === "agent-stamps" ? "ledger" : "issued");
29503
29515
  for (const slug of readdirSync5(path42.join(state, "folders")))
29504
29516
  add(path42.join(state, "folders", slug, "ledger"), "ledger");
29505
29517
  } catch {}
@@ -29570,7 +29582,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
29570
29582
  const first = parts[0];
29571
29583
  if (first?.startsWith("issued"))
29572
29584
  return "issued";
29573
- if (first === "verdicts" || first === "folders" && parts[2] === "ledger")
29585
+ if (first === "verdicts" || first === "agent-stamps" || first === "folders" && parts[2] === "ledger")
29574
29586
  return "ledger";
29575
29587
  return first === "approvals" ? "approvals" : null;
29576
29588
  };
@@ -29587,7 +29599,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
29587
29599
  const state = flat(resolveStateDir());
29588
29600
  const configs = configDirs().map(flat);
29589
29601
  const folders = `${state}/folders/`;
29590
- const ledger = (at, named = false) => at.includes(`${state}/verdicts`) || (named ? inRepoLedger(at) : /\/workit\/ledger(?:[/\s'"]|$)/.test(at)) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
29602
+ const ledger = (at, named = false) => at.includes(`${state}/verdicts`) || at.includes(`${state}/agent-stamps`) || (named ? inRepoLedger(at) : /\/workit\/ledger(?:[/\s'"]|$)/.test(at)) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
29591
29603
  const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
29592
29604
  if (!present.length)
29593
29605
  return null;
@@ -31739,6 +31751,12 @@ var remoteIn = (dir, name, repo) => {
31739
31751
  const url = configEntries(fs30.readFileSync(path49.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
31740
31752
  return url !== undefined && literalIn(url, repo, true);
31741
31753
  };
31754
+ var judgeEnvAllowed = (word) => {
31755
+ if (EXEMPT_LOADER.test(word))
31756
+ return true;
31757
+ const [, name = "", value = ""] = /^(\w+)\+?=([\s\S]*)$/.exec(word) ?? [];
31758
+ return !LOADER_ENV.test(name) && !GIT_CONFIG_ENV2.test(name) && !/[$`]/.test(value);
31759
+ };
31742
31760
  var judgeGit = (command, repo, cwd, depth = 0) => {
31743
31761
  const runsGit = /\bgit\b/.test(command);
31744
31762
  for (const segment of segmentsOf(command)) {
@@ -31750,6 +31768,15 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
31750
31768
  const lead = [];
31751
31769
  while (/^\w+\+?=/.test(words[at] ?? ""))
31752
31770
  lead.push(words[at++]);
31771
+ if (words[at] === "env" && !segment.expands?.includes(at)) {
31772
+ let after = at + 1;
31773
+ while (/^\w+\+?=/.test(words[after] ?? ""))
31774
+ after++;
31775
+ if (!words[after]?.startsWith("-")) {
31776
+ lead.push(...words.slice(at + 1, after));
31777
+ at = after;
31778
+ }
31779
+ }
31753
31780
  const name = path49.basename(words[at] ?? "");
31754
31781
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
31755
31782
  if (start > at) {
@@ -31770,7 +31797,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
31770
31797
  if (/^(?:export|declare|local|readonly|typeset)$/.test(name))
31771
31798
  lead.push(...words.slice(at + 1).filter((word) => /^\w+\+?=/.test(word)));
31772
31799
  for (const word of runsGit ? lead : lead.filter((set) => /^(?:BASH_)?ENV=/.test(set)))
31773
- if (!/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0|(?:LC_\w+|LANG|TZ)=[^$`]*)$/.test(word))
31800
+ if (!judgeEnvAllowed(word))
31774
31801
  why ??= `\`${word}\` is not allowed`;
31775
31802
  let index = start < 0 ? words.length : start + 1;
31776
31803
  let dir = "";
@@ -33639,8 +33666,265 @@ Retry as: ${retry}`,
33639
33666
  return null;
33640
33667
  }
33641
33668
 
33669
+ // packages/workit-core/src/agent-stamp.ts
33670
+ import { createHash as createHash24, randomBytes as randomBytes5 } from "node:crypto";
33671
+ import fs35 from "node:fs";
33672
+ import path56 from "node:path";
33673
+ var STAMP_TTL_MS = 120000;
33674
+ var AGENT_ID = /^[\w-]{1,64}$/u;
33675
+ var hash2 = (text) => createHash24("sha256").update(text).digest("hex").slice(0, 32);
33676
+ var stampDir = (env, session) => path56.join(stateDir(env), "agent-stamps", hash2(session));
33677
+ var workitCalls2 = (command, dialect = "posix") => {
33678
+ const calls = [];
33679
+ try {
33680
+ for (const { words, expands = [] } of segmentsOf(command, dialect)) {
33681
+ const call = unwrapped(words);
33682
+ const at = words.length - call.length;
33683
+ if (/^(?:.*[\\/])?workit$/u.test(call[0] ?? "") && !expands.some((index) => index >= at))
33684
+ calls.push(call.slice(1));
33685
+ }
33686
+ } catch {}
33687
+ return calls;
33688
+ };
33689
+ var noteAgentStamps = (env, session, agentId, command, options = {}) => {
33690
+ if (!session || !command.includes("workit") || agentId !== null && !AGENT_ID.test(agentId))
33691
+ return;
33692
+ const calls = workitCalls2(command, options.dialect);
33693
+ if (!calls.length)
33694
+ return;
33695
+ const call = options.toolUseId ? callTag(options.toolUseId) : randomBytes5(4).toString("hex");
33696
+ try {
33697
+ const dir = stampDir(env, session);
33698
+ fs35.mkdirSync(dir, { recursive: true, mode: 448 });
33699
+ const now = Date.now();
33700
+ for (const name of fs35.readdirSync(dir))
33701
+ if (now - fs35.statSync(path56.join(dir, name)).mtimeMs > STAMP_TTL_MS)
33702
+ fs35.rmSync(path56.join(dir, name), { force: true });
33703
+ calls.forEach((argv, index) => fs35.writeFileSync(path56.join(dir, `${hash2(argv.join("\x00"))}.${agentId ?? ""}.${call}-${index}`), ""));
33704
+ } catch {}
33705
+ };
33706
+ var callTag = (toolUseId) => hash2(toolUseId).slice(0, 8);
33707
+ var dropAgentStamps = (env, session, toolUseId, command) => {
33708
+ if (!session || !toolUseId || !command.includes("workit") || /(?:^|[^&<>])&(?![&>])/u.test(command))
33709
+ return;
33710
+ try {
33711
+ const dir = stampDir(env, session);
33712
+ const tag = `.${callTag(toolUseId)}-`;
33713
+ for (const name of fs35.readdirSync(dir))
33714
+ if (name.includes(tag))
33715
+ fs35.rmSync(path56.join(dir, name), { force: true });
33716
+ } catch {}
33717
+ };
33718
+
33719
+ // packages/workit-core/src/hooks/identity-env.ts
33720
+ var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
33721
+ var IDENTITY = new RegExp(`^${NAMES}$`, "u");
33722
+ var POWERSHELL = new RegExp(`\\$env:${NAMES}\\b|env:[\\\\/]?${NAMES}\\b|EnvironmentVariable\\(\\s*['"]${NAMES}\\b`, "iu");
33723
+ var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
33724
+ var OPAQUE = new Set([
33725
+ "watch",
33726
+ "strace",
33727
+ "chroot",
33728
+ "flock",
33729
+ "ssh",
33730
+ "su",
33731
+ "runuser",
33732
+ "script",
33733
+ "parallel"
33734
+ ]);
33735
+ var ENV_VALUED = new Set(["u", "C", "S", "a", "P"]);
33736
+ var ENV_FLAGS = new Set(["i", "0", "v"]);
33737
+ var ENV_LONG_VALUED = new Set(["--unset", "--chdir", "--split-string", "--argv0"]);
33738
+ var ENV_LONG_FLAGS = /^--(?:ignore-environment|null|debug|(?:block|default|ignore)-signal(?:=.*)?)$/u;
33739
+ var base3 = (word) => (word?.split(/[\\/]/u).at(-1) ?? "").replace(/\.exe$/iu, "");
33740
+ var named = (word) => IDENTITY.test(word?.split("=")[0] ?? "");
33741
+ var isWorkit = (word) => /^workit(?:-cli)?$/u.test(base3(word));
33742
+ var UNREADABLE = "env/unset arguments Workit cannot read";
33743
+ var scanEnv = (words, at, expands, scan, depth) => {
33744
+ const risky = (what) => void (scan.risky ??= what);
33745
+ const unset = (name) => {
33746
+ if (named(name))
33747
+ scan.hit ??= name ?? null;
33748
+ };
33749
+ const split = (line, rest, built) => {
33750
+ if (line === undefined || depth >= 4)
33751
+ return risky(UNREADABLE);
33752
+ if (built || /[$`]/u.test(line))
33753
+ risky(UNREADABLE);
33754
+ const tokens = [];
33755
+ const expanded = new Set;
33756
+ try {
33757
+ for (const segment of segmentsOf(line)) {
33758
+ for (const index of segment.expands ?? [])
33759
+ expanded.add(tokens.length + index);
33760
+ tokens.push(...segment.words);
33761
+ }
33762
+ } catch {
33763
+ return risky(UNREADABLE);
33764
+ }
33765
+ scanEnv([...tokens, ...words.slice(rest)], 0, expanded, scan, depth + 1);
33766
+ };
33767
+ let options = true;
33768
+ for (let index = at;index < words.length; index += 1) {
33769
+ const word = words[index] ?? "";
33770
+ if (expands.has(index)) {
33771
+ risky(UNREADABLE);
33772
+ const built = options ? /^(?:--split-string=|-[\w]*S)(.+)$/su.exec(word) : null;
33773
+ if (built)
33774
+ return split(built[1], index + 1, true);
33775
+ continue;
33776
+ }
33777
+ if (options && word === "--") {
33778
+ options = false;
33779
+ continue;
33780
+ }
33781
+ if (options && word === "-") {
33782
+ risky("env -i");
33783
+ continue;
33784
+ }
33785
+ if (options && word.startsWith("--")) {
33786
+ const [name = "", value] = word.split(/=(.*)/su);
33787
+ if (name === "--ignore-environment")
33788
+ risky("env -i");
33789
+ else if (name === "--unset")
33790
+ unset(value ?? words[index += 1]);
33791
+ else if (name === "--split-string")
33792
+ return split(value ?? words[index + 1], index + (value === undefined ? 2 : 1), expands.has(index + (value === undefined ? 1 : 0)));
33793
+ else if (ENV_LONG_VALUED.has(name))
33794
+ index += value === undefined ? 1 : 0;
33795
+ else if (!ENV_LONG_FLAGS.test(word))
33796
+ risky(UNREADABLE);
33797
+ continue;
33798
+ }
33799
+ if (options && word.startsWith("-") && word.length > 1) {
33800
+ for (let at2 = 1;at2 < word.length; at2 += 1) {
33801
+ const letter = word[at2] ?? "";
33802
+ if (letter === "i")
33803
+ risky("env -i");
33804
+ else if (ENV_FLAGS.has(letter))
33805
+ continue;
33806
+ else if (ENV_VALUED.has(letter)) {
33807
+ const glued = word.slice(at2 + 1);
33808
+ if (!glued)
33809
+ index += 1;
33810
+ const value = glued || words[index];
33811
+ if (letter === "u")
33812
+ unset(value);
33813
+ if (letter === "S")
33814
+ return split(value, index + 1, expands.has(index));
33815
+ break;
33816
+ } else {
33817
+ risky(UNREADABLE);
33818
+ break;
33819
+ }
33820
+ }
33821
+ continue;
33822
+ }
33823
+ if (/^[A-Za-z_]\w*=/u.test(word)) {
33824
+ unset(word);
33825
+ continue;
33826
+ }
33827
+ return commandAt(words.slice(index), scan);
33828
+ }
33829
+ };
33830
+ var commandAt = (words, scan, expands = new Set, from = 0) => {
33831
+ let index = from;
33832
+ while (index < words.length) {
33833
+ while (/^[A-Za-z_]\w*=/u.test(words[index] ?? "")) {
33834
+ if (named(words[index]))
33835
+ scan.hit ??= words[index]?.split("=")[0] ?? null;
33836
+ index += 1;
33837
+ }
33838
+ const name = base3(words[index]).toLowerCase();
33839
+ if (name === "env")
33840
+ return scanEnv(words, index + 1, expands, scan, 0);
33841
+ if (OPAQUE.has(name))
33842
+ return opaque(words.slice(index + 1), scan, true);
33843
+ if (name === "busybox" || name === "toybox") {
33844
+ index += 1;
33845
+ continue;
33846
+ }
33847
+ const takes = WRAPPERS3[name];
33848
+ if (takes === undefined)
33849
+ break;
33850
+ index = pastOptions(words, index + 1, takes);
33851
+ }
33852
+ if (isWorkit(words[index]))
33853
+ scan.runs = true;
33854
+ else if (words.slice(index + 1).some((word) => base3(word).toLowerCase() === "env"))
33855
+ opaque(words.slice(index + 1), scan, false);
33856
+ };
33857
+ var opaque = (rest, scan, assigns) => {
33858
+ if (!rest.some(isWorkit))
33859
+ return;
33860
+ scan.runs = true;
33861
+ const changes = (word) => base3(word).toLowerCase() === "env" || DECLARES.has(word) || assigns && /^[A-Za-z_]\w*=/u.test(word);
33862
+ if (rest.some(changes))
33863
+ scan.risky ??= UNREADABLE;
33864
+ const hit = rest.find(named);
33865
+ if (hit && rest.some((word) => base3(word).toLowerCase() === "env"))
33866
+ scan.hit ??= hit.split("=")[0] ?? null;
33867
+ };
33868
+ var loginScript = (words) => {
33869
+ const at = words.findIndex((word) => /^(?:su|runuser|script)$/u.test(base3(word)));
33870
+ if (at < 0)
33871
+ return null;
33872
+ for (let index = at + 1;index < words.length; index += 1) {
33873
+ const word = words[index] ?? "";
33874
+ if (word === "-c" || word === "--command")
33875
+ return words[index + 1] ?? null;
33876
+ if (word.startsWith("--command="))
33877
+ return word.slice("--command=".length);
33878
+ }
33879
+ return null;
33880
+ };
33881
+ var scanCommand = (command, dialect, depth, scan) => {
33882
+ let segments;
33883
+ try {
33884
+ segments = segmentsOf(command, dialect);
33885
+ } catch {
33886
+ return;
33887
+ }
33888
+ for (const { words, expands = [] } of segments) {
33889
+ const expanded = new Set(expands);
33890
+ let at = 0;
33891
+ while (/^[A-Za-z_]\w*=/u.test(words[at] ?? "")) {
33892
+ if (named(words[at]))
33893
+ scan.hit ??= words[at]?.split("=")[0] ?? null;
33894
+ at += 1;
33895
+ }
33896
+ let declare = at;
33897
+ if (["builtin", "command"].includes(words[declare] ?? ""))
33898
+ declare += 1;
33899
+ if (DECLARES.has(words[declare] ?? "")) {
33900
+ for (let index = declare + 1;index < words.length; index += 1) {
33901
+ if (named(words[index]))
33902
+ scan.hit ??= words[index]?.split("=")[0] ?? null;
33903
+ if (expanded.has(index))
33904
+ scan.risky ??= UNREADABLE;
33905
+ }
33906
+ continue;
33907
+ }
33908
+ commandAt(words, scan, expanded, at);
33909
+ const script = depth < 4 ? shellScript2(words) ?? loginScript(words) : null;
33910
+ if (script)
33911
+ scanCommand(script, dialect, depth + 1, scan);
33912
+ }
33913
+ };
33914
+ var identityEnvChange = (command, dialect = "posix") => {
33915
+ if (!/WORKIT_|\b(?:env|unset|export|declare|typeset|local|readonly)\b/u.test(command))
33916
+ return null;
33917
+ if (dialect === "powershell")
33918
+ return POWERSHELL.exec(command)?.[0] ?? null;
33919
+ const scan = { hit: null, risky: null, runs: false };
33920
+ scanCommand(command, dialect, 0, scan);
33921
+ return scan.hit ?? (scan.runs ? scan.risky : null);
33922
+ };
33923
+ var identityEnvDeny = (change) => `workit identity: ${change === UNREADABLE ? `this command runs workit with ${UNREADABLE}` : `this command changes ${change}`}. The host sets WORKIT_HOST, WORKIT_SESSION_ID and WORKIT_AGENT_ID, and Workit acts as who they name; run it without changing them (a verifier or reviewer passes the --session and --token its start text names).`;
33924
+
33642
33925
  // packages/workit-core/src/hooks/handle.ts
33643
33926
  var usable2 = (value) => value === "native" || value === "partial";
33927
+ var stampsAgents = (descriptor) => descriptor.transport === "hook-process" && usable2(descriptor.provenance.agentIdOnTool);
33644
33928
  var NONE6 = { kind: "none" };
33645
33929
  var resendsOnChange = (descriptor) => descriptor.context.turnResend === "on-change" && usable2(descriptor.context.perTurn);
33646
33930
  var offered = new Set;
@@ -33833,6 +34117,9 @@ function decide(input, deps) {
33833
34117
  const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
33834
34118
  if (gate.kind === "deny")
33835
34119
  return gate;
34120
+ const identity = canDeny && stampsAgents(descriptor) ? identityEnvChange(event.command, event.dialect) : null;
34121
+ if (identity)
34122
+ return { kind: "deny", reason: identityEnvDeny(identity), unblock: null };
33836
34123
  const plan = heavyGate(input.cwd, event.command, {
33837
34124
  host: input.host,
33838
34125
  dialect: event.dialect,
@@ -33850,6 +34137,8 @@ function decide(input, deps) {
33850
34137
  const aside = plan.kind === "passthrough" ? plan.note : null;
33851
34138
  noteRawCommit(input, event.command, postTool ? callKey(event.toolUseId, event.command) : NEXT_COMMAND);
33852
34139
  const bypass = !lease && input.host === "claude_code" ? workitBypassFlag(event.command, event.dialect) : null;
34140
+ if (stampsAgents(descriptor))
34141
+ noteAgentStamps(process.env, input.session.id, input.session.agentId, lease?.command ?? cwdCommand ?? event.command, { dialect: event.dialect, toolUseId: event.toolUseId });
33853
34142
  if (bypass)
33854
34143
  return { kind: "ask", reason: bypass };
33855
34144
  const rewrittenTo = lease?.command ?? cwdCommand;
@@ -33878,6 +34167,8 @@ function decide(input, deps) {
33878
34167
  case "shell.post":
33879
34168
  if (usable2(descriptor.events["shell.post"].support))
33880
34169
  rawGitPost(input, event.command, callKey(event.toolUseId, event.command));
34170
+ if (stampsAgents(descriptor))
34171
+ dropAgentStamps(process.env, input.session.id, event.toolUseId, event.command);
33881
34172
  return NONE6;
33882
34173
  case "write.pre": {
33883
34174
  if (!usable2(descriptor.events["write.pre"].support))
@@ -33962,12 +34253,12 @@ var modelKey = (model) => {
33962
34253
  };
33963
34254
 
33964
34255
  // packages/workit-core/src/hooks/budget-signal.ts
33965
- import { createHash as createHash24 } from "node:crypto";
33966
- import fs35 from "node:fs";
33967
- import path56 from "node:path";
33968
- var hash2 = (text) => createHash24("sha256").update(text).digest("hex").slice(0, 32);
33969
- var budgetDir = (store) => path56.join(store, "budget");
33970
- var agentBase = (store, session, agentId) => path56.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
34256
+ import { createHash as createHash25 } from "node:crypto";
34257
+ import fs36 from "node:fs";
34258
+ import path57 from "node:path";
34259
+ var hash3 = (text) => createHash25("sha256").update(text).digest("hex").slice(0, 32);
34260
+ var budgetDir = (store) => path57.join(store, "budget");
34261
+ var agentBase = (store, session, agentId) => path57.join(budgetDir(store), hash3(`${session}\x00${agentId ?? ""}`));
33971
34262
  var spawnBudget = (prompt) => {
33972
34263
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
33973
34264
  const n = found ? Number(found[1]) : NaN;
@@ -33975,7 +34266,7 @@ var spawnBudget = (prompt) => {
33975
34266
  };
33976
34267
  var readBudget = (file) => {
33977
34268
  try {
33978
- const { limit, told } = JSON.parse(fs35.readFileSync(file, "utf8"));
34269
+ const { limit, told } = JSON.parse(fs36.readFileSync(file, "utf8"));
33979
34270
  return typeof limit === "number" && limit > 0 ? { limit, told: Number(told) || 0 } : null;
33980
34271
  } catch {
33981
34272
  return null;
@@ -33983,16 +34274,16 @@ var readBudget = (file) => {
33983
34274
  };
33984
34275
  var startBudget = (store, session, agentId, n) => {
33985
34276
  const dir = budgetDir(store);
33986
- fs35.mkdirSync(dir, { recursive: true });
34277
+ fs36.mkdirSync(dir, { recursive: true });
33987
34278
  const cutoff = Date.now() - 604800000;
33988
- for (const name of fs35.readdirSync(dir))
34279
+ for (const name of fs36.readdirSync(dir))
33989
34280
  try {
33990
- if (fs35.statSync(path56.join(dir, name)).mtimeMs < cutoff)
33991
- fs35.rmSync(path56.join(dir, name));
34281
+ if (fs36.statSync(path57.join(dir, name)).mtimeMs < cutoff)
34282
+ fs36.rmSync(path57.join(dir, name));
33992
34283
  } catch {}
33993
34284
  const base = agentBase(store, session, agentId);
33994
- fs35.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
33995
- fs35.rmSync(`${base}.calls`, { force: true });
34285
+ fs36.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
34286
+ fs36.rmSync(`${base}.calls`, { force: true });
33996
34287
  };
33997
34288
  var bindBudget = (cwd, session, agentId, prompt) => {
33998
34289
  try {
@@ -34015,8 +34306,8 @@ var tickBudget = (cwd, session, agentId) => {
34015
34306
  const budget = readBudget(`${base}.json`);
34016
34307
  if (!budget)
34017
34308
  return false;
34018
- fs35.appendFileSync(`${base}.calls`, ".");
34019
- return fs35.statSync(`${base}.calls`).size >= budget.limit * (budget.told + 1);
34309
+ fs36.appendFileSync(`${base}.calls`, ".");
34310
+ return fs36.statSync(`${base}.calls`).size >= budget.limit * (budget.told + 1);
34020
34311
  } catch {
34021
34312
  return false;
34022
34313
  }
@@ -34028,14 +34319,14 @@ var reachedOf = (cwd, session, agentId) => {
34028
34319
  const budget = base && readBudget(`${base}.json`);
34029
34320
  if (!budget)
34030
34321
  return null;
34031
- return { base, budget, reached: Math.floor(fs35.statSync(`${base}.calls`).size / budget.limit) };
34322
+ return { base, budget, reached: Math.floor(fs36.statSync(`${base}.calls`).size / budget.limit) };
34032
34323
  };
34033
34324
  var budgetLine = (cwd, session, agentId) => {
34034
34325
  try {
34035
34326
  const at = reachedOf(cwd, session, agentId);
34036
34327
  if (!at || at.reached <= at.budget.told)
34037
34328
  return null;
34038
- fs35.writeFileSync(`${at.base}.json`, JSON.stringify({ ...at.budget, told: at.reached }));
34329
+ fs36.writeFileSync(`${at.base}.json`, JSON.stringify({ ...at.budget, told: at.reached }));
34039
34330
  return lineFor(at.budget.limit * at.reached);
34040
34331
  } catch {
34041
34332
  return null;
@@ -34127,11 +34418,11 @@ var unfinishedTaskOffer2 = (ctx) => {
34127
34418
  };
34128
34419
 
34129
34420
  // packages/workit-core/src/hooks/repeat-failure.ts
34130
- import { createHash as createHash25 } from "node:crypto";
34421
+ import { createHash as createHash26 } from "node:crypto";
34131
34422
  var SAME_CALL_FAILED = "Same call failed twice:";
34132
34423
  var MAX_SESSIONS = 256;
34133
34424
  var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
34134
- var hashOf = (call) => createHash25("sha256").update(call).digest("hex").slice(0, 32);
34425
+ var hashOf = (call) => createHash26("sha256").update(call).digest("hex").slice(0, 32);
34135
34426
  var record2 = (memo, sessionId, call, failed, next) => {
34136
34427
  const previous = memo.get(sessionId);
34137
34428
  memo.delete(sessionId);
@@ -34443,12 +34734,12 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
34443
34734
  // packages/workit-pi/src/launches.ts
34444
34735
  import { mkdirSync as mkdirSync8, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
34445
34736
  import os13 from "node:os";
34446
- import path57 from "node:path";
34737
+ import path58 from "node:path";
34447
34738
  var launchDir = (root) => {
34448
34739
  const location = resolveStore(root);
34449
- return location instanceof Error ? null : path57.join(location.dir, "pi-launches");
34740
+ return location instanceof Error ? null : path58.join(location.dir, "pi-launches");
34450
34741
  };
34451
- var fileFor = (dir, workerId) => path57.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
34742
+ var fileFor = (dir, workerId) => path58.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
34452
34743
  var recordLaunch = (root, attempt) => {
34453
34744
  const dir = launchDir(root);
34454
34745
  if (!dir)
@@ -34494,7 +34785,7 @@ var abandonedLaunches = (root) => {
34494
34785
  const found = [];
34495
34786
  for (const name of names) {
34496
34787
  try {
34497
- const attempt = JSON.parse(readFileSync16(path57.join(dir, name), "utf8"));
34788
+ const attempt = JSON.parse(readFileSync16(path58.join(dir, name), "utf8"));
34498
34789
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
34499
34790
  if (!alive(attempt))
34500
34791
  found.push(attempt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.26.1",
3
+ "version": "2.27.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",