@aperant/framework 0.6.4 → 0.6.5
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 +38 -0
- package/README.md +64 -10
- package/agents/apt-improver.md +99 -0
- package/agents/apt-planner.md +115 -10
- package/dist/__test-helpers/run-cmd.d.mts +4 -2
- package/dist/__test-helpers/run-cmd.d.mts.map +1 -1
- package/dist/__test-helpers/run-cmd.mjs +56 -15
- package/dist/__test-helpers/run-cmd.mjs.map +1 -1
- package/dist/cli/ci-watch/lock.d.mts +53 -0
- package/dist/cli/ci-watch/lock.d.mts.map +1 -0
- package/dist/cli/ci-watch/lock.mjs +172 -0
- package/dist/cli/ci-watch/lock.mjs.map +1 -0
- package/dist/cli/ci-watch/state.d.mts +36 -0
- package/dist/cli/ci-watch/state.d.mts.map +1 -0
- package/dist/cli/ci-watch/state.mjs +103 -0
- package/dist/cli/ci-watch/state.mjs.map +1 -0
- package/dist/cli/ci-watch/stop-matrix.d.mts +58 -0
- package/dist/cli/ci-watch/stop-matrix.d.mts.map +1 -0
- package/dist/cli/ci-watch/stop-matrix.mjs +164 -0
- package/dist/cli/ci-watch/stop-matrix.mjs.map +1 -0
- package/dist/cli/cli-wrappers/ci-watch.d.mts +2 -0
- package/dist/cli/cli-wrappers/ci-watch.d.mts.map +1 -0
- package/dist/cli/cli-wrappers/ci-watch.mjs +9 -0
- package/dist/cli/cli-wrappers/ci-watch.mjs.map +1 -0
- package/dist/cli/commands/adr.d.mts +5 -0
- package/dist/cli/commands/adr.d.mts.map +1 -0
- package/dist/cli/commands/adr.mjs +228 -0
- package/dist/cli/commands/adr.mjs.map +1 -0
- package/dist/cli/commands/ci-watch.d.mts +7 -0
- package/dist/cli/commands/ci-watch.d.mts.map +1 -0
- package/dist/cli/commands/ci-watch.mjs +465 -0
- package/dist/cli/commands/ci-watch.mjs.map +1 -0
- package/dist/cli/commands/context.d.mts +7 -0
- package/dist/cli/commands/context.d.mts.map +1 -0
- package/dist/cli/commands/context.mjs +224 -0
- package/dist/cli/commands/context.mjs.map +1 -0
- package/dist/cli/commands/event.d.mts.map +1 -1
- package/dist/cli/commands/event.mjs +59 -24
- package/dist/cli/commands/event.mjs.map +1 -1
- package/dist/cli/commands/host-detect.d.mts +1 -1
- package/dist/cli/commands/host-detect.d.mts.map +1 -1
- package/dist/cli/commands/host-detect.mjs +30 -3
- package/dist/cli/commands/host-detect.mjs.map +1 -1
- package/dist/cli/commands/modes.d.mts +13 -0
- package/dist/cli/commands/modes.d.mts.map +1 -0
- package/dist/cli/commands/modes.mjs +220 -0
- package/dist/cli/commands/modes.mjs.map +1 -0
- package/dist/cli/commands/route.mjs +1 -1
- package/dist/cli/commands/route.mjs.map +1 -1
- package/dist/cli/commands/task.d.mts.map +1 -1
- package/dist/cli/commands/task.mjs +108 -6
- package/dist/cli/commands/task.mjs.map +1 -1
- package/dist/cli/commands/tokens.d.mts.map +1 -1
- package/dist/cli/commands/tokens.mjs +150 -6
- package/dist/cli/commands/tokens.mjs.map +1 -1
- package/dist/cli/commands/triage.d.mts +8 -0
- package/dist/cli/commands/triage.d.mts.map +1 -0
- package/dist/cli/commands/triage.mjs +259 -0
- package/dist/cli/commands/triage.mjs.map +1 -0
- package/dist/cli/config/post-merge-sweep.d.mts +18 -0
- package/dist/cli/config/post-merge-sweep.d.mts.map +1 -1
- package/dist/cli/config/post-merge-sweep.mjs +48 -3
- package/dist/cli/config/post-merge-sweep.mjs.map +1 -1
- package/dist/cli/consistency/registry.d.mts +11 -0
- package/dist/cli/consistency/registry.d.mts.map +1 -1
- package/dist/cli/consistency/registry.mjs +13 -0
- package/dist/cli/consistency/registry.mjs.map +1 -1
- package/dist/cli/coordination/agent-identity.d.mts +9 -0
- package/dist/cli/coordination/agent-identity.d.mts.map +1 -1
- package/dist/cli/coordination/agent-identity.mjs +11 -0
- package/dist/cli/coordination/agent-identity.mjs.map +1 -1
- package/dist/cli/coordination/event-log.d.mts +27 -0
- package/dist/cli/coordination/event-log.d.mts.map +1 -1
- package/dist/cli/coordination/event-log.mjs +72 -2
- package/dist/cli/coordination/event-log.mjs.map +1 -1
- package/dist/cli/dispatch.d.mts.map +1 -1
- package/dist/cli/dispatch.mjs +14 -1
- package/dist/cli/dispatch.mjs.map +1 -1
- package/dist/cli/gate/registry.d.mts +11 -0
- package/dist/cli/gate/registry.d.mts.map +1 -1
- package/dist/cli/gate/registry.mjs +13 -0
- package/dist/cli/gate/registry.mjs.map +1 -1
- package/dist/cli/help.d.mts.map +1 -1
- package/dist/cli/help.mjs +1 -0
- package/dist/cli/help.mjs.map +1 -1
- package/dist/cli/host/detect.d.mts +1 -0
- package/dist/cli/host/detect.d.mts.map +1 -1
- package/dist/cli/host/detect.mjs +5 -0
- package/dist/cli/host/detect.mjs.map +1 -1
- package/dist/cli/route/envelope.d.mts +68 -4
- package/dist/cli/route/envelope.d.mts.map +1 -1
- package/dist/cli/route/envelope.mjs +140 -103
- package/dist/cli/route/envelope.mjs.map +1 -1
- package/dist/cli/route/skill-discover.d.mts +9 -0
- package/dist/cli/route/skill-discover.d.mts.map +1 -1
- package/dist/cli/route/skill-discover.mjs +11 -0
- package/dist/cli/route/skill-discover.mjs.map +1 -1
- package/dist/cli/skill-author/contract.d.mts +1 -0
- package/dist/cli/skill-author/contract.d.mts.map +1 -1
- package/dist/cli/skill-author/contract.mjs +7 -0
- package/dist/cli/skill-author/contract.mjs.map +1 -1
- package/dist/cli/task/worktree-cleanup.d.mts +9 -1
- package/dist/cli/task/worktree-cleanup.d.mts.map +1 -1
- package/dist/cli/task/worktree-cleanup.mjs +190 -9
- package/dist/cli/task/worktree-cleanup.mjs.map +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/agents/apt-planner.md +1 -1
- package/dist/plugin/skills/apt/SKILL.md +111 -5
- package/dist/plugin/skills/apt-author-skill/SKILL.md +11 -0
- package/dist/plugin/skills/apt-bootstrap/SKILL.md +1 -0
- package/dist/plugin/skills/apt-classify/SKILL.md +1 -0
- package/dist/plugin/skills/apt-close-task/SKILL.md +1 -0
- package/dist/plugin/skills/apt-create-docs/SKILL.md +1 -0
- package/dist/plugin/skills/apt-debug/SKILL.md +2 -0
- package/dist/plugin/skills/apt-design/SKILL.md +2 -0
- package/dist/plugin/skills/apt-discuss/SKILL.md +2 -0
- package/dist/plugin/skills/apt-docs/SKILL.md +2 -0
- package/dist/plugin/skills/apt-execute/SKILL.md +1 -0
- package/dist/plugin/skills/apt-mockup/SKILL.md +2 -0
- package/dist/plugin/skills/apt-pause/SKILL.md +1 -0
- package/dist/plugin/skills/apt-personas/SKILL.md +1 -0
- package/dist/plugin/skills/apt-plan/SKILL.md +2 -0
- package/dist/plugin/skills/apt-pr-review/SKILL.md +1 -0
- package/dist/plugin/skills/apt-quick/SKILL.md +2 -0
- package/dist/plugin/skills/apt-resume/SKILL.md +1 -0
- package/dist/plugin/skills/apt-review/SKILL.md +1 -0
- package/dist/plugin/skills/apt-roadmap/SKILL.md +1 -0
- package/dist/plugin/skills/apt-roundtable/SKILL.md +2 -0
- package/dist/plugin/skills/apt-run/SKILL.md +1 -0
- package/dist/plugin/skills/apt-scan/SKILL.md +1 -0
- package/dist/plugin/skills/apt-setup/SKILL.md +1 -0
- package/dist/plugin/skills/apt-ship/SKILL.md +6 -5
- package/dist/plugin/skills/apt-stress-test/SKILL.md +1 -0
- package/dist/plugin/skills/apt-terminal/SKILL.md +1 -0
- package/dist/plugin/skills/apt-update/SKILL.md +5 -0
- package/dist/plugin/skills/apt-verify/SKILL.md +1 -0
- package/dist/plugin/skills/apt-verify-proof/SKILL.md +1 -0
- package/dist/types/config.d.ts +85 -0
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +125 -125
- package/prompts/coder.md +2 -0
- package/prompts/planner.md +12 -0
- package/prompts/spec_writer.md +9 -0
- package/skills/apt/SKILL.md +1 -0
- package/skills/apt-close-task/SKILL.md +32 -1
- package/skills/apt-debug/SKILL.md +39 -6
- package/skills/apt-debug/appendices/diagnose-discipline.md +119 -0
- package/skills/apt-diagram/SKILL.md +342 -0
- package/skills/apt-diagram/appendices/design-discipline.md +97 -0
- package/skills/apt-discuss/SKILL.md +25 -0
- package/skills/apt-discuss/appendices/grill-discipline.md +104 -0
- package/skills/apt-discuss/appendices/zoom-out-helper.md +79 -0
- package/skills/apt-execute/SKILL.md +48 -5
- package/skills/apt-execute/appendices/tdd-mode.md +107 -0
- package/skills/apt-improve/DEEPENING.md +84 -0
- package/skills/apt-improve/INTERFACE-DESIGN.md +97 -0
- package/skills/apt-improve/LANGUAGE.md +104 -0
- package/skills/apt-improve/SKILL.md +141 -0
- package/skills/apt-plan/SKILL.md +147 -4
- package/skills/apt-planner.md +42 -1
- package/skills/apt-pr-review/SKILL.md +46 -16
- package/skills/apt-prototype/LOGIC.md +109 -0
- package/skills/apt-prototype/SKILL.md +143 -0
- package/skills/apt-prototype/UI.md +90 -0
- package/skills/apt-quick/SKILL.md +30 -0
- package/skills/apt-review/SKILL.md +2 -0
- package/skills/apt-run/SKILL.md +32 -4
- package/skills/apt-setup/SKILL.md +128 -2
- package/skills/apt-ship/SKILL.md +47 -0
- package/skills/apt-triage/AGENT-BRIEF.md +84 -0
- package/skills/apt-triage/OUT-OF-SCOPE.md +75 -0
- package/skills/apt-triage/SKILL.md +169 -0
- package/skills/apt-verify/SKILL.md +3 -0
- package/skills/apt-verify-proof/SKILL.md +3 -0
- package/skills/apt-watch-ci/SKILL.md +163 -0
- package/skills/apt-zoom-out/SKILL.md +130 -0
- package/src/cli/ci-watch/lock.mjs +178 -0
- package/src/cli/ci-watch/state.mjs +103 -0
- package/src/cli/ci-watch/stop-matrix.mjs +181 -0
- package/src/cli/cli-wrappers/ci-watch.mjs +9 -0
- package/src/cli/commands/adr.mjs +243 -0
- package/src/cli/commands/ci-watch.mjs +503 -0
- package/src/cli/commands/context.mjs +244 -0
- package/src/cli/commands/event.mjs +63 -24
- package/src/cli/commands/host-detect.mjs +33 -7
- package/src/cli/commands/modes.mjs +215 -0
- package/src/cli/commands/route.mjs +1 -1
- package/src/cli/commands/task.mjs +125 -18
- package/src/cli/commands/tokens.mjs +157 -6
- package/src/cli/commands/triage.mjs +277 -0
- package/src/cli/config/post-merge-sweep.mjs +49 -3
- package/src/cli/consistency/registry.mjs +14 -0
- package/src/cli/coordination/agent-identity.mjs +12 -0
- package/src/cli/coordination/event-log.mjs +73 -2
- package/src/cli/dispatch.mjs +15 -1
- package/src/cli/gate/registry.mjs +14 -0
- package/src/cli/help.mjs +1 -0
- package/src/cli/host/detect.mjs +5 -0
- package/src/cli/route/envelope.mjs +140 -106
- package/src/cli/route/skill-discover.mjs +12 -0
- package/src/cli/skill-author/contract.mjs +7 -0
- package/src/cli/task/worktree-cleanup.mjs +191 -9
- package/templates/adr-format.md +56 -0
- package/templates/config.json +4 -0
- package/templates/context-format.md +34 -0
|
@@ -10,13 +10,84 @@
|
|
|
10
10
|
* 'auto' → merge back into base_branch, then remove the worktree + branch
|
|
11
11
|
*/
|
|
12
12
|
import { execFileSync } from 'node:child_process';
|
|
13
|
+
/**
|
|
14
|
+
* Truncate a thrown git error to its first 3 stderr/message lines for
|
|
15
|
+
* surfacing in cleanup envelopes. Extracted from the original inline
|
|
16
|
+
* duplication at the auto-mode merge-error catch.
|
|
17
|
+
*
|
|
18
|
+
* @param {unknown} err
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
function shortErr(err) {
|
|
22
|
+
return (err?.stderr || err?.message || '').toString().trim().split('\n').slice(0, 3).join(' ');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sanitize an error message for inclusion in returned envelopes: first line
|
|
26
|
+
* only, absolute paths replaced with a placeholder to avoid leaking local
|
|
27
|
+
* filesystem layout.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} msg
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
function sanitizeErrMsg(msg) {
|
|
33
|
+
return msg
|
|
34
|
+
.split('\n')[0]
|
|
35
|
+
.replace(/\/[^\s:'"]+/g, '<path>')
|
|
36
|
+
.trim();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run `git <args>` with up to 3 attempts and ~200ms backoff when the
|
|
40
|
+
* thrown error's stderr names `.git/index.lock`. Other errors propagate
|
|
41
|
+
* on the first failure. Two concurrent `task close-merged` invocations
|
|
42
|
+
* from different terminals race on git's internal index.lock;
|
|
43
|
+
* retry-on-EEXIST handles that without an app-level mutex (which
|
|
44
|
+
* wouldn't prevent the underlying git race anyway).
|
|
45
|
+
*
|
|
46
|
+
* Sleep uses the same Atomics.wait pattern as withFileLock in
|
|
47
|
+
* util/fs-lock.mjs to park the event loop without spinning the CPU.
|
|
48
|
+
*
|
|
49
|
+
* @param {string[]} args
|
|
50
|
+
* @param {object} opts - forwarded to execFileSync
|
|
51
|
+
* @returns {string} stdout
|
|
52
|
+
*/
|
|
53
|
+
function runGitWithRetry(args, opts) {
|
|
54
|
+
const maxAttempts = 3;
|
|
55
|
+
const backoffMs = 200;
|
|
56
|
+
let lastErr = null;
|
|
57
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
58
|
+
try {
|
|
59
|
+
return execFileSync('git', args, opts);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
lastErr = err;
|
|
63
|
+
const stderrText = String(err?.stderr ?? '');
|
|
64
|
+
if (!/index\.lock/i.test(stderrText) || attempt === maxAttempts) {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, backoffMs);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
/* runtime without SharedArrayBuffer — fall through, retry immediately */
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Unreachable — the loop either returns or throws.
|
|
76
|
+
throw lastErr;
|
|
77
|
+
}
|
|
13
78
|
/**
|
|
14
79
|
* @param {object} task - closed task record with worktree_path/branch/base_branch.
|
|
15
80
|
* @param {string} mode - 'never' | 'ask' | 'auto'
|
|
16
81
|
* @param {string} targetDir - main-repo project directory (cwd for git ops).
|
|
82
|
+
* @param {object} [opts]
|
|
83
|
+
* @param {boolean} [opts.prMerged=false] - true when the PR has been confirmed
|
|
84
|
+
* merged on the remote. Skips local merge-back regardless of merge strategy
|
|
85
|
+
* (merge / squash / rebase). Instead: fetch + ff-only the base branch, then
|
|
86
|
+
* GC worktree + branch. Defaults to false so existing callers retain
|
|
87
|
+
* byte-identical legacy behavior.
|
|
17
88
|
* @returns {object|null} cleanup report block, or null if no worktree on task.
|
|
18
89
|
*/
|
|
19
|
-
export function computeWorktreeCleanup(task, mode, targetDir) {
|
|
90
|
+
export function computeWorktreeCleanup(task, mode, targetDir, opts = {}) {
|
|
20
91
|
if (!task?.worktree_path)
|
|
21
92
|
return null;
|
|
22
93
|
const wtPath = task.worktree_path;
|
|
@@ -32,16 +103,131 @@ export function computeWorktreeCleanup(task, mode, targetDir) {
|
|
|
32
103
|
};
|
|
33
104
|
}
|
|
34
105
|
if (mode === 'ask') {
|
|
106
|
+
// When the PR is already merged on the remote, teach humans the
|
|
107
|
+
// fetch + ff-only recipe instead of the legacy local-merge recipe
|
|
108
|
+
// (which corrupts main when local task ref is stale or the PR used
|
|
109
|
+
// squash/rebase).
|
|
110
|
+
const cleanupCmd = opts.prMerged === true
|
|
111
|
+
? `git fetch origin '${baseBranch}' && git checkout '${baseBranch}' && git merge --ff-only 'origin/${baseBranch}' && git worktree remove '${wtPath}' && git branch -d '${taskBranch}'`
|
|
112
|
+
: `git checkout '${baseBranch}' && git merge --no-edit '${taskBranch}' && git worktree remove '${wtPath}' && git branch -d '${taskBranch}'`;
|
|
35
113
|
return {
|
|
36
114
|
mode,
|
|
37
115
|
worktree_path: wtPath,
|
|
38
116
|
branch: taskBranch,
|
|
39
117
|
base_branch: baseBranch,
|
|
40
118
|
action: 'pending',
|
|
41
|
-
cleanup_command:
|
|
119
|
+
cleanup_command: cleanupCmd,
|
|
120
|
+
...(opts.prMerged === true ? { pr_merged_remotely: true } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
// mode === 'auto' && opts.prMerged === true.
|
|
124
|
+
// Trust origin as the merge authority. Method-agnostic across merge,
|
|
125
|
+
// squash, and rebase: fetch + checkout + ff-only, then GC. Never
|
|
126
|
+
// local-merge the task branch when GitHub already merged the PR.
|
|
127
|
+
if (opts.prMerged === true) {
|
|
128
|
+
let fetchOk = false;
|
|
129
|
+
let ffOk = false;
|
|
130
|
+
let branchDeleted = false;
|
|
131
|
+
const warnings = [];
|
|
132
|
+
try {
|
|
133
|
+
runGitWithRetry(['fetch', 'origin', baseBranch, '--no-tags'], {
|
|
134
|
+
cwd: targetDir,
|
|
135
|
+
encoding: 'utf-8',
|
|
136
|
+
stdio: 'pipe',
|
|
137
|
+
});
|
|
138
|
+
fetchOk = true;
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
// Offline or network-error. Skip ff-only; user must
|
|
142
|
+
// `git pull --ff-only` later. Cleanup still proceeds.
|
|
143
|
+
warnings.push(`fetch_failed: ${sanitizeErrMsg(shortErr(err))}`);
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
runGitWithRetry(['checkout', baseBranch], {
|
|
147
|
+
cwd: targetDir,
|
|
148
|
+
encoding: 'utf-8',
|
|
149
|
+
stdio: 'pipe',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
// Couldn't switch to base branch (e.g. fresh clone where base
|
|
154
|
+
// doesn't exist locally). Surface and abort cleanup; preserve
|
|
155
|
+
// local repo state — do NOT GC the worktree+branch.
|
|
156
|
+
return {
|
|
157
|
+
mode,
|
|
158
|
+
worktree_path: wtPath,
|
|
159
|
+
branch: taskBranch,
|
|
160
|
+
base_branch: baseBranch,
|
|
161
|
+
action: 'checkout_failed',
|
|
162
|
+
error: shortErr(err),
|
|
163
|
+
message: `Could not checkout ${baseBranch}; local repo state preserved. Resolve and re-run.`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (fetchOk) {
|
|
167
|
+
try {
|
|
168
|
+
runGitWithRetry(['merge', '--ff-only', `origin/${baseBranch}`], {
|
|
169
|
+
cwd: targetDir,
|
|
170
|
+
encoding: 'utf-8',
|
|
171
|
+
stdio: 'pipe',
|
|
172
|
+
});
|
|
173
|
+
ffOk = true;
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
// ff-only failed → local base has commits not on origin. Do
|
|
177
|
+
// NOT auto-resolve; warn and leave local at its current
|
|
178
|
+
// commit. Worktree + branch GC still runs.
|
|
179
|
+
warnings.push(`ff_only_failed: ${sanitizeErrMsg(shortErr(err))}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
runGitWithRetry(['worktree', 'remove', wtPath], {
|
|
184
|
+
cwd: targetDir,
|
|
185
|
+
encoding: 'utf-8',
|
|
186
|
+
stdio: 'pipe',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
try {
|
|
191
|
+
runGitWithRetry(['worktree', 'remove', '--force', wtPath], {
|
|
192
|
+
cwd: targetDir,
|
|
193
|
+
encoding: 'utf-8',
|
|
194
|
+
stdio: 'pipe',
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
/* worktree already gone or unreachable */
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
runGitWithRetry(['branch', '-d', taskBranch], {
|
|
203
|
+
cwd: targetDir,
|
|
204
|
+
encoding: 'utf-8',
|
|
205
|
+
stdio: 'pipe',
|
|
206
|
+
});
|
|
207
|
+
branchDeleted = true;
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
// Squash/rebase strategies leave the local task branch as
|
|
211
|
+
// "not fully merged" (different SHAs from origin). Surface as
|
|
212
|
+
// a warning rather than force-delete; user can `git branch -D`
|
|
213
|
+
// manually if they want.
|
|
214
|
+
warnings.push(`branch_delete_failed: ${sanitizeErrMsg(shortErr(err))}`);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
mode,
|
|
218
|
+
worktree_path: wtPath,
|
|
219
|
+
branch: taskBranch,
|
|
220
|
+
base_branch: baseBranch,
|
|
221
|
+
action: 'pr_merged_remotely_cleaned',
|
|
222
|
+
fetched: fetchOk,
|
|
223
|
+
fast_forwarded: ffOk,
|
|
224
|
+
branch_deleted: branchDeleted,
|
|
225
|
+
...(warnings.length ? { warnings } : {}),
|
|
42
226
|
};
|
|
43
227
|
}
|
|
44
|
-
// mode === 'auto' — attempt merge-back in the main repo
|
|
228
|
+
// mode === 'auto' (legacy) — attempt merge-back in the main repo
|
|
229
|
+
// (never in the worktree). Direct `task close` callers without
|
|
230
|
+
// --pr-merged-remotely hit this path; byte-identical legacy behavior.
|
|
45
231
|
let mergeOk = false;
|
|
46
232
|
let mergeError = null;
|
|
47
233
|
try {
|
|
@@ -58,12 +244,7 @@ export function computeWorktreeCleanup(task, mode, targetDir) {
|
|
|
58
244
|
mergeOk = true;
|
|
59
245
|
}
|
|
60
246
|
catch (err) {
|
|
61
|
-
mergeError = (err
|
|
62
|
-
.toString()
|
|
63
|
-
.trim()
|
|
64
|
-
.split('\n')
|
|
65
|
-
.slice(0, 3)
|
|
66
|
-
.join(' ');
|
|
247
|
+
mergeError = shortErr(err);
|
|
67
248
|
// Abort the failed merge so the main repo is left clean.
|
|
68
249
|
try {
|
|
69
250
|
execFileSync('git', ['merge', '--abort'], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-cleanup.mjs","sourceRoot":"","sources":["../../../src/cli/task/worktree-cleanup.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD
|
|
1
|
+
{"version":3,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;QACvB,OAAO,EAAE,eAAe,UAAU,gCAAgC,UAAU,2BAA2B,MAAM,oCAAoC,UAAU,iBAAiB,UAAU,EAAE;KACxL,CAAA;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aperant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "AI coding framework — composable skills for planning, executing, verifying, and reviewing code with any LLM provider. Works as Claude Code commands, Codex tasks, or programmatically.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mikalsen AI",
|
|
@@ -26,7 +26,7 @@ Before planning, discover project context:
|
|
|
26
26
|
|
|
27
27
|
**Rationalizations (R4):** Read `.aperant/rationalizations/claude-opus-4-6.md` once at session start. It catalogues observed planner failure modes — especially ceremonialization (plan prose treated as progress) and postcondition triviality (`postcondition: "true"` rubber stamps). Every postcondition you emit must be a real, evaluable predicate.
|
|
28
28
|
|
|
29
|
-
**Multi-runtime install awareness:** Plans that touch shipped framework files (skills/agents/hooks under `packages/framework/`) must respect the multi-runtime install pipeline. Each canonical file ships with an `apt-skill-version: {{APT_VERSION}}` header (substituted at install time) and is reflected in per-runtime `apt-file-manifest.json` files. Drift is detected per-file (header_mismatch, hash_mismatch, missing_header, missing_file) by `apt-tools check-version` — not via a single global version string. After modifying any canonical file, callers must re-run `apt-tools init . --<runtime>` (or `/apt:update`) so the manifest stays in sync.
|
|
29
|
+
**Multi-runtime install awareness:** Plans that touch shipped framework files (skills/agents/hooks under `packages/framework/`) must respect the multi-runtime install pipeline. Each canonical file ships with an `apt-skill-version: {{APT_VERSION}}` header (substituted at install time) and is reflected in per-runtime `apt-file-manifest.json` files. Drift is detected per-file (header_mismatch, hash_mismatch, missing_header, missing_file) by `apt-tools check-version` — not via a single global version string. After modifying any canonical file, callers must re-run `apt-tools init . --<runtime>` (or `/apt:update`) so the manifest stays in sync. **Note (0.6.1):** when an agent re-runs install, the call must include `--team`/`--solo` plus the runtime flag (or `--yes`) — non-TTY `init` no longer silently defaults to `visibility:'solo'`. Without an explicit Class A flag the command exits 2 with a `requires_input` envelope.
|
|
30
30
|
</project_context>
|
|
31
31
|
|
|
32
32
|
<environment>
|
|
@@ -9,6 +9,7 @@ user_invocable: true
|
|
|
9
9
|
internal: false
|
|
10
10
|
spawns_agent: false
|
|
11
11
|
agent_name: null
|
|
12
|
+
task_context: none
|
|
12
13
|
default_execution_mode: auto
|
|
13
14
|
execution_modes:
|
|
14
15
|
- auto
|
|
@@ -139,13 +140,118 @@ Show current state summary and autonomy flags (`--supervised`, `--guided`, `--au
|
|
|
139
140
|
|
|
140
141
|
The user invoked a specific skill by name (e.g., `/apt plan`, `/apt resume`,
|
|
141
142
|
`/apt:ship`). The router matched the first word against the installed skill
|
|
142
|
-
set and filled in `skill`, `skill_args`, `spawn_agent`,
|
|
143
|
+
set and filled in `skill`, `skill_args`, `spawn_agent`, `agent`, AND
|
|
144
|
+
`task_context` + (optional) `default_track`.
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
Dispatch on `task_context` — never just on `spawn_agent`. The four-branch
|
|
147
|
+
policy below is hardcoded contract; do NOT improvise. See
|
|
148
|
+
`docs/frameworks/spec-gaps.md#g25` for the defect that motivated this.
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
### Missing `task_context` — fail-closed
|
|
151
|
+
|
|
152
|
+
When the envelope's `task_context` is null (the `?? null` fallback in
|
|
153
|
+
`route.mjs:skillIndex.taskContextOf`), print verbatim and STOP. Do NOT
|
|
154
|
+
invoke the skill:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
[APT] ERROR — skill "apt:{skill}" has no task_context declared in SKILL.md frontmatter.
|
|
158
|
+
Cannot dispatch safely until the policy is set. Run /apt:author-skill validate
|
|
159
|
+
packages/framework/skills/apt-{skill}/SKILL.md to see required keys.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Note:** In practice, a skill missing `task_context` is dropped by
|
|
163
|
+
`discoverSkills` during the Zod schema validation step and will never reach
|
|
164
|
+
the skill-passthrough branch — it will be absent from `knownSlugs`. The
|
|
165
|
+
user sees the skill disappear silently from routing; run
|
|
166
|
+
`apt-tools route .` to surface dropped skills logged to
|
|
167
|
+
`.aperant/logs/route-dropped.jsonl`. The `task_context: null` path is
|
|
168
|
+
reachable if the field is marked optional in a future schema version —
|
|
169
|
+
this error fires in that case.
|
|
170
|
+
|
|
171
|
+
### `task_context = none`
|
|
172
|
+
|
|
173
|
+
No task semantics. Invoke the skill directly with `skill_args` (or spawn
|
|
174
|
+
`agent` when `spawn_agent` is true). No `task create`, no worktree banner.
|
|
175
|
+
|
|
176
|
+
### `task_context = self-managed`
|
|
177
|
+
|
|
178
|
+
The skill manages its own task / worktree lifecycle (e.g. `apt:run` calls
|
|
179
|
+
`task create` in its own Step 2; `apt:pr-review` sets up a PR-scoped
|
|
180
|
+
worktree). Dispatch identically to `none` — the skill's own SKILL.md is
|
|
181
|
+
responsible for any task record + worktree banner.
|
|
182
|
+
|
|
183
|
+
### `task_context = create-new`
|
|
184
|
+
|
|
185
|
+
Resolve the track, then create a fresh task record before invoking the skill.
|
|
186
|
+
|
|
187
|
+
**Track resolution chain (first match wins):**
|
|
188
|
+
|
|
189
|
+
1. Explicit user flag in `skill_args` — `--quick` → `QUICK`, `--deep` → `DEEP`,
|
|
190
|
+
`--debug` → `DEBUG`.
|
|
191
|
+
2. `envelope.default_track` if present (the skill's declared default).
|
|
192
|
+
3. Per-slug hardcoded fallback:
|
|
193
|
+
- `quick` → `QUICK`
|
|
194
|
+
- `debug` → `DEBUG`
|
|
195
|
+
- `plan` → `STANDARD`
|
|
196
|
+
- everything else with `task_context: create-new` → `STANDARD`
|
|
197
|
+
|
|
198
|
+
Then run:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
node packages/framework/bin/apt-tools.mjs task create . --description "{slug}" --track {track} --autonomy {autonomy} [--scope {scope}]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Security note:** Do NOT interpolate `{skill_args}` directly into `--description "..."`. `skill_args` is verbatim user input and can contain double-quote characters that break out of the argument boundary and inject extra flags (e.g. `--autonomy`, `--scope`). The task slug is sufficient as the description; `skill_args` is passed to the skill separately after the task record is created.
|
|
205
|
+
|
|
206
|
+
(Use `--scope framework` only when the user is on a framework-scoped task —
|
|
207
|
+
otherwise omit and let the default `project` scope apply.)
|
|
208
|
+
|
|
209
|
+
Parse `task_id`, `task_dir`, and (if present) `worktree.worktree_path` /
|
|
210
|
+
`worktree.branch` / `worktree.base_branch` from the result. Print the
|
|
211
|
+
worktree banner when `worktree` is returned:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
[APT] Working in isolated worktree: {worktree_path}
|
|
215
|
+
[APT] Task branch: {branch} (from {base_branch})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Then invoke `apt:{skill}` with `skill_args` + the new task context
|
|
219
|
+
(`task_id`, `task_dir`, `worktree_path`). When `spawn_agent` is true, spawn
|
|
220
|
+
`agent` with the same context.
|
|
221
|
+
|
|
222
|
+
### `task_context = require-existing`
|
|
223
|
+
|
|
224
|
+
Resolve which active task this invocation refers to, then dispatch. Read
|
|
225
|
+
`state.active_tasks` from `.aperant/state.json`.
|
|
226
|
+
|
|
227
|
+
**Active-task resolution chain (first match wins):**
|
|
228
|
+
|
|
229
|
+
1. `--task-id <id>` flag present in `skill_args` → use it. If `<id>` is not
|
|
230
|
+
in `state.active_tasks`, error and stop.
|
|
231
|
+
2. `state.active_tasks` has exactly one entry AND that entry's
|
|
232
|
+
`lifecycle_phase` is non-terminal (`planning`, `executing`, `verifying`,
|
|
233
|
+
`reviewing`) → use it. If the single entry is in a terminal phase
|
|
234
|
+
(`shipped-pending-merge` or `rejected`), fall through to step 4.
|
|
235
|
+
3. `state.active_tasks` has more than one entry with exactly one in a
|
|
236
|
+
non-terminal lifecycle phase (`planning`, `executing`, `verifying`,
|
|
237
|
+
`reviewing`) → use it.
|
|
238
|
+
(Terminal phases in `active_tasks` are `shipped-pending-merge` and
|
|
239
|
+
`rejected`. Note: `completed` tasks are removed from `active_tasks`
|
|
240
|
+
entirely at close and can never appear here.)
|
|
241
|
+
4. Otherwise, print the numbered menu and STOP. Auto-mode (autonomy 2/3)
|
|
242
|
+
does NOT bypass this prompt — multi-task ambiguity is the user's call,
|
|
243
|
+
never the framework's guess:
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
[APT] Multiple active tasks — pick one with `--task-id <id>`:
|
|
247
|
+
1. {task-id-1} {description} ({lifecycle_phase})
|
|
248
|
+
2. {task-id-2} {description} ({lifecycle_phase})
|
|
249
|
+
...
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Once resolved, print the worktree banner if the task has a `worktree_path`,
|
|
253
|
+
then invoke `apt:{skill}` with `skill_args` + the resolved `task_id`. When
|
|
254
|
+
`spawn_agent` is true, spawn `agent` with the same context.
|
|
149
255
|
|
|
150
256
|
---
|
|
151
257
|
|
|
@@ -9,6 +9,7 @@ user_invocable: true
|
|
|
9
9
|
internal: false
|
|
10
10
|
spawns_agent: false
|
|
11
11
|
agent_name: null
|
|
12
|
+
task_context: create-new
|
|
12
13
|
default_execution_mode: step
|
|
13
14
|
execution_modes:
|
|
14
15
|
- auto
|
|
@@ -129,6 +130,16 @@ the author sees the full checklist of gaps to fill. Group by section:
|
|
|
129
130
|
The generated structural test only checks tags and numbered steps — the
|
|
130
131
|
TODOs are the semantic gaps the author must close.
|
|
131
132
|
|
|
133
|
+
**Required frontmatter field — `task_context`.** The scaffold ships with
|
|
134
|
+
`task_context: create-new` as the safest default (the new skill will get a
|
|
135
|
+
fresh task record + worktree via `apt-tools task create` when invoked as
|
|
136
|
+
`/apt <slug>`). Verify this is correct for your skill before merging — the
|
|
137
|
+
allowed values are `create-new | require-existing | self-managed | none`.
|
|
138
|
+
See `packages/framework/docs/skill-passthrough.md` for the four-policy
|
|
139
|
+
contract and the orchestrator dispatch behavior. Missing or wrong values
|
|
140
|
+
are caught by the structural test in
|
|
141
|
+
`packages/framework/src/__tests__/skill-frontmatter-task-context.test.ts`.
|
|
142
|
+
|
|
132
143
|
## 4. Show the Structural Test
|
|
133
144
|
|
|
134
145
|
Read the generated structural test file and echo its contents so the
|