@christang/keel 5.229.1 → 5.229.3
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/README.md +3 -2
- package/README.zh-CN.md +2 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +3 -3
- package/package.json +2 -2
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/bump_version.js +2 -1
- package/scripts/test_codex_host.js +9 -4
- package/scripts/validation/baseline.py +3 -2
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/hosts.py +2 -2
- package/scripts/verify_installed_openspec.js +64 -0
- 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.3",
|
|
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/README.md
CHANGED
|
@@ -50,8 +50,9 @@ Node.js `>=20.19.0` (the bundled OpenSpec CLI needs it).
|
|
|
50
50
|
|
|
51
51
|
**Claude Code** — the plugin is the whole install. It is the npm package `@christang/keel` at the
|
|
52
52
|
release version, the same package the `keel` CLI comes from, so it carries the CLI along with the
|
|
53
|
-
skills and hooks
|
|
54
|
-
|
|
53
|
+
skills and hooks. Its manifest explicitly pins the tested OpenSpec release named in its lockfile,
|
|
54
|
+
so registry installs and local-tarball updates select the same release (#534). Claude installs
|
|
55
|
+
that dependency with the plugin (#337). The agent's `keel` commands run the copy the plugin brought:
|
|
55
56
|
|
|
56
57
|
```bash
|
|
57
58
|
claude plugin marketplace add TanglmChris/keel
|
package/README.zh-CN.md
CHANGED
|
@@ -40,7 +40,8 @@ Node.js `>=20.19.0`(内置的 OpenSpec CLI 需要)。
|
|
|
40
40
|
## 安装
|
|
41
41
|
|
|
42
42
|
**Claude Code** —— 装插件就够了。插件就是发布版本的 npm 包 `@christang/keel`,和 `keel` CLI 来自同一个包,
|
|
43
|
-
所以技能和 hook 之外还带着 CLI
|
|
43
|
+
所以技能和 hook 之外还带着 CLI。包清单也显式固定锁文件中已经测试的 OpenSpec 版本,
|
|
44
|
+
让 registry 安装和本地 tarball 更新使用同一版本(#534);Claude 会在安装插件时一并安装它(#337)。
|
|
44
45
|
agent 运行的 `keel` 命令用的就是插件带来的这一份:
|
|
45
46
|
|
|
46
47
|
```bash
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.3",
|
|
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.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@fission-ai/openspec": "
|
|
12
|
+
"@fission-ai/openspec": "1.14.0"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
15
|
"keel": "bin/keel.js"
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@christang/keel",
|
|
3
3
|
"displayName": "Keel",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
|
|
5
|
-
"version": "5.229.
|
|
5
|
+
"version": "5.229.3",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "node scripts/run_python.js scripts/validate_plugin.py --all"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@fission-ai/openspec": "
|
|
31
|
+
"@fission-ai/openspec": "1.14.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=20.19.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.3",
|
|
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.3",
|
|
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/scripts/bump_version.js
CHANGED
|
@@ -152,12 +152,13 @@ function prependChangelogEntry(newVersion) {
|
|
|
152
152
|
if (!content.startsWith(CHANGELOG_HEADER)) {
|
|
153
153
|
fail("keel/CHANGELOG.md does not start with the expected header");
|
|
154
154
|
}
|
|
155
|
+
const openspecPin = JSON.parse(fs.readFileSync(PKG_PATH, "utf8")).dependencies["@fission-ai/openspec"];
|
|
155
156
|
const entry =
|
|
156
157
|
`## ${newVersion} - TODO: summarize this release\n\n` +
|
|
157
158
|
"- TODO: describe the change.\n" +
|
|
158
159
|
"- Version alignment: the npm package, both native plugin manifests, " +
|
|
159
160
|
`protocol docs, and this changelog share Keel ${newVersion}; the OpenSpec ` +
|
|
160
|
-
|
|
161
|
+
`dependency pin stays \`${openspecPin}\`.\n\n`;
|
|
161
162
|
content = CHANGELOG_HEADER + entry + content.slice(CHANGELOG_HEADER.length);
|
|
162
163
|
fs.writeFileSync(CHANGELOG_PATH, content);
|
|
163
164
|
process.stdout.write(" updated keel/CHANGELOG.md (fill in the TODO lines)\n");
|
|
@@ -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));
|
|
@@ -158,11 +158,12 @@ def validate_npm_package(errors: list[str]) -> None:
|
|
|
158
158
|
)
|
|
159
159
|
|
|
160
160
|
dependencies = package.get("dependencies")
|
|
161
|
+
locked_openspec = json.loads((ROOT / "npm-shrinkwrap.json").read_text(encoding="utf-8"))["packages"]["node_modules/@fission-ai/openspec"]["version"]
|
|
161
162
|
if (
|
|
162
163
|
not isinstance(dependencies, dict)
|
|
163
|
-
or dependencies.get("@fission-ai/openspec") !=
|
|
164
|
+
or dependencies.get("@fission-ai/openspec") != locked_openspec
|
|
164
165
|
):
|
|
165
|
-
errors.append("package.json must
|
|
166
|
+
errors.append("package.json must pin @fission-ai/openspec to the exact shrinkwrap version")
|
|
166
167
|
|
|
167
168
|
files = package.get("files")
|
|
168
169
|
if not isinstance(files, list):
|
|
@@ -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.3"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.229.
|
|
41
|
+
PROTOCOL_VERSION = "5.229.3"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
@@ -204,9 +204,9 @@ def validate_version_alignment_scenario() -> int:
|
|
|
204
204
|
dependencies = package.get("dependencies")
|
|
205
205
|
if (
|
|
206
206
|
not isinstance(dependencies, dict)
|
|
207
|
-
or dependencies.get("@fission-ai/openspec") !=
|
|
207
|
+
or dependencies.get("@fission-ai/openspec") != shrinkwrap_openspec_version()
|
|
208
208
|
):
|
|
209
|
-
report("version-alignment scenario
|
|
209
|
+
report("version-alignment scenario OpenSpec declaration differs from its exact lock.")
|
|
210
210
|
return 1
|
|
211
211
|
|
|
212
212
|
version_result = run_keel(ROOT, "--version")
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Native release acceptance (#534). Registry and local-tarball installs do not
|
|
5
|
+
// treat nested shrinkwrap metadata identically on npm 11. Keep this networked
|
|
6
|
+
// test separate from the ordinary scenario suite, and run it in Full-gate CI.
|
|
7
|
+
const fs = require('node:fs');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const os = require('node:os');
|
|
10
|
+
const assert = require('node:assert/strict');
|
|
11
|
+
const {spawnSync} = require('node:child_process');
|
|
12
|
+
const root = path.resolve(__dirname, '..');
|
|
13
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
14
|
+
const expected = JSON.parse(fs.readFileSync(path.join(root, 'npm-shrinkwrap.json'), 'utf8'))
|
|
15
|
+
.packages['node_modules/@fission-ai/openspec'].version;
|
|
16
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'keel-installed-openspec-'));
|
|
17
|
+
|
|
18
|
+
function run(command, args, env = process.env, cwd = root, allowFailure = false) {
|
|
19
|
+
const result = spawnSync(command, args, {
|
|
20
|
+
env, cwd, encoding: 'utf8', timeout: 180000,
|
|
21
|
+
shell: process.platform === 'win32' && command === npm,
|
|
22
|
+
});
|
|
23
|
+
if (!allowFailure && (result.error || result.status !== 0)) {
|
|
24
|
+
throw Error(`${path.basename(command)} ${args[0]} failed: ${result.error?.message || result.stderr || result.stdout}`);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const project = path.join(temp, 'project');
|
|
31
|
+
fs.mkdirSync(path.join(project, 'openspec'), {recursive: true});
|
|
32
|
+
fs.cpSync(path.join(root, 'openspec', 'specs'), path.join(project, 'openspec', 'specs'), {recursive: true});
|
|
33
|
+
const packed = JSON.parse(run(npm, ['pack', root, '--pack-destination', temp, '--json']).stdout)[0];
|
|
34
|
+
const tarball = path.join(temp, packed.filename);
|
|
35
|
+
console.log(`installed-openspec: node ${process.version}; npm ${run(npm, ['--version']).stdout.trim()}; expected ${expected}`);
|
|
36
|
+
for (const kind of ['clean-tarball', 'updater']) {
|
|
37
|
+
const env = {
|
|
38
|
+
...process.env,
|
|
39
|
+
npm_config_prefix: path.join(temp, kind),
|
|
40
|
+
KEEL_UPDATE_CLAUDE: path.join(temp, 'absent-claude'),
|
|
41
|
+
KEEL_UPDATE_CODEX: path.join(temp, 'absent-codex'),
|
|
42
|
+
};
|
|
43
|
+
// This immutable old release has the broad range that exposed #534. Only
|
|
44
|
+
// this disposable prefix is upgraded; host plugin commands stay absent.
|
|
45
|
+
run(npm, ['install', '-g', kind === 'updater' ? '@christang/keel@5.229.2' : tarball], env);
|
|
46
|
+
if (kind === 'updater') {
|
|
47
|
+
run(process.execPath, [path.join(root, 'bin', 'keel.js'), '--update', '--source', tarball], env, project);
|
|
48
|
+
}
|
|
49
|
+
const globalRoot = run(npm, ['root', '-g'], env).stdout.trim();
|
|
50
|
+
const cli = path.join(globalRoot, '@christang', 'keel', 'bin', 'keel.js');
|
|
51
|
+
const version = run(process.execPath, [cli, 'openspec', '--version'], env, project).stdout.trim();
|
|
52
|
+
const strict = run(process.execPath, [cli, 'openspec', 'validate', '--specs', '--strict'], env, project, true);
|
|
53
|
+
console.log(JSON.stringify({case: kind, version, expected, strictExit: strict.status,
|
|
54
|
+
totals: (strict.stdout + strict.stderr).split('\n').filter(line => line.includes('Totals:'))}));
|
|
55
|
+
assert.equal(version, expected, `installed OpenSpec ${version} differs from locked ${expected}`);
|
|
56
|
+
assert.equal(strict.status, 0, `installed strict validation failed: ${(strict.stdout + strict.stderr).slice(-1200)}`);
|
|
57
|
+
}
|
|
58
|
+
console.log('installed-openspec: clean tarball and updater acceptance passed');
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(`installed-openspec: ${error.message}`);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
} finally {
|
|
63
|
+
fs.rmSync(temp, {recursive: true, force: true});
|
|
64
|
+
}
|
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});
|