mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-06 15:12:02 +09:00
fix(ck): also refuse a context.json that is not a ck context
A context.json that parses but has no sessions array (for example a JSON array at the root) passed the guard, and init wrote an empty context over it. Require a sessions array before reusing the context. Rebind the skill triggers manifest to the new registry digest. Refs #3922
This commit is contained in:
1 parent
3ecdcac3b4
commit
fb6b26eafc
3 files changed
+9
-8
No files matched your search
@@ -10,7 +10,7 @@
|
||||
"id": "hand-seeded",
|
||||
"source": "manual-curation-pending-regeneration"
|
||||
},
|
||||
"registryDigest": "7f1ea8d6abde21485bf7134fcb54d08ebe30e7d475d1fe89d10e03492300742c",
|
||||
"registryDigest": "2ac0c5730ebd1cd96d2d64310f499f47ccebf2a7754c3a8c83bcb0830301530a",
|
||||
"schemaVersion": 1,
|
||||
"triggers": {
|
||||
"skill:agent-runtime-gateway-smoke-test": [
|
||||
|
||||
@@ -55,8 +55,8 @@ if (isInit) {
|
||||
const projects = readProjects();
|
||||
const registered = projects[projectPath];
|
||||
const previous = registered ? loadContext(registered.contextDir) : null;
|
||||
if (registered && !previous && existsSync(contextPath(registered.contextDir))) {
|
||||
console.log(`ck init: ${contextPath(registered.contextDir)} cannot be read. Nothing was changed; fix or move that file, then run init again.`);
|
||||
if (registered && !Array.isArray(previous?.sessions) && existsSync(contextPath(registered.contextDir))) {
|
||||
console.log(`ck init: ${contextPath(registered.contextDir)} is not a readable ck context. Nothing was changed; fix or move that file, then run init again.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,12 +88,13 @@ test('initializing a registered project whose context cannot be read changes not
|
||||
fs.mkdirSync(project);
|
||||
runOk(home, project, 'save.mjs', ['--init'], { name: 'app', path: project });
|
||||
const contextFile = path.join(home, '.claude', 'ck', 'contexts', 'app', 'context.json');
|
||||
const damaged = '{"version": 2, "sessions": [{"summary": "built the parser"}';
|
||||
fs.writeFileSync(contextFile, damaged);
|
||||
for (const damaged of ['{"version": 2, "sessions": [{"summary": "built the parser"}', '[{"summary": "built the parser"}]']) {
|
||||
fs.writeFileSync(contextFile, damaged);
|
||||
|
||||
const result = run(home, project, 'save.mjs', ['--init'], JSON.stringify({ name: 'app', path: project }));
|
||||
assert.strictEqual(result.status, 1, result.stdout + result.stderr);
|
||||
assert.strictEqual(fs.readFileSync(contextFile, 'utf8'), damaged);
|
||||
const result = run(home, project, 'save.mjs', ['--init'], JSON.stringify({ name: 'app', path: project }));
|
||||
assert.strictEqual(result.status, 1, result.stdout + result.stderr);
|
||||
assert.strictEqual(fs.readFileSync(contextFile, 'utf8'), damaged);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`\nPassed: ${passed}`);
|
||||
|
||||
Reference in new issue
Block a user