@xenonbyte/da-vinci-workflow 0.2.7 → 0.2.9

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,25 +1,39 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
- const { spawnSync } = require("child_process");
3
+ const childProcess = require("child_process");
4
4
  const { STATUS } = require("./workflow-contract");
5
5
 
6
- function runGit(projectRoot, args) {
7
- return spawnSync("git", args, {
6
+ const DEFAULT_GIT_TIMEOUT_MS = 30 * 1000;
7
+
8
+ function resolveGitTimeoutMs(options = {}) {
9
+ const candidate = Number(options.gitTimeoutMs);
10
+ if (Number.isFinite(candidate) && candidate > 0) {
11
+ return candidate;
12
+ }
13
+ return DEFAULT_GIT_TIMEOUT_MS;
14
+ }
15
+
16
+ function runGit(projectRoot, args, options = {}) {
17
+ return childProcess.spawnSync("git", args, {
8
18
  cwd: projectRoot,
9
19
  encoding: "utf8",
10
- maxBuffer: 8 * 1024 * 1024
20
+ maxBuffer: 8 * 1024 * 1024,
21
+ timeout: resolveGitTimeoutMs(options)
11
22
  });
12
23
  }
13
24
 
14
- function checkIgnoredDirectory(projectRoot, directoryPath) {
25
+ function checkIgnoredDirectory(projectRoot, directoryPath, options = {}) {
15
26
  const relativePath = path.relative(projectRoot, directoryPath) || path.basename(directoryPath);
16
- const result = runGit(projectRoot, ["check-ignore", relativePath]);
27
+ const result = runGit(projectRoot, ["check-ignore", relativePath], options);
17
28
  if (result.error) {
29
+ const timeoutMs = resolveGitTimeoutMs(options);
30
+ const timeoutSuffix =
31
+ result.error.code === "ETIMEDOUT" ? ` after ${timeoutMs}ms` : "";
18
32
  return {
19
33
  directory: directoryPath,
20
34
  relativePath,
21
35
  ignored: false,
22
- error: `failed to execute git check-ignore: ${result.error.message || "unknown error"}`
36
+ error: `failed to execute git check-ignore${timeoutSuffix}: ${result.error.message || "unknown error"}`
23
37
  };
24
38
  }
25
39
  if (result.status === 0) {
@@ -72,7 +86,8 @@ function runWorktreePreflight(projectPathInput, options = {}) {
72
86
  const candidateDirs = [".worktrees", "worktrees"]
73
87
  .map((name) => path.join(projectRoot, name))
74
88
  .filter((candidate) => fs.existsSync(candidate));
75
- const gitStatus = runGit(projectRoot, ["status", "--porcelain"]);
89
+ const gitTimeoutMs = resolveGitTimeoutMs(options);
90
+ const gitStatus = runGit(projectRoot, ["status", "--porcelain"], options);
76
91
  const gitStatusSummary = {
77
92
  healthy: false,
78
93
  exitCode: Number.isFinite(gitStatus.status) ? gitStatus.status : null,
@@ -80,9 +95,14 @@ function runWorktreePreflight(projectPathInput, options = {}) {
80
95
  };
81
96
  const dirtyEntries = [];
82
97
  if (gitStatus.error) {
83
- gitStatusSummary.message = `failed to execute git status: ${gitStatus.error.message || "unknown error"}`;
98
+ const timedOut = gitStatus.error.code === "ETIMEDOUT";
99
+ gitStatusSummary.message = timedOut
100
+ ? `git status timed out after ${gitTimeoutMs}ms`
101
+ : `failed to execute git status: ${gitStatus.error.message || "unknown error"}`;
84
102
  findings.warnings.push(
85
- "Unable to execute `git status`; worktree-isolation preflight cannot be trusted in the current environment."
103
+ timedOut
104
+ ? `git status timed out after ${gitTimeoutMs}ms; worktree-isolation preflight cannot be trusted in the current environment.`
105
+ : "Unable to execute `git status`; worktree-isolation preflight cannot be trusted in the current environment."
86
106
  );
87
107
  } else if (gitStatus.status !== 0) {
88
108
  const stderr = String(gitStatus.stderr || "").trim();
@@ -113,7 +133,7 @@ function runWorktreePreflight(projectPathInput, options = {}) {
113
133
  );
114
134
  } else {
115
135
  for (const candidate of candidateDirs) {
116
- const check = checkIgnoredDirectory(projectRoot, candidate);
136
+ const check = checkIgnoredDirectory(projectRoot, candidate, options);
117
137
  ignoreChecks.push(check);
118
138
  if (check.error) {
119
139
  findings.warnings.push(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenonbyte/da-vinci-workflow",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Requirement-to-design-to-code workflow skill for Codex, Claude, and Gemini",
5
5
  "bin": {
6
6
  "da-vinci": "bin/da-vinci.js",