@contractspec/bundle.workspace 3.7.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -759,7 +759,8 @@ function createNodeAdapters(options = {}) {
759
759
  }
760
760
  // src/adapters/workspace.ts
761
761
  import { existsSync, readFileSync } from "fs";
762
- import { dirname as dirname3, join as join3, resolve as resolve4 } from "path";
762
+ import { tmpdir } from "os";
763
+ import { dirname as dirname3, isAbsolute as isAbsolute3, join as join3, relative as relative3, resolve as resolve4 } from "path";
763
764
  var LOCK_FILES = {
764
765
  "bun.lockb": "bun",
765
766
  "bun.lock": "bun",
@@ -774,14 +775,24 @@ var MONOREPO_FILES = [
774
775
  "turbo.json",
775
776
  "rush.json"
776
777
  ];
778
+ function isWithinDirectory(target, directory) {
779
+ const pathFromDirectory = relative3(directory, target);
780
+ return pathFromDirectory === "" || !pathFromDirectory.startsWith("..") && !isAbsolute3(pathFromDirectory);
781
+ }
782
+ function getTraversalBoundary(startDir) {
783
+ const resolvedStartDir = resolve4(startDir);
784
+ const tempRoot = resolve4(tmpdir());
785
+ return isWithinDirectory(resolvedStartDir, tempRoot) ? tempRoot : undefined;
786
+ }
777
787
  function findPackageRoot(startDir = process.cwd()) {
778
788
  let current = resolve4(startDir);
789
+ const traversalBoundary = getTraversalBoundary(startDir);
779
790
  while (true) {
780
791
  if (existsSync(join3(current, "package.json"))) {
781
792
  return current;
782
793
  }
783
794
  const parent = dirname3(current);
784
- if (parent === current) {
795
+ if (parent === current || current === traversalBoundary) {
785
796
  break;
786
797
  }
787
798
  current = parent;
@@ -791,6 +802,7 @@ function findPackageRoot(startDir = process.cwd()) {
791
802
  function findWorkspaceRoot(startDir = process.cwd()) {
792
803
  let current = resolve4(startDir);
793
804
  let lastPackageJson = null;
805
+ const traversalBoundary = getTraversalBoundary(startDir);
794
806
  while (true) {
795
807
  for (const file of MONOREPO_FILES) {
796
808
  if (existsSync(join3(current, file))) {
@@ -813,7 +825,7 @@ function findWorkspaceRoot(startDir = process.cwd()) {
813
825
  }
814
826
  }
815
827
  const parent = dirname3(current);
816
- if (parent === current) {
828
+ if (parent === current || current === traversalBoundary) {
817
829
  break;
818
830
  }
819
831
  current = parent;
@@ -942,12 +954,13 @@ function checkHasWorkspaces(dir) {
942
954
  }
943
955
  function findMetaRepoRoot(startDir) {
944
956
  let current = resolve4(startDir);
957
+ const traversalBoundary = getTraversalBoundary(startDir);
945
958
  while (true) {
946
959
  if (existsSync(join3(current, ".gitmodules"))) {
947
960
  return current;
948
961
  }
949
962
  const parent = dirname3(current);
950
- if (parent === current) {
963
+ if (parent === current || current === traversalBoundary) {
951
964
  break;
952
965
  }
953
966
  current = parent;
@@ -1815,7 +1828,7 @@ ${task.existingCode}`;
1815
1828
  import { spawn } from "child_process";
1816
1829
  import { mkdir as mkdir3, readFile as readFile4, rm as rm2, writeFile as writeFile2 } from "fs/promises";
1817
1830
  import { join as join4 } from "path";
1818
- import { homedir, tmpdir } from "os";
1831
+ import { homedir, tmpdir as tmpdir2 } from "os";
1819
1832
  import { existsSync as existsSync2 } from "fs";
1820
1833
 
1821
1834
  class CursorAgent {
@@ -1832,7 +1845,7 @@ class CursorAgent {
1832
1845
  }
1833
1846
  async generate(task) {
1834
1847
  try {
1835
- const workDir = join4(tmpdir(), `cursor-agent-${Date.now()}`);
1848
+ const workDir = join4(tmpdir2(), `cursor-agent-${Date.now()}`);
1836
1849
  await mkdir3(workDir, { recursive: true });
1837
1850
  const result = await this.executeWithBestMethod(task, workDir);
1838
1851
  await this.cleanupWorkDir(workDir);
@@ -1846,7 +1859,7 @@ class CursorAgent {
1846
1859
  }
1847
1860
  async validate(task) {
1848
1861
  try {
1849
- const workDir = join4(tmpdir(), `cursor-validate-${Date.now()}`);
1862
+ const workDir = join4(tmpdir2(), `cursor-validate-${Date.now()}`);
1850
1863
  await mkdir3(workDir, { recursive: true });
1851
1864
  await this.setupValidationWorkspace(task, workDir);
1852
1865
  const result = await this.executeWithBestMethod({
@@ -8577,7 +8590,7 @@ init_config();
8577
8590
  // src/services/drift.ts
8578
8591
  import path4 from "path";
8579
8592
  import { mkdtemp, rm as rm3 } from "fs/promises";
8580
- import { tmpdir as tmpdir2 } from "os";
8593
+ import { tmpdir as tmpdir3 } from "os";
8581
8594
 
8582
8595
  // src/services/generate-artifacts.ts
8583
8596
  import path3 from "path";
@@ -8737,7 +8750,7 @@ async function generateArtifacts(adapters, contractsDir, generatedDir, rootPath)
8737
8750
 
8738
8751
  // src/services/drift.ts
8739
8752
  async function detectDrift(adapters, contractsDir, generatedDir) {
8740
- const tempDir = await mkdtemp(path4.join(tmpdir2(), "contractspec-drift-"));
8753
+ const tempDir = await mkdtemp(path4.join(tmpdir3(), "contractspec-drift-"));
8741
8754
  try {
8742
8755
  await generateArtifacts(adapters, contractsDir, tempDir);
8743
8756
  const differences = [];
@@ -759,7 +759,8 @@ function createNodeAdapters(options = {}) {
759
759
  }
760
760
  // src/adapters/workspace.ts
761
761
  import { existsSync, readFileSync } from "node:fs";
762
- import { dirname as dirname3, join as join3, resolve as resolve4 } from "node:path";
762
+ import { tmpdir } from "node:os";
763
+ import { dirname as dirname3, isAbsolute as isAbsolute3, join as join3, relative as relative3, resolve as resolve4 } from "node:path";
763
764
  var LOCK_FILES = {
764
765
  "bun.lockb": "bun",
765
766
  "bun.lock": "bun",
@@ -774,14 +775,24 @@ var MONOREPO_FILES = [
774
775
  "turbo.json",
775
776
  "rush.json"
776
777
  ];
778
+ function isWithinDirectory(target, directory) {
779
+ const pathFromDirectory = relative3(directory, target);
780
+ return pathFromDirectory === "" || !pathFromDirectory.startsWith("..") && !isAbsolute3(pathFromDirectory);
781
+ }
782
+ function getTraversalBoundary(startDir) {
783
+ const resolvedStartDir = resolve4(startDir);
784
+ const tempRoot = resolve4(tmpdir());
785
+ return isWithinDirectory(resolvedStartDir, tempRoot) ? tempRoot : undefined;
786
+ }
777
787
  function findPackageRoot(startDir = process.cwd()) {
778
788
  let current = resolve4(startDir);
789
+ const traversalBoundary = getTraversalBoundary(startDir);
779
790
  while (true) {
780
791
  if (existsSync(join3(current, "package.json"))) {
781
792
  return current;
782
793
  }
783
794
  const parent = dirname3(current);
784
- if (parent === current) {
795
+ if (parent === current || current === traversalBoundary) {
785
796
  break;
786
797
  }
787
798
  current = parent;
@@ -791,6 +802,7 @@ function findPackageRoot(startDir = process.cwd()) {
791
802
  function findWorkspaceRoot(startDir = process.cwd()) {
792
803
  let current = resolve4(startDir);
793
804
  let lastPackageJson = null;
805
+ const traversalBoundary = getTraversalBoundary(startDir);
794
806
  while (true) {
795
807
  for (const file of MONOREPO_FILES) {
796
808
  if (existsSync(join3(current, file))) {
@@ -813,7 +825,7 @@ function findWorkspaceRoot(startDir = process.cwd()) {
813
825
  }
814
826
  }
815
827
  const parent = dirname3(current);
816
- if (parent === current) {
828
+ if (parent === current || current === traversalBoundary) {
817
829
  break;
818
830
  }
819
831
  current = parent;
@@ -942,12 +954,13 @@ function checkHasWorkspaces(dir) {
942
954
  }
943
955
  function findMetaRepoRoot(startDir) {
944
956
  let current = resolve4(startDir);
957
+ const traversalBoundary = getTraversalBoundary(startDir);
945
958
  while (true) {
946
959
  if (existsSync(join3(current, ".gitmodules"))) {
947
960
  return current;
948
961
  }
949
962
  const parent = dirname3(current);
950
- if (parent === current) {
963
+ if (parent === current || current === traversalBoundary) {
951
964
  break;
952
965
  }
953
966
  current = parent;
@@ -1815,7 +1828,7 @@ ${task.existingCode}`;
1815
1828
  import { spawn } from "child_process";
1816
1829
  import { mkdir as mkdir3, readFile as readFile4, rm as rm2, writeFile as writeFile2 } from "fs/promises";
1817
1830
  import { join as join4 } from "path";
1818
- import { homedir, tmpdir } from "os";
1831
+ import { homedir, tmpdir as tmpdir2 } from "os";
1819
1832
  import { existsSync as existsSync2 } from "fs";
1820
1833
 
1821
1834
  class CursorAgent {
@@ -1832,7 +1845,7 @@ class CursorAgent {
1832
1845
  }
1833
1846
  async generate(task) {
1834
1847
  try {
1835
- const workDir = join4(tmpdir(), `cursor-agent-${Date.now()}`);
1848
+ const workDir = join4(tmpdir2(), `cursor-agent-${Date.now()}`);
1836
1849
  await mkdir3(workDir, { recursive: true });
1837
1850
  const result = await this.executeWithBestMethod(task, workDir);
1838
1851
  await this.cleanupWorkDir(workDir);
@@ -1846,7 +1859,7 @@ class CursorAgent {
1846
1859
  }
1847
1860
  async validate(task) {
1848
1861
  try {
1849
- const workDir = join4(tmpdir(), `cursor-validate-${Date.now()}`);
1862
+ const workDir = join4(tmpdir2(), `cursor-validate-${Date.now()}`);
1850
1863
  await mkdir3(workDir, { recursive: true });
1851
1864
  await this.setupValidationWorkspace(task, workDir);
1852
1865
  const result = await this.executeWithBestMethod({
@@ -8577,7 +8590,7 @@ init_config();
8577
8590
  // src/services/drift.ts
8578
8591
  import path4 from "path";
8579
8592
  import { mkdtemp, rm as rm3 } from "node:fs/promises";
8580
- import { tmpdir as tmpdir2 } from "node:os";
8593
+ import { tmpdir as tmpdir3 } from "node:os";
8581
8594
 
8582
8595
  // src/services/generate-artifacts.ts
8583
8596
  import path3 from "path";
@@ -8737,7 +8750,7 @@ async function generateArtifacts(adapters, contractsDir, generatedDir, rootPath)
8737
8750
 
8738
8751
  // src/services/drift.ts
8739
8752
  async function detectDrift(adapters, contractsDir, generatedDir) {
8740
- const tempDir = await mkdtemp(path4.join(tmpdir2(), "contractspec-drift-"));
8753
+ const tempDir = await mkdtemp(path4.join(tmpdir3(), "contractspec-drift-"));
8741
8754
  try {
8742
8755
  await generateArtifacts(adapters, contractsDir, tempDir);
8743
8756
  const differences = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/bundle.workspace",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "description": "Workspace utilities for monorepo development",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -33,14 +33,14 @@
33
33
  "dependencies": {
34
34
  "@ai-sdk/anthropic": "3.0.58",
35
35
  "@ai-sdk/openai": "3.0.41",
36
- "@contractspec/lib.ai-agent": "7.0.0",
37
- "@contractspec/lib.ai-providers": "3.7.0",
38
- "@contractspec/lib.contracts-spec": "3.7.0",
39
- "@contractspec/lib.contracts-integrations": "3.7.0",
40
- "@contractspec/lib.contracts-transformers": "3.7.0",
41
- "@contractspec/lib.source-extractors": "2.7.0",
42
- "@contractspec/module.workspace": "3.7.0",
43
- "@contractspec/lib.utils-typescript": "3.7.0",
36
+ "@contractspec/lib.ai-agent": "7.0.1",
37
+ "@contractspec/lib.ai-providers": "3.7.1",
38
+ "@contractspec/lib.contracts-spec": "3.7.1",
39
+ "@contractspec/lib.contracts-integrations": "3.7.1",
40
+ "@contractspec/lib.contracts-transformers": "3.7.1",
41
+ "@contractspec/lib.source-extractors": "2.7.1",
42
+ "@contractspec/module.workspace": "3.7.1",
43
+ "@contractspec/lib.utils-typescript": "3.7.1",
44
44
  "ai": "6.0.116",
45
45
  "chalk": "^5.6.2",
46
46
  "chokidar": "^5.0.0",
@@ -52,12 +52,12 @@
52
52
  "zod": "^4.3.5"
53
53
  },
54
54
  "devDependencies": {
55
- "@contractspec/tool.typescript": "3.7.0",
55
+ "@contractspec/tool.typescript": "3.7.1",
56
56
  "@types/bun": "^1.3.10",
57
57
  "@types/micromatch": "^4.0.10",
58
58
  "@types/node": "^25.3.5",
59
59
  "typescript": "^5.9.3",
60
- "@contractspec/tool.bun": "3.7.0"
60
+ "@contractspec/tool.bun": "3.7.1"
61
61
  },
62
62
  "exports": {
63
63
  ".": {