@wyxos/zephyr 0.8.2 → 0.8.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/package.json
CHANGED
|
@@ -15,6 +15,7 @@ const GENERIC_SUBJECT_PATTERNS = [
|
|
|
15
15
|
/^stage and commit (all )?(current |pending )?changes( before .+)?$/i,
|
|
16
16
|
/^(allow|enable|support) committing pending changes( before .+)?$/i,
|
|
17
17
|
/^commit changes$/i,
|
|
18
|
+
/^no pending changes$/i,
|
|
18
19
|
/^update changes$/i,
|
|
19
20
|
/^update files$/i,
|
|
20
21
|
/^update work$/i,
|
|
@@ -147,14 +148,63 @@ export function sanitizeSuggestedCommitMessage(message) {
|
|
|
147
148
|
return normalized
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
function getStatusPaths(statusEntries = []) {
|
|
152
|
+
return statusEntries
|
|
153
|
+
.map((entry) => entry?.path)
|
|
154
|
+
.filter((entryPath) => typeof entryPath === 'string' && entryPath.length > 0)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function suggestFallbackCommitMessage(statusEntries = []) {
|
|
158
|
+
const paths = getStatusPaths(statusEntries)
|
|
159
|
+
|
|
160
|
+
if (paths.length === 0) {
|
|
161
|
+
return null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (paths.some((entryPath) => entryPath.includes('FullscreenPreviewRail'))) {
|
|
165
|
+
return 'feat: refine fullscreen preview rail'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (paths.some((entryPath) => entryPath.includes('consumer') && entryPath.includes('dependency'))) {
|
|
169
|
+
return 'feat: support dirty consumer release chains'
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (paths.every((entryPath) => /(^README\.md$|\.md$|^docs\/)/.test(entryPath))) {
|
|
173
|
+
return 'docs: update project documentation'
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (paths.some((entryPath) => entryPath.startsWith('src/'))) {
|
|
177
|
+
return paths.some((entryPath) => entryPath.startsWith('tests/') || entryPath.includes('.test.'))
|
|
178
|
+
? 'fix: update source behavior and tests'
|
|
179
|
+
: 'fix: update source behavior'
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (paths.some((entryPath) => /(^package\.json$|package-lock\.json$|npm-shrinkwrap\.json$)/.test(entryPath))) {
|
|
183
|
+
return 'chore: update package metadata'
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return null
|
|
187
|
+
}
|
|
188
|
+
|
|
150
189
|
export async function suggestCommitMessage(rootDir = process.cwd(), {
|
|
151
190
|
runCommand,
|
|
152
191
|
commandExistsImpl = commandExists,
|
|
153
192
|
logStep,
|
|
154
|
-
logWarning
|
|
193
|
+
logWarning,
|
|
194
|
+
statusEntries = []
|
|
155
195
|
} = {}) {
|
|
196
|
+
const fallbackMessage = () => {
|
|
197
|
+
const message = suggestFallbackCommitMessage(statusEntries)
|
|
198
|
+
|
|
199
|
+
if (message) {
|
|
200
|
+
logWarning?.(`Using path-based fallback commit message "${message}".`)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return message
|
|
204
|
+
}
|
|
205
|
+
|
|
156
206
|
if (!commandExistsImpl('codex')) {
|
|
157
|
-
return
|
|
207
|
+
return fallbackMessage()
|
|
158
208
|
}
|
|
159
209
|
|
|
160
210
|
let tempDir = null
|
|
@@ -188,10 +238,17 @@ export async function suggestCommitMessage(rootDir = process.cwd(), {
|
|
|
188
238
|
})
|
|
189
239
|
|
|
190
240
|
const rawMessage = await readFile(outputPath, 'utf8')
|
|
191
|
-
|
|
241
|
+
const message = sanitizeSuggestedCommitMessage(rawMessage)
|
|
242
|
+
|
|
243
|
+
if (message) {
|
|
244
|
+
return message
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
logWarning?.('Codex suggested an unusable commit message.')
|
|
248
|
+
return fallbackMessage()
|
|
192
249
|
} catch (error) {
|
|
193
250
|
logWarning?.(`Codex could not suggest a commit message: ${error.message}`)
|
|
194
|
-
return
|
|
251
|
+
return fallbackMessage()
|
|
195
252
|
} finally {
|
|
196
253
|
if (tempDir) {
|
|
197
254
|
await rm(tempDir, {recursive: true, force: true}).catch(() => {})
|