@aperant/framework 0.10.0 → 0.11.0
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 +52 -0
- package/dist/cli/commands/catch-up.d.mts +9 -0
- package/dist/cli/commands/catch-up.d.mts.map +1 -0
- package/dist/cli/commands/catch-up.mjs +64 -0
- package/dist/cli/commands/catch-up.mjs.map +1 -0
- package/dist/cli/commands/pr-review.d.mts +16 -4
- package/dist/cli/commands/pr-review.d.mts.map +1 -1
- package/dist/cli/commands/pr-review.mjs +30 -11
- package/dist/cli/commands/pr-review.mjs.map +1 -1
- package/dist/cli/commands/route.d.mts.map +1 -1
- package/dist/cli/commands/route.mjs +92 -2
- package/dist/cli/commands/route.mjs.map +1 -1
- package/dist/cli/commands/validate-evidence.d.mts +1 -1
- package/dist/cli/config/share-policy.d.mts.map +1 -1
- package/dist/cli/config/share-policy.mjs +1 -0
- package/dist/cli/config/share-policy.mjs.map +1 -1
- package/dist/cli/config/upgrade-gitignore.d.mts.map +1 -1
- package/dist/cli/config/upgrade-gitignore.mjs +1 -0
- package/dist/cli/config/upgrade-gitignore.mjs.map +1 -1
- package/dist/cli/coordination/catch-up.d.mts +26 -0
- package/dist/cli/coordination/catch-up.d.mts.map +1 -0
- package/dist/cli/coordination/catch-up.mjs +239 -0
- package/dist/cli/coordination/catch-up.mjs.map +1 -0
- package/dist/cli/coordination/last-seen.d.mts +45 -0
- package/dist/cli/coordination/last-seen.d.mts.map +1 -0
- package/dist/cli/coordination/last-seen.mjs +128 -0
- package/dist/cli/coordination/last-seen.mjs.map +1 -0
- package/dist/cli/coordination/store.d.mts +15 -0
- package/dist/cli/coordination/store.d.mts.map +1 -1
- package/dist/cli/coordination/store.mjs +16 -0
- package/dist/cli/coordination/store.mjs.map +1 -1
- package/dist/cli/design/frontmatter-schema.d.mts +8 -8
- package/dist/cli/dispatch.d.mts.map +1 -1
- package/dist/cli/dispatch.mjs +2 -0
- package/dist/cli/dispatch.mjs.map +1 -1
- package/dist/cli/git/default-branch.d.mts +51 -0
- package/dist/cli/git/default-branch.d.mts.map +1 -0
- package/dist/cli/git/default-branch.mjs +234 -0
- package/dist/cli/git/default-branch.mjs.map +1 -0
- package/dist/cli/git/identity.d.mts +3 -5
- package/dist/cli/git/identity.d.mts.map +1 -1
- package/dist/cli/git/identity.mjs +10 -4
- package/dist/cli/git/identity.mjs.map +1 -1
- package/dist/cli/install/legacy-paths.d.mts.map +1 -1
- package/dist/cli/install/legacy-paths.mjs +2 -0
- package/dist/cli/install/legacy-paths.mjs.map +1 -1
- package/dist/cli/personas/sidecar.d.mts +1 -1
- package/dist/cli/roadmap/lifecycle.d.mts +1 -1
- package/dist/cli/roadmap/rollup.d.mts +2 -2
- package/dist/plugin/.claude-plugin/plugin.json +2 -1
- package/dist/plugin/skills/apt/SKILL.md +29 -0
- package/dist/plugin/skills/apt-catch-up/SKILL.md +79 -0
- package/dist/plugin/skills/apt-pr-review/SKILL.md +5 -4
- package/dist/plugin/skills/apt-setup/SKILL.md +76 -0
- package/package.json +138 -138
- package/skills/apt/SKILL.md +29 -0
- package/skills/apt-catch-up/SKILL.md +79 -0
- package/skills/apt-pr-review/SKILL.md +5 -4
- package/skills/apt-setup/SKILL.md +76 -0
- package/src/cli/commands/catch-up.mjs +67 -0
- package/src/cli/commands/pr-review.mjs +32 -11
- package/src/cli/commands/route.mjs +92 -1
- package/src/cli/config/share-policy.mjs +1 -0
- package/src/cli/config/upgrade-gitignore.mjs +1 -0
- package/src/cli/coordination/catch-up.mjs +231 -0
- package/src/cli/coordination/last-seen.mjs +131 -0
- package/src/cli/coordination/store.mjs +18 -0
- package/src/cli/dispatch.mjs +2 -0
- package/src/cli/git/default-branch.mjs +250 -0
- package/src/cli/git/identity.mjs +9 -3
- package/src/cli/install/legacy-paths.mjs +2 -0
- package/templates/config.json +11 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git/default-branch.mjs — local default-branch resolution + merged-PR parsing
|
|
3
|
+
* for the Team-Change Digest (LD-03/04/05).
|
|
4
|
+
*
|
|
5
|
+
* Pure git helpers (no .aperant IO). Every git call uses the no-throw
|
|
6
|
+
* execFileSync pattern from git/remote.mjs (stdio ['ignore','pipe','ignore'])
|
|
7
|
+
* so a non-git dir / unresolvable ref returns null instead of throwing.
|
|
8
|
+
*
|
|
9
|
+
* The resolver reads the LOCAL default-branch ref only — it NEVER calls
|
|
10
|
+
* `git fetch`. The digest surfaces work the user has actually pulled, not
|
|
11
|
+
* unfetched server state (ADR Consequences ¶1).
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { execFileSync } from 'node:child_process'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Run a git command, returning trimmed stdout or null on any error.
|
|
20
|
+
* @param {string} targetDir
|
|
21
|
+
* @param {string[]} args
|
|
22
|
+
* @returns {string|null}
|
|
23
|
+
*/
|
|
24
|
+
function git(targetDir, args) {
|
|
25
|
+
try {
|
|
26
|
+
return execFileSync('git', args, {
|
|
27
|
+
cwd: targetDir,
|
|
28
|
+
encoding: 'utf-8',
|
|
29
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
30
|
+
}).trim()
|
|
31
|
+
} catch {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the local default-branch ref, with its current sha. Resolution order:
|
|
38
|
+
* 1. `git symbolic-ref refs/remotes/origin/HEAD` (strip the
|
|
39
|
+
* 'refs/remotes/origin/' prefix);
|
|
40
|
+
* 2. `git config init.defaultBranch`;
|
|
41
|
+
* 3. existence check of `main` then `master` via `git rev-parse --verify`.
|
|
42
|
+
*
|
|
43
|
+
* NEVER fetches. Returns null outside a git repo or when nothing resolves.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} targetDir
|
|
46
|
+
* @returns {{ branch: string, sha: string }|null}
|
|
47
|
+
*/
|
|
48
|
+
export function resolveLocalDefaultBranch(targetDir) {
|
|
49
|
+
// Fast bail when not a git repo.
|
|
50
|
+
if (git(targetDir, ['rev-parse', '--git-dir']) === null) return null
|
|
51
|
+
|
|
52
|
+
let branch = null
|
|
53
|
+
|
|
54
|
+
// (1) origin/HEAD symbolic-ref — the authoritative "what main points at".
|
|
55
|
+
const originHead = git(targetDir, ['symbolic-ref', 'refs/remotes/origin/HEAD'])
|
|
56
|
+
if (originHead?.startsWith('refs/remotes/origin/')) {
|
|
57
|
+
branch = originHead.slice('refs/remotes/origin/'.length)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// (2) init.defaultBranch config.
|
|
61
|
+
if (!branch) {
|
|
62
|
+
const configured = git(targetDir, ['config', 'init.defaultBranch'])
|
|
63
|
+
if (configured) branch = configured
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// (3) existence check main → master.
|
|
67
|
+
if (!branch) {
|
|
68
|
+
for (const candidate of ['main', 'master']) {
|
|
69
|
+
if (git(targetDir, ['rev-parse', '--verify', '--quiet', candidate]) !== null) {
|
|
70
|
+
branch = candidate
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!branch) return null
|
|
77
|
+
|
|
78
|
+
const sha = git(targetDir, ['rev-parse', branch])
|
|
79
|
+
if (!sha) return null
|
|
80
|
+
|
|
81
|
+
return { branch, sha }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Parse a PR number + title from a merge-commit subject/body.
|
|
86
|
+
*
|
|
87
|
+
* GitHub merge-commit format:
|
|
88
|
+
* subject: "Merge pull request #N from owner/branch"
|
|
89
|
+
* body: "<PR title>" (first non-empty body line)
|
|
90
|
+
* Squash-merge format:
|
|
91
|
+
* subject: "<PR title> (#N)"
|
|
92
|
+
*
|
|
93
|
+
* @param {string} subject
|
|
94
|
+
* @param {string} body
|
|
95
|
+
* @returns {{ number: number, title: string }|null}
|
|
96
|
+
*/
|
|
97
|
+
function parsePullRequest(subject, body) {
|
|
98
|
+
const mergeMatch = subject.match(/^Merge pull request #(\d+) from /)
|
|
99
|
+
if (mergeMatch) {
|
|
100
|
+
const number = Number(mergeMatch[1])
|
|
101
|
+
const firstBodyLine = (body || '')
|
|
102
|
+
.split('\n')
|
|
103
|
+
.map((l) => l.trim())
|
|
104
|
+
.find((l) => l.length > 0)
|
|
105
|
+
return { number, title: firstBodyLine || subject }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// GitHub squash-merge convention: greedy `(.*)` captures the longest prefix
|
|
109
|
+
// so titles with parentheses (e.g. "feat(core): ...") are handled correctly.
|
|
110
|
+
const squashMatch = subject.match(/^(.*)\s\(#(\d+)\)\s*$/)
|
|
111
|
+
if (squashMatch) {
|
|
112
|
+
return { number: Number(squashMatch[2]), title: squashMatch[1].trim() }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Resolve both the introduced-commit author emails (LD-05) and a display name
|
|
120
|
+
* from a single `git log` call per merge. Replaces the former separate
|
|
121
|
+
* `introducedAuthorEmails` + `pickAuthorName` pair (PRF-002).
|
|
122
|
+
*
|
|
123
|
+
* @param {string} targetDir
|
|
124
|
+
* @param {string[]} parents parent shas of the merge commit
|
|
125
|
+
* @param {string} authorEmail the merge commit's own author email
|
|
126
|
+
* @param {string} currentUserEmail the user's git email (for name picking)
|
|
127
|
+
* @param {string} fallbackName merge/commit author name when no better pick
|
|
128
|
+
* @returns {{ emails: string[], authorName: string }}
|
|
129
|
+
*/
|
|
130
|
+
function resolveIntroducedAuthors(targetDir, parents, authorEmail, currentUserEmail, fallbackName) {
|
|
131
|
+
if (parents.length >= 2) {
|
|
132
|
+
const raw = git(targetDir, ['log', `${parents[0]}..${parents[1]}`, '--format=%ae%x1f%an'])
|
|
133
|
+
if (raw) {
|
|
134
|
+
const emails = new Set()
|
|
135
|
+
let pickedName = null
|
|
136
|
+
for (const line of raw.split('\n')) {
|
|
137
|
+
const [email, name] = line.split('\x1f')
|
|
138
|
+
if (!email) continue
|
|
139
|
+
const normEmail = email.trim().toLowerCase()
|
|
140
|
+
if (normEmail.length > 0) emails.add(normEmail)
|
|
141
|
+
if (!pickedName && normEmail !== currentUserEmail) {
|
|
142
|
+
pickedName = (name || fallbackName).trim()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (emails.size > 0) {
|
|
146
|
+
return { emails: [...emails], authorName: pickedName || fallbackName.trim() }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const own = authorEmail.trim().toLowerCase()
|
|
151
|
+
return {
|
|
152
|
+
emails: own.length > 0 ? [own] : [],
|
|
153
|
+
authorName: fallbackName.trim(),
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* List merged PRs on the local default branch since `sinceSha`, attributed to
|
|
159
|
+
* whoever actually wrote the work (LD-04/05).
|
|
160
|
+
*
|
|
161
|
+
* Walks `git log --first-parent <sinceSha>..<defaultBranch>`. Each commit that
|
|
162
|
+
* parses as a PR (merge-commit or squash form) becomes one entry, attributed
|
|
163
|
+
* via its introduced-commit author emails. An entry is excluded only when ALL
|
|
164
|
+
* its introduced emails equal `currentUserEmail` (the user's own work) — so a
|
|
165
|
+
* PR the user merged but a teammate authored still appears.
|
|
166
|
+
*
|
|
167
|
+
* The scan is bounded (R3): at most `maxEntries * SCAN_MULTIPLIER` commits are
|
|
168
|
+
* inspected, so a stale marker can't enumerate an unbounded history.
|
|
169
|
+
*
|
|
170
|
+
* @param {string} targetDir
|
|
171
|
+
* @param {object} opts
|
|
172
|
+
* @param {string} opts.sinceSha baseline sha (exclusive lower bound)
|
|
173
|
+
* @param {string} [opts.defaultBranch] branch to walk to (default: resolved)
|
|
174
|
+
* @param {string} opts.currentUserEmail the user's git email (own-work filter)
|
|
175
|
+
* @param {number} [opts.maxEntries=7] cap on returned entries
|
|
176
|
+
* @returns {{ entries: Array<{ number: number, title: string, author: string }>, more_count: number }}
|
|
177
|
+
*/
|
|
178
|
+
export function listMergedPullRequests(targetDir, opts = {}) {
|
|
179
|
+
const empty = { entries: [], more_count: 0, more_capped: false }
|
|
180
|
+
const sinceSha = opts.sinceSha
|
|
181
|
+
const maxEntries = Number.isInteger(opts.maxEntries) && opts.maxEntries > 0 ? opts.maxEntries : 7
|
|
182
|
+
const currentUserEmail = (opts.currentUserEmail || '').trim().toLowerCase()
|
|
183
|
+
|
|
184
|
+
let defaultBranch = opts.defaultBranch
|
|
185
|
+
if (!defaultBranch) {
|
|
186
|
+
const resolved = resolveLocalDefaultBranch(targetDir)
|
|
187
|
+
if (!resolved) return empty
|
|
188
|
+
defaultBranch = resolved.branch
|
|
189
|
+
}
|
|
190
|
+
if (!sinceSha) return empty
|
|
191
|
+
if (!/^[0-9a-f]{7,40}$/i.test(sinceSha)) return empty
|
|
192
|
+
|
|
193
|
+
const SCAN_MULTIPLIER = 4
|
|
194
|
+
const scanCap = maxEntries * SCAN_MULTIPLIER
|
|
195
|
+
|
|
196
|
+
// One commit per record, fields separated by \x1f, records by \x1e.
|
|
197
|
+
// %H sha · %P parents · %an author name · %ae author email · %s subject · %b body
|
|
198
|
+
const FIELD = '\x1f'
|
|
199
|
+
const RECORD = '\x1e'
|
|
200
|
+
const format = `%H${FIELD}%P${FIELD}%an${FIELD}%ae${FIELD}%s${FIELD}%b${RECORD}`
|
|
201
|
+
const raw = git(targetDir, [
|
|
202
|
+
'log',
|
|
203
|
+
'--first-parent',
|
|
204
|
+
`--max-count=${scanCap}`,
|
|
205
|
+
`--format=${format}`,
|
|
206
|
+
`${sinceSha}..${defaultBranch}`,
|
|
207
|
+
])
|
|
208
|
+
if (!raw) return empty
|
|
209
|
+
|
|
210
|
+
const records = raw
|
|
211
|
+
.split(RECORD)
|
|
212
|
+
.map((r) => r.replace(/^\n+/, ''))
|
|
213
|
+
.filter((r) => r.trim().length > 0)
|
|
214
|
+
|
|
215
|
+
const matched = []
|
|
216
|
+
for (const rec of records) {
|
|
217
|
+
const [sha, parentsRaw, authorName, authorEmail, subject, body] = rec.split(FIELD)
|
|
218
|
+
if (!sha) continue
|
|
219
|
+
const pr = parsePullRequest(subject || '', body || '')
|
|
220
|
+
if (!pr) continue
|
|
221
|
+
|
|
222
|
+
const parents = (parentsRaw || '').trim().split(/\s+/).filter(Boolean)
|
|
223
|
+
const { emails, authorName: resolvedAuthor } = resolveIntroducedAuthors(
|
|
224
|
+
targetDir,
|
|
225
|
+
parents,
|
|
226
|
+
authorEmail || '',
|
|
227
|
+
currentUserEmail,
|
|
228
|
+
authorName || 'unknown',
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
// Exclude only when EVERY introduced commit is the current user's own.
|
|
232
|
+
const allOwn =
|
|
233
|
+
currentUserEmail.length > 0 &&
|
|
234
|
+
emails.length > 0 &&
|
|
235
|
+
emails.every((e) => e === currentUserEmail)
|
|
236
|
+
if (allOwn) continue
|
|
237
|
+
|
|
238
|
+
matched.push({ number: pr.number, title: pr.title, author: resolvedAuthor })
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const more_capped = records.length >= scanCap
|
|
242
|
+
if (matched.length <= maxEntries) {
|
|
243
|
+
return { entries: matched, more_count: 0, more_capped }
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
entries: matched.slice(0, maxEntries),
|
|
247
|
+
more_count: matched.length - maxEntries,
|
|
248
|
+
more_capped,
|
|
249
|
+
}
|
|
250
|
+
}
|
package/src/cli/git/identity.mjs
CHANGED
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { execSync } from 'node:child_process'
|
|
6
6
|
|
|
7
|
+
const _identityCache = new Map()
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Auto-detect the current user's git identity. Returns null if git config is unset.
|
|
11
|
+
* Memoized per targetDir for the process lifetime (git identity is stable within a CLI invocation).
|
|
9
12
|
*/
|
|
10
13
|
export function getGitIdentity(targetDir) {
|
|
14
|
+
if (_identityCache.has(targetDir)) return _identityCache.get(targetDir)
|
|
15
|
+
let result = null
|
|
11
16
|
try {
|
|
12
17
|
const name = execSync('git config user.name 2>/dev/null', {
|
|
13
18
|
cwd: targetDir,
|
|
@@ -17,11 +22,12 @@ export function getGitIdentity(targetDir) {
|
|
|
17
22
|
cwd: targetDir,
|
|
18
23
|
encoding: 'utf-8',
|
|
19
24
|
}).trim()
|
|
20
|
-
if (
|
|
21
|
-
return { name, email }
|
|
25
|
+
if (name && email) result = { name, email }
|
|
22
26
|
} catch {
|
|
23
|
-
|
|
27
|
+
/* no git config — result stays null */
|
|
24
28
|
}
|
|
29
|
+
_identityCache.set(targetDir, result)
|
|
30
|
+
return result
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
/**
|
|
@@ -88,6 +88,7 @@ export const LEGACY_INSTALL_PATHS = Object.freeze({
|
|
|
88
88
|
'agents/apt.md',
|
|
89
89
|
'agents/apt-author-skill.md',
|
|
90
90
|
'agents/apt-bootstrap.md',
|
|
91
|
+
'agents/apt-catch-up.md',
|
|
91
92
|
'agents/apt-caveman.md',
|
|
92
93
|
'agents/apt-classify.md',
|
|
93
94
|
'agents/apt-close-task.md',
|
|
@@ -131,6 +132,7 @@ export const LEGACY_INSTALL_PATHS = Object.freeze({
|
|
|
131
132
|
'commands/apt.md',
|
|
132
133
|
'commands/apt-author-skill.md',
|
|
133
134
|
'commands/apt-bootstrap.md',
|
|
135
|
+
'commands/apt-catch-up.md',
|
|
134
136
|
'commands/apt-caveman.md',
|
|
135
137
|
'commands/apt-classify.md',
|
|
136
138
|
'commands/apt-close-task.md',
|
package/templates/config.json
CHANGED
|
@@ -97,6 +97,17 @@
|
|
|
97
97
|
"interval_minutes": 30
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
+
"collaboration": {
|
|
101
|
+
"$comment": "Collaboration catch-up surfaces shown on interactive (TTY) apt calls — Welcome-Back Summary (your half-finished work, always-on) + Team-Change Digest (teammates' merged PRs since your last pull, gated to share.visibility team/oss). Tune via /apt:setup. See packages/framework/CONTEXT.md + docs/adr/0001-collaboration-summaries-from-git-not-event-log.md.",
|
|
102
|
+
"welcome_back": {
|
|
103
|
+
"enabled": true,
|
|
104
|
+
"threshold_hours": 16
|
|
105
|
+
},
|
|
106
|
+
"team_digest": {
|
|
107
|
+
"enabled": true,
|
|
108
|
+
"max_entries": 7
|
|
109
|
+
}
|
|
110
|
+
},
|
|
100
111
|
"orchestration": {
|
|
101
112
|
"phase_delegation": "auto",
|
|
102
113
|
"review_mode": "auto",
|