feat: remove legacy OpenCode runtime
Cut product flows over to Coding/Pi and retain only the migration-owned v1 boundary. Promote supported native optional packages because electron-builder omitted pnpm transitive optional closure from the packaged ASAR.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { readFile, readdir } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {
|
||||
BUNDLED_CODING_SKILL_IDS,
|
||||
@@ -50,18 +50,40 @@ function selectedSkillIds(value: readonly string[]): Set<BundledCodingSkillId> {
|
||||
return selected;
|
||||
}
|
||||
|
||||
async function listSkillEntries(
|
||||
directory: string,
|
||||
relative = '',
|
||||
): Promise<Array<{ path: string; type: 'file' | 'directory' }>> {
|
||||
const entries = await readdir(path.join(directory, relative), { withFileTypes: true });
|
||||
const result: Array<{ path: string; type: 'file' | 'directory' }> = [];
|
||||
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
||||
const entryPath = relative ? path.posix.join(relative, entry.name) : entry.name;
|
||||
if (entry.isDirectory()) {
|
||||
result.push({ path: entryPath, type: 'directory' });
|
||||
result.push(...await listSkillEntries(directory, entryPath));
|
||||
} else if (entry.isFile()) {
|
||||
result.push({ path: entryPath, type: 'file' });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function listProductCodingSkills(
|
||||
bundledSkillsDir: string,
|
||||
selectedIds: readonly string[] = [],
|
||||
): Promise<ProductCodingSkill[]> {
|
||||
const selected = selectedSkillIds(selectedIds);
|
||||
return await Promise.all(BUNDLED_CODING_SKILL_IDS.map(async (id) => {
|
||||
const content = await readFile(path.join(bundledSkillsDir, id, 'SKILL.md'), 'utf8');
|
||||
const location = path.join(bundledSkillsDir, id);
|
||||
const content = await readFile(path.join(location, 'SKILL.md'), 'utf8');
|
||||
return {
|
||||
id,
|
||||
name: frontmatterScalar(content, 'name') ?? id,
|
||||
description: frontmatterScalar(content, 'description') ?? '',
|
||||
selected: selected.has(id),
|
||||
location,
|
||||
content,
|
||||
entries: await listSkillEntries(location),
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user