@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.
- package/CHANGELOG.md +31 -0
- package/README.md +7 -7
- package/README.zh-CN.md +7 -7
- package/lib/async-offload.js +39 -2
- package/lib/cli/command-handlers-core.js +132 -0
- package/lib/cli/command-handlers-design.js +129 -0
- package/lib/cli/command-handlers-pen.js +231 -0
- package/lib/cli/command-handlers-workflow.js +221 -0
- package/lib/cli/command-handlers.js +49 -0
- package/lib/cli/helpers.js +62 -0
- package/lib/cli.js +98 -533
- package/lib/execution-signals.js +33 -0
- package/lib/fs-safety.js +1 -12
- package/lib/path-inside.js +17 -0
- package/lib/utils.js +2 -7
- package/lib/workflow-base-view.js +134 -0
- package/lib/workflow-decision-trace.js +335 -0
- package/lib/workflow-overlay.js +1033 -0
- package/lib/workflow-persisted-state.js +4 -0
- package/lib/workflow-stage.js +244 -0
- package/lib/workflow-state.js +414 -1708
- package/lib/workflow-task-groups.js +881 -0
- package/lib/worktree-preflight.js +31 -11
- package/package.json +1 -1
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const
|
|
3
|
+
const childProcess = require("child_process");
|
|
4
4
|
const { STATUS } = require("./workflow-contract");
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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(
|