@link-assistant/hive-mind 1.78.2 → 1.78.3
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 +6 -0
- package/package.json +1 -1
- package/src/github.lib.mjs +1 -1
- package/src/log-upload.lib.mjs +66 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 1.78.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b346808: Use the latest gh-upload-log package for attached log uploads and rely on its default auto mode/shared repository fallback instead of passing explicit strategy flags.
|
|
8
|
+
|
|
3
9
|
## 1.78.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/src/github.lib.mjs
CHANGED
|
@@ -631,7 +631,7 @@ ${logContent}
|
|
|
631
631
|
// Use the original sanitized content for upload since it's a plain text file
|
|
632
632
|
await fs.writeFile(tempLogFile, await sanitizeLogContent(rawLogContent));
|
|
633
633
|
|
|
634
|
-
// Use gh-upload-log
|
|
634
|
+
// Use gh-upload-log default auto mode and shared repository fallback.
|
|
635
635
|
const uploadDescription = `Solution draft log for https://github.com/${owner}/${repo}/${targetType === 'pr' ? 'pull' : 'issues'}/${targetNumber}`;
|
|
636
636
|
const uploadResult = await uploadLogWithGhUploadLog({
|
|
637
637
|
logFile: tempLogFile,
|
package/src/log-upload.lib.mjs
CHANGED
|
@@ -28,6 +28,63 @@ const summarizeCommandOutput = value => {
|
|
|
28
28
|
return text.length > 500 ? `${text.slice(0, 500)}... [truncated ${text.length - 500} chars]` : text;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
export const buildGhUploadLogArgs = ({ logFile, isPublic, description, verbose = false }) => {
|
|
32
|
+
if (!logFile) {
|
|
33
|
+
throw new Error('logFile is required for gh-upload-log');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const args = [logFile, isPublic ? '--public' : '--private'];
|
|
37
|
+
|
|
38
|
+
if (description) {
|
|
39
|
+
args.push('--description', description);
|
|
40
|
+
}
|
|
41
|
+
if (verbose) {
|
|
42
|
+
args.push('--verbose');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return args;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const quoteShellArg = value => {
|
|
49
|
+
const text = String(value);
|
|
50
|
+
if (/^[A-Za-z0-9_./:=@+-]+$/u.test(text)) return text;
|
|
51
|
+
return `"${text.replace(/(["\\$`])/gu, '\\$1')}"`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const formatGhUploadLogCommand = args => `gh-upload-log ${args.map(quoteShellArg).join(' ')}`;
|
|
55
|
+
|
|
56
|
+
const runGhUploadLogCommand = async args => {
|
|
57
|
+
const { spawn } = await use('child_process');
|
|
58
|
+
|
|
59
|
+
return new Promise(resolve => {
|
|
60
|
+
const child = spawn('gh-upload-log', args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
61
|
+
let stdout = '';
|
|
62
|
+
let stderr = '';
|
|
63
|
+
let settled = false;
|
|
64
|
+
|
|
65
|
+
const settle = value => {
|
|
66
|
+
if (!settled) {
|
|
67
|
+
settled = true;
|
|
68
|
+
resolve(value);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
child.stdout?.on('data', chunk => {
|
|
73
|
+
stdout += chunk.toString();
|
|
74
|
+
});
|
|
75
|
+
child.stderr?.on('data', chunk => {
|
|
76
|
+
stderr += chunk.toString();
|
|
77
|
+
});
|
|
78
|
+
child.on('error', error => {
|
|
79
|
+
const errorText = stderr ? `${stderr}\n${error.message}` : error.message;
|
|
80
|
+
settle({ code: error.code === 'ENOENT' ? 127 : 1, stdout, stderr: errorText });
|
|
81
|
+
});
|
|
82
|
+
child.on('close', code => {
|
|
83
|
+
settle({ code: code ?? 1, stdout, stderr });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
31
88
|
export const parseGhUploadLogOutput = outputValue => {
|
|
32
89
|
const output = outputValue?.toString?.() || '';
|
|
33
90
|
const parsed = {
|
|
@@ -89,30 +146,18 @@ export const uploadLogWithGhUploadLog = async ({ logFile, isPublic, description,
|
|
|
89
146
|
const result = { success: false, url: null, rawUrl: null, type: null, chunks: 1 };
|
|
90
147
|
|
|
91
148
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
149
|
+
const commandArgs = buildGhUploadLogArgs({
|
|
150
|
+
logFile,
|
|
151
|
+
isPublic,
|
|
152
|
+
description,
|
|
153
|
+
verbose,
|
|
154
|
+
});
|
|
98
155
|
|
|
99
156
|
if (verbose) {
|
|
100
|
-
|
|
101
|
-
await log(` 📤 Running: gh-upload-log "${logFile}" ${publicFlag}${descDisplay} --verbose`, { verbose: true });
|
|
157
|
+
await log(` 📤 Running: ${formatGhUploadLogCommand(commandArgs)}`, { verbose: true });
|
|
102
158
|
}
|
|
103
159
|
|
|
104
|
-
|
|
105
|
-
// Each ${} is properly passed as a separate argument to the shell
|
|
106
|
-
let uploadResult;
|
|
107
|
-
if (description && verbose) {
|
|
108
|
-
uploadResult = await $`gh-upload-log ${logFile} ${publicFlag} --description ${description} --verbose`;
|
|
109
|
-
} else if (description) {
|
|
110
|
-
uploadResult = await $`gh-upload-log ${logFile} ${publicFlag} --description ${description}`;
|
|
111
|
-
} else if (verbose) {
|
|
112
|
-
uploadResult = await $`gh-upload-log ${logFile} ${publicFlag} --verbose`;
|
|
113
|
-
} else {
|
|
114
|
-
uploadResult = await $`gh-upload-log ${logFile} ${publicFlag}`;
|
|
115
|
-
}
|
|
160
|
+
const uploadResult = await runGhUploadLogCommand(commandArgs);
|
|
116
161
|
const output = (uploadResult.stdout?.toString() || '') + (uploadResult.stderr?.toString() || '');
|
|
117
162
|
|
|
118
163
|
if (uploadResult.code !== 0) {
|
|
@@ -252,5 +297,6 @@ export const uploadLogWithGhUploadLog = async ({ logFile, isPublic, description,
|
|
|
252
297
|
// Export all functions as default object too
|
|
253
298
|
export default {
|
|
254
299
|
parseGhUploadLogOutput,
|
|
300
|
+
buildGhUploadLogArgs,
|
|
255
301
|
uploadLogWithGhUploadLog,
|
|
256
302
|
};
|