@workit-dev/pi 2.12.0 → 2.13.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 (2) hide show
  1. package/dist/workit.js +59 -33
  2. package/package.json +1 -1
package/dist/workit.js CHANGED
@@ -4,7 +4,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
4
4
 
5
5
  // packages/workit-core/src/core.ts
6
6
  import { spawnSync as spawnSync22 } from "node:child_process";
7
- import { existsSync as existsSync13, realpathSync as realpathSync9 } from "node:fs";
7
+ import { existsSync as existsSync14, realpathSync as realpathSync9 } from "node:fs";
8
8
  import path35 from "node:path";
9
9
 
10
10
  // packages/workit-core/src/core/task-contract.ts
@@ -18359,7 +18359,7 @@ var exportDigest = (bundle) => sha256({
18359
18359
  });
18360
18360
  // packages/workit-core/src/core/route-intent.ts
18361
18361
  import { spawnSync as spawnSync17 } from "node:child_process";
18362
- import { existsSync as existsSync11 } from "node:fs";
18362
+ import { existsSync as existsSync12 } from "node:fs";
18363
18363
  import path30 from "node:path";
18364
18364
 
18365
18365
  // packages/workit-core/src/hooks/raw-git.ts
@@ -18370,6 +18370,7 @@ import os6 from "node:os";
18370
18370
  import path29 from "node:path";
18371
18371
 
18372
18372
  // packages/workit-core/src/autonomy.ts
18373
+ import { closeSync as closeSync3, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync3 } from "node:fs";
18373
18374
  import path27 from "node:path";
18374
18375
 
18375
18376
  // packages/workit-core/src/core/eval-world.ts
@@ -18535,12 +18536,36 @@ function checkSeal(dir) {
18535
18536
  }
18536
18537
 
18537
18538
  // packages/workit-core/src/autonomy.ts
