@workit-dev/codex 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.26.1",
3
+ "version": "2.27.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -11864,11 +11864,6 @@ if (!globalConfig.localeError)
11864
11864
  config(en_default());
11865
11865
  if (!globalConfig.memoizer)
11866
11866
  config({ memoizer: memoizer() });
11867
- var described = (schema, description) => {
11868
- const copy = schema.clone();
11869
- globalRegistry.add(copy, { description });
11870
- return copy;
11871
- };
11872
11867
 
11873
11868
  // packages/workit-core/src/core/scope-glob.ts
11874
11869
  var GLOB = /[*?[\]{}]/u;
@@ -14744,25 +14739,25 @@ var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must
14744
14739
  var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
14745
14740
  var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
14746
14741
  var workspaceBranchPolicySchema = strictObject({
14747
- preset: described(branchPreset, "The branch model: gitflow, github-flow, trunk-based or custom (allowed/protected set by hand)."),
14748
- developBranch: described(optional(nonBlank), "The integration branch gitflow uses (default develop)."),
14749
- prefixes: described(optional(looseObject({
14742
+ preset: branchPreset,
14743
+ developBranch: optional(nonBlank),
14744
+ prefixes: optional(looseObject({
14750
14745
  feature: nonBlank,
14751
14746
  bugfix: nonBlank,
14752
14747
  release: nonBlank,
14753
14748
  hotfix: nonBlank
14754
- })), "The branch prefix per kind (feature/, bugfix/, release/, hotfix/)."),
14755
- allowed: described(optional(array(nonBlank)), "Branch name globs a new branch must match (`feature/*`)."),
14756
- protected: described(optional(array(nonBlank)), "Branches nobody commits or pushes to directly."),
14757
- integration: described(optional(_enum(["pr", "merge"])), "How work reaches its base: `pr` (default) opens a PR, `merge` merges locally.")
14749
+ })),
14750
+ allowed: optional(array(nonBlank)),
14751
+ protected: optional(array(nonBlank)),
14752
+ integration: optional(_enum(["pr", "merge"]))
14758
14753
  });
14759
14754
  var workspaceCommitPolicySchema = strictObject({
14760
- preset: described(commitPreset, "The commit message flavor, e.g. conventional."),
14761
- pattern: described(optional(string2()), "A regular expression every commit subject must match.")
14755
+ preset: commitPreset,
14756
+ pattern: optional(string2())
14762
14757
  });
14763
14758
  var workspaceProfileSchema = strictObject({
14764
- branchPolicy: described(optional(workspaceBranchPolicySchema), "This profile's branch policy."),
14765
- commitPolicy: described(optional(workspaceCommitPolicySchema), "This profile's commit policy.")
14759
+ branchPolicy: optional(workspaceBranchPolicySchema),
14760
+ commitPolicy: optional(workspaceCommitPolicySchema)
14766
14761
  }).check(refine((profile) => profile.branchPolicy !== undefined || profile.commitPolicy !== undefined, { message: "a profile must define branchPolicy or commitPolicy" }));
