nightytidy 0.2.8 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nightytidy",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Automated overnight codebase improvement through Claude Code",
5
5
  "license": "MIT",
6
6
  "author": "Dorian Spitz",
@@ -76,7 +76,7 @@ export class CliBridge {
76
76
  }
77
77
 
78
78
  _run(args, onOutput, opts = {}) {
79
- return new Promise((resolve, reject) => {
79
+ return new Promise((resolve) => {
80
80
  const binPath = path.resolve(import.meta.dirname, '../../bin/nightytidy.js');
81
81
  const proc = spawn('node', [binPath, ...args], {
82
82
  cwd: this.projectDir,
@@ -87,15 +87,40 @@ export class CliBridge {
87
87
  let stdout = '';
88
88
  let stderr = '';
89
89
  let killed = false;
90
+ let settled = false;
91
+
92
+ const settle = (result) => {
93
+ if (settled) return;
94
+ settled = true;
95
+ if (timer) clearTimeout(timer);
96
+ if (killTimer) clearTimeout(killTimer);
97
+ resolve(result);
98
+ };
90
99
 
91
100
  // Timeout — kill the process if it takes too long
92
101
  let timer = null;
102
+ let killTimer = null;
93
103
  if (opts.timeout) {
94
104
  timer = setTimeout(() => {
95
105
  killed = true;
96
106
  const timeoutSec = Math.round(opts.timeout / 1000);
97
107
  warn(`CLI process timed out after ${timeoutSec}s: ${args.join(' ')}`);
98
108
  this.kill();
109
+ // On Windows, taskkill is fire-and-forget — the 'close' event may
110
+ // never fire. Force-resolve after 5s to prevent the agent from
111
+ // hanging forever.
112
+ killTimer = setTimeout(() => {
113
+ warn(`CLI process did not exit within 5s after kill — force-resolving`);
114
+ this.activeProcess = null;
115
+ settle({
116
+ success: false,
117
+ exitCode: -1,
118
+ stdout,
119
+ stderr: `Process timed out after ${timeoutSec}s — Claude Code may be unavailable`,
120
+ parsed: CliBridge.parseOutput(stdout),
121
+ timedOut: true,
122
+ });
123
+ }, 5000);
99
124
  }, opts.timeout);
100
125
  }
101
126
 
@@ -127,26 +152,23 @@ export class CliBridge {
127
152
  });
128
153
 
129
154
  proc.on('close', (code) => {
130
- if (timer) clearTimeout(timer);
131
155
  this.activeProcess = null;
132
- const parsed = CliBridge.parseOutput(stdout);
133
- resolve({
156
+ settle({
134
157
  success: code === 0 && !killed,
135
158
  exitCode: code,
136
159
  stdout,
137
160
  stderr: killed
138
161
  ? `Process timed out after ${Math.round(opts.timeout / 1000)}s — Claude Code may be unavailable`
139
162
  : stderr,
140
- parsed,
163
+ parsed: CliBridge.parseOutput(stdout),
141
164
  timedOut: killed,
142
165
  });
143
166
  });
144
167
 
145
168
  proc.on('error', (err) => {
146
- if (timer) clearTimeout(timer);
147
169
  this.activeProcess = null;
148
170
  logError(`CLI process error: ${err.message}`);
149
- resolve({
171
+ settle({
150
172
  success: false,
151
173
  exitCode: -1,
152
174
  stdout,