@sideboard-ai/core 0.1.279 → 0.1.280

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.
@@ -4443,10 +4443,49 @@ async function confirmLand(thread, opts) {
4443
4443
  }
4444
4444
  }
4445
4445
 
4446
+ // src/diff/read-worktree-tail.ts
4447
+ import { closeSync, fstatSync, openSync, readSync } from "fs";
4448
+ import { join as join9 } from "path";
4449
+ var WORKTREE_TAIL_BYTES = 2e5;
4450
+ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TAIL_BYTES) {
4451
+ if (!relativePath || relativePath.includes("..") || relativePath.startsWith("/")) {
4452
+ throw new Error("Invalid path");
4453
+ }
4454
+ const abs = join9(worktreePath, relativePath);
4455
+ const fd = openSync(abs, "r");
4456
+ try {
4457
+ const st = fstatSync(fd);
4458
+ if (!st.isFile()) throw new Error(`Not a file: ${relativePath}`);
4459
+ const size = st.size;
4460
+ const start = Math.max(0, size - maxBytes);
4461
+ const length = size - start;
4462
+ const buf = Buffer.alloc(length);
4463
+ if (length > 0) readSync(fd, buf, 0, length, start);
4464
+ if (buf.subarray(0, Math.min(buf.length, 8e3)).includes(0)) {
4465
+ return {
4466
+ path: relativePath,
4467
+ content: `(binary file, ${size} bytes)`,
4468
+ truncated: false,
4469
+ binary: true,
4470
+ encoding: "utf8"
4471
+ };
4472
+ }
4473
+ let content = buf.toString("utf8");
4474
+ const truncated = start > 0;
4475
+ if (truncated) {
4476
+ const nl = content.indexOf("\n");
4477
+ if (nl >= 0) content = content.slice(nl + 1);
4478
+ }
4479
+ return { path: relativePath, content, truncated, binary: false, encoding: "utf8" };
4480
+ } finally {
4481
+ closeSync(fd);
4482
+ }
4483
+ }
4484
+
4446
4485
  // src/skills/discover.ts
4447
4486
  import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
4448
4487
  import { homedir } from "os";
4449
- import { join as join9 } from "path";
4488
+ import { join as join10 } from "path";
4450
4489
 
4451
4490
  // src/skills/bundled/long-running.ts
4452
4491
  var LONG_RUNNING_SKILL_COMMAND = "long-running";
@@ -4615,7 +4654,7 @@ function scanSkillsDir(dir, source, out) {
4615
4654
  }
4616
4655
  for (const entry of entries) {
4617
4656
  if (entry.startsWith(".")) continue;
4618
- const skillMd = join9(dir, entry, "SKILL.md");
4657
+ const skillMd = join10(dir, entry, "SKILL.md");
4619
4658
  if (!existsSync10(skillMd)) continue;
4620
4659
  try {
4621
4660
  if (!statSync3(skillMd).isFile()) continue;
@@ -4637,12 +4676,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
4637
4676
  return;
4638
4677
  }
4639
4678
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
4640
- const skill = readSkill(join9(dir, "SKILL.md"), "cli");
4679
+ const skill = readSkill(join10(dir, "SKILL.md"), "cli");
4641
4680
  if (skill) out.push(skill);
4642
4681
  }
