@wyxos/zephyr 0.8.2 → 0.8.4
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,85 @@ 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
|
+
const hasTests = paths.some((entryPath) => (
|
|
165
|
+
entryPath.startsWith('tests/')
|
|
166
|
+
|| entryPath.includes('.test.')
|
|
167
|
+
|| entryPath.includes('.spec.')
|
|
168
|
+
))
|
|
169
|
+
const hasApplicationCode = paths.some((entryPath) => (
|
|
170
|
+
['app/', 'bootstrap/', 'config/', 'database/', 'extension/', 'resources/', 'routes/'].some((prefix) => entryPath.startsWith(prefix))
|
|
171
|
+
|| entryPath.startsWith('artisan')
|
|
172
|
+
|| entryPath.startsWith('vite.config.')
|
|
173
|
+
))
|
|
174
|
+
|
|
175
|
+
if (paths.some((entryPath) => entryPath.includes('FullscreenPreviewRail'))) {
|
|
176
|
+
return 'feat: refine fullscreen preview rail'
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (paths.some((entryPath) => entryPath.includes('consumer') && entryPath.includes('dependency'))) {
|
|
180
|
+
return 'feat: support dirty consumer release chains'
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (paths.every((entryPath) => /(^README\.md$|\.md$|^docs\/)/.test(entryPath))) {
|
|
184
|
+
return 'docs: update project documentation'
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (paths.some((entryPath) => entryPath.startsWith('src/'))) {
|
|
188
|
+
return hasTests
|
|
189
|
+
? 'fix: update source behavior and tests'
|
|
190
|
+
: 'fix: update source behavior'
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (paths.some((entryPath) => /(^package\.json$|package-lock\.json$|npm-shrinkwrap\.json$)/.test(entryPath))) {
|
|
194
|
+
return 'chore: update package metadata'
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (hasApplicationCode) {
|
|
198
|
+
return hasTests
|
|
199
|
+
? 'fix: update application behavior and tests'
|
|
200
|
+
: 'fix: update application behavior'
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (hasTests) {
|
|
204
|
+
return 'test: update test coverage'
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return 'chore: update project files'
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
150
211
|
export async function suggestCommitMessage(rootDir = process.cwd(), {
|
|
151
212
|
runCommand,
|
|
152
213
|
commandExistsImpl = commandExists,
|
|
153
214
|
logStep,
|
|
154
|
-
logWarning
|
|
215
|
+
logWarning,
|
|
216
|
+
statusEntries = []
|
|
155
217
|
} = {}) {
|
|
218
|
+
const fallbackMessage = () => {
|
|
219
|
+
const message = suggestFallbackCommitMessage(statusEntries)
|
|
220
|
+
|
|
221
|
+
if (message) {
|
|
222
|
+
logWarning?.(`Using path-based fallback commit message "${message}".`)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return message
|
|
226
|
+
}
|
|
227
|
+
|
|
156
228
|
if (!commandExistsImpl('codex')) {
|
|
157
|
-
return
|
|
229
|
+
return fallbackMessage()
|
|
158
230
|
}
|
|
159
231
|
|
|
160
232
|
let tempDir = null
|
|
@@ -188,10 +260,17 @@ export async function suggestCommitMessage(rootDir = process.cwd(), {
|
|
|
188
260
|
})
|
|
189
261
|
|
|
190
262
|
const rawMessage = await readFile(outputPath, 'utf8')
|
|
191
|
-
|
|
263
|
+
const message = sanitizeSuggestedCommitMessage(rawMessage)
|
|
264
|
+
|
|
265
|
+
if (message) {
|
|
266
|
+
return message
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
logWarning?.('Codex suggested an unusable commit message.')
|
|
270
|
+
return fallbackMessage()
|
|
192
271
|
} catch (error) {
|
|
193
272
|
logWarning?.(`Codex could not suggest a commit message: ${error.message}`)
|
|
194
|
-
return
|
|
273
|
+
return fallbackMessage()
|
|
195
274
|
} finally {
|
|
196
275
|
if (tempDir) {
|
|
197
276
|
await rm(tempDir, {recursive: true, force: true}).catch(() => {})
|