Merge commit 'refs/review/3987'; commit 'refs/review/4031'; commit 'refs/review/4037'; commit 'refs/review/4038' into review/adapters-20261119

This commit is contained in:
haelyra committed 2026-11-19 15:14:26 -05:00
11 files changed
+351 -61

No files matched your search

+2 -2
View File
@@ -370,8 +370,8 @@ function main() {
}), "enabled")
applyInstallPlan(plan)
const config = JSON.parse(fs.readFileSync(path.join(plan.targetRoot, "opencode.json"), "utf8"))
assert.deepStrictEqual(config.skills.paths, ["./skills"])
assert.ok(fs.existsSync(path.join(plan.targetRoot, config.skills.paths[0], "tdd-workflow", "SKILL.md")))
assert.deepStrictEqual(config.skills.paths, [path.join(plan.targetRoot, "skills")])
assert.ok(fs.existsSync(path.join(config.skills.paths[0], "tdd-workflow", "SKILL.md")))
assert.ok(!fs.existsSync(path.join(plan.targetRoot, "tools", "run-tests.js")))
checkRuntime(
plan.targetRoot,
@@ -258,6 +258,52 @@ if (process.platform !== 'win32') {
}
});
test('scan counts literal backslashes in skill paths without interpreting escape sequences', () => {
const skillsDir = path.join(tempRoot, 'backslash-skills');
const skillDir = path.join(skillsDir, String.raw`literal\tname\nending`);
writeSkill(skillDir, 'backslash-skill');
const skillPath = path.join(skillDir, 'SKILL.md');
const observationsPath = path.join(tempRoot, 'backslash-observations.jsonl');
const observations = [0, 1, 10, 40].map(days => ({
tool: 'Read',
path: skillPath,
timestamp: new Date(Date.now() - days * 86400000).toISOString(),
}));
fs.writeFileSync(observationsPath, `${observations.map(record => JSON.stringify(record)).join('\n')}\n`);
const result = runBash(scanScript, [], {
SKILL_STOCKTAKE_GLOBAL_DIR: path.join(tempRoot, 'missing-global'),
SKILL_STOCKTAKE_PROJECT_DIR: skillsDir,
SKILL_STOCKTAKE_OBSERVATIONS: observationsPath,
});
assert.strictEqual(result.status, 0, result.stderr);
const skills = JSON.parse(result.stdout).skills;
assert.strictEqual(skills.length, 1);
assert.strictEqual(skills[0].path, skillPath);
assert.strictEqual(skills[0].use_7d, 2);
assert.strictEqual(skills[0].use_30d, 3);
});
test('scan does not count a newline-delimited path fragment as an observed skill', () => {
const skillPath = path.join(globalSkills, 'active', 'SKILL.md');
// This is one real file outside the inventory. Its newline is immediately
// followed by the complete path of a different, unobserved tracked skill.
const unrelatedPath = `${tempRoot}/unrelated\n${skillPath}`;
fs.mkdirSync(path.dirname(unrelatedPath), { recursive: true });
fs.writeFileSync(unrelatedPath, '# unrelated file\n');
const observationsPath = path.join(tempRoot, 'newline-fragment-observations.jsonl');
fs.writeFileSync(observationsPath, `${JSON.stringify({
tool: 'Read', path: unrelatedPath, timestamp: new Date().toISOString(),
})}\n`);
assert.notStrictEqual(unrelatedPath, skillPath);
assert.ok(fs.statSync(unrelatedPath).isFile());
const result = runBash(scanScript, [], { ...env, SKILL_STOCKTAKE_OBSERVATIONS: observationsPath });
assert.strictEqual(result.status, 0, result.stderr);
const skill = JSON.parse(result.stdout).skills.find(entry => entry.path === skillPath);
assert.ok(skill, 'the unobserved skill must remain in the inventory');
assert.strictEqual(skill.use_7d, 0);
assert.strictEqual(skill.use_30d, 0);
});
test('scan preserves exact usage counts and date windows for normal and whitespace paths', () => {
const observationsPath = path.join(tempRoot, 'matching-observations.jsonl');
const observedPaths = [path.join(linkedSkill, 'SKILL.md'),