@yasaswy.nagavolu/agents 0.26.4 → 0.26.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/content/mods/handoff/.claude-plugin/plugin.json +1 -1
- package/content/mods/handoff/README.md +13 -13
- package/content/mods/handoff/hooks/register.js +15 -17
- package/content/mods/handoff/lib/auto.mjs +4 -13
- package/content/mods/handoff/lib/template.mjs +3 -2
- package/content/mods/handoff/prompts/handoff-prep.md +2 -2
- package/content/mods/handoff/tests/auto.test.mjs +10 -23
- package/content/mods/handoff/tests/e2e/run_e2e.py +25 -5
- package/content/mods/handoff/tests/gitgate.test.mjs +3 -3
- package/content/mods/handoff/tests/register.test.mjs +95 -19
- package/content/mods/handoff/tests/template.test.mjs +10 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "handoff",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "One-click session handoff: prepares the work, writes a lean handoff file, verifies it, clears the session and submits the handoff as the first message",
|
|
5
5
|
"author": { "name": "Yasaswy Nagavolu" },
|
|
6
6
|
"metadata": { "minClaudeCodeVersion": "2.1.287" }
|
|
@@ -37,22 +37,22 @@ an unattended session's prompt cache warm. Needs Claude Code 2.1.287 or later (m
|
|
|
37
37
|
writes `~/.claude/handoffs/<session_id>.md`, then prints `HANDOFF_READY <path>` or `HANDOFF_ABORT <reason>`.
|
|
38
38
|
- Phase B (turn complete): sentinel, `lib/validate.mjs`, git gate (`lib/gitgate.mjs`).
|
|
39
39
|
Only then: clipboard, `/clear`, submit the handoff. Any failed check keeps the session and the file.
|
|
40
|
-
- Git gate:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- Running work never blocks:
|
|
45
|
-
background tasks (
|
|
46
|
-
step 0
|
|
40
|
+
- Git gate (advisory): dirty tracked files, unpushed commits, detached HEAD or no upstream never abort. It counts
|
|
41
|
+
`@{upstream}..HEAD`, else commits not on the remote default branch (`origin/HEAD`, `origin/main`, `origin/master`).
|
|
42
|
+
On a reason: one toast `Handoff continues: <reason>` and `Warning: <reason>.` ends the submitted text (file unchanged).
|
|
43
|
+
Prep step 4 commits only this session's work and lists the rest in open risks.
|
|
44
|
+
- Running work never blocks: at start (or queue release) the mod counts running subagents (`$.agent.list()`, live) and
|
|
45
|
+
background tasks (`background_tasks` of the last `classic.Stop`) and shows one toast if any run. Nothing is stopped or
|
|
46
|
+
waited for; prep step 0 lists them in the handoff's open risks.
|
|
47
47
|
|
|
48
48
|
## Auto-handoff
|
|
49
49
|
|
|
50
|
-
- On by default.
|
|
51
|
-
|
|
52
|
-
- Idle
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
- On by default. At 65% context or more with an idle chat, the mod runs the same flow as `Alt+H` and shows
|
|
51
|
+
the toast `Auto-handoff: context is at N% ...`.
|
|
52
|
+
- Idle: no running turn, prompt waiting, nudge or handoff, and an empty prompt box. Busy defers to the next tick (15 s). Unknown context never fires.
|
|
53
|
+
- At most one automatic attempt per session. After any abort (auto or manual) auto turns itself off for the rest of
|
|
54
|
+
the session with one toast and leaves the saved `auto` value alone. `/handoff auto on` or the toggle re-arms it;
|
|
55
|
+
a new session reads the saved value. Manual `Alt+H` or a click always works. One run at a time.
|
|
56
56
|
- The toggle button or `/handoff auto on|off|status` flips it. The value is saved with `$.store` (key `auto`,
|
|
57
57
|
file `~/.claude/plugins/store/handoff_inline-*.json`), read at each session start.
|
|
58
58
|
|
|
@@ -8,7 +8,7 @@ import { renderPrep, isPrepTurn, prepStartExpired } from '../lib/prep.mjs'
|
|
|
8
8
|
import { evaluateGitState, collectGitState } from '../lib/gitgate.mjs'
|
|
9
9
|
import { summarizeActiveWork, activeWorkNote } from '../lib/activework.mjs'
|
|
10
10
|
import { claudeSubdir, sessionFilePath, cacheInfoFromState, cacheRemainingMs } from '../lib/cache.mjs'
|
|
11
|
-
import { AUTO_THRESHOLD_PERCENT, AUTO_STORE_KEY, HANDOFF_USAGE, newAuto, storedEnabled,
|
|
11
|
+
import { AUTO_THRESHOLD_PERCENT, AUTO_STORE_KEY, HANDOFF_USAGE, newAuto, storedEnabled, onAutoFailure, decideAuto, autoLabel, autoStatusText, parseHandoffArgs } from '../lib/auto.mjs'
|
|
12
12
|
import {
|
|
13
13
|
NUDGE_WINDOW_MS,
|
|
14
14
|
TICK_MS,
|
|
@@ -33,31 +33,30 @@ import {
|
|
|
33
33
|
applyVerdict,
|
|
34
34
|
} from '../lib/keepwarm.mjs'
|
|
35
35
|
|
|
36
|
+
const AUTO_STOPPED_TOAST = 'Auto-handoff stopped after a failed attempt. Use /handoff or the band button; /handoff auto on re-enables it'
|
|
36
37
|
const REFRESH_MS = 30000
|
|
37
38
|
const TOAST_MS = 8000
|
|
38
39
|
const TICK_STUCK_MS = 20000
|
|
39
40
|
const REREAD_DELAYS_MS = [1500, 3500, 7000, 12000, 20000]
|
|
40
41
|
|
|
41
|
-
const flow = { phase: 'idle', path: '', error: '', text: '', turnId: null, submittedAt: null,
|
|
42
|
+
const flow = { phase: 'idle', path: '', error: '', text: '', turnId: null, submittedAt: null, byAuto: false }
|
|
42
43
|
let supported = false
|
|
43
44
|
let stopTick = null
|
|
44
45
|
|
|
45
46
|
function setPhase($, phase, error) {
|
|
46
47
|
flow.phase = phase
|
|
47
48
|
flow.error = error || ''
|
|
48
|
-
if (phase === 'idle') Object.assign(flow, { text: '', turnId: null, submittedAt: null,
|
|
49
|
+
if (phase === 'idle') Object.assign(flow, { text: '', turnId: null, submittedAt: null, byAuto: false })
|
|
49
50
|
$.ui.invalidate('ui.render')
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
const level = flow.autoLevel
|
|
53
|
+
function fail($, message) {
|
|
54
54
|
setPhase($, 'idle', message)
|
|
55
55
|
$.ui.log('Handoff aborted, session kept: ' + message)
|
|
56
56
|
$.ui.toast('Handoff aborted: ' + message, { timeoutMs: TOAST_MS })
|
|
57
|
-
if (
|
|
58
|
-
auto =
|
|
59
|
-
|
|
60
|
-
if (usage) auto = onAutoAbort(auto, usage.context.percent)
|
|
57
|
+
if (!auto.enabled) return
|
|
58
|
+
auto = onAutoFailure()
|
|
59
|
+
$.ui.toast(AUTO_STOPPED_TOAST, { timeoutMs: TOAST_MS })
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
async function tryOr($, what, fn, fallback) {
|
|
@@ -76,10 +75,10 @@ async function copyToClipboard($, text, file) {
|
|
|
76
75
|
return copyViaSystem({ osEnv, file, text, run: (argv, init) => $.process.run(argv, init) })
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
async function startHandoff($,
|
|
78
|
+
async function startHandoff($, byAuto = false) {
|
|
80
79
|
if (!supported) return fail($, 'needs Claude Code ' + MIN_CLAUDE_CODE_VERSION + ' or later')
|
|
81
80
|
if (flow.phase !== 'idle') return
|
|
82
|
-
flow.
|
|
81
|
+
flow.byAuto = byAuto
|
|
83
82
|
setPhase($, 'starting')
|
|
84
83
|
try {
|
|
85
84
|
const work = await activeWork($)
|
|
@@ -92,7 +91,7 @@ async function startHandoff($, autoLevel = null) {
|
|
|
92
91
|
flow.path = path
|
|
93
92
|
flow.text = renderPrep(normalize(template), { path, root })
|
|
94
93
|
if (isBusy(state, await $.clock.now())) {
|
|
95
|
-
if (
|
|
94
|
+
if (byAuto) return setPhase($, 'idle')
|
|
96
95
|
setPhase($, 'queued')
|
|
97
96
|
$.ui.toast('Handoff queued - waiting for the current turn to finish', { timeoutMs: TOAST_MS })
|
|
98
97
|
return
|
|
@@ -146,10 +145,10 @@ async function finishHandoff($, reason) {
|
|
|
146
145
|
const verdict = validateHandoff(handoff)
|
|
147
146
|
if (!verdict.ok) return fail($, verdict.errors.join('; '))
|
|
148
147
|
|
|
149
|
-
const gate = evaluateGitState(await collectGitState((argv) => $.process.run(argv)))
|
|
150
|
-
if (!gate.ok)
|
|
148
|
+
const gate = evaluateGitState(await tryOr($, 'git state', () => collectGitState((argv) => $.process.run(argv)), { isRepo: false }))
|
|
149
|
+
if (!gate.ok) $.ui.toast('Handoff continues: ' + gate.reason, { timeoutMs: TOAST_MS })
|
|
151
150
|
|
|
152
|
-
const submission = prepareSubmission(handoff)
|
|
151
|
+
const submission = prepareSubmission(handoff, gate.reason)
|
|
153
152
|
const copied = await copyToClipboard($, handoff, flow.path)
|
|
154
153
|
await $.command.run({ command: 'clear', args: '' })
|
|
155
154
|
try {
|
|
@@ -259,7 +258,6 @@ async function tick($) {
|
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
function autoFires($, now, contextPercent, draft) {
|
|
262
|
-
auto = settleAuto(auto, contextPercent, settings.autoPercent)
|
|
263
261
|
const verdict = decideAuto({
|
|
264
262
|
auto,
|
|
265
263
|
contextPercent,
|
|
@@ -271,7 +269,7 @@ function autoFires($, now, contextPercent, draft) {
|
|
|
271
269
|
})
|
|
272
270
|
if (!verdict.fire) return false
|
|
273
271
|
$.ui.toast('Auto-handoff: context is at ' + Math.round(contextPercent) + '% (limit ' + settings.autoPercent + '%). Starting the handoff.', { timeoutMs: TOAST_MS })
|
|
274
|
-
$.clock.after(0, () => startHandoff($,
|
|
272
|
+
$.clock.after(0, () => startHandoff($, true))
|
|
275
273
|
return true
|
|
276
274
|
}
|
|
277
275
|
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
export const AUTO_THRESHOLD_PERCENT = 65
|
|
2
|
-
export const AUTO_REARM_PERCENT = 5
|
|
3
2
|
export const AUTO_STORE_KEY = 'auto'
|
|
4
3
|
export const HANDOFF_USAGE = 'usage: /handoff | /handoff auto on | off | status'
|
|
5
4
|
|
|
6
5
|
export function newAuto(enabled) {
|
|
7
|
-
return { enabled,
|
|
6
|
+
return { enabled, stopped: false }
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
export function storedEnabled(value) {
|
|
11
10
|
return value !== false
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
return { ...auto, abortLevel: auto.abortLevel === null ? level : Math.max(level, auto.abortLevel) }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function settleAuto(auto, contextPercent, thresholdPercent) {
|
|
20
|
-
const dropped = typeof contextPercent === 'number' && contextPercent < thresholdPercent
|
|
21
|
-
return dropped && auto.abortLevel !== null ? { ...auto, abortLevel: null } : auto
|
|
13
|
+
export function onAutoFailure() {
|
|
14
|
+
return { enabled: false, stopped: true }
|
|
22
15
|
}
|
|
23
16
|
|
|
24
17
|
export function decideAuto({ auto, contextPercent, thresholdPercent, supported, phase, busy, draft }) {
|
|
@@ -27,7 +20,6 @@ export function decideAuto({ auto, contextPercent, thresholdPercent, supported,
|
|
|
27
20
|
if (!supported) return none('unsupported')
|
|
28
21
|
if (typeof contextPercent !== 'number') return none('unknown')
|
|
29
22
|
if (contextPercent < thresholdPercent) return none('below')
|
|
30
|
-
if (auto.abortLevel !== null && contextPercent < auto.abortLevel + AUTO_REARM_PERCENT) return none('cooldown')
|
|
31
23
|
if (phase !== 'idle') return none('flow')
|
|
32
24
|
if (busy) return none('busy')
|
|
33
25
|
if (String(draft || '').trim() !== '') return none('typing')
|
|
@@ -40,8 +32,7 @@ export function autoLabel(auto, thresholdPercent) {
|
|
|
40
32
|
|
|
41
33
|
export function autoStatusText(auto, thresholdPercent) {
|
|
42
34
|
const text = 'auto-handoff ' + (auto.enabled ? 'on' : 'off') + ' at ' + thresholdPercent + '% context'
|
|
43
|
-
|
|
44
|
-
return text + ', paused after an abort until context ' + Math.max(thresholdPercent, Math.ceil(auto.abortLevel + AUTO_REARM_PERCENT)) + '%'
|
|
35
|
+
return auto.stopped ? text + ', stopped after a failed attempt (use /handoff auto on to re-enable)' : text
|
|
45
36
|
}
|
|
46
37
|
|
|
47
38
|
export function parseHandoffArgs(args) {
|
|
@@ -22,6 +22,7 @@ export function handoffPathFor(dir, sessionId) {
|
|
|
22
22
|
return base + '/' + String(sessionId).replace(/[^A-Za-z0-9_-]/g, '') + '.md'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function prepareSubmission(text) {
|
|
26
|
-
|
|
25
|
+
export function prepareSubmission(text, warning = '') {
|
|
26
|
+
const body = 'Session handoff from the previous session. Continue from the state below.\n\n' + normalize(text).trim()
|
|
27
|
+
return warning ? body + '\n\nWarning: ' + warning + '.' : body
|
|
27
28
|
}
|
|
@@ -4,9 +4,9 @@ Prepare this session for a handoff. The session is cleared after you finish, so
|
|
|
4
4
|
1. Tasks. Use TaskList and TaskUpdate so every task matches reality (done, in progress, pending).
|
|
5
5
|
2. PRD issue. Find the single open PRD issue for this session (task metadata or this conversation). Update its description (TODO mirror and status) and post one status comment, using the issue-tracker access this project already uses (a repo script or the tracker's CLI). Never print the token. If no PRD issue exists, write "none" in the PRD section.
|
|
6
6
|
3. Docs. Update only the markdown docs, README rows and memory that this session touched or made stale.
|
|
7
|
-
4. Code. Run the tests that cover the changed
|
|
7
|
+
4. Code. Run the tests that cover the files this session changed. If they pass, commit and push only what this session changed: pull and rebase on the default branch (on a conflict, resolve it keeping both sides' intent, re-run the tests, and record any override in open risks), then push to the default branch. Other uncommitted files, unpushed commits or a detached HEAD may belong to other sessions: leave them, do not abort, and list them (paths, owner if known) in open risks.
|
|
8
8
|
5. Handoff file. Write the handoff to `{{handoff_path}}` (not a transcript, at most {{max_chars}} characters, about 1500 tokens). Use these level-2 headers, each with content: {{required_headers}}. Include the goal, current state, decisions, commit SHAs, PRD IID and task list, exact next steps, file paths and open risks. Write it after the last commit and push, list the final HEAD SHA, and make no commit or tracked-file change after it.
|
|
9
9
|
6. Check. Run `{{validator_cmd}}`. Fix the file until it exits 0.
|
|
10
10
|
7. Finish. Print exactly one final line: `HANDOFF_READY {{handoff_path}}`.
|
|
11
11
|
|
|
12
|
-
Abort rule: only if tests fail or the push fails, do not write the ready line. Print one final line `HANDOFF_ABORT <short reason>` instead. Keep the handoff file if you wrote it.
|
|
12
|
+
Abort rule: only if tests of files this session changed fail or the push of this session's own commits fails, do not write the ready line. Print one final line `HANDOFF_ABORT <short reason>` instead. Keep the handoff file if you wrote it.
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
AUTO_THRESHOLD_PERCENT,
|
|
5
5
|
newAuto,
|
|
6
6
|
storedEnabled,
|
|
7
|
-
|
|
8
|
-
settleAuto,
|
|
7
|
+
onAutoFailure,
|
|
9
8
|
decideAuto,
|
|
10
9
|
autoLabel,
|
|
11
10
|
autoStatusText,
|
|
@@ -38,26 +37,11 @@ test('threshold default is 65 percent', () => {
|
|
|
38
37
|
assert.equal(AUTO_THRESHOLD_PERCENT, 65)
|
|
39
38
|
})
|
|
40
39
|
|
|
41
|
-
test('
|
|
42
|
-
const
|
|
43
|
-
assert.
|
|
44
|
-
assert.
|
|
45
|
-
assert.deepEqual(decide({ auto:
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('cooldown keeps the highest abort level and ignores an unknown level', () => {
|
|
49
|
-
const a = onAutoAbort(onAutoAbort(newAuto(true), 70), 66)
|
|
50
|
-
assert.equal(a.abortLevel, 70)
|
|
51
|
-
assert.equal(onAutoAbort(a, undefined), a)
|
|
52
|
-
assert.equal(onAutoAbort(newAuto(true), 66).abortLevel, 66)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('cooldown clears when context drops below the threshold (clear or compact)', () => {
|
|
56
|
-
const aborted = onAutoAbort(newAuto(true), 70)
|
|
57
|
-
assert.equal(settleAuto(aborted, 80, 65), aborted)
|
|
58
|
-
assert.equal(settleAuto(aborted, undefined, 65), aborted)
|
|
59
|
-
assert.equal(settleAuto(aborted, 12, 65).abortLevel, null)
|
|
60
|
-
assert.equal(settleAuto(newAuto(true), 12, 65).abortLevel, null)
|
|
40
|
+
test('a failed attempt turns auto off for the session and never re-arms by context growth', () => {
|
|
41
|
+
const stopped = onAutoFailure(newAuto(true))
|
|
42
|
+
assert.deepEqual(stopped, { enabled: false, stopped: true })
|
|
43
|
+
for (const contextPercent of [65, 70, 99]) assert.deepEqual(decide({ auto: stopped, contextPercent }), { fire: false, reason: 'disabled' })
|
|
44
|
+
assert.deepEqual(decide({ auto: newAuto(true), contextPercent: 99 }), { fire: true, reason: 'context' })
|
|
61
45
|
})
|
|
62
46
|
|
|
63
47
|
test('stored value: only an explicit false turns auto off', () => {
|
|
@@ -73,7 +57,10 @@ test('label and status text', () => {
|
|
|
73
57
|
assert.equal(autoLabel(newAuto(false), 65), 'auto 65%: off')
|
|
74
58
|
assert.equal(autoStatusText(newAuto(true), 65), 'auto-handoff on at 65% context')
|
|
75
59
|
assert.equal(autoStatusText(newAuto(false), 65), 'auto-handoff off at 65% context')
|
|
76
|
-
assert.equal(
|
|
60
|
+
assert.equal(
|
|
61
|
+
autoStatusText(onAutoFailure(newAuto(true)), 65),
|
|
62
|
+
'auto-handoff off at 65% context, stopped after a failed attempt (use /handoff auto on to re-enable)',
|
|
63
|
+
)
|
|
77
64
|
})
|
|
78
65
|
|
|
79
66
|
test('command parsing: bare starts, auto takes on, off or status, anything else is usage', () => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Copies the mod to a temp dir, swaps the real prep prompt for a stub that needs no
|
|
4
4
|
git or network work, drives /handoff, and asserts on the observer plugin's log.
|
|
5
|
-
Run: python mods/handoff/tests/e2e/run_e2e.py [success|abort|invalid|all]
|
|
5
|
+
Run: python mods/handoff/tests/e2e/run_e2e.py [success|dirty|abort|invalid|all]
|
|
6
6
|
"""
|
|
7
7
|
import json
|
|
8
8
|
import os
|
|
@@ -53,6 +53,7 @@ STUBS = {
|
|
|
53
53
|
"`{{validator_cmd}}` with Bash, then print one final line `HANDOFF_READY {{handoff_path}}` and nothing after it. "
|
|
54
54
|
"Required headers: {{required_headers}} (max {{max_chars}} chars).\n<<<\n" + HANDOFF_BODY + ">>>\n"
|
|
55
55
|
),
|
|
56
|
+
"dirty": None,
|
|
56
57
|
"abort": "Do not write any file. Print exactly one line: HANDOFF_ABORT tests failed in stub. Ignore: {{handoff_path}} {{validator_cmd}} {{required_headers}} {{max_chars}}",
|
|
57
58
|
"invalid": (
|
|
58
59
|
"Use the Write tool to create the file {{handoff_path}} containing only the text `too short`, then print one final line "
|
|
@@ -61,6 +62,23 @@ STUBS = {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
|
|
65
|
+
STUBS["dirty"] = STUBS["success"]
|
|
66
|
+
FLOW_SCENARIOS = ("success", "dirty")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def make_dirty_repo(cwd):
|
|
70
|
+
def git(*args):
|
|
71
|
+
subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, creationflags=CREATE_NO_WINDOW if os.name == "nt" else 0)
|
|
72
|
+
|
|
73
|
+
git("init", "-q")
|
|
74
|
+
git("config", "user.email", "e2e@example.invalid")
|
|
75
|
+
git("config", "user.name", "e2e")
|
|
76
|
+
(cwd / "tracked.txt").write_text("one" + chr(10), encoding="utf-8")
|
|
77
|
+
git("add", "tracked.txt")
|
|
78
|
+
git("commit", "-q", "-m", "init")
|
|
79
|
+
(cwd / "tracked.txt").write_text("two" + chr(10), encoding="utf-8")
|
|
80
|
+
|
|
81
|
+
|
|
64
82
|
def claude_exe():
|
|
65
83
|
cand = Path(os.environ.get("APPDATA", "")) / "npm/node_modules/@anthropic-ai/claude-code/bin/claude.exe"
|
|
66
84
|
return str(cand) if cand.exists() else shutil.which("claude")
|
|
@@ -86,6 +104,8 @@ def run(scenario, timeout=150):
|
|
|
86
104
|
(mod / "prompts" / "handoff-prep.md").write_text(STUBS[scenario], encoding="utf-8")
|
|
87
105
|
cwd = work / "cwd"
|
|
88
106
|
cwd.mkdir()
|
|
107
|
+
if scenario == "dirty":
|
|
108
|
+
make_dirty_repo(cwd)
|
|
89
109
|
log = work / "observer.log"
|
|
90
110
|
env = dict(
|
|
91
111
|
os.environ,
|
|
@@ -134,15 +154,15 @@ def run(scenario, timeout=150):
|
|
|
134
154
|
|
|
135
155
|
def done():
|
|
136
156
|
text = observed_text()
|
|
137
|
-
if scenario
|
|
157
|
+
if scenario in FLOW_SCENARIOS:
|
|
138
158
|
tail = text.split("session.end reason=clear")[-1] if "session.end reason=clear" in text else ""
|
|
139
159
|
return "turn.complete" in tail
|
|
140
160
|
return "turn.complete" in text.split("handoff")[-1] and text.count("turn.complete") >= 2
|
|
141
161
|
|
|
142
|
-
end = time.time() + (200 if scenario
|
|
162
|
+
end = time.time() + (200 if scenario in FLOW_SCENARIOS else 90)
|
|
143
163
|
while time.time() < end and not done():
|
|
144
164
|
time.sleep(1)
|
|
145
|
-
time.sleep(
|
|
165
|
+
time.sleep(2 if scenario in FLOW_SCENARIOS else 10)
|
|
146
166
|
try:
|
|
147
167
|
proc.stdin.close()
|
|
148
168
|
except OSError:
|
|
@@ -170,7 +190,7 @@ def run(scenario, timeout=150):
|
|
|
170
190
|
def check(report):
|
|
171
191
|
obs = report["observer"]
|
|
172
192
|
cleared = "session.end reason=clear" in obs
|
|
173
|
-
if report["scenario"]
|
|
193
|
+
if report["scenario"] in FLOW_SCENARIOS:
|
|
174
194
|
ok = (cleared and "asUser" in obs and any("HANDOFF-RECEIVED" in r for r in report["results"])
|
|
175
195
|
and report["clipboard_matches_handoff"])
|
|
176
196
|
else:
|
|
@@ -12,13 +12,13 @@ test('evaluate: non-repo, clean synced and remote-less repos pass', () => {
|
|
|
12
12
|
assert.equal(evaluateGitState({ isRepo: true, porcelain: '', hasRemote: false }).ok, true)
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
test('evaluate: dirty tracked files
|
|
15
|
+
test('evaluate: dirty tracked files are reported first', () => {
|
|
16
16
|
const v = evaluateGitState({ isRepo: true, porcelain: ' M a.js\n', upstreamAhead: 0 })
|
|
17
17
|
assert.equal(v.ok, false)
|
|
18
18
|
assert.match(v.reason, /1 tracked file/)
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
test('evaluate: ahead of upstream
|
|
21
|
+
test('evaluate: ahead of upstream is reported', () => {
|
|
22
22
|
assert.match(evaluateGitState({ isRepo: true, porcelain: '', upstreamAhead: 2 }).reason, /2 commit\(s\) not pushed/)
|
|
23
23
|
})
|
|
24
24
|
|
|
@@ -85,7 +85,7 @@ test('real git: not a repository passes', async (t) => {
|
|
|
85
85
|
assert.equal((await verdict(scratch(t, 'gitgate-none-'))).ok, true)
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
test('real git: pushed branch passes, an unpushed commit and a dirty file
|
|
88
|
+
test('real git: pushed branch passes, an unpushed commit and a dirty file are reported', async (t) => {
|
|
89
89
|
const { proj } = sandbox(t)
|
|
90
90
|
assert.equal((await verdict(proj)).ok, true)
|
|
91
91
|
commit(proj, 'b.txt')
|
|
@@ -561,7 +561,7 @@ test('the running-work note shows once at start and not again at /clear', async
|
|
|
561
561
|
assert.equal(noteToasts(h).length, 1)
|
|
562
562
|
})
|
|
563
563
|
|
|
564
|
-
test('handoff
|
|
564
|
+
test('handoff continues with a warning when the branch has unpushed commits and no upstream', async () => {
|
|
565
565
|
const h = await harness()
|
|
566
566
|
await h.start()
|
|
567
567
|
await startHandoffFlow(h)
|
|
@@ -577,8 +577,8 @@ test('handoff does not clear when the branch has unpushed commits and no upstrea
|
|
|
577
577
|
return { exitCode: 1, stdout: '' }
|
|
578
578
|
}
|
|
579
579
|
await finishPrep(h)
|
|
580
|
-
assert.equal(h.cleared,
|
|
581
|
-
assert.
|
|
580
|
+
assert.equal(h.cleared, 1)
|
|
581
|
+
assert.deepEqual(h.toasts.filter((t) => /^Handoff continues: /.test(t)), ['Handoff continues: branch has no upstream: 2 commit(s) not on origin/main'])
|
|
582
582
|
})
|
|
583
583
|
|
|
584
584
|
test('the prep prompt opens with a plain label and keeps the sentinel path', async () => {
|
|
@@ -848,30 +848,48 @@ test('auto: a running subagent does not stop the auto run', async () => {
|
|
|
848
848
|
assert.equal(noteToasts(h).length, 1)
|
|
849
849
|
})
|
|
850
850
|
|
|
851
|
-
|
|
851
|
+
const STOPPED = 'Auto-handoff stopped after a failed attempt. Use /handoff or the band button; /handoff auto on re-enables it'
|
|
852
|
+
const stoppedToasts = (h) => h.toasts.filter((t) => t === STOPPED)
|
|
853
|
+
|
|
854
|
+
test('auto: one attempt per session, an abort turns auto off with one toast, however far context grows', async () => {
|
|
852
855
|
const h = await autoHarness()
|
|
853
856
|
await h.tick()
|
|
854
857
|
await settle()
|
|
855
858
|
await abortPrep(h)
|
|
856
|
-
assert.
|
|
857
|
-
for (
|
|
859
|
+
assert.deepEqual(stoppedToasts(h), [STOPPED])
|
|
860
|
+
for (const percent of [70, 75, 80, 95, 99]) {
|
|
861
|
+
h.context = { percent, tokens: 1 }
|
|
858
862
|
advance(h, 20000)
|
|
859
863
|
await h.tick()
|
|
860
864
|
await settle()
|
|
861
865
|
}
|
|
862
866
|
assert.equal(prepSubmitted(h).length, 1)
|
|
863
|
-
h.
|
|
867
|
+
assert.equal(stoppedToasts(h).length, 1)
|
|
868
|
+
assert.match((await h.fire('command.run', { args: 'auto status' }, 'handoff')).text, /auto-handoff off .*stopped after a failed attempt/)
|
|
869
|
+
})
|
|
870
|
+
|
|
871
|
+
test('auto: the persisted preference is untouched by a failed attempt and a new session reads it back', async () => {
|
|
872
|
+
const h = await autoHarness({ store: { auto: true } })
|
|
864
873
|
await h.tick()
|
|
865
874
|
await settle()
|
|
866
|
-
|
|
867
|
-
assert.
|
|
868
|
-
h.
|
|
875
|
+
await abortPrep(h)
|
|
876
|
+
assert.equal(h.store.auto, true)
|
|
877
|
+
await h.start()
|
|
878
|
+
assert.equal((await h.fire('command.run', { args: 'auto status' }, 'handoff')).text, 'auto-handoff on at 65% context')
|
|
879
|
+
})
|
|
880
|
+
|
|
881
|
+
test('auto: /handoff auto on re-arms after a failed attempt', async () => {
|
|
882
|
+
const h = await autoHarness()
|
|
883
|
+
await h.tick()
|
|
884
|
+
await settle()
|
|
885
|
+
await abortPrep(h)
|
|
886
|
+
await h.fire('command.run', { args: 'auto on' }, 'handoff')
|
|
869
887
|
await h.tick()
|
|
870
888
|
await settle()
|
|
871
889
|
assert.equal(prepSubmitted(h).length, 2)
|
|
872
890
|
})
|
|
873
891
|
|
|
874
|
-
test('auto: manual start after an aborted auto run
|
|
892
|
+
test('auto: manual start after an aborted auto run works', async () => {
|
|
875
893
|
const h = await autoHarness()
|
|
876
894
|
await h.tick()
|
|
877
895
|
await settle()
|
|
@@ -880,29 +898,87 @@ test('auto: manual start after an aborted auto run is not blocked by the cooldow
|
|
|
880
898
|
assert.equal(prepSubmitted(h).length, 2)
|
|
881
899
|
})
|
|
882
900
|
|
|
883
|
-
test('auto:
|
|
901
|
+
test('auto: a failed manual handoff never triggers an automatic one', async () => {
|
|
884
902
|
const h = await autoHarness()
|
|
885
|
-
await h
|
|
886
|
-
await settle()
|
|
903
|
+
await startHandoffFlow(h)
|
|
887
904
|
await abortPrep(h)
|
|
888
|
-
h.
|
|
889
|
-
await h.tick()
|
|
890
|
-
h.context = HIGH
|
|
905
|
+
assert.equal(stoppedToasts(h).length, 1)
|
|
891
906
|
await h.tick()
|
|
892
907
|
await settle()
|
|
893
|
-
assert.equal(prepSubmitted(h).length,
|
|
908
|
+
assert.equal(prepSubmitted(h).length, 1)
|
|
894
909
|
})
|
|
895
910
|
|
|
896
|
-
test('auto: a manual
|
|
911
|
+
test('auto: a failed manual handoff with auto already off shows no stopped toast; auto on re-arms', async () => {
|
|
897
912
|
const h = await autoHarness({ store: { auto: false } })
|
|
898
913
|
await startHandoffFlow(h)
|
|
899
914
|
await abortPrep(h)
|
|
915
|
+
assert.equal(stoppedToasts(h).length, 0)
|
|
916
|
+
await h.tick()
|
|
917
|
+
await settle()
|
|
918
|
+
assert.equal(prepSubmitted(h).length, 1)
|
|
900
919
|
await h.fire('command.run', { args: 'auto on' }, 'handoff')
|
|
901
920
|
await h.tick()
|
|
902
921
|
await settle()
|
|
903
922
|
assert.equal(prepSubmitted(h).length, 2)
|
|
904
923
|
})
|
|
905
924
|
|
|
925
|
+
const gitRun = (porcelain, ahead = 0) => async (argv) => {
|
|
926
|
+
const cmd = argv.slice(1).join(' ')
|
|
927
|
+
if (cmd === 'rev-parse --is-inside-work-tree') return { exitCode: 0, stdout: 'true\n' }
|
|
928
|
+
if (cmd.startsWith('status --porcelain')) return { exitCode: 0, stdout: porcelain }
|
|
929
|
+
if (cmd.startsWith('symbolic-ref --quiet HEAD')) return { exitCode: 0, stdout: 'refs/heads/main\n' }
|
|
930
|
+
if (cmd === 'rev-list --count @{upstream}..HEAD') return { exitCode: 0, stdout: ahead + '\n' }
|
|
931
|
+
return { exitCode: 1, stdout: '' }
|
|
932
|
+
}
|
|
933
|
+
const handoffText = (h) => h.submitted.find((s) => s.asUser && /Session handoff/.test(s.text)).text
|
|
934
|
+
const continuesToasts = (h) => h.toasts.filter((t) => /^Handoff continues: /.test(t))
|
|
935
|
+
|
|
936
|
+
test('git state is advisory: a dirty tree does not abort, one toast, warning line at the end of the submission', async () => {
|
|
937
|
+
const h = await harness()
|
|
938
|
+
h.$.process.run = gitRun(' M a.js\n M b.js\n')
|
|
939
|
+
await h.start()
|
|
940
|
+
await startHandoffFlow(h)
|
|
941
|
+
await finishPrep(h)
|
|
942
|
+
assert.equal(h.cleared, 1)
|
|
943
|
+
assert.deepEqual(continuesToasts(h), ['Handoff continues: 2 tracked file(s) have uncommitted changes'])
|
|
944
|
+
assert.ok(!h.toasts.some((t) => /aborted/i.test(t)))
|
|
945
|
+
assert.ok(handoffText(h).endsWith('\n\nWarning: 2 tracked file(s) have uncommitted changes.'))
|
|
946
|
+
assert.equal(h.files[HANDOFF_PATH], HANDOFF_BODY)
|
|
947
|
+
})
|
|
948
|
+
|
|
949
|
+
test('git state is advisory: unpushed commits continue with the warning', async () => {
|
|
950
|
+
const h = await harness()
|
|
951
|
+
h.$.process.run = gitRun('', 3)
|
|
952
|
+
await h.start()
|
|
953
|
+
await startHandoffFlow(h)
|
|
954
|
+
await finishPrep(h)
|
|
955
|
+
assert.equal(h.cleared, 1)
|
|
956
|
+
assert.deepEqual(continuesToasts(h), ['Handoff continues: 3 commit(s) not pushed'])
|
|
957
|
+
assert.ok(handoffText(h).endsWith('Warning: 3 commit(s) not pushed.'))
|
|
958
|
+
})
|
|
959
|
+
|
|
960
|
+
test('a clean git state adds no toast and no warning line', async () => {
|
|
961
|
+
const h = await harness()
|
|
962
|
+
h.$.process.run = gitRun('')
|
|
963
|
+
await h.start()
|
|
964
|
+
await startHandoffFlow(h)
|
|
965
|
+
await finishPrep(h)
|
|
966
|
+
assert.equal(continuesToasts(h).length, 0)
|
|
967
|
+
assert.ok(!/Warning:/.test(handoffText(h)))
|
|
968
|
+
})
|
|
969
|
+
|
|
970
|
+
test('a throwing git probe does not abort the handoff', async () => {
|
|
971
|
+
const h = await harness()
|
|
972
|
+
h.$.process.run = async () => {
|
|
973
|
+
throw new Error('git missing')
|
|
974
|
+
}
|
|
975
|
+
await h.start()
|
|
976
|
+
await startHandoffFlow(h)
|
|
977
|
+
await finishPrep(h)
|
|
978
|
+
assert.equal(h.cleared, 1)
|
|
979
|
+
assert.ok(!h.toasts.some((t) => /aborted/i.test(t)))
|
|
980
|
+
})
|
|
981
|
+
|
|
906
982
|
test('auto: the toggle button flips the setting, saves it, redraws, and a new session reads it back', async () => {
|
|
907
983
|
const h = await harness({ store: {} })
|
|
908
984
|
await h.start()
|
|
@@ -34,6 +34,16 @@ test('template starts with the running-work step and carries rebase-conflict gui
|
|
|
34
34
|
assert.match(template, /4\. Code\..*conflict.*both sides' intent.*re-run the tests.*open risks/)
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
+
test('step 4 commits only this session work, never aborts on other uncommitted or unpushed state', () => {
|
|
38
|
+
const step4 = template.slice(template.indexOf('4. Code.'), template.indexOf('5. Handoff file.'))
|
|
39
|
+
assert.match(step4, /only what this session changed/)
|
|
40
|
+
assert.match(step4, /Other uncommitted files, unpushed commits or a detached HEAD may belong to other sessions: leave them, do not abort, and list them \(paths, owner if known\) in open risks/)
|
|
41
|
+
assert.ok(!step4.includes('Leave no uncommitted'))
|
|
42
|
+
const abort = template.slice(template.indexOf('Abort rule:'))
|
|
43
|
+
assert.match(abort, /^Abort rule: only if tests of files this session changed fail or the push of this session's own commits fails/)
|
|
44
|
+
assert.ok(!/uncommitted|unpushed/.test(abort))
|
|
45
|
+
})
|
|
46
|
+
|
|
37
47
|
test('template is lean', () => {
|
|
38
48
|
assert.ok(template.length < 2500, 'template length ' + template.length)
|
|
39
49
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.5",
|
|
4
4
|
"description": "CLI for installing the yasaswy.nagavolu agent/skill/hook bundle. `install` opens an interactive bundle menu in a TTY (or `--bundle <key> --yes` for non-interactive installs), with hash-tracked idempotent deploys, automatic hook wiring into settings.json, and masked secret prompting. `update` reconciles installed bundles against the current source (hash-tracked: silent overwrite, conflict diff+prompt, or --theirs/--keep-mine). `uninstall` removes a bundle's files and wiring. `secrets` re-runs secret prompting for already-installed bundles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|