fix: align Kilo config and agent conversion
Honor KILO_CONFIG across installer and workflow resolution, preserve Claude agent tool intent as explicit Kilo permissions, and rewrite relative .claude references during Kilo conversion.
This commit is contained in:
@@ -87,9 +87,15 @@ describe('getGlobalDir (Kilo)', () => {
|
||||
assert.strictEqual(getGlobalDir('kilo'), path.join(os.homedir(), 'xdg-config', 'kilo'));
|
||||
});
|
||||
|
||||
test('ignores KILO_CONFIG file env var and uses XDG/default resolution only', () => {
|
||||
process.env.KILO_CONFIG = '/tmp/ignored-kilo.json';
|
||||
assert.strictEqual(getGlobalDir('kilo'), path.join(os.homedir(), '.config', 'kilo'));
|
||||
test('uses dirname(KILO_CONFIG) when KILO_CONFIG_DIR is unset', () => {
|
||||
process.env.KILO_CONFIG = '~/profiles/work/kilo.jsonc';
|
||||
assert.strictEqual(getGlobalDir('kilo'), path.join(os.homedir(), 'profiles', 'work'));
|
||||
});
|
||||
|
||||
test('KILO_CONFIG_DIR takes precedence over KILO_CONFIG', () => {
|
||||
process.env.KILO_CONFIG_DIR = '~/custom-kilo';
|
||||
process.env.KILO_CONFIG = '~/profiles/work/kilo.jsonc';
|
||||
assert.strictEqual(getGlobalDir('kilo'), path.join(os.homedir(), 'custom-kilo'));
|
||||
});
|
||||
|
||||
test('explicit config-dir overrides env vars', () => {
|
||||
@@ -248,10 +254,12 @@ describe('Source code integration (Kilo)', () => {
|
||||
assert.ok(updateWorkflowSrc.includes('PREFERRED_CONFIG_DIR'), 'workflow tracks preferred config dir');
|
||||
assert.ok(updateWorkflowSrc.includes('kilo.jsonc'), 'workflow infers Kilo from config files');
|
||||
assert.ok(updateWorkflowSrc.includes('ENV_RUNTIME_DIRS'), 'workflow checks env-derived config dirs');
|
||||
assert.ok(updateWorkflowSrc.includes('KILO_CONFIG'), 'workflow checks KILO_CONFIG');
|
||||
});
|
||||
|
||||
test('reapply-patches checks Kilo custom config env vars first', () => {
|
||||
assert.ok(reapplyPatchesSrc.includes('KILO_CONFIG_DIR'), 'reapply-patches checks KILO_CONFIG_DIR');
|
||||
assert.ok(reapplyPatchesSrc.includes('KILO_CONFIG'), 'reapply-patches checks KILO_CONFIG');
|
||||
assert.ok(reapplyPatchesSrc.includes('XDG_CONFIG_HOME'), 'reapply-patches checks XDG_CONFIG_HOME');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -91,6 +91,18 @@ for (const { label, convert, configDir } of flatRuntimeSuites) {
|
||||
const frontmatter = result.split('---')[1];
|
||||
assert.ok(!frontmatter.includes('tools:'), 'tools: should be stripped for agents');
|
||||
assert.ok(!frontmatter.includes('read: true'), 'tools object should not be generated');
|
||||
|
||||
if (label === 'Kilo') {
|
||||
assert.ok(frontmatter.includes('permission:'), 'Kilo agents should emit permission block');
|
||||
assert.ok(frontmatter.includes('read: allow'), 'Read should map to read: allow');
|
||||
assert.ok(frontmatter.includes('edit: allow'), 'Write/Edit should map to edit: allow');
|
||||
assert.ok(frontmatter.includes('bash: allow'), 'Bash should map to bash: allow');
|
||||
assert.ok(frontmatter.includes('grep: allow'), 'Grep should map to grep: allow');
|
||||
assert.ok(frontmatter.includes('glob: allow'), 'Glob should map to glob: allow');
|
||||
assert.ok(frontmatter.includes('task: deny'), 'unspecified permissions should be denied');
|
||||
} else {
|
||||
assert.ok(!frontmatter.includes('permission:'), 'OpenCode agents should not emit permission block');
|
||||
}
|
||||
});
|
||||
|
||||
test('strips skills: array', () => {
|
||||
@@ -133,11 +145,21 @@ tools: Read
|
||||
---
|
||||
|
||||
Read ~/.claude/agent-memory/ for context.
|
||||
Use $HOME/.claude/skills/ for reference.`;
|
||||
Use $HOME/.claude/skills/ for reference.
|
||||
Check .claude/skills/ and .claude/agents/ locally.
|
||||
Use ./.claude/hooks/gsd-statusline.js during local testing.
|
||||
Fallback skills live in .agents/skills/.`;
|
||||
|
||||
const result = convert(agentWithClaudePaths, { isAgent: true });
|
||||
assert.ok(result.includes(`~/${configDir}/agent-memory/`), '~/.claude should be replaced');
|
||||
assert.ok(result.includes(`$HOME/${configDir}/skills/`), '$HOME/.claude should be replaced');
|
||||
|
||||
if (label === 'Kilo') {
|
||||
assert.ok(result.includes('.kilo/skills/'), '.claude/skills should be replaced for Kilo');
|
||||
assert.ok(result.includes('.kilo/agents/'), '.claude/agents should be replaced for Kilo');
|
||||
assert.ok(result.includes('./.kilo/hooks/'), './.claude should be replaced for Kilo');
|
||||
assert.ok(result.includes('.kilo/skill/'), '.agents/skills should be rewritten to Kilo skill dir');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user