14767
14762
  var versionSourceSchema = discriminatedUnion("kind", [
14768
14763
  strictObject({
@@ -14774,22 +14769,22 @@ var versionSourceSchema = discriminatedUnion("kind", [
14774
14769
  strictObject({ kind: literal("manual") })
14775
14770
  ]);
14776
14771
  var releaseTrackSchema = looseObject({
14777
- strategy: described(optional(branchPreset), "The branch model this track follows."),
14778
- productionBranch: described(nonBlank, "The branch releases land on (main)."),
14779
- integrationBranch: described(nonBlank, "The branch work integrates into (develop)."),
14780
- naming: described(optional(looseObject({
14772
+ strategy: optional(branchPreset),
14773
+ productionBranch: nonBlank,
14774
+ integrationBranch: nonBlank,
14775
+ naming: optional(looseObject({
14781
14776
  feature: optional(nonBlank),
14782
14777
  release: optional(nonBlank),
14783
14778
  hotfix: optional(nonBlank)
14784
- })), "Branch name templates per kind, e.g. `feature/{name}`."),
14785
- baseBranch: described(optional(nonBlank), "The branch new work starts from."),
14786
- mergeBackBranches: described(optional(array(nonBlank)), "Branches a finished release or hotfix is merged back into."),
14787
- pullRequestTarget: described(optional(nonBlank), "The branch PRs target."),
14788
- tagNamespace: described(optional(string2()), "A prefix for this track's release tags."),
14789
- versionSource: described(optional(versionSourceSchema), "Where the version comes from: package-json, git-tag or manual."),
14790
- requiredChecks: described(optional(array(nonBlank)), "CI checks that must pass before a release."),
14791
- critical: described(optional(array(nonBlank)), "Fields an older Workit must not ignore: when one is unknown or malformed, Workit fails closed."),
14792
- releaseNotes: described(optional(unknown()), "This track's release notes mode, over the workspace's `releaseNotes`.")
14779
+ })),
14780
+ baseBranch: optional(nonBlank),
14781
+ mergeBackBranches: optional(array(nonBlank)),
14782
+ pullRequestTarget: optional(nonBlank),
14783
+ tagNamespace: optional(string2()),
14784
+ versionSource: optional(versionSourceSchema),
14785
+ requiredChecks: optional(array(nonBlank)),
14786
+ critical: optional(array(nonBlank)),
14787
+ releaseNotes: optional(unknown())
14793
14788
  }).check(superRefine((track, context) => {
14794
14789
  for (const [field, values] of [
14795
14790
  ["mergeBackBranches", track.mergeBackBranches ?? []],
@@ -14811,67 +14806,67 @@ var releaseTrackSchema = looseObject({
14811
14806
  });
14812
14807
  }
14813
14808
  }));
14814
- 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).");
14809
+ var modelRoles = optional(unknown());
14815
14810
  var workspaceConfigSchema = looseObject({
14816
- name: described(nonBlank, "The workspace's unique name."),
14817
- glob: described(nonBlank, "The directories this entry covers, an absolute path glob with * and ** (`/home/you/work/**`); the narrowest match wins."),
14818
- vcs: described(optional(looseObject({
14819
- provider: described(_enum(["gitlab", "github"]), "The forge: github or gitlab."),
14820
- defaultTargetBranch: described(optional(nonBlank), "The branch PRs target by default."),
14821
- tokenFile: described(optional(nonBlank), "A file holding the forge token for this workspace."),
14822
- account: described(optional(nonBlank), "The forge login delivery runs as; grants need it to reach the forge."),
14823
- host: described(optional(unknown()), "A self-hosted forge's host name.")
14824
- })), "The forge this workspace's repositories live on."),
14825
- autoApprove: described(optional(union([boolean2(), array(nonBlank)])), "Legacy (≤4.x) standing approvals, read once as autonomy grants; use `autonomy`."),
14826
- defaultEndpoint: described(optional(unknown()), "Where an unnamed request stops: commit (default), pr, green or merged. Set with `workit grant set`, like grants."),
14827
- 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."),
14828
- 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."),
14829
- 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."),
14830
- docs: described(optional(unknown()), "The docs refresh the ship skill does before a PR opens: `off` (default) or `when-user-facing`."),
14831
- 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."),
14832
- 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."),
14833
- 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."),
14834
- trailers: described(optional(boolean2()), "Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
14835
- deleteBranch: described(optional(boolean2()), "Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
14836
- 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`."),
14837
- 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.'),
14838
- liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
14839
- 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."),
14840
- fanout: described(optional(looseObject({
14841
- tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
14842
- 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."),
14843
- 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.")
14844
- })), "Fanout settings."),
14845
- 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."),
14846
- resources: described(optional(unknown()), "Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
14847
- 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."),
14848
- 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."),
14849
- 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."),
14850
- autonomy: described(optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
14811
+ name: nonBlank,
14812
+ glob: nonBlank,
14813
+ vcs: optional(looseObject({
14814
+ provider: _enum(["gitlab", "github"]),
14815
+ defaultTargetBranch: optional(nonBlank),
14816
+ tokenFile: optional(nonBlank),
14817
+ account: optional(nonBlank),
14818
+ host: optional(unknown())
14819
+ })),
14820
+ autoApprove: optional(union([boolean2(), array(nonBlank)])),
14821
+ defaultEndpoint: optional(unknown()),
14822
+ verification: optional(_enum(["proportional", "self", "independent"])),
14823
+ delegation: optional(unknown()),
14824
+ changelog: optional(unknown()),
14825
+ docs: optional(unknown()),
14826
+ changelogPath: optional(unknown()),
14827
+ prTemplate: optional(unknown()),
14828
+ releaseNotes: optional(unknown()),
14829
+ trailers: optional(boolean2()),
14830
+ deleteBranch: optional(boolean2()),
14831
+ cleanup: optional(unknown()),
14832
+ feedback: optional(unknown()),
14833
+ liveSessionGuard: optional(boolean2()),
14834
+ shared: optional(boolean2()),
14835
+ fanout: optional(looseObject({
14836
+ tierModels: optional(unknown()),
14837
+ deps: optional(unknown()),
14838
+ installTimeout: optional(unknown())
14839
+ })),
14840
+ models: optional(looseObject({ roles: modelRoles })),
14841
+ resources: optional(unknown()),
14842
+ 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/*)")))),
14843
+ 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")))),
14844
+ additiveRiskPaths: optional(array(nonBlank)),
14845
+ autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
14851
14846
  kind,
14852
- described(optional(union([boolean2(), literal("verified")])), `The ${kind} grant: true, false, or "verified" (only after a verdict).`)
14853
- ])))), "Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
14854
- youtrack: described(optional(looseObject({
14855
- baseUrl: described(optional(nonBlank), "This workspace's YouTrack URL."),
14856
- link_issues: described(optional(boolean2()), "Legacy alias of `issues: { provider: youtrack, link: true }`."),
14857
- 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."),
14858
- 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`).")
14859
- })), "YouTrack settings for this workspace."),
14860
- issues: described(optional(looseObject({
14861
- provider: described(optional(_enum(["github", "gitlab", "youtrack"])), "The issue tracker PRs link to."),
14862
- link: described(optional(boolean2()), "Derive the issue from the branch name."),
14863
- relation: described(optional(unknown()), "How a PR names its issue: `closes` (default) or `refs`."),
14864
- backlink: described(optional(boolean2()), "Post the PR URL on each linked issue after the PR is opened."),
14865
- link_on_pr: described(optional(boolean2()), "Legacy alias of `link`."),
14866
- repo: described(optional(unknown()), "The GitHub/GitLab repository (owner/name) that holds the issues; default the PR's own."),
14867
- host: described(optional(unknown()), "That repository's host; default the PR's host, or the tracker's public one.")
14868
- })), "The issue tracker PRs link to (any forge with any tracker)."),
14869
- branchPolicy: described(optional(workspaceBranchPolicySchema), "Which branches may be created and which are protected."),
14870
- commitPolicy: described(optional(workspaceCommitPolicySchema), "The commit message rules."),
14871
- defaultProfile: described(optional(nonBlank), "The profile used when none is named; must be a key of `profiles`."),
14872
- profiles: described(optional(record(nonBlank, workspaceProfileSchema)), "Named branch/commit policy variants of this workspace."),
14873
- releaseTracks: described(optional(record(nonBlank, releaseTrackSchema)), "Named release tracks: production and integration branches, naming and versioning."),
14874
- 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.")
14847
+ optional(union([boolean2(), literal("verified")]))
14848
+ ])))),
14849
+ youtrack: optional(looseObject({
14850
+ baseUrl: optional(nonBlank),
14851
+ link_issues: optional(boolean2()),
14852
+ writes: optional(_enum(["ask", "auto"])),
14853
+ autoHosts: optional(array(nonBlank))
14854
+ })),
14855
+ issues: optional(looseObject({
14856
+ provider: optional(_enum(["github", "gitlab", "youtrack"])),
14857
+ link: optional(boolean2()),
14858
+ relation: optional(unknown()),
14859
+ backlink: optional(boolean2()),
14860
+ link_on_pr: optional(boolean2()),
14861
+ repo: optional(unknown()),
14862
+ host: optional(unknown())
14863
+ })),
14864
+ branchPolicy: optional(workspaceBranchPolicySchema),
14865
+ commitPolicy: optional(workspaceCommitPolicySchema),
14866
+ defaultProfile: optional(nonBlank),
14867
+ profiles: optional(record(nonBlank, workspaceProfileSchema)),
14868
+ releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
14869
+ releasePackages: optional(unknown())
14875
14870
  }).check(superRefine((workspace, context) => {
14876
14871
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
14877
14872
  context.addIssue({
@@ -14882,11 +14877,11 @@ var workspaceConfigSchema = looseObject({
14882
14877
  }
14883
14878
  }));
14884
14879
  var workspacesFileSchema = looseObject({
14885
- workspaces: described(optional(array(workspaceConfigSchema)), "Workspace entries, each mapping a path glob to its forge, policies and grants."),
14886
- 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)."),
14887
- feedback: described(optional(looseObject({
14888
- account: described(optional(nonBlank), "The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
14889
- })), "`workit feedback` defaults for every workspace.")
14880
+ workspaces: optional(array(workspaceConfigSchema)),
14881
+ models: optional(looseObject({ roles: modelRoles })),
14882
+ feedback: optional(looseObject({
14883
+ account: optional(nonBlank)
14884
+ }))
14890
14885
  }).check(superRefine((file, context) => {
14891
14886
  const names = new Set;
14892
14887
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -32159,7 +32154,6 @@ var READ_CMDLETS = new Set([
32159
32154
  "pop-location",
32160
32155
  "help"
32161
32156
  ]);
32162
- 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;
32163
32157
 
32164
32158
  // packages/workit-core/src/hooks/write-gate.ts
32165
32159
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
@@ -32196,7 +32190,6 @@ var PUSHD2 = new Set(["pushd", "push-location"]);
32196
32190
  var POPD2 = new Set(["popd", "pop-location"]);
32197
32191
  var UNKNOWN_DIR = path35.resolve(path35.parse(process.cwd()).root, ".workit-unknown-dir");
32198
32192
  var DECLARERS = new Set(["export", "declare", "typeset", "local", "readonly"]);
32199
- var POSIX_LOADER = new RegExp(LOADER_ENV.source);
32200
32193
  var REBINDS_ANY = new Set([
32201
32194
  "source",
32202
32195
  ".",
@@ -33079,6 +33072,26 @@ var gap = (part) => ({ workit: null, gap: part });
33079
33072
  var READ = new Map;
33080
33073
  var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wrapper, loop, substitution or script around it can change or repeat it)");
33081
33074
 
33075
+ // packages/workit-core/src/hooks/identity-env.ts
33076
+ var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
33077
+ var IDENTITY = new RegExp(`^${NAMES}$`, "u");
33078
+ var POWERSHELL = new RegExp(`\\$env:${NAMES}\\b|env:[\\\\/]?${NAMES}\\b|EnvironmentVariable\\(\\s*['"]${NAMES}\\b`, "iu");
33079
+ var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
33080
+ var OPAQUE = new Set([
33081
+ "watch",
33082
+ "strace",
33083
+ "chroot",
33084
+ "flock",
33085
+ "ssh",
33086
+ "su",
33087
+ "runuser",
33088
+ "script",
33089
+ "parallel"
33090
+ ]);
33091
+ var ENV_VALUED = new Set(["u", "C", "S", "a", "P"]);
33092
+ var ENV_FLAGS = new Set(["i", "0", "v"]);
33093
+ var ENV_LONG_VALUED = new Set(["--unset", "--chdir", "--split-string", "--argv0"]);
33094
+
33082
33095
  // packages/workit-core/src/hooks/handle.ts
33083
33096
  var offered = new Set;
33084
33097
  var PRE_TOOL = new Set(["shell.pre", "write.pre", "tool.pre"]);
@@ -80,7 +80,7 @@ var reachTests = (dirs) => {
80
80
  const gitDir = file.slice(0, index);
81
81
  return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync(path.join(gitDir, "HEAD")) && existsSync(path.join(gitDir, "objects"));
82
82
  });
83
- const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals|verdicts|folders[\\/][^\\/]+[\\/]ledger)(?:[\\/]|$)/.test(path.relative(state, file)) || repoLedger(file);
83
+ const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps|folders[\\/][^\\/]+[\\/]ledger)(?:[\\/]|$)/.test(path.relative(state, file)) || repoLedger(file);
84
84
  const above = (file) => within(file, state) || configs.some((dir) => within(file, dir));
85
85
  const linked = (file) => {
86
86
  try {
@@ -2554,54 +2554,6 @@ function en_default() {
2554
2554
  };
2555
2555
  }
2556
2556
 
2557
- // node_modules/zod/v4/core/registries.js
2558
- var _a2;
2559
- class $ZodRegistry {
2560
- constructor() {
2561
- this._map = new WeakMap;
2562
- this._idmap = new Map;
2563
- }
2564
- add(schema, ..._meta) {
2565
- const meta = _meta[0];
2566
- this._map.set(schema, meta);
2567
- if (meta && typeof meta === "object" && "id" in meta) {
2568
- this._idmap.set(meta.id, schema);
2569
- }
2570
- return this;
2571
- }
2572
- clear() {
2573
- this._map = new WeakMap;
2574
- this._idmap = new Map;
2575
- return this;
2576
- }
2577
- remove(schema) {
2578
- const meta = this._map.get(schema);
2579
- if (meta && typeof meta === "object" && "id" in meta) {
2580
- this._idmap.delete(meta.id);
2581
- }
2582
- this._map.delete(schema);
2583
- return this;
2584
- }
2585
- get(schema) {
2586
- const p = schema._zod.parent;
2587
- if (p) {
2588
- const pm = { ...this.get(p) ?? {} };
2589
- delete pm.id;
2590
- const f = { ...pm, ...this._map.get(schema) };
2591
- return Object.keys(f).length ? f : undefined;
2592
- }
2593
- return this._map.get(schema);
2594
- }
2595
- has(schema) {
2596
- return this._map.has(schema);
2597
- }
2598
- }
2599
- function registry() {
2600
- return new $ZodRegistry;
2601
- }
2602
- (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
2603
- var globalRegistry = globalThis.__zod_globalRegistry;
2604
-
2605
2557
  // node_modules/zod/v4/core/api.js
2606
2558
  function snapshotChecks(def) {
2607
2559
  if (def.checks)
@@ -2981,11 +2933,6 @@ if (!globalConfig.localeError)
2981
2933
  config(en_default());
2982
2934
  if (!globalConfig.memoizer)
2983
2935
  config({ memoizer: memoizer() });
2984
- var described = (schema, description) => {
2985
- const copy = schema.clone();
2986
- globalRegistry.add(copy, { description });
2987
- return copy;
2988
- };
2989
2936
 
2990
2937
  // packages/workit-core/src/core/remotes.ts
2991
2938
  import { lstatSync, readFileSync as readFileSync3, realpathSync as realpathSync2, statSync } from "node:fs";
@@ -4091,25 +4038,25 @@ var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must
4091
4038
  var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
4092
4039
  var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
4093
4040
  var workspaceBranchPolicySchema = strictObject({
4094
- preset: described(branchPreset, "The branch model: gitflow, github-flow, trunk-based or custom (allowed/protected set by hand)."),
4095
- developBranch: described(optional(nonBlank), "The integration branch gitflow uses (default develop)."),
4096
- prefixes: described(optional(looseObject({
4041
+ preset: branchPreset,
4042
+ developBranch: optional(nonBlank),
4043
+ prefixes: optional(looseObject({
4097
4044
  feature: nonBlank,
4098
4045
  bugfix: nonBlank,
4099
4046
  release: nonBlank,
4100
4047
  hotfix: nonBlank
4101
- })), "The branch prefix per kind (feature/, bugfix/, release/, hotfix/)."),
4102
- allowed: described(optional(array(nonBlank)), "Branch name globs a new branch must match (`feature/*`)."),
4103
- protected: described(optional(array(nonBlank)), "Branches nobody commits or pushes to directly."),
4104
- integration: described(optional(_enum(["pr", "merge"])), "How work reaches its base: `pr` (default) opens a PR, `merge` merges locally.")
4048
+ })),
4049
+ allowed: optional(array(nonBlank)),
4050
+ protected: optional(array(nonBlank)),
4051
+ integration: optional(_enum(["pr", "merge"]))
4105
4052
  });
4106
4053
  var workspaceCommitPolicySchema = strictObject({
4107
- preset: described(commitPreset, "The commit message flavor, e.g. conventional."),
4108
- pattern: described(optional(string2()), "A regular expression every commit subject must match.")
4054
+ preset: commitPreset,
4055
+ pattern: optional(string2())
4109
4056
  });
4110
4057
  var workspaceProfileSchema = strictObject({
4111
- branchPolicy: described(optional(workspaceBranchPolicySchema), "This profile's branch policy."),
4112
- commitPolicy: described(optional(workspaceCommitPolicySchema), "This profile's commit policy.")
4058
+ branchPolicy: optional(workspaceBranchPolicySchema),
4059
+ commitPolicy: optional(workspaceCommitPolicySchema)
4113
4060
  }).check(refine((profile) => profile.branchPolicy !== undefined || profile.commitPolicy !== undefined, { message: "a profile must define branchPolicy or commitPolicy" }));
4114
4061
  var versionSourceSchema = discriminatedUnion("kind", [
4115
4062
  strictObject({
@@ -4121,22 +4068,22 @@ var versionSourceSchema = discriminatedUnion("kind", [
4121
4068
  strictObject({ kind: literal("manual") })
4122
4069
  ]);
4123
4070
  var releaseTrackSchema = looseObject({
4124
- strategy: described(optional(branchPreset), "The branch model this track follows."),
4125
- productionBranch: described(nonBlank, "The branch releases land on (main)."),
4126
- integrationBranch: described(nonBlank, "The branch work integrates into (develop)."),
4127
- naming: described(optional(looseObject({
4071
+ strategy: optional(branchPreset),
4072
+ productionBranch: nonBlank,
4073
+ integrationBranch: nonBlank,
4074
+ naming: optional(looseObject({
4128
4075
  feature: optional(nonBlank),
4129
4076
  release: optional(nonBlank),
4130
4077
  hotfix: optional(nonBlank)
4131
- })), "Branch name templates per kind, e.g. `feature/{name}`."),
4132
- baseBranch: described(optional(nonBlank), "The branch new work starts from."),
4133
- mergeBackBranches: described(optional(array(nonBlank)), "Branches a finished release or hotfix is merged back into."),
4134
- pullRequestTarget: described(optional(nonBlank), "The branch PRs target."),
4135
- tagNamespace: described(optional(string2()), "A prefix for this track's release tags."),
4136
- versionSource: described(optional(versionSourceSchema), "Where the version comes from: package-json, git-tag or manual."),
4137
- requiredChecks: described(optional(array(nonBlank)), "CI checks that must pass before a release."),
4138
- critical: described(optional(array(nonBlank)), "Fields an older Workit must not ignore: when one is unknown or malformed, Workit fails closed."),
4139
- releaseNotes: described(optional(unknown()), "This track's release notes mode, over the workspace's `releaseNotes`.")
4078
+ })),
4079
+ baseBranch: optional(nonBlank),
4080
+ mergeBackBranches: optional(array(nonBlank)),
4081
+ pullRequestTarget: optional(nonBlank),
4082
+ tagNamespace: optional(string2()),
4083
+ versionSource: optional(versionSourceSchema),
4084
+ requiredChecks: optional(array(nonBlank)),
4085
+ critical: optional(array(nonBlank)),
4086
+ releaseNotes: optional(unknown())
4140
4087
  }).check(superRefine((track, context) => {
4141
4088
  for (const [field, values] of [
4142
4089
  ["mergeBackBranches", track.mergeBackBranches ?? []],
@@ -4158,67 +4105,67 @@ var releaseTrackSchema = looseObject({
4158
4105
  });
4159
4106
  }
4160
4107
  }));
4161
- 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).");
4108
+ var modelRoles = optional(unknown());
4162
4109
  var workspaceConfigSchema = looseObject({
4163
- name: described(nonBlank, "The workspace's unique name."),
4164
- glob: described(nonBlank, "The directories this entry covers, an absolute path glob with * and ** (`/home/you/work/**`); the narrowest match wins."),
4165
- vcs: described(optional(looseObject({
4166
- provider: described(_enum(["gitlab", "github"]), "The forge: github or gitlab."),
4167
- defaultTargetBranch: described(optional(nonBlank), "The branch PRs target by default."),
4168
- tokenFile: described(optional(nonBlank), "A file holding the forge token for this workspace."),
4169
- account: described(optional(nonBlank), "The forge login delivery runs as; grants need it to reach the forge."),
4170
- host: described(optional(unknown()), "A self-hosted forge's host name.")
4171
- })), "The forge this workspace's repositories live on."),
4172
- autoApprove: described(optional(union([boolean2(), array(nonBlank)])), "Legacy (≤4.x) standing approvals, read once as autonomy grants; use `autonomy`."),
4173
- defaultEndpoint: described(optional(unknown()), "Where an unnamed request stops: commit (default), pr, green or merged. Set with `workit grant set`, like grants."),
4174
- 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."),
4175
- 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."),
4176
- 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."),
4177
- docs: described(optional(unknown()), "The docs refresh the ship skill does before a PR opens: `off` (default) or `when-user-facing`."),
4178
- 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."),
4179
- 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."),
4180
- 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."),
4181
- trailers: described(optional(boolean2()), "Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
4182
- deleteBranch: described(optional(boolean2()), "Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
4183
- 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`."),
4184
- 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.'),
4185
- liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
4186
- 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."),
4187
- fanout: described(optional(looseObject({
4188
- tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
4189
- 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."),
4190
- 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.")
4191
- })), "Fanout settings."),
4192
- 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."),
4193
- resources: described(optional(unknown()), "Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
4194
- 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."),
4195
- 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."),
4196
- 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."),
4197
- autonomy: described(optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
4110
+ name: nonBlank,
4111
+ glob: nonBlank,
4112
+ vcs: optional(looseObject({
4113
+ provider: _enum(["gitlab", "github"]),
4114
+ defaultTargetBranch: optional(nonBlank),
4115
+ tokenFile: optional(nonBlank),
4116
+ account: optional(nonBlank),
4117
+ host: optional(unknown())
4118
+ })),
4119
+ autoApprove: optional(union([boolean2(), array(nonBlank)])),
4120
+ defaultEndpoint: optional(unknown()),
4121
+ verification: optional(_enum(["proportional", "self", "independent"])),
4122
+ delegation: optional(unknown()),
4123
+ changelog: optional(unknown()),
4124
+ docs: optional(unknown()),
4125
+ changelogPath: optional(unknown()),
4126
+ prTemplate: optional(unknown()),
4127
+ releaseNotes: optional(unknown()),
4128
+ trailers: optional(boolean2()),
4129
+ deleteBranch: optional(boolean2()),
4130
+ cleanup: optional(unknown()),
4131
+ feedback: optional(unknown()),
4132
+ liveSessionGuard: optional(boolean2()),
4133
+ shared: optional(boolean2()),
4134
+ fanout: optional(looseObject({
4135
+ tierModels: optional(unknown()),
4136
+ deps: optional(unknown()),
4137
+ installTimeout: optional(unknown())
4138
+ })),
4139
+ models: optional(looseObject({ roles: modelRoles })),
4140
+ resources: optional(unknown()),
4141
+ 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/*)")))),
4142
+ 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")))),
4143
+ additiveRiskPaths: optional(array(nonBlank)),
4144
+ autonomy: optional(looseObject(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
4198
4145
  kind,
4199
- described(optional(union([boolean2(), literal("verified")])), `The ${kind} grant: true, false, or "verified" (only after a verdict).`)
4200
- ])))), "Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
4201
- youtrack: described(optional(looseObject({
4202
- baseUrl: described(optional(nonBlank), "This workspace's YouTrack URL."),
4203
- link_issues: described(optional(boolean2()), "Legacy alias of `issues: { provider: youtrack, link: true }`."),
4204
- 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."),
4205
- 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`).")
4206
- })), "YouTrack settings for this workspace."),
4207
- issues: described(optional(looseObject({
4208
- provider: described(optional(_enum(["github", "gitlab", "youtrack"])), "The issue tracker PRs link to."),
4209
- link: described(optional(boolean2()), "Derive the issue from the branch name."),
4210
- relation: described(optional(unknown()), "How a PR names its issue: `closes` (default) or `refs`."),
4211
- backlink: described(optional(boolean2()), "Post the PR URL on each linked issue after the PR is opened."),
4212
- link_on_pr: described(optional(boolean2()), "Legacy alias of `link`."),
4213
- repo: described(optional(unknown()), "The GitHub/GitLab repository (owner/name) that holds the issues; default the PR's own."),
4214
- host: described(optional(unknown()), "That repository's host; default the PR's host, or the tracker's public one.")
4215
- })), "The issue tracker PRs link to (any forge with any tracker)."),
4216
- branchPolicy: described(optional(workspaceBranchPolicySchema), "Which branches may be created and which are protected."),
4217
- commitPolicy: described(optional(workspaceCommitPolicySchema), "The commit message rules."),
4218
- defaultProfile: described(optional(nonBlank), "The profile used when none is named; must be a key of `profiles`."),
4219
- profiles: described(optional(record(nonBlank, workspaceProfileSchema)), "Named branch/commit policy variants of this workspace."),
4220
- releaseTracks: described(optional(record(nonBlank, releaseTrackSchema)), "Named release tracks: production and integration branches, naming and versioning."),
4221
- 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.")
4146
+ optional(union([boolean2(), literal("verified")]))
4147
+ ])))),
4148
+ youtrack: optional(looseObject({
4149
+ baseUrl: optional(nonBlank),
4150
+ link_issues: optional(boolean2()),
4151
+ writes: optional(_enum(["ask", "auto"])),
4152
+ autoHosts: optional(array(nonBlank))
4153
+ })),
4154
+ issues: optional(looseObject({
4155
+ provider: optional(_enum(["github", "gitlab", "youtrack"])),
4156
+ link: optional(boolean2()),
4157
+ relation: optional(unknown()),
4158
+ backlink: optional(boolean2()),
4159
+ link_on_pr: optional(boolean2()),
4160
+ repo: optional(unknown()),
4161
+ host: optional(unknown())
4162
+ })),
4163
+ branchPolicy: optional(workspaceBranchPolicySchema),
4164
+ commitPolicy: optional(workspaceCommitPolicySchema),
4165
+ defaultProfile: optional(nonBlank),
4166
+ profiles: optional(record(nonBlank, workspaceProfileSchema)),
4167
+ releaseTracks: optional(record(nonBlank, releaseTrackSchema)),
4168
+ releasePackages: optional(unknown())
4222
4169
  }).check(superRefine((workspace, context) => {
4223
4170
  if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
4224
4171
  context.addIssue({
@@ -4229,11 +4176,11 @@ var workspaceConfigSchema = looseObject({
4229
4176
  }
4230
4177
  }));
4231
4178
  var workspacesFileSchema = looseObject({
4232
- workspaces: described(optional(array(workspaceConfigSchema)), "Workspace entries, each mapping a path glob to its forge, policies and grants."),
4233
- 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)."),
4234
- feedback: described(optional(looseObject({
4235
- account: described(optional(nonBlank), "The GitHub login `workit feedback --post` uses when no workspace names one; never the workspace's work account by default.")
4236
- })), "`workit feedback` defaults for every workspace.")
4179
+ workspaces: optional(array(workspaceConfigSchema)),
4180
+ models: optional(looseObject({ roles: modelRoles })),
4181
+ feedback: optional(looseObject({
4182
+ account: optional(nonBlank)
4183
+ }))
4237
4184
  }).check(superRefine((file, context) => {
4238
4185
  const names = new Set;
4239
4186
  for (const [index, workspace] of (file.workspaces ?? []).entries()) {
@@ -14737,12 +14684,20 @@ var POWERSHELL_PARAMETERS = [
14737
14684
  { name: "workingdirectory", min: 2, aliases: ["wd"], kind: "value" }
14738
14685
  ];
14739
14686
  var powershellRun = (words, stdin) => {
14687
+ const { script, opaque, dir } = powershellParameters(words, stdin);
14688
+ return {
14689
+ script: script !== null && dir !== undefined ? `Set-Location -LiteralPath '${dir.replaceAll("'", "''")}'; ${script}` : script,
14690
+ opaque
14691
+ };
14692
+ };
14693
+ var powershellParameters = (words, stdin) => {
14740
14694
  const host = /powershell/i.test(words[0] ?? "") ? "powershell" : "pwsh";
14741
14695
  let opaque = false;
14696
+ let dir;
14742
14697
  for (let index = 1;index < words.length; index++) {
14743
14698
  const word = words[index];
14744
14699
  if (!/^[-/]/.test(word))
14745
- return host === "powershell" ? { script: words.slice(index).join(" "), opaque } : { script: null, opaque: true };
14700
+ return host === "powershell" ? { script: words.slice(index).join(" "), opaque, dir } : { script: null, opaque: true };
14746
14701
  const [, key = "", glued] = /^(?:--?|\/)([^:=]*)(?:[:=](.*))?$/s.exec(word) ?? [];
14747
14702
  const flag = key.toLowerCase();
14748
14703
  const matches = POWERSHELL_PARAMETERS.filter((parameter) => (parameter.host ?? host) === host && flag !== "" && (parameter.aliases?.includes(flag) || flag.length >= parameter.min && parameter.name.startsWith(flag)));
@@ -14750,13 +14705,19 @@ var powershellRun = (words, stdin) => {
14750
14705
  opaque = true;
14751
14706
  continue;
14752
14707
  }
14753
- const [{ kind }] = matches;
14708
+ const [{ kind, name }] = matches;
14754
14709
  const value = glued ?? words[index + 1];
14710
+ if (name === "workingdirectory")
14711
+ dir = value;
14755
14712
  if (kind === "info")
14756
14713
  return { script: null, opaque: opaque || index < words.length - 1 };
14757
14714
  if (kind === "encoded") {
14758
14715
  try {
14759
- return { script: Buffer.from(value ?? "", "base64").toString("utf16le"), opaque: true };
14716
+ return {
14717
+ script: Buffer.from(value ?? "", "base64").toString("utf16le"),
14718
+ opaque: true,
14719
+ dir
14720
+ };
14760
14721
  } catch {
14761
14722
  return { script: null, opaque: true };
14762
14723
  }
@@ -14764,15 +14725,17 @@ var powershellRun = (words, stdin) => {
14764
14725
  if (kind === "args")
14765
14726
  return {
14766
14727
  script: value ?? null,
14767
- opaque: opaque || glued !== undefined || value === undefined
14728
+ opaque: opaque || glued !== undefined || value === undefined,
14729
+ dir
14768
14730
  };
14769
14731
  if (kind === "script") {
14770
14732
  if (value === "-")
14771
- return { script: stdin ?? null, opaque: true };
14733
+ return { script: stdin ?? null, opaque: true, dir };
14772
14734
  const rest = glued === undefined ? words.slice(index + 1) : [glued, ...words.slice(index + 1)];
14773
14735
  return {
14774
14736
  script: rest.join(" ") || null,
14775
- opaque: opaque || glued !== undefined || !rest.length
14737
+ opaque: opaque || glued !== undefined || !rest.length,
14738
+ dir
14776
14739
  };
14777
14740
  }
14778
14741
  opaque ||= kind === "opaque";
@@ -17910,7 +17873,9 @@ var KEYWORDS2 = /^(?:if|elseif|else|switch|while|do|until|for|foreach|try|catch|
17910
17873
  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)$/;
17911
17874
  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;
17912
17875
  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;
17913
- 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;
17876
+ 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;
17877
+ var GIT_CONFIG_ENV2 = /^(?:HOME|USERPROFILE|HOMEDRIVE|HOMEPATH|XDG_\w+|LESS\w*)$/i;
17878
+ var EXEMPT_LOADER = /^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/;
17914
17879
  var CMD_VAR = /%[^%\s]+%|![^!\s]+!/;
17915
17880
  var NULL_SINK = /^(?:\$null|nul|\/dev\/null)$/i;
17916
17881
  var pwshCode = (text) => {
@@ -17963,7 +17928,7 @@ var powershellTextWriter = (text) => {
17963
17928
  if (statics)
17964
17929
  return `${statics[1]}::${statics[2]}`;
17965
17930
  for (const [, name] of code.matchAll(/\$\{?env:(\w+)\}?\s*[-+]?=/gi))
17966
- if (LOADER_ENV.test(name))
17931
+ if (LOADER_ENV.test(name) || GIT_CONFIG_ENV2.test(name))
17967
17932
  return `$env:${name} =`;
17968
17933
  for (const [, name] of code.matchAll(/\.([A-Za-z_]\w*)\(/g))
17969
17934
  if (!READ_METHODS.test(name))
@@ -18279,7 +18244,7 @@ var WRAPPERS3 = {
18279
18244
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
18280
18245
  var INLINE_CODE = /^-[a-zA-Z]*[cep]$|^--(?:eval|print)(?:=|$)/;
18281
18246
  var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
18282
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts)$/.test(path30.relative(canonical5(resolveStateDir()), canonical5(file)));
18247
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals|verdicts|agent-stamps)$/.test(path30.relative(canonical5(resolveStateDir()), canonical5(file)));
18283
18248
  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)$/;
18284
18249
  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)$/;
18285
18250
  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*\(/;
@@ -19037,14 +19002,13 @@ var commandWords = (words) => {
19037
19002
  start++;
19038
19003
  return words.slice(start);
19039
19004
  };
19040
- var POSIX_LOADER = new RegExp(LOADER_ENV.source);
19041
19005
  var loaderAssignment = (words) => {
19042
19006
  for (const word of words) {
19043
19007
  const name = /^(\w+)\+?=/.exec(word)?.[1];
19044
- if (/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0)$/.test(word))
19008
+ if (EXEMPT_LOADER.test(word))
19045
19009
  continue;
19046
19010
  if (name !== undefined) {
19047
- if (POSIX_LOADER.test(name))
19011
+ if (LOADER_ENV.test(name))
19048
19012
  return word.split("=")[0];
19049
19013
  } else if (!DECLARERS.has(word) && word !== "env" && !word.startsWith("-"))
19050
19014
  return;
@@ -19654,7 +19618,7 @@ var globbed = (cwd, target, state, configs) => {
19654
19618
  };
19655
19619
  let roots = [];
19656
19620
  try {
19657
- roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$|verdicts$)/.test(name));
19621
+ roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name));
19658
19622
  } catch {}
19659
19623
  return [
19660
19624
  ...roots.map((name) => path30.join(state, name)).filter((root) => hit(root, true)),
@@ -19679,8 +19643,8 @@ var guardedInodes = (state, configs) => {
19679
19643
  for (const name of CONFIG_FILES)
19680
19644
  add(path30.join(dir, name), "grants");
19681
19645
  for (const name of readdirSync3(state))
19682
- if (/^(?:issued|approvals$|verdicts$)/.test(name))
19683
- add(path30.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" ? "ledger" : "issued");
19646
+ if (/^(?:issued|approvals$|verdicts$|agent-stamps$)/.test(name))
19647
+ add(path30.join(state, name), name === "approvals" ? "approvals" : name === "verdicts" || name === "agent-stamps" ? "ledger" : "issued");
19684
19648
  for (const slug of readdirSync3(path30.join(state, "folders")))
19685
19649
  add(path30.join(state, "folders", slug, "ledger"), "ledger");
19686
19650
  } catch {}
@@ -19751,7 +19715,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
19751
19715
  const first = parts[0];
19752
19716
  if (first?.startsWith("issued"))
19753
19717
  return "issued";
19754
- if (first === "verdicts" || first === "folders" && parts[2] === "ledger")
19718
+ if (first === "verdicts" || first === "agent-stamps" || first === "folders" && parts[2] === "ledger")
19755
19719
  return "ledger";
19756
19720
  return first === "approvals" ? "approvals" : null;
19757
19721
  };
@@ -19768,7 +19732,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
19768
19732
  const state = flat(resolveStateDir());
19769
19733
  const configs = configDirs().map(flat);
19770
19734
  const folders = `${state}/folders/`;
19771
- 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));
19735
+ 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));
19772
19736
  const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
19773
19737
  if (!present.length)
19774
19738
  return null;
@@ -21744,6 +21708,12 @@ var remoteIn = (dir, name, repo) => {
21744
21708
  const url = configEntries(fs22.readFileSync(path34.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
21745
21709
  return url !== undefined && literalIn(url, repo, true);
21746
21710
  };
21711
+ var judgeEnvAllowed = (word) => {
21712
+ if (EXEMPT_LOADER.test(word))
21713
+ return true;
21714
+ const [, name = "", value = ""] = /^(\w+)\+?=([\s\S]*)$/.exec(word) ?? [];
21715
+ return !LOADER_ENV.test(name) && !GIT_CONFIG_ENV2.test(name) && !/[$`]/.test(value);
21716
+ };
21747
21717
  var judgeGit = (command, repo, cwd, depth = 0) => {
21748
21718
  const runsGit = /\bgit\b/.test(command);
21749
21719
  for (const segment of segmentsOf(command)) {
@@ -21755,6 +21725,15 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
21755
21725
  const lead = [];
21756
21726
  while (/^\w+\+?=/.test(words[at] ?? ""))
21757
21727
  lead.push(words[at++]);
21728
+ if (words[at] === "env" && !segment.expands?.includes(at)) {
21729
+ let after = at + 1;
21730
+ while (/^\w+\+?=/.test(words[after] ?? ""))
21731
+ after++;
21732
+ if (!words[after]?.startsWith("-")) {
21733
+ lead.push(...words.slice(at + 1, after));
21734
+ at = after;
21735
+ }
21736
+ }
21758
21737
  const name = path34.basename(words[at] ?? "");
21759
21738
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
21760
21739
  if (start > at) {
@@ -21775,7 +21754,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
21775
21754
  if (/^(?:export|declare|local|readonly|typeset)$/.test(name))
21776
21755
  lead.push(...words.slice(at + 1).filter((word) => /^\w+\+?=/.test(word)));
21777
21756
  for (const word of runsGit ? lead : lead.filter((set) => /^(?:BASH_)?ENV=/.test(set)))
21778
- if (!/^(?:(?:GIT_)?PAGER=cat|GIT_OPTIONAL_LOCKS=0|(?:LC_\w+|LANG|TZ)=[^$`]*)$/.test(word))
21757
+ if (!judgeEnvAllowed(word))
21779
21758
  why ??= `\`${word}\` is not allowed`;
21780
21759
  let index = start < 0 ? words.length : start + 1;
21781
21760
  let dir = "";
@@ -23523,8 +23502,265 @@ Retry as: ${retry}`,
23523
23502
  return null;
23524
23503
  }
23525
23504
 
23505
+ // packages/workit-core/src/agent-stamp.ts
23506
+ import { createHash as createHash17, randomBytes as randomBytes4 } from "node:crypto";
23507
+ import fs26 from "node:fs";
23508
+ import path39 from "node:path";
23509
+ var STAMP_TTL_MS = 120000;
23510
+ var AGENT_ID = /^[\w-]{1,64}$/u;
23511
+ var hash2 = (text) => createHash17("sha256").update(text).digest("hex").slice(0, 32);
23512
+ var stampDir = (env, session) => path39.join(stateDir3(env), "agent-stamps", hash2(session));
23513
+ var workitCalls2 = (command, dialect = "posix") => {
23514
+ const calls = [];
23515
+ try {
23516
+ for (const { words, expands = [] } of segmentsOf(command, dialect)) {
23517
+ const call = unwrapped(words);
23518
+ const at = words.length - call.length;
23519
+ if (/^(?:.*[\\/])?workit$/u.test(call[0] ?? "") && !expands.some((index) => index >= at))
23520
+ calls.push(call.slice(1));
23521
+ }
23522
+ } catch {}
23523
+ return calls;
23524
+ };
23525
+ var noteAgentStamps = (env, session, agentId, command, options = {}) => {
23526
+ if (!session || !command.includes("workit") || agentId !== null && !AGENT_ID.test(agentId))
23527
+ return;
23528
+ const calls = workitCalls2(command, options.dialect);
23529
+ if (!calls.length)
23530
+ return;
23531
+ const call = options.toolUseId ? callTag(options.toolUseId) : randomBytes4(4).toString("hex");
23532
+ try {
23533
+ const dir = stampDir(env, session);
23534
+ fs26.mkdirSync(dir, { recursive: true, mode: 448 });
23535
+ const now = Date.now();
23536
+ for (const name of fs26.readdirSync(dir))
23537
+ if (now - fs26.statSync(path39.join(dir, name)).mtimeMs > STAMP_TTL_MS)
23538
+ fs26.rmSync(path39.join(dir, name), { force: true });
23539
+ calls.forEach((argv, index) => fs26.writeFileSync(path39.join(dir, `${hash2(argv.join("\x00"))}.${agentId ?? ""}.${call}-${index}`), ""));
23540
+ } catch {}
23541
+ };
23542
+ var callTag = (toolUseId) => hash2(toolUseId).slice(0, 8);
23543
+ var dropAgentStamps = (env, session, toolUseId, command) => {
23544
+ if (!session || !toolUseId || !command.includes("workit") || /(?:^|[^&<>])&(?![&>])/u.test(command))
23545
+ return;
23546
+ try {
23547
+ const dir = stampDir(env, session);
23548
+ const tag = `.${callTag(toolUseId)}-`;
23549
+ for (const name of fs26.readdirSync(dir))
23550
+ if (name.includes(tag))
23551
+ fs26.rmSync(path39.join(dir, name), { force: true });
23552
+ } catch {}
23553
+ };
23554
+
23555
+ // packages/workit-core/src/hooks/identity-env.ts
23556
+ var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
23557
+ var IDENTITY = new RegExp(`^${NAMES}$`, "u");
23558
+ var POWERSHELL = new RegExp(`\\$env:${NAMES}\\b|env:[\\\\/]?${NAMES}\\b|EnvironmentVariable\\(\\s*['"]${NAMES}\\b`, "iu");
23559
+ var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
23560
+ var OPAQUE = new Set([
23561
+ "watch",
23562
+ "strace",
23563
+ "chroot",
23564
+ "flock",
23565
+ "ssh",
23566
+ "su",
23567
+ "runuser",
23568
+ "script",
23569
+ "parallel"
23570
+ ]);
23571
+ var ENV_VALUED = new Set(["u", "C", "S", "a", "P"]);
23572
+ var ENV_FLAGS = new Set(["i", "0", "v"]);
23573
+ var ENV_LONG_VALUED = new Set(["--unset", "--chdir", "--split-string", "--argv0"]);
23574
+ var ENV_LONG_FLAGS = /^--(?:ignore-environment|null|debug|(?:block|default|ignore)-signal(?:=.*)?)$/u;
23575
+ var base2 = (word) => (word?.split(/[\\/]/u).at(-1) ?? "").replace(/\.exe$/iu, "");
23576
+ var named = (word) => IDENTITY.test(word?.split("=")[0] ?? "");
23577
+ var isWorkit = (word) => /^workit(?:-cli)?$/u.test(base2(word));
23578
+ var UNREADABLE = "env/unset arguments Workit cannot read";
23579
+ var scanEnv = (words, at, expands, scan, depth) => {
23580
+ const risky = (what) => void (scan.risky ??= what);
23581
+ const unset = (name) => {
23582
+ if (named(name))
23583
+ scan.hit ??= name ?? null;
23584
+ };
23585
+ const split = (line, rest, built) => {
23586
+ if (line === undefined || depth >= 4)
23587
+ return risky(UNREADABLE);
23588
+ if (built || /[$`]/u.test(line))
23589
+ risky(UNREADABLE);
23590
+ const tokens = [];
23591
+ const expanded = new Set;
23592
+ try {
23593
+ for (const segment of segmentsOf(line)) {
23594
+ for (const index of segment.expands ?? [])
23595
+ expanded.add(tokens.length + index);
23596
+ tokens.push(...segment.words);
23597
+ }
23598
+ } catch {
23599
+ return risky(UNREADABLE);
23600
+ }
23601
+ scanEnv([...tokens, ...words.slice(rest)], 0, expanded, scan, depth + 1);
23602
+ };
23603
+ let options = true;
23604
+ for (let index = at;index < words.length; index += 1) {
23605
+ const word = words[index] ?? "";
23606
+ if (expands.has(index)) {
23607
+ risky(UNREADABLE);
23608
+ const built = options ? /^(?:--split-string=|-[\w]*S)(.+)$/su.exec(word) : null;
23609
+ if (built)
23610
+ return split(built[1], index + 1, true);
23611
+ continue;
23612
+ }
23613
+ if (options && word === "--") {
23614
+ options = false;
23615
+ continue;
23616
+ }
23617
+ if (options && word === "-") {
23618
+ risky("env -i");
23619
+ continue;
23620
+ }
23621
+ if (options && word.startsWith("--")) {
23622
+ const [name = "", value] = word.split(/=(.*)/su);
23623
+ if (name === "--ignore-environment")
23624
+ risky("env -i");
23625
+ else if (name === "--unset")
23626
+ unset(value ?? words[index += 1]);
23627
+ else if (name === "--split-string")
23628
+ return split(value ?? words[index + 1], index + (value === undefined ? 2 : 1), expands.has(index + (value === undefined ? 1 : 0)));
23629
+ else if (ENV_LONG_VALUED.has(name))
23630
+ index += value === undefined ? 1 : 0;
23631
+ else if (!ENV_LONG_FLAGS.test(word))
23632
+ risky(UNREADABLE);
23633
+ continue;
23634
+ }
23635
+ if (options && word.startsWith("-") && word.length > 1) {
23636
+ for (let at2 = 1;at2 < word.length; at2 += 1) {
23637
+ const letter = word[at2] ?? "";
23638
+ if (letter === "i")
23639
+ risky("env -i");
23640
+ else if (ENV_FLAGS.has(letter))
23641
+ continue;
23642
+ else if (ENV_VALUED.has(letter)) {
23643
+ const glued = word.slice(at2 + 1);
23644
+ if (!glued)
23645
+ index += 1;
23646
+ const value = glued || words[index];
23647
+ if (letter === "u")
23648
+ unset(value);
23649
+ if (letter === "S")
23650
+ return split(value, index + 1, expands.has(index));
23651
+ break;
23652
+ } else {
23653
+ risky(UNREADABLE);
23654
+ break;
23655
+ }
23656
+ }
23657
+ continue;
23658
+ }
23659
+ if (/^[A-Za-z_]\w*=/u.test(word)) {
23660
+ unset(word);
23661
+ continue;
23662
+ }
23663
+ return commandAt(words.slice(index), scan);
23664
+ }
23665
+ };
23666
+ var commandAt = (words, scan, expands = new Set, from = 0) => {
23667
+ let index = from;
23668
+ while (index < words.length) {
23669
+ while (/^[A-Za-z_]\w*=/u.test(words[index] ?? "")) {
23670
+ if (named(words[index]))
23671
+ scan.hit ??= words[index]?.split("=")[0] ?? null;
23672
+ index += 1;
23673
+ }
23674
+ const name = base2(words[index]).toLowerCase();
23675
+ if (name === "env")
23676
+ return scanEnv(words, index + 1, expands, scan, 0);
23677
+ if (OPAQUE.has(name))
23678
+ return opaque(words.slice(index + 1), scan, true);
23679
+ if (name === "busybox" || name === "toybox") {
23680
+ index += 1;
23681
+ continue;
23682
+ }
23683
+ const takes = WRAPPERS3[name];
23684
+ if (takes === undefined)
23685
+ break;
23686
+ index = pastOptions(words, index + 1, takes);
23687
+ }
23688
+ if (isWorkit(words[index]))
23689
+ scan.runs = true;
23690
+ else if (words.slice(index + 1).some((word) => base2(word).toLowerCase() === "env"))
23691
+ opaque(words.slice(index + 1), scan, false);
23692
+ };
23693
+ var opaque = (rest, scan, assigns) => {
23694
+ if (!rest.some(isWorkit))
23695
+ return;
23696
+ scan.runs = true;
23697
+ const changes = (word) => base2(word).toLowerCase() === "env" || DECLARES.has(word) || assigns && /^[A-Za-z_]\w*=/u.test(word);
23698
+ if (rest.some(changes))
23699
+ scan.risky ??= UNREADABLE;
23700
+ const hit = rest.find(named);
23701
+ if (hit && rest.some((word) => base2(word).toLowerCase() === "env"))
23702
+ scan.hit ??= hit.split("=")[0] ?? null;
23703
+ };
23704
+ var loginScript = (words) => {
23705
+ const at = words.findIndex((word) => /^(?:su|runuser|script)$/u.test(base2(word)));
23706
+ if (at < 0)
23707
+ return null;
23708
+ for (let index = at + 1;index < words.length; index += 1) {
23709
+ const word = words[index] ?? "";
23710
+ if (word === "-c" || word === "--command")
23711
+ return words[index + 1] ?? null;
23712
+ if (word.startsWith("--command="))
23713
+ return word.slice("--command=".length);
23714
+ }
23715
+ return null;
23716
+ };
23717
+ var scanCommand = (command, dialect, depth, scan) => {
23718
+ let segments;
23719
+ try {
23720
+ segments = segmentsOf(command, dialect);
23721
+ } catch {
23722
+ return;
23723
+ }
23724
+ for (const { words, expands = [] } of segments) {
23725
+ const expanded = new Set(expands);
23726
+ let at = 0;
23727
+ while (/^[A-Za-z_]\w*=/u.test(words[at] ?? "")) {
23728
+ if (named(words[at]))
23729
+ scan.hit ??= words[at]?.split("=")[0] ?? null;
23730
+ at += 1;
23731
+ }
23732
+ let declare = at;
23733
+ if (["builtin", "command"].includes(words[declare] ?? ""))
23734
+ declare += 1;
23735
+ if (DECLARES.has(words[declare] ?? "")) {
23736
+ for (let index = declare + 1;index < words.length; index += 1) {
23737
+ if (named(words[index]))
23738
+ scan.hit ??= words[index]?.split("=")[0] ?? null;
23739
+ if (expanded.has(index))
23740
+ scan.risky ??= UNREADABLE;
23741
+ }
23742
+ continue;
23743
+ }
23744
+ commandAt(words, scan, expanded, at);
23745
+ const script = depth < 4 ? shellScript2(words) ?? loginScript(words) : null;
23746
+ if (script)
23747
+ scanCommand(script, dialect, depth + 1, scan);
23748
+ }
23749
+ };
23750
+ var identityEnvChange = (command, dialect = "posix") => {
23751
+ if (!/WORKIT_|\b(?:env|unset|export|declare|typeset|local|readonly)\b/u.test(command))
23752
+ return null;
23753
+ if (dialect === "powershell")
23754
+ return POWERSHELL.exec(command)?.[0] ?? null;
23755
+ const scan = { hit: null, risky: null, runs: false };
23756
+ scanCommand(command, dialect, 0, scan);
23757
+ return scan.hit ?? (scan.runs ? scan.risky : null);
23758
+ };
23759
+ 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).`;
23760
+
23526
23761
  // packages/workit-core/src/hooks/handle.ts
23527
23762
  var usable2 = (value) => value === "native" || value === "partial";
23763
+ var stampsAgents = (descriptor) => descriptor.transport === "hook-process" && usable2(descriptor.provenance.agentIdOnTool);
23528
23764
  var NONE6 = { kind: "none" };
23529
23765
  var resendsOnChange = (descriptor) => descriptor.context.turnResend === "on-change" && usable2(descriptor.context.perTurn);
23530
23766
  var offered = new Set;
@@ -23717,6 +23953,9 @@ function decide(input, deps) {
23717
23953
  const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
23718
23954
  if (gate.kind === "deny")
23719
23955
  return gate;
23956
+ const identity = canDeny && stampsAgents(descriptor) ? identityEnvChange(event.command, event.dialect) : null;
23957
+ if (identity)
23958
+ return { kind: "deny", reason: identityEnvDeny(identity), unblock: null };
23720
23959
  const plan = heavyGate(input.cwd, event.command, {
23721
23960
  host: input.host,
23722
23961
  dialect: event.dialect,
@@ -23734,6 +23973,8 @@ function decide(input, deps) {
23734
23973
  const aside = plan.kind === "passthrough" ? plan.note : null;
23735
23974
  noteRawCommit(input, event.command, postTool ? callKey(event.toolUseId, event.command) : NEXT_COMMAND);
23736
23975
  const bypass = !lease && input.host === "claude_code" ? workitBypassFlag(event.command, event.dialect) : null;
23976
+ if (stampsAgents(descriptor))
23977
+ noteAgentStamps(process.env, input.session.id, input.session.agentId, lease?.command ?? cwdCommand ?? event.command, { dialect: event.dialect, toolUseId: event.toolUseId });
23737
23978
  if (bypass)
23738
23979
  return { kind: "ask", reason: bypass };
23739
23980
  const rewrittenTo = lease?.command ?? cwdCommand;
@@ -23762,6 +24003,8 @@ function decide(input, deps) {
23762
24003
  case "shell.post":
23763
24004
  if (usable2(descriptor.events["shell.post"].support))
23764
24005
  rawGitPost(input, event.command, callKey(event.toolUseId, event.command));
24006
+ if (stampsAgents(descriptor))
24007
+ dropAgentStamps(process.env, input.session.id, event.toolUseId, event.command);
23765
24008
  return NONE6;
23766
24009
  case "write.pre": {
23767
24010
  if (!usable2(descriptor.events["write.pre"].support))
@@ -23853,7 +24096,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
23853
24096
  };
23854
24097
  // packages/workit-core/src/hooks/deadline.ts
23855
24098
  import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
23856
- import path39 from "node:path";
24099
+ import path40 from "node:path";
23857
24100
  var HOOK_SKIP_TEXT = "workit context skipped: host under load";
23858
24101
  var HOOK_DEADLINE_MS = 8000;
23859
24102
  var HOST_DEADLINES = {
@@ -23871,7 +24114,7 @@ var hookDeadlineMs = (env, host = "", native) => {
23871
24114
  const row = HOST_DEADLINES[host];
23872
24115
  return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
23873
24116
  };
23874
- var skipsFile = (stateDir) => path39.join(stateDir, HOOK_SKIPS_FILE);
24117
+ var skipsFile = (stateDir) => path40.join(stateDir, HOOK_SKIPS_FILE);
23875
24118
  var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
23876
24119
  try {
23877
24120
  mkdirSync4(stateDir, { recursive: true });
@@ -40,7 +40,7 @@ var { standingPending } = await import("./workit-hook-mk64s4fk.js");
40
40
  var { procNoticeFile } = await import("./workit-hook-dv9s0sjq.js");
41
41
  var { recordHookRun } = await import("./workit-hook-a7qmf2t8.js");
42
42
  var { observeHookBudget } = await import("./workit-hook-3g6cv3hd.js");
43
- var { hasTaskStore, mayReach } = await import("./workit-hook-zgd5gqzm.js");
43
+ var { hasTaskStore, mayReach } = await import("./workit-hook-3c7ce65d.js");
44
44
  var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
45
45
  var namesYtrack = (text) => {
46
46
  const bare = text.replace(/['"\\]/g, "");
@@ -101,7 +101,7 @@ if (quiet) {
101
101
  `);
102
102
  } else {
103
103
  try {
104
- const { runCodexHook } = await import("./workit-hook-c77z370x.js");
104
+ const { runCodexHook } = await import("./workit-hook-qsr5czks.js");
105
105
  await runCodexHook([payload]);
106
106
  } catch (error) {
107
107
  const { answerRuntimeFailure } = await import("./workit-hook-2j7nwxvz.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.26.1",
3
+ "version": "2.27.0",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^2.26.1",
45
- "@workit-dev/mcp": "^2.26.1"
44
+ "@workit-dev/core": "^2.27.0",
45
+ "@workit-dev/mcp": "^2.27.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"