18538
- var accountDir = () => {
18539
+ var accountHomeDir = () => {
18539
18540
  const home = grantsHome.resolve();
18540
18541
  return home === null ? null : configDir({ HOME: home });
18541
18542
  };
18542
- var grantsDir = () => accountDir() ?? resolveConfigDir();
18543
+ var deniedFile = (dir) => {
18544
+ for (const name of ["workspaces.json", SEAL_FILE]) {
18545
+ const file = path27.join(dir, name);
18546
+ try {
18547
+ closeSync3(openSync3(file, "r"));
18548
+ } catch (error) {
18549
+ const code = error.code;
18550
+ if (code === "EACCES" || code === "EPERM")
18551
+ return file;
18552
+ }
18553
+ }
18554
+ return null;
18555
+ };
18556
+ var accountDir = () => {
18557
+ const dir = accountHomeDir();
18558
+ return dir === null || deniedFile(dir) !== null ? null : dir;
18559
+ };
18560
+ var grantsDir = () => accountHomeDir() ?? resolveConfigDir();
18543
18561
  var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
18562
+ var accountUnread = () => {
18563
+ const dir = accountHomeDir();
18564
+ if (dir === null)
18565
+ return NO_ACCOUNT;
18566
+ const file = deniedFile(dir);
18567
+ return file === null ? null : `the account's ${path27.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
18568
+ };
18544
18569
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
18545
18570
  var fileSource = (dir = accountDir()) => ({
18546
18571
  resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
@@ -18600,7 +18625,7 @@ var benchWorld = (cwd) => {
18600
18625
  var grantsOverride = () => {
18601
18626
  const shown = shownGrantsDir();
18602
18627
  if (shown === null)
18603
- return NO_ACCOUNT;
18628
+ return accountUnread() ?? NO_ACCOUNT;
18604
18629
  const configured = path27.resolve(resolveConfigDir());
18605
18630
  return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
18606
18631
  };
@@ -18769,9 +18794,10 @@ function capAt(source, named, where, by, why, main = false) {
18769
18794
  }
18770
18795
  function resolveAutonomy(cwd, target) {
18771
18796
  const world = benchWorld(cwd);
18797
+ const unread = world ? null : accountUnread();
18798
+ if (unread !== null)
18799
+ return { ...autonomyOf(null), note: unread };
18772
18800
  const override = world ? null : grantsOverride();
18773
- if (override === NO_ACCOUNT)
18774
- return { ...autonomyOf(null), note: override };
18775
18801
  let resolved;
18776
18802
  const once = typeof target === "function" ? () => resolved ??= target() : target;
18777
18803
  const account = accountAuthority(cwd, world, once);
@@ -18870,9 +18896,9 @@ function capAtRemotes(source, autonomy, cwd, target) {
18870
18896
  return capped;
18871
18897
  }
18872
18898
  var grantsMatter = (kind) => {
18873
- const override = grantsOverride();
18874
- if (override === NO_ACCOUNT)
18899
+ if (accountUnread() !== null)
18875
18900
  return false;
18901
+ const override = grantsOverride();
18876
18902
  const entries = entriesIn(accountDir());
18877
18903
  const matters = entries.some((entry) => {
18878
18904
  const autonomy = autonomyOf(entry);
@@ -21485,7 +21511,7 @@ var judgedDir = (root, dir) => {
21485
21511
  if (dir === null)
21486
21512
  return root;
21487
21513
  const resolved = path30.resolve(root, dir);
21488
- return existsSync11(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
21514
+ return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
21489
21515
  };
21490
21516
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
21491
21517
  let judged = false;
@@ -23481,7 +23507,7 @@ class WorkitCore {
23481
23507
  }
23482
23508
  // packages/workit-core/src/core/repo-context.ts
23483
23509
  import { spawnSync as spawnSync18 } from "node:child_process";
23484
- import { existsSync as existsSync12, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
23510
+ import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
23485
23511
  import path31 from "node:path";
23486
23512
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
23487
23513
  try {
@@ -23663,7 +23689,7 @@ var diffStatForRange = (cwd, range) => {
23663
23689
  };
23664
23690
  var packageScripts = (cwd, keys) => {
23665
23691
  const pkgPath = path31.join(cwd, "package.json");
23666
- if (!existsSync12(pkgPath))
23692
+ if (!existsSync13(pkgPath))
23667
23693
  return [];
23668
23694
  try {
23669
23695
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
@@ -23698,7 +23724,7 @@ var documentationFiles = (cwd) => {
23698
23724
  return matches.toSorted().slice(0, 200);
23699
23725
  };
23700
23726
  var readTrimmed2 = (file, maxLines) => {
23701
- if (!existsSync12(file))
23727
+ if (!existsSync13(file))
23702
23728
  return "";
23703
23729
  const lines = readFileSync11(file, "utf8").split(`
23704
23730
  `);
@@ -23774,7 +23800,7 @@ ${status.stderr}` : "");
23774
23800
  stdout += `
23775
23801
  `;
23776
23802
  stdout += printSection("Recent Validation Signals");
23777
- if (existsSync12(path31.join(cwd, "package.json"))) {
23803
+ if (existsSync13(path31.join(cwd, "package.json"))) {
23778
23804
  stdout += `package.json detected. Common scripts:
23779
23805
  `;
23780
23806
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -23783,7 +23809,7 @@ ${status.stderr}` : "");
23783
23809
  `) + `
23784
23810
  `;
23785
23811
  }
23786
- if (existsSync12(path31.join(cwd, "Cargo.toml")) || existsSync12(path31.join(cwd, "src-tauri/Cargo.toml"))) {
23812
+ if (existsSync13(path31.join(cwd, "Cargo.toml")) || existsSync13(path31.join(cwd, "src-tauri/Cargo.toml"))) {
23787
23813
  stdout += `Rust project detected.
23788
23814
  `;
23789
23815
  }
@@ -23835,7 +23861,7 @@ function changelogContext(root, range) {
23835
23861
  `;
23836
23862
  stdout += printSection("Existing CHANGELOG.md");
23837
23863
  const changelogPath = path31.join(cwd, "CHANGELOG.md");
23838
- if (existsSync12(changelogPath)) {
23864
+ if (existsSync13(changelogPath)) {
23839
23865
  stdout += readTrimmed2(changelogPath, 260) + `
23840
23866
  `;
23841
23867
  } else {
@@ -23877,7 +23903,7 @@ function docsRefreshContext(root, range) {
23877
23903
  `;
23878
23904
  stdout += printSection("README Preview");
23879
23905
  const readme = path31.join(cwd, "README.md");
23880
- if (existsSync12(readme)) {
23906
+ if (existsSync13(readme)) {
23881
23907
  stdout += readTrimmed2(readme, 220) + `
23882
23908
  `;
23883
23909
  } else {
@@ -23886,7 +23912,7 @@ function docsRefreshContext(root, range) {
23886
23912
  }
23887
23913
  stdout += printSection("Package Scripts");
23888
23914
  const pkgPath = path31.join(cwd, "package.json");
23889
- if (existsSync12(pkgPath)) {
23915
+ if (existsSync13(pkgPath)) {
23890
23916
  try {
23891
23917
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
23892
23918
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
@@ -23942,7 +23968,7 @@ function releaseNotesContext(root, rangeOrTag) {
23942
23968
  `;
23943
23969
  stdout += printSection("Existing Release Files");
23944
23970
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
23945
- if (existsSync12(path31.join(cwd, rel)))
23971
+ if (existsSync13(path31.join(cwd, rel)))
23946
23972
  stdout += rel + `
23947
23973
  `;
23948
23974
  }
@@ -24565,7 +24591,7 @@ function resolveInside(root, candidate) {
24565
24591
  throw new Error("path must stay inside repository root");
24566
24592
  }
24567
24593
  let ancestor = target;
24568
- while (!existsSync13(ancestor))
24594
+ while (!existsSync14(ancestor))
24569
24595
  ancestor = path35.dirname(ancestor);
24570
24596
  const canonicalAncestor = realpathSync9(ancestor);
24571
24597
  if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
@@ -25904,7 +25930,7 @@ var splitDenial = (plan) => ({
25904
25930
  });
25905
25931
  // packages/workit-core/src/hooks/write-gate.ts
25906
25932
  import {
25907
- existsSync as existsSync14,
25933
+ existsSync as existsSync15,
25908
25934
  readdirSync as readdirSync5,
25909
25935
  readFileSync as readFileSync12,
25910
25936
  readlinkSync as readlinkSync3,
@@ -26616,7 +26642,7 @@ var linkSources = (args, at) => {
26616
26642
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
26617
26643
  const target = dest === undefined ? null : at(dest);
26618
26644
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
26619
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync14(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
26645
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync15(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
26620
26646
  return sources.flatMap((source) => {
26621
26647
  if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
26622
26648
  return [path41.resolve(base, source)];
@@ -28345,7 +28371,7 @@ import path46 from "node:path";
28345
28371
 
28346
28372
  // packages/workit-core/src/approvals/release-notes-ask.ts
28347
28373
  import { createHash as createHash20 } from "node:crypto";
28348
- import { existsSync as existsSync15, readFileSync as readFileSync14 } from "node:fs";
28374
+ import { existsSync as existsSync16, readFileSync as readFileSync14 } from "node:fs";
28349
28375
  import path44 from "node:path";
28350
28376
  var sha2563 = (data) => createHash20("sha256").update(data).digest("hex");
28351
28377
  var isReleaseNotesApprove = (words) => words[0] === "notes" && words[1] === "approve";
@@ -28391,7 +28417,7 @@ var releaseNotesAskAt = (args, cwd) => {
28391
28417
  path44.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
28392
28418
  path44.join(dir, `${version}.md`)
28393
28419
  ])
28394
- if (existsSync15(file))
28420
+ if (existsSync16(file))
28395
28421
  try {
28396
28422
  return releaseNotesAsk(args, { path: file, notes: readFileSync14(file, "utf8") });
28397
28423
  } catch {
@@ -30131,7 +30157,7 @@ var cdWorkitSplit = (command) => {
30131
30157
  };
30132
30158
 
30133
30159
  // packages/workit-core/src/hooks/model-limit.ts
30134
- import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
30160
+ import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
30135
30161
  import os11 from "node:os";
30136
30162
  import path49 from "node:path";
30137
30163
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
@@ -30272,21 +30298,21 @@ var TAIL_BYTES2 = 16384;
30272
30298
  var tail = (file, size) => {
30273
30299
  const length = Math.min(size, TAIL_BYTES2);
30274
30300
  const buffer = Buffer.alloc(length);
30275
- const fd = openSync3(file, "r");
30301
+ const fd = openSync4(file, "r");
30276
30302
  try {
30277
30303
  readSync(fd, buffer, 0, length, size - length);
30278
30304
  } finally {
30279
- closeSync3(fd);
30305
+ closeSync4(fd);
30280
30306
  }
30281
30307
  return buffer.toString("utf8");
30282
30308
  };
30283
30309
  var start = (file) => {
30284
30310
  const buffer = Buffer.alloc(TAIL_BYTES2);
30285
- const fd = openSync3(file, "r");
30311
+ const fd = openSync4(file, "r");
30286
30312
  try {
30287
30313
  return buffer.subarray(0, readSync(fd, buffer, 0, TAIL_BYTES2, 0)).toString("utf8");
30288
30314
  } finally {
30289
- closeSync3(fd);
30315
+ closeSync4(fd);
30290
30316
  }
30291
30317
  };
30292
30318
  var parse5 = (line) => {
@@ -31841,7 +31867,7 @@ var abandonedLaunches = (root) => {
31841
31867
  var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel","workerId":"${workerId}","reason":"launch outcome unknown"} (CLI: workit worker cancel --payload '{"workerId":"${workerId}","reason":"launch outcome unknown"}')`;
31842
31868
 
31843
31869
  // packages/workit-core/src/core/cli-locate.ts
31844
- import { closeSync as closeSync4, existsSync as existsSync16, openSync as openSync4, readSync as readSync2 } from "node:fs";
31870
+ import { closeSync as closeSync5, existsSync as existsSync17, openSync as openSync5, readSync as readSync2 } from "node:fs";
31845
31871
  import path53 from "node:path";
31846
31872
  var LAUNCHER_MARKER = "workit-owned-launcher";
31847
31873
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
@@ -31856,7 +31882,7 @@ var ownedCurrentEntry = (env, platform = process.platform) => path53.join(instal
31856
31882
  var head = (file) => {
31857
31883
  let fd;
31858
31884
  try {
31859
- fd = openSync4(file, "r");
31885
+ fd = openSync5(file, "r");
31860
31886
  const buffer = Buffer.alloc(256);
31861
31887
  const read = readSync2(fd, buffer, 0, buffer.length, 0);
31862
31888
  return buffer.subarray(0, read).toString("utf8");
@@ -31864,13 +31890,13 @@ var head = (file) => {
31864
31890
  return "";
31865
31891
  } finally {
31866
31892
  if (fd !== undefined)
31867
- closeSync4(fd);
31893
+ closeSync5(fd);
31868
31894
  }
31869
31895
  };
31870
31896
  var locateWorkitCli = (options = {}) => {
31871
31897
  const env = options.env ?? process.env;
31872
31898
  const platform = options.platform ?? process.platform;
31873
- const exists = options.exists ?? existsSync16;
31899
+ const exists = options.exists ?? existsSync17;
31874
31900
  const read = options.read ?? head;
31875
31901
  const node = options.node ?? process.execPath;
31876
31902
  const launcher = ownedLauncherPath(env, platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",