@ghl-ai/aw 0.1.36-beta.13 ā 0.1.36-beta.15
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/commands/push.mjs +35 -13
- package/git.mjs +19 -0
- package/package.json +1 -1
package/commands/push.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
isWorktree,
|
|
19
19
|
getLocalRegistryDir,
|
|
20
20
|
commitsAheadOfMain,
|
|
21
|
+
logAheadOfMain,
|
|
21
22
|
} from '../git.mjs';
|
|
22
23
|
|
|
23
24
|
const PUSHABLE_TYPES = ['agents', 'skills', 'commands', 'evals'];
|
|
@@ -55,8 +56,26 @@ function singular(type, count) {
|
|
|
55
56
|
return count === 1 ? s : `${s}s`;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function
|
|
59
|
-
|
|
59
|
+
function extractNamespaceFromCommits(commits) {
|
|
60
|
+
// Try to extract a common namespace from commit messages like
|
|
61
|
+
// "registry: add agents/foo to revex/courses/backend"
|
|
62
|
+
const matches = commits
|
|
63
|
+
.map(c => c.message.match(/\bto\s+([\w/]+)$/))
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.map(m => m[1]);
|
|
66
|
+
if (matches.length === 0) return null;
|
|
67
|
+
const unique = [...new Set(matches)];
|
|
68
|
+
return unique.length === 1 ? unique[0] : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function generatePrTitle(files, awHome = null) {
|
|
72
|
+
if (files.length === 0) {
|
|
73
|
+
const commits = awHome ? logAheadOfMain(awHome) : [];
|
|
74
|
+
const ns = extractNamespaceFromCommits(commits);
|
|
75
|
+
return ns
|
|
76
|
+
? `feat(${ns}): push local changes`
|
|
77
|
+
: 'feat(registry): push local changes';
|
|
78
|
+
}
|
|
60
79
|
|
|
61
80
|
const namespaces = [...new Set(files.map(f => f.namespace))];
|
|
62
81
|
|
|
@@ -81,21 +100,24 @@ function generatePrTitle(files) {
|
|
|
81
100
|
return `feat(registry): ${verb} ${files.length} files across ${namespaces.length} namespaces`;
|
|
82
101
|
}
|
|
83
102
|
|
|
84
|
-
const AW_BRANDING = `---\
|
|
103
|
+
const AW_BRANDING = `---\nš¤ Generated by [AW CLI](https://github.com/GoHighLevel/ghl-agentic-workspace)`;
|
|
85
104
|
|
|
86
|
-
function generatePrBody(files, newNamespaces) {
|
|
105
|
+
function generatePrBody(files, newNamespaces, awHome = null) {
|
|
87
106
|
const added = files.filter(f => !f.deleted);
|
|
88
107
|
const deleted = files.filter(f => f.deleted);
|
|
89
108
|
const bodyParts = [];
|
|
90
109
|
|
|
91
110
|
if (files.length === 0) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
const commits = awHome ? logAheadOfMain(awHome) : [];
|
|
112
|
+
bodyParts.push('## What\'s included', '');
|
|
113
|
+
if (commits.length > 0) {
|
|
114
|
+
for (const c of commits) {
|
|
115
|
+
bodyParts.push(`- \`${c.hash}\` ${c.message}`);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
bodyParts.push('Syncing current state to registry.');
|
|
119
|
+
}
|
|
120
|
+
bodyParts.push('', AW_BRANDING);
|
|
99
121
|
return bodyParts.join('\n');
|
|
100
122
|
}
|
|
101
123
|
|
|
@@ -321,8 +343,8 @@ function doPush(files, awHome, dryRun, worktreeFlow = false, preStaged = false)
|
|
|
321
343
|
}
|
|
322
344
|
|
|
323
345
|
const commitMsg = generateCommitMsg(files);
|
|
324
|
-
const prTitle = generatePrTitle(files);
|
|
325
|
-
const prBody = generatePrBody(files, newNamespaces);
|
|
346
|
+
const prTitle = generatePrTitle(files, awHome);
|
|
347
|
+
const prBody = generatePrBody(files, newNamespaces, awHome);
|
|
326
348
|
|
|
327
349
|
const s = fmt.spinner();
|
|
328
350
|
s.start('Committing and pushing...');
|
package/git.mjs
CHANGED
|
@@ -397,6 +397,25 @@ export function commitsAheadOfMain(awHome) {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Get one-line log of commits ahead of main.
|
|
402
|
+
* Returns array of { hash, message } objects.
|
|
403
|
+
*/
|
|
404
|
+
export function logAheadOfMain(awHome) {
|
|
405
|
+
try {
|
|
406
|
+
const out = execSync(
|
|
407
|
+
`git -C "${awHome}" log ${REGISTRY_BASE_BRANCH}..HEAD --oneline`,
|
|
408
|
+
{ stdio: 'pipe', encoding: 'utf8' },
|
|
409
|
+
);
|
|
410
|
+
return out.trim().split('\n').filter(Boolean).map(line => {
|
|
411
|
+
const spaceIdx = line.indexOf(' ');
|
|
412
|
+
return { hash: line.slice(0, spaceIdx), message: line.slice(spaceIdx + 1) };
|
|
413
|
+
});
|
|
414
|
+
} catch {
|
|
415
|
+
return [];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
400
419
|
/**
|
|
401
420
|
* Get the current branch name in awHome.
|
|
402
421
|
*/
|