4643
4682
  for (const entry of entries) {
4644
4683
  if (entry === "node_modules" || entry === ".git") continue;
4645
- const full = join9(dir, entry);
4684
+ const full = join10(dir, entry);
4646
4685
  try {
4647
4686
  if (!statSync3(full).isDirectory()) continue;
4648
4687
  } catch {
@@ -4662,17 +4701,17 @@ function discoverSkills(worktreePath) {
4662
4701
  const home = homedir();
4663
4702
  const collected = [];
4664
4703
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
4665
- scanSkillsDir(join9(worktreePath, rel), "workspace", collected);
4704
+ scanSkillsDir(join10(worktreePath, rel), "workspace", collected);
4666
4705
  }
4667
4706
  for (const abs of [
4668
- join9(home, ".claude/skills"),
4669
- join9(home, ".cursor/skills"),
4670
- join9(home, ".sideboard/skills"),
4671
- join9(home, ".brightsy/skills")
4707
+ join10(home, ".claude/skills"),
4708
+ join10(home, ".cursor/skills"),
4709
+ join10(home, ".sideboard/skills"),
4710
+ join10(home, ".brightsy/skills")
4672
4711
  ]) {
4673
4712
  scanSkillsDir(abs, "user", collected);
4674
4713
  }
4675
- scanClaudePluginSkills(join9(home, ".claude/plugins"), collected);
4714
+ scanClaudePluginSkills(join10(home, ".claude/plugins"), collected);
4676
4715
  collected.push(...bundledSkills());
4677
4716
  const rank = {
4678
4717
  workspace: 0,
@@ -4844,11 +4883,11 @@ function shiftQueuedItem(queue, queueAttachments) {
4844
4883
 
4845
4884
  // src/agents/instructions.ts
4846
4885
  import { existsSync as existsSync12 } from "fs";
4847
- import { join as join11 } from "path";
4886
+ import { join as join12 } from "path";
4848
4887
 
4849
4888
  // src/skills/detached-job-path.ts
4850
4889
  import { existsSync as existsSync11 } from "fs";
4851
- import { dirname as dirname2, join as join10 } from "path";
4890
+ import { dirname as dirname2, join as join11 } from "path";
4852
4891
  import { fileURLToPath } from "url";
4853
4892
  var DETACHED_JOB_FILENAMES = ["detached-job.cjs", "detached-job.js"];
4854
4893
  function compiledModuleDir() {
@@ -4865,7 +4904,7 @@ function compiledModuleDir() {
4865
4904
  }
4866
4905
  function detachedJobScriptIn(dir) {
4867
4906
  for (const name of DETACHED_JOB_FILENAMES) {
4868
- const script = join10(dir, "scripts", name);
4907
+ const script = join11(dir, "scripts", name);
4869
4908
  if (existsSync11(script)) return script;
4870
4909
  }
4871
4910
  return null;
@@ -5084,9 +5123,9 @@ function formatPrGateDirective() {
5084
5123
  }
5085
5124
  function formatProcessGuideDirective(opts) {
5086
5125
  const worktree = opts?.worktreePath?.trim();
5087
- const hasGraphSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/graph-engineering/SKILL.md"));
5088
- const hasReviewSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/review/SKILL.md"));
5089
- const hasInstallSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/worktree-install/SKILL.md"));
5126
+ const hasGraphSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/graph-engineering/SKILL.md"));
5127
+ const hasReviewSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/review/SKILL.md"));
5128
+ const hasInstallSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/worktree-install/SKILL.md"));
5090
5129
  return [
5091
5130
  "Process guides (recurring work only):",
5092
5131
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
@@ -5252,7 +5291,7 @@ async function syncThreadBranchFromGit(threadId) {
5252
5291
  // src/store/schedules.ts
5253
5292
  import { randomUUID as randomUUID2 } from "crypto";
5254
5293
  import { existsSync as existsSync13, readFileSync as readFileSync8 } from "fs";
5255
- import { join as join12 } from "path";
5294
+ import { join as join13 } from "path";
5256
5295
  import { Cron } from "croner";
5257
5296
  var DURATION_RE = /^(\d+)(s|m|h|d)$/i;
5258
5297
  var UNIT_MS = {
@@ -5262,7 +5301,7 @@ var UNIT_MS = {
5262
5301
  d: 864e5
5263
5302
  };
5264
5303
  function schedulesPath() {
5265
- return join12(appDataDir(), "schedules.json");
5304
+ return join13(appDataDir(), "schedules.json");
5266
5305
  }
5267
5306
  function parseDurationMs(every) {
5268
5307
  const m = every.trim().match(DURATION_RE);
@@ -5500,7 +5539,7 @@ function formatScheduledPrompt(name, prompt) {
5500
5539
  ${prompt}`;
5501
5540
  }
5502
5541
  async function defaultDeps() {
5503
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-E5WK57DA.js");
5542
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-K66OMTQO.js");
5504
5543
  const orch = getOrchestrator2();
5505
5544
  return {
5506
5545
  findThread: (id) => findThreadByRef(id),
@@ -7728,12 +7767,12 @@ var Orchestrator = class {
7728
7767
  return "missing";
7729
7768
  }
7730
7769
  }
7731
- async readFile(threadRef, relativePath) {
7770
+ async readFile(threadRef, relativePath, tail) {
7732
7771
  const thread = this.requireThread(threadRef);
7733
7772
  if (relativePath.includes("..") || relativePath.startsWith("/")) {
7734
7773
  throw new Error("Invalid path");
7735
7774
  }
7736
- return readWorktreeFile(thread.worktreePath, relativePath);
7775
+ return (tail ? readWorktreeFileTail : readWorktreeFile)(thread.worktreePath, relativePath);
7737
7776
  }
7738
7777
  async readFileForUpload(threadRef, relativePath) {
7739
7778
  const thread = this.requireThread(threadRef);
@@ -4589,10 +4589,49 @@ async function confirmLand(thread, opts) {
4589
4589
  }
4590
4590
  }
4591
4591
 
4592
+ // src/diff/read-worktree-tail.ts
4593
+ import { closeSync, fstatSync, openSync, readSync } from "fs";
4594
+ import { join as join9 } from "path";
4595
+ var WORKTREE_TAIL_BYTES = 2e5;
4596
+ function readWorktreeFileTail(worktreePath, relativePath, maxBytes = WORKTREE_TAIL_BYTES) {
4597
+ if (!relativePath || relativePath.includes("..") || relativePath.startsWith("/")) {
4598
+ throw new Error("Invalid path");
4599
+ }
4600
+ const abs = join9(worktreePath, relativePath);
4601
+ const fd = openSync(abs, "r");
4602
+ try {
4603
+ const st = fstatSync(fd);
4604
+ if (!st.isFile()) throw new Error(`Not a file: ${relativePath}`);
4605
+ const size = st.size;
4606
+ const start = Math.max(0, size - maxBytes);
4607
+ const length = size - start;
4608
+ const buf = Buffer.alloc(length);
4609
+ if (length > 0) readSync(fd, buf, 0, length, start);
4610
+ if (buf.subarray(0, Math.min(buf.length, 8e3)).includes(0)) {
4611
+ return {
4612
+ path: relativePath,
4613
+ content: `(binary file, ${size} bytes)`,
4614
+ truncated: false,
4615
+ binary: true,
4616
+ encoding: "utf8"
4617
+ };
4618
+ }
4619
+ let content = buf.toString("utf8");
4620
+ const truncated = start > 0;
4621
+ if (truncated) {
4622
+ const nl = content.indexOf("\n");
4623
+ if (nl >= 0) content = content.slice(nl + 1);
4624
+ }
4625
+ return { path: relativePath, content, truncated, binary: false, encoding: "utf8" };
4626
+ } finally {
4627
+ closeSync(fd);
4628
+ }
4629
+ }
4630
+
4592
4631
  // src/skills/discover.ts
4593
4632
  import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
4594
4633
  import { homedir } from "os";
4595
- import { join as join9 } from "path";
4634
+ import { join as join10 } from "path";
4596
4635
 
4597
4636
  // src/skills/bundled/long-running.ts
4598
4637
  var LONG_RUNNING_SKILL_COMMAND = "long-running";
@@ -4761,7 +4800,7 @@ function scanSkillsDir(dir, source, out) {
4761
4800
  }
4762
4801
  for (const entry of entries) {
4763
4802
  if (entry.startsWith(".")) continue;
4764
- const skillMd = join9(dir, entry, "SKILL.md");
4803
+ const skillMd = join10(dir, entry, "SKILL.md");
4765
4804
  if (!existsSync10(skillMd)) continue;
4766
4805
  try {
4767
4806
  if (!statSync3(skillMd).isFile()) continue;
@@ -4783,12 +4822,12 @@ function scanClaudePluginSkills(pluginsRoot, out) {
4783
4822
  return;
4784
4823
  }
4785
4824
  if (lookingForSkillsDir && entries.includes("SKILL.md")) {
4786
- const skill = readSkill(join9(dir, "SKILL.md"), "cli");
4825
+ const skill = readSkill(join10(dir, "SKILL.md"), "cli");
4787
4826
  if (skill) out.push(skill);
4788
4827
  }
4789
4828
  for (const entry of entries) {
4790
4829
  if (entry === "node_modules" || entry === ".git") continue;
4791
- const full = join9(dir, entry);
4830
+ const full = join10(dir, entry);
4792
4831
  try {
4793
4832
  if (!statSync3(full).isDirectory()) continue;
4794
4833
  } catch {
@@ -4808,17 +4847,17 @@ function discoverSkills(worktreePath) {
4808
4847
  const home = homedir();
4809
4848
  const collected = [];
4810
4849
  for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
4811
- scanSkillsDir(join9(worktreePath, rel), "workspace", collected);
4850
+ scanSkillsDir(join10(worktreePath, rel), "workspace", collected);
4812
4851
  }
4813
4852
  for (const abs of [
4814
- join9(home, ".claude/skills"),
4815
- join9(home, ".cursor/skills"),
4816
- join9(home, ".sideboard/skills"),
4817
- join9(home, ".brightsy/skills")
4853
+ join10(home, ".claude/skills"),
4854
+ join10(home, ".cursor/skills"),
4855
+ join10(home, ".sideboard/skills"),
4856
+ join10(home, ".brightsy/skills")
4818
4857
  ]) {
4819
4858
  scanSkillsDir(abs, "user", collected);
4820
4859
  }
4821
- scanClaudePluginSkills(join9(home, ".claude/plugins"), collected);
4860
+ scanClaudePluginSkills(join10(home, ".claude/plugins"), collected);
4822
4861
  collected.push(...bundledSkills());
4823
4862
  const rank = {
4824
4863
  workspace: 0,
@@ -4990,11 +5029,11 @@ function shiftQueuedItem(queue, queueAttachments) {
4990
5029
 
4991
5030
  // src/agents/instructions.ts
4992
5031
  import { existsSync as existsSync12 } from "fs";
4993
- import { join as join11 } from "path";
5032
+ import { join as join12 } from "path";
4994
5033
 
4995
5034
  // src/skills/detached-job-path.ts
4996
5035
  import { existsSync as existsSync11 } from "fs";
4997
- import { dirname as dirname2, join as join10 } from "path";
5036
+ import { dirname as dirname2, join as join11 } from "path";
4998
5037
  import { fileURLToPath } from "url";
4999
5038
  var DETACHED_JOB_FILENAMES = ["detached-job.cjs", "detached-job.js"];
5000
5039
  function compiledModuleDir() {
@@ -5011,7 +5050,7 @@ function compiledModuleDir() {
5011
5050
  }
5012
5051
  function detachedJobScriptIn(dir) {
5013
5052
  for (const name of DETACHED_JOB_FILENAMES) {
5014
- const script = join10(dir, "scripts", name);
5053
+ const script = join11(dir, "scripts", name);
5015
5054
  if (existsSync11(script)) return script;
5016
5055
  }
5017
5056
  return null;
@@ -5252,9 +5291,9 @@ function formatPrGateDirective() {
5252
5291
  }
5253
5292
  function formatProcessGuideDirective(opts) {
5254
5293
  const worktree = opts?.worktreePath?.trim();
5255
- const hasGraphSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/graph-engineering/SKILL.md"));
5256
- const hasReviewSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/review/SKILL.md"));
5257
- const hasInstallSkill = !!worktree && existsSync12(join11(worktree, ".claude/skills/worktree-install/SKILL.md"));
5294
+ const hasGraphSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/graph-engineering/SKILL.md"));
5295
+ const hasReviewSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/review/SKILL.md"));
5296
+ const hasInstallSkill = !!worktree && existsSync12(join12(worktree, ".claude/skills/worktree-install/SKILL.md"));
5258
5297
  return [
5259
5298
  "Process guides (recurring work only):",
5260
5299
  hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
@@ -5582,7 +5621,7 @@ async function syncThreadBranchFromGit(threadId) {
5582
5621
  // src/store/schedules.ts
5583
5622
  import { randomUUID as randomUUID2 } from "crypto";
5584
5623
  import { existsSync as existsSync13, readFileSync as readFileSync8 } from "fs";
5585
- import { join as join12 } from "path";
5624
+ import { join as join13 } from "path";
5586
5625
  import { Cron } from "croner";
5587
5626
  var DURATION_RE = /^(\d+)(s|m|h|d)$/i;
5588
5627
  var UNIT_MS = {
@@ -5592,7 +5631,7 @@ var UNIT_MS = {
5592
5631
  d: 864e5
5593
5632
  };
5594
5633
  function schedulesPath() {
5595
- return join12(appDataDir(), "schedules.json");
5634
+ return join13(appDataDir(), "schedules.json");
5596
5635
  }
5597
5636
  function parseDurationMs(every) {
5598
5637
  const m = every.trim().match(DURATION_RE);
@@ -5839,7 +5878,7 @@ function formatScheduledPrompt(name, prompt) {
5839
5878
  ${prompt}`;
5840
5879
  }
5841
5880
  async function defaultDeps() {
5842
- const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-KY2KBBE2.js");
5881
+ const { getOrchestrator: getOrchestrator2, startOrchestration: startOrchestration2 } = await import("./orchestrator-XEKODYDQ.js");
5843
5882
  const orch = getOrchestrator2();
5844
5883
  return {
5845
5884
  findThread: (id) => findThreadByRef(id),
@@ -8067,12 +8106,12 @@ var Orchestrator = class {
8067
8106
  return "missing";
8068
8107
  }
8069
8108
  }
8070
- async readFile(threadRef, relativePath) {
8109
+ async readFile(threadRef, relativePath, tail) {
8071
8110
  const thread = this.requireThread(threadRef);
8072
8111
  if (relativePath.includes("..") || relativePath.startsWith("/")) {
8073
8112
  throw new Error("Invalid path");
8074
8113
  }
8075
- return readWorktreeFile(thread.worktreePath, relativePath);
8114
+ return (tail ? readWorktreeFileTail : readWorktreeFile)(thread.worktreePath, relativePath);
8076
8115
  }
8077
8116
  async readFileForUpload(threadRef, relativePath) {
8078
8117
  const thread = this.requireThread(threadRef);