@christang/keel 5.144.0 → 5.145.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/.claude-plugin/plugin.json +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +88 -2
- package/src/core/chat/notice.js +41 -4
- package/src/core/shift.js +17 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.145.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.145.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.145.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.145.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.145.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
|
|
|
49
49
|
"scripts/validate_plugin.py",
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
-
PACKAGE_VERSION = "5.
|
|
53
|
-
PROTOCOL_VERSION = "5.
|
|
52
|
+
PACKAGE_VERSION = "5.145.0"
|
|
53
|
+
PROTOCOL_VERSION = "5.145.0"
|
|
54
54
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
55
55
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
56
56
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -6373,6 +6373,91 @@ def validate_shift_keeps_transcripts_scenario() -> int:
|
|
|
6373
6373
|
return 0
|
|
6374
6374
|
|
|
6375
6375
|
|
|
6376
|
+
def validate_shift_keeps_found_transcripts_scenario() -> int:
|
|
6377
|
+
"""Issue #361: a transcript `history` finds but never recorded is kept too.
|
|
6378
|
+
|
|
6379
|
+
Transcripts from before segments were recorded (#304) are listed
|
|
6380
|
+
`(found)`; the hook copied only recorded segments, and `history` read a
|
|
6381
|
+
copy only through a segment record, so the oldest conversations were the
|
|
6382
|
+
ones left unkept.
|
|
6383
|
+
"""
|
|
6384
|
+
label = "shift-keeps-found-transcripts:"
|
|
6385
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-361-") as raw:
|
|
6386
|
+
base = Path(raw)
|
|
6387
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
6388
|
+
kept_dir = mailbox_common_dir(rtl) / "keel-chat" / "shift" / "transcripts" / "verify"
|
|
6389
|
+
roles = json.loads((mailbox_common_dir(rtl) / "keel-chat" / "roles.json").read_text(encoding="utf-8"))
|
|
6390
|
+
bound = next(path for path, role in roles.items() if role == "verify")
|
|
6391
|
+
project = base / "claude-config" / "projects" / re.sub(r"[^A-Za-z0-9]", "-", bound)
|
|
6392
|
+
project.mkdir(parents=True)
|
|
6393
|
+
env = {**env, "CLAUDE_CONFIG_DIR": str(base / "claude-config")}
|
|
6394
|
+
|
|
6395
|
+
def transcript(name: str, opening: str, said: str) -> Path:
|
|
6396
|
+
path = project / f"{name}.jsonl"
|
|
6397
|
+
path.write_text("\n".join(json.dumps(record) for record in (
|
|
6398
|
+
{"type": "user", "timestamp": "2026-10-02T01:00:00.000Z", "cwd": bound, "message": {"role": "user", "content": opening}},
|
|
6399
|
+
{"type": "assistant", "timestamp": "2026-10-02T01:00:05.000Z", "cwd": bound,
|
|
6400
|
+
"message": {"role": "assistant", "content": [{"type": "text", "text": said}]}},
|
|
6401
|
+
)) + "\n", encoding="utf-8")
|
|
6402
|
+
return path
|
|
6403
|
+
|
|
6404
|
+
def hook(path: Path) -> None:
|
|
6405
|
+
for event, name in (("session-start", "SessionStart"), ("user-prompt-submit", "UserPromptSubmit")):
|
|
6406
|
+
subprocess.run(
|
|
6407
|
+
["node", str(ROOT / "bin" / "keel.js"), "chat", "hook", event],
|
|
6408
|
+
cwd=verify, env=env, text=True, capture_output=True, check=False,
|
|
6409
|
+
input=json.dumps({"cwd": str(verify), "hook_event_name": name, "session_id": "s1",
|
|
6410
|
+
"prompt": "go", "source": "startup", "transcript_path": str(path)}),
|
|
6411
|
+
)
|
|
6412
|
+
|
|
6413
|
+
old = transcript("old", "start the shift", "The ECC syndrome table was settled on day one.")
|
|
6414
|
+
scheduled = transcript("patrol", '<scheduled-task name="patrol">run', "patrol ran")
|
|
6415
|
+
listed = run_keel(verify, "shift", "history", "verify", env=env)
|
|
6416
|
+
if "(found)" not in next((l for l in listed.stdout.splitlines() if "old.jsonl" in l), ""):
|
|
6417
|
+
report(f"{label} the unrecorded transcript is not listed as found: {listed.stdout!r} {listed.stderr!r}")
|
|
6418
|
+
return 1
|
|
6419
|
+
hook(transcript("a", "carry on", "first recorded shift"))
|
|
6420
|
+
hook(transcript("b", "carry on", "second recorded shift"))
|
|
6421
|
+
kept_old = kept_dir / "old.jsonl.gz"
|
|
6422
|
+
if not kept_old.is_file():
|
|
6423
|
+
report(f"{label} a segment change left the found transcript unkept: "
|
|
6424
|
+
f"{sorted(p.name for p in kept_dir.glob('*')) if kept_dir.exists() else 'no directory'}")
|
|
6425
|
+
return 1
|
|
6426
|
+
if gzip.decompress(kept_old.read_bytes()) != old.read_bytes():
|
|
6427
|
+
report(f"{label} the found transcript's copy is not its bytes.")
|
|
6428
|
+
return 1
|
|
6429
|
+
if (kept_dir / "patrol.jsonl.gz").exists():
|
|
6430
|
+
report(f"{label} a scheduled run's transcript was kept as the role's conversation.")
|
|
6431
|
+
return 1
|
|
6432
|
+
if (kept_dir / "b.jsonl.gz").exists():
|
|
6433
|
+
report(f"{label} the current transcript was copied while it is still being written.")
|
|
6434
|
+
return 1
|
|
6435
|
+
|
|
6436
|
+
old.unlink()
|
|
6437
|
+
listed = run_keel(verify, "shift", "history", "verify", env=env)
|
|
6438
|
+
line = next((l for l in listed.stdout.splitlines() if "old.jsonl" in l), "")
|
|
6439
|
+
if "(missing)" in line:
|
|
6440
|
+
report(f"{label} the found transcript, deleted but kept, is listed missing: {listed.stdout!r}")
|
|
6441
|
+
return 1
|
|
6442
|
+
if "(kept)" not in line:
|
|
6443
|
+
report(f"{label} the found transcript, deleted but kept, is not listed (kept): {listed.stdout!r}")
|
|
6444
|
+
return 1
|
|
6445
|
+
found = run_keel(verify, "shift", "history", "verify", "--grep", "syndrome table", env=env)
|
|
6446
|
+
if "syndrome table" not in found.stdout:
|
|
6447
|
+
report(f"{label} --grep does not search the found transcript's copy: {found.stdout!r} {found.stderr!r}")
|
|
6448
|
+
return 1
|
|
6449
|
+
hook(transcript("c", "carry on", "third recorded shift"))
|
|
6450
|
+
listed = run_keel(verify, "shift", "history", "verify", env=env)
|
|
6451
|
+
if sum(1 for l in listed.stdout.splitlines() if "old.jsonl" in l) != 1:
|
|
6452
|
+
report(f"{label} another segment change did not leave the kept found transcript listed once: {listed.stdout!r}")
|
|
6453
|
+
return 1
|
|
6454
|
+
if "shift-keeps-found-transcripts" not in {name for name, _ in SCENARIOS}:
|
|
6455
|
+
report(f"{label} scenario is not registered.")
|
|
6456
|
+
return 1
|
|
6457
|
+
report("shift-keeps-found-transcripts scenario passed.")
|
|
6458
|
+
return 0
|
|
6459
|
+
|
|
6460
|
+
|
|
6376
6461
|
def validate_shift_history_scenario() -> int:
|
|
6377
6462
|
"""Issue #304: a cleared shift's conversation stays findable.
|
|
6378
6463
|
|
|
@@ -41445,6 +41530,7 @@ SCENARIOS: tuple = (
|
|
|
41445
41530
|
("owner-language-after-tools", validate_owner_language_after_tools_scenario),
|
|
41446
41531
|
("shift-history", validate_shift_history_scenario),
|
|
41447
41532
|
("shift-keeps-transcripts", validate_shift_keeps_transcripts_scenario),
|
|
41533
|
+
("shift-keeps-found-transcripts", validate_shift_keeps_found_transcripts_scenario),
|
|
41448
41534
|
("role-drift", validate_role_drift_scenario),
|
|
41449
41535
|
("host-run-session", validate_host_run_session_scenario),
|
|
41450
41536
|
("shift-without-role", validate_shift_without_role_scenario),
|
package/src/core/chat/notice.js
CHANGED
|
@@ -268,6 +268,13 @@ function keptFile(where, role, transcript) {
|
|
|
268
268
|
// copy. The host deletes transcripts after its cleanup period (30 days by
|
|
269
269
|
// default for Claude), so the copy is what keeps a shift's conversation. The
|
|
270
270
|
// current segment is left alone: it is still being written.
|
|
271
|
+
function writeKept(target, transcript) {
|
|
272
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
273
|
+
const temporary = `${target}.${process.pid}.tmp`;
|
|
274
|
+
fs.writeFileSync(temporary, zlib.gzipSync(fs.readFileSync(transcript)));
|
|
275
|
+
fs.renameSync(temporary, target);
|
|
276
|
+
}
|
|
277
|
+
|
|
271
278
|
function keepEnded(where, role, segments) {
|
|
272
279
|
for (const segment of segments) {
|
|
273
280
|
if (!segment.ended || !segment.transcript) continue;
|
|
@@ -276,16 +283,45 @@ function keepEnded(where, role, segments) {
|
|
|
276
283
|
const target = keptFile(where, role, segment.transcript);
|
|
277
284
|
const kept = segment.kept_from;
|
|
278
285
|
if (fs.existsSync(target) && kept && kept.size === source.size && kept.mtime === source.mtimeMs) continue;
|
|
279
|
-
|
|
280
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
281
|
-
fs.writeFileSync(temporary, zlib.gzipSync(fs.readFileSync(segment.transcript)));
|
|
282
|
-
fs.renameSync(temporary, target);
|
|
286
|
+
writeKept(target, segment.transcript);
|
|
283
287
|
segment.kept = target;
|
|
284
288
|
segment.kept_from = { size: source.size, mtime: source.mtimeMs };
|
|
285
289
|
} catch {
|
|
286
290
|
// The host's file may already be gone; a copy is a convenience.
|
|
287
291
|
}
|
|
288
292
|
}
|
|
293
|
+
keepFound(where, role, segments);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// The transcripts `history` finds for the role but no record names — those
|
|
297
|
+
// from before segments were recorded (#304) — are kept too, and recorded,
|
|
298
|
+
// still marked found, so `history` lists them once the host's file is gone
|
|
299
|
+
// and later changes refresh their copy like any other ended segment (#361).
|
|
300
|
+
// Each is read once, when it is first recorded.
|
|
301
|
+
function keepFound(where, role, segments) {
|
|
302
|
+
const recorded = new Set(segments.map((segment) => segment.transcript));
|
|
303
|
+
let found = [];
|
|
304
|
+
try {
|
|
305
|
+
found = require("../shift").foundTranscripts(where, role, (transcript) => !recorded.has(transcript));
|
|
306
|
+
} catch {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const added = [];
|
|
310
|
+
for (const segment of found) {
|
|
311
|
+
if (recorded.has(segment.transcript)) continue;
|
|
312
|
+
recorded.add(segment.transcript);
|
|
313
|
+
try {
|
|
314
|
+
const source = fs.statSync(segment.transcript);
|
|
315
|
+
const target = keptFile(where, role, segment.transcript);
|
|
316
|
+
// A copy at least as new as the transcript, such as one made by hand, is kept as it is.
|
|
317
|
+
if (!fs.existsSync(target) || fs.statSync(target).mtimeMs < source.mtimeMs) writeKept(target, segment.transcript);
|
|
318
|
+
added.push({ ...segment, kept: target, kept_from: { size: source.size, mtime: source.mtimeMs } });
|
|
319
|
+
} catch {
|
|
320
|
+
// As for a recorded segment, a copy is a convenience.
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// The current segment stays last: `recordSegment` reads it there.
|
|
324
|
+
segments.splice(Math.max(segments.length - 1, 0), 0, ...added);
|
|
289
325
|
}
|
|
290
326
|
|
|
291
327
|
function recordSegment(where, role, transcript) {
|
|
@@ -485,6 +521,7 @@ module.exports = {
|
|
|
485
521
|
wakeStep,
|
|
486
522
|
check,
|
|
487
523
|
bridgeLine,
|
|
524
|
+
keptFile,
|
|
488
525
|
hook,
|
|
489
526
|
noticeText,
|
|
490
527
|
presenceFile,
|
package/src/core/shift.js
CHANGED
|
@@ -707,7 +707,8 @@ function grepTranscript(file, needle, limit = 3) {
|
|
|
707
707
|
|
|
708
708
|
// Transcripts Claude already keeps for a worktree (#304 D6, F5): its project
|
|
709
709
|
// directory is the cwd with every non-alphanumeric character turned into `-`.
|
|
710
|
-
|
|
710
|
+
// `wanted` is asked before a file is read, so a caller can skip the parse.
|
|
711
|
+
function claudeTranscripts(worktree, wanted = () => true) {
|
|
711
712
|
const config = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
|
|
712
713
|
const found = [];
|
|
713
714
|
for (const cwd of new Set([worktree, realpath(worktree)])) {
|
|
@@ -715,6 +716,7 @@ function claudeTranscripts(worktree) {
|
|
|
715
716
|
for (const name of safeList(dir)) {
|
|
716
717
|
if (!name.endsWith(".jsonl")) continue;
|
|
717
718
|
const file = path.join(dir, name);
|
|
719
|
+
if (!wanted(file)) continue;
|
|
718
720
|
let first = null;
|
|
719
721
|
let last = null;
|
|
720
722
|
let opening = null;
|
|
@@ -741,6 +743,13 @@ function claudeTranscripts(worktree) {
|
|
|
741
743
|
return found;
|
|
742
744
|
}
|
|
743
745
|
|
|
746
|
+
// The Claude transcripts of every worktree bound to `role`, scheduled runs left out.
|
|
747
|
+
function foundTranscripts(where, role, wanted) {
|
|
748
|
+
const bound = Object.entries(store.readJsonFile(path.join(where.root, "roles.json")))
|
|
749
|
+
.filter(([, name]) => name === role).map(([worktree]) => worktree);
|
|
750
|
+
return bound.flatMap((worktree) => claudeTranscripts(worktree, wanted));
|
|
751
|
+
}
|
|
752
|
+
|
|
744
753
|
function history(where, named, grep) {
|
|
745
754
|
const role = named || store.currentRole(where);
|
|
746
755
|
if (!role) throw new ShiftError("keel shift history needs a role: name it, or run it in a worktree bound to one.");
|
|
@@ -749,9 +758,11 @@ function history(where, named, grep) {
|
|
|
749
758
|
const stored = fs.existsSync(file) ? store.readJsonFile(file).segments : [];
|
|
750
759
|
const recorded = Array.isArray(stored) ? stored : [];
|
|
751
760
|
const known = new Set(recorded.map((segment) => segment.transcript));
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
761
|
+
const earlier = foundTranscripts(where, role).filter((segment) => !known.has(segment.transcript));
|
|
762
|
+
const { keptFile } = require("./chat/notice");
|
|
763
|
+
// A found segment has no record to name its copy, so the kept path is looked at directly (#361).
|
|
764
|
+
const keptCopy = (segment) => [segment.kept, keptFile(where, role, segment.transcript)]
|
|
765
|
+
.find((file) => file && fs.existsSync(file)) || null;
|
|
755
766
|
const seen = new Set();
|
|
756
767
|
// Newest first; the sort is stable, so segments recorded in the same second keep their order.
|
|
757
768
|
const segments = [...recorded.slice().reverse(), ...earlier]
|
|
@@ -760,7 +771,7 @@ function history(where, named, grep) {
|
|
|
760
771
|
.map((segment) => ({
|
|
761
772
|
...segment,
|
|
762
773
|
exists: fs.existsSync(segment.transcript),
|
|
763
|
-
kept:
|
|
774
|
+
kept: keptCopy(segment),
|
|
764
775
|
}));
|
|
765
776
|
const notes = safeList(path.join(shiftDir(where), "history"))
|
|
766
777
|
.filter((name) => name.startsWith(`${role}-`) && name.endsWith(".md"))
|
|
@@ -1021,4 +1032,4 @@ function waitingFor(repo) {
|
|
|
1021
1032
|
}
|
|
1022
1033
|
|
|
1023
1034
|
module.exports = {
|
|
1024
|
-
desktopProcess, check, describe, runShift, shiftStatus: status, waitingFor };
|
|
1035
|
+
desktopProcess, foundTranscripts, check, describe, runShift, shiftStatus: status, waitingFor };
|