@christang/keel 5.229.1 → 5.229.2
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/test_codex_host.js +9 -4
- package/scripts/validation/common.py +2 -2
- package/src/core/codex-host.js +14 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.2",
|
|
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.229.
|
|
3
|
+
"version": "5.229.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.229.
|
|
9
|
+
"version": "5.229.2",
|
|
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.229.
|
|
3
|
+
"version": "5.229.2",
|
|
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.229.
|
|
3
|
+
"version": "5.229.2",
|
|
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",
|
|
@@ -10,8 +10,8 @@ const {spawn}=require('node:child_process');
|
|
|
10
10
|
const cli=path.resolve(__dirname,'../bin/keel.js');
|
|
11
11
|
function run(args,action="status"){return new Promise(resolve=>{const p=spawn(process.execPath,action==='tick'?[cli,'tick',...args]:[cli,'codex',action,...args]);let out='',err='';p.stdout.on('data',b=>out+=b);p.stderr.on('data',b=>err+=b);p.on('close',code=>resolve({code,out,err}));});}
|
|
12
12
|
test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
13
|
-
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const requestDetails=[];const peers=[];let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false,unloaded=false,resumeActive=false,resumeFails=false,resumeMismatch=false,readMismatch=false,resumeDelay=false;
|
|
14
|
-
const server=http.createServer();server.on('upgrade',(req,s)=>{peers.push(s);s.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: '+crypto.createHash('sha1').update(req.headers['sec-websocket-key']+'258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')+'\r\n\r\n');let initialized=false;let buf=Buffer.alloc(0);s.on('data',chunk=>{buf=Buffer.concat([buf,chunk]);while(buf.length>=6){let n=buf[1]&127,off=2;if(n===126){if(buf.length<8)return;n=buf.readUInt16BE(2);off=4;}else if(n===127){if(buf.length<14)return;n=Number(buf.readBigUInt64BE(2));off=10;}if(buf.length<off+4+n)return;const mask=buf.subarray(off,off+4);const data=Buffer.from(buf.subarray(off+4,off+4+n));buf=buf.subarray(off+4+n);for(let i=0;i<data.length;i++)data[i]^=mask[i%4];const x=JSON.parse(data);requests.push(x.method);requestDetails.push(x);if(x.method==='initialized'){initialized=true;continue;}if(!x.id)continue;if(x.method!=='initialize'&&!initialized){s.destroy();return;}if(x.method==='thread/resume'){if(resumeFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture resume failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}unloaded=false;if(resumeActive)active=true;}const result=x.method==='initialize'?(invalidHost?{}:{userAgent:'test-host'}):x.method==='turn/start'?{turn:uncertain?{}:{id:'turn-fixture'}}:{thread:{id:x.method==='thread/start'?`fixture-thread-${++serial}`:(x.params.threadId||'fixture-thread'),status:{type:unloaded?'notLoaded':active?'active':'idle'},cwd:readMismatch||(x.method==='thread/resume'&&resumeMismatch)?'/wrong-worktree':dir}};const b=Buffer.from(JSON.stringify({id:x.id,result}));const h=b.length<126?Buffer.from([129,b.length]):Buffer.from([129,126,b.length>>8,b.length&255]);const split=Math.floor(b.length/2);const frame=(op,body)=>Buffer.concat([body.length<126?Buffer.from([op,body.length]):Buffer.from([op,126,body.length>>8,body.length&255]),body]);if(injectNotice){const notice=Buffer.from(JSON.stringify({id:x.id,method:'server/notice',params:{}}));s.write(frame(129,notice));}const reply=()=>{if(!s.destroyed)s.write(Buffer.concat([frame(1,b.subarray(0,split)),frame(128,b.subarray(split))]));};if(resumeDelay&&x.method==='thread/resume')setTimeout(reply,5500).unref();else reply();}});});
|
|
13
|
+
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const requestDetails=[];const peers=[];const blank=new Set(),lost=new Set();let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false,unloaded=false,resumeActive=false,resumeFails=false,resumeMismatch=false,readMismatch=false,resumeDelay=false,initNameFails=false;
|
|
14
|
+
const server=http.createServer();server.on('upgrade',(req,s)=>{peers.push(s);s.on('end',()=>{for(const id of blank)lost.add(id);});s.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: '+crypto.createHash('sha1').update(req.headers['sec-websocket-key']+'258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')+'\r\n\r\n');let initialized=false;let buf=Buffer.alloc(0);s.on('data',chunk=>{buf=Buffer.concat([buf,chunk]);while(buf.length>=6){let n=buf[1]&127,off=2;if(n===126){if(buf.length<8)return;n=buf.readUInt16BE(2);off=4;}else if(n===127){if(buf.length<14)return;n=Number(buf.readBigUInt64BE(2));off=10;}if(buf.length<off+4+n)return;const mask=buf.subarray(off,off+4);const data=Buffer.from(buf.subarray(off+4,off+4+n));buf=buf.subarray(off+4+n);for(let i=0;i<data.length;i++)data[i]^=mask[i%4];const x=JSON.parse(data);requests.push(x.method);requestDetails.push(x);if(x.method==='initialized'){initialized=true;continue;}if(!x.id)continue;if(x.method!=='initialize'&&!initialized){s.destroy();return;}if(x.method==='thread/read'&&lost.has(x.params.threadId)){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'thread not loaded: '+x.params.threadId}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}if(x.method==='thread/name/set'&&!initNameFails)blank.delete(x.params.threadId);if(x.method==='thread/name/set'&&initNameFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture name persistence failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}if(x.method==='thread/resume'){if(resumeFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture resume failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}unloaded=false;if(resumeActive)active=true;}const result=x.method==='initialize'?(invalidHost?{}:{userAgent:'test-host'}):x.method==='turn/start'?{turn:uncertain?{}:{id:'turn-fixture'}}:{thread:{id:x.method==='thread/start'?`fixture-thread-${++serial}`:(x.params.threadId||'fixture-thread'),status:{type:unloaded?'notLoaded':active?'active':'idle'},cwd:(x.method==='thread/read'&&readMismatch)||(x.method==='thread/resume'&&resumeMismatch)?'/wrong-worktree':dir}};if(x.method==='thread/start')blank.add(result.thread.id);const b=Buffer.from(JSON.stringify({id:x.id,result}));const h=b.length<126?Buffer.from([129,b.length]):Buffer.from([129,126,b.length>>8,b.length&255]);const split=Math.floor(b.length/2);const frame=(op,body)=>Buffer.concat([body.length<126?Buffer.from([op,body.length]):Buffer.from([op,126,body.length>>8,body.length&255]),body]);if(injectNotice){const notice=Buffer.from(JSON.stringify({id:x.id,method:'server/notice',params:{}}));s.write(frame(129,notice));}const reply=()=>{if(!s.destroyed)s.write(Buffer.concat([frame(1,b.subarray(0,split)),frame(128,b.subarray(split))]));};if(resumeDelay&&x.method==='thread/resume')setTimeout(reply,5500).unref();else reply();}});});
|
|
15
15
|
await new Promise(r=>server.listen(sock,r));
|
|
16
16
|
try{const x=await run(['--socket',sock,'--thread','fixture-thread','--json']);assert.equal(x.code,0,x.err);assert.equal(JSON.parse(x.out).thread.status.type,'active');assert.deepEqual(requests.filter(x=>x!=='initialized'),['initialize','thread/read']);
|
|
17
17
|
active=false;const {spawnSync}=require('node:child_process');spawnSync('git',['init','-q',dir]);
|
|
@@ -21,12 +21,13 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
|
21
21
|
assert.equal(JSON.parse(started.out).role,'test-role');
|
|
22
22
|
const again=await run(['--socket',sock,'--repo',dir,'--role','test-role'],'start');assert.notEqual(again.code,0);assert.match(again.err,/already|exists/);
|
|
23
23
|
const own=await run(['--repo',dir,'--role','test-role','--json']);assert.equal(own.code,0,own.err);
|
|
24
|
+
assert.deepEqual(requestDetails.find(x=>x.method==='thread/name/set')?.params,{threadId:'fixture-thread-1',name:'test-role'},'successful start must persist its original identity through native naming');
|
|
24
25
|
assert.equal(requests.filter(x=>x==='thread/start').length,1);
|
|
25
26
|
const message=['--repo',dir,'--role','test-role','--record','fixture-record','--text','Run keel chat unread','--json'];
|
|
26
27
|
const sent=await run(message,'deliver');assert.equal(sent.code,0,sent.err);
|
|
27
28
|
const duplicate=await run(message,'deliver');assert.equal(duplicate.code,0,duplicate.err);assert.equal(requests.filter(x=>x==='turn/start').length,1);
|
|
28
29
|
active=true;const waiting=await run(['--repo',dir,'--role','test-role','--note','finish fixture','--json'],'handover');assert.equal(waiting.code,0,waiting.err);assert.equal(JSON.parse(waiting.out).state,'waiting');assert.equal(serial,1);
|
|
29
|
-
active=false;const handed=await run(['--repo',dir,'--role','test-role','--note','finish fixture','--json'],'handover');assert.equal(handed.code,0,handed.err);assert.equal(serial,2);
|
|
30
|
+
active=false;const handed=await run(['--repo',dir,'--role','test-role','--note','finish fixture','--json'],'handover');assert.equal(handed.code,0,handed.err);assert.equal(serial,2);assert.ok(requestDetails.some(x=>x.method==='thread/name/set'&&x.params.threadId==='fixture-thread-2'&&x.params.name==='test-role'),'successor must be persisted before handover succeeds');
|
|
30
31
|
const store=require('../src/core/chat/store');const where=store.requireLocation(dir);
|
|
31
32
|
store.createGroup(where,'owner','team',['test-role']);
|
|
32
33
|
store.writeRecord(where,{group:'team',kind:'message',from:'owner',mentions:['test-role'],text:'addressed fixture'});
|
|
@@ -63,7 +64,11 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
|
63
64
|
const unloadedHandover=await run(['--repo',dir,'--role','test-role','--note','not an implicit resume'],'handover');assert.notEqual(unloadedHandover.code,0);assert.equal(resumes(),rb);assert.equal(serial,2);unloaded=false;
|
|
64
65
|
injectNotice=true;const notified=await run(['--socket',sock,'--json']);assert.equal(notified.code,0,notified.err);assert.equal(JSON.parse(notified.out).host.userAgent,'test-host');injectNotice=false;
|
|
65
66
|
invalidHost=true;const malformed=await run(['--socket',sock,'--json']);assert.notEqual(malformed.code,0);assert.match(malformed.err,/identity/i);invalidHost=false;
|
|
66
|
-
const bad=await run(['--socket',path.join(dir,'missing'),'--timeout','100']);assert.notEqual(bad.code,0);assert.match(bad.err,/connect|ENOENT/i);
|
|
67
|
+
const bad=await run(['--socket',path.join(dir,'missing'),'--timeout','100']);assert.notEqual(bad.code,0);assert.match(bad.err,/connect|ENOENT/i);
|
|
68
|
+
initNameFails=true;active=false;const beforeFailedHandover=serial;const failedInitHandover=await run(['--repo',dir,'--role','test-role','--note','retain failed successor','--json'],'handover');assert.notEqual(failedInitHandover.code,0);assert.match(failedInitHandover.err,/fixture name persistence failure/);const pendingHandover=JSON.parse(fs.readFileSync(roleFile));assert.equal(pendingHandover.thread,'fixture-thread-2');assert.equal(pendingHandover.handover.thread,`fixture-thread-${beforeFailedHandover+1}`);const retryHandover=await run(['--repo',dir,'--role','test-role','--note','retry must not replace'],'handover');assert.notEqual(retryHandover.code,0);assert.equal(serial,beforeFailedHandover+1);
|
|
69
|
+
fs.unlinkSync(roleFile);const beforeFailedStart=serial;const failedInitStart=await run(['--socket',sock,'--repo',dir,'--role','test-role','--json'],'start');assert.notEqual(failedInitStart.code,0);assert.match(failedInitStart.err,/fixture name persistence failure/);const pendingStart=JSON.parse(fs.readFileSync(roleFile));assert.equal(pendingStart.state,'creation-pending');assert.equal(pendingStart.thread,`fixture-thread-${beforeFailedStart+1}`);const retryStart=await run(['--socket',sock,'--repo',dir,'--role','test-role'],'start');assert.notEqual(retryStart.code,0);assert.equal(serial,beforeFailedStart+1);
|
|
70
|
+
initNameFails=false;fs.unlinkSync(roleFile);readMismatch=true;const badIdentityStart=await run(['--socket',sock,'--repo',dir,'--role','test-role'],'start');assert.notEqual(badIdentityStart.code,0);assert.match(badIdentityStart.err,/identity/);
|
|
71
|
+
}finally{peers.forEach(s=>s.destroy());await new Promise(r=>server.close(r));fs.rmSync(dir,{recursive:true,force:true});}
|
|
67
72
|
});
|
|
68
73
|
test('silent endpoint fails before the deadline',async()=>{
|
|
69
74
|
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-silent-')),sock=path.join(dir,'host.sock');const server=http.createServer();const peers=[];server.on('connection',s=>peers.push(s));await new Promise(r=>server.listen(sock,r));
|
|
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
|
|
|
35
35
|
os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
PACKAGE_VERSION = "5.229.
|
|
38
|
+
PACKAGE_VERSION = "5.229.2"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.229.
|
|
41
|
+
PROTOCOL_VERSION = "5.229.2"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
package/src/core/codex-host.js
CHANGED
|
@@ -184,6 +184,15 @@ async function run(args) {
|
|
|
184
184
|
if (!host || typeof host.userAgent !== "string" || !host.userAgent) throw Error("Codex host returned no initialization identity");
|
|
185
185
|
client.notify("initialized");
|
|
186
186
|
const result = {socket: options.socket, host};
|
|
187
|
+
async function initializeThread(thread) {
|
|
188
|
+
// Native metadata writes materialize fresh persistent threads without a
|
|
189
|
+
// model turn. Blank thread/start alone has no durable rollout yet.
|
|
190
|
+
await client.call("thread/name/set", {threadId: thread.id, name: options.role});
|
|
191
|
+
const verified = (await client.call("thread/read", {threadId: thread.id, includeTurns: false})).thread;
|
|
192
|
+
if (!verified || verified.id !== thread.id || verified.cwd !== where.worktree) {
|
|
193
|
+
throw Error("initialized managed role identity mismatch");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
187
196
|
if (action === "start") {
|
|
188
197
|
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
189
198
|
const fd = fs.openSync(file, "wx");
|
|
@@ -193,6 +202,8 @@ async function run(args) {
|
|
|
193
202
|
const started = await client.call("thread/start", {cwd: where.worktree, sandbox: "workspace-write", approvalPolicy: "on-request", serviceName: "keel"});
|
|
194
203
|
const thread = started.thread;
|
|
195
204
|
if (!thread || !thread.id || thread.cwd !== where.worktree) throw Error("Codex created thread with unexpected identity");
|
|
205
|
+
store.writeJsonAtomic(where, file, {state: "creation-pending", role: options.role, thread: thread.id, worktree: where.worktree, socket: options.socket});
|
|
206
|
+
await initializeThread(thread);
|
|
196
207
|
const entry = {state: "managed", role: options.role, thread: thread.id, worktree: where.worktree, socket: options.socket};
|
|
197
208
|
store.writeJsonAtomic(where, file, entry);
|
|
198
209
|
store.setRole(where, options.role);
|
|
@@ -237,6 +248,9 @@ async function run(args) {
|
|
|
237
248
|
store.writeJsonAtomic(where, file, recorded);
|
|
238
249
|
const next = (await client.call("thread/start", {cwd: recorded.worktree, sandbox: "workspace-write", approvalPolicy: "on-request", serviceName: "keel"})).thread;
|
|
239
250
|
if (!next || !next.id || next.cwd !== recorded.worktree) throw Error("successor identity mismatch; handover retained");
|
|
251
|
+
recorded.handover.thread = next.id;
|
|
252
|
+
store.writeJsonAtomic(where, file, recorded);
|
|
253
|
+
await initializeThread(next);
|
|
240
254
|
const history = [...(recorded.history || []), {thread: recorded.thread, note: options.note}];
|
|
241
255
|
delete recorded.handover;
|
|
242
256
|
Object.assign(recorded, {thread: next.id, history, note: options.note});
|