openai-code
Version:
An unofficial proxy layer that lets you use Anthropic Claude Code with any OpenAI API backend.
48 lines (41 loc) • 1.24 kB
JavaScript
import { getAllSourceFilePaths, safeReadFileSync } from './fs.mjs';
// lol
const configFileMapping = {
PHP: 'composer.json',
JavaScript: 'package.json',
Go: 'go.mod',
Rust: 'Cargo.toml',
Python: 'requirements.txt',
Java: 'pom.xml',
CSharp: 'csproj',
Ruby: 'Gemfile',
Swift: 'Package.swift',
Kotlin: 'build.gradle.kts',
TypeScript: 'tsconfig.json',
C: 'Makefile',
CPlusPlus: 'CMakeLists.txt',
Haskell: 'stack.yaml',
Elixir: 'mix.exs',
Scala: 'build.sbt',
Dart: 'pubspec.yaml',
Perl: 'cpanfile',
R: 'DESCRIPTION',
};
export const getTechsetConfigContext = async (workingDirectory) => {
const sourceFilePaths = getAllSourceFilePaths(workingDirectory);
const techsets = {};
// map each language to its config file content
for (const [language, configFile] of Object.entries(configFileMapping)) {
const configFilePath = sourceFilePaths.find(filePath => filePath.endsWith(configFile));
if (configFilePath) {
const configContent = safeReadFileSync(configFilePath, "utf-8");
if (configContent) {
techsets[language] = {
configFilePath,
configContent,
};
}
}
}
return Object.keys(techsets).length > 0 ? techsets : null;
};