@nogataka/smart-edit 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,7 @@ import { loadYaml, saveYaml } from '../util/general.js';
|
|
|
7
7
|
import { determineProgrammingLanguageComposition } from '../util/inspection.js';
|
|
8
8
|
import { singleton } from '../util/class_decorators.js';
|
|
9
9
|
import { ToolRegistry } from '../tools/tools_base.js';
|
|
10
|
-
import { Language, coerceLanguage } from '../../smart-lsp/ls_config.js';
|
|
10
|
+
import { Language, coerceLanguage, listLanguages, getLanguageFilenameMatcher } from '../../smart-lsp/ls_config.js';
|
|
11
11
|
const { logger: log } = createSmartEditLogger({ name: 'smart-edit.config' });
|
|
12
12
|
export class ToolInclusionDefinition {
|
|
13
13
|
excludedTools;
|
|
@@ -259,7 +259,11 @@ export class ProjectConfig extends ToolInclusionDefinition {
|
|
|
259
259
|
const name = options.projectName ?? path.basename(resolvedRoot);
|
|
260
260
|
let language = options.projectLanguage;
|
|
261
261
|
if (!language) {
|
|
262
|
-
const
|
|
262
|
+
const languageDefinitions = listLanguages().map((lang) => ({
|
|
263
|
+
name: lang,
|
|
264
|
+
matcher: getLanguageFilenameMatcher(lang)
|
|
265
|
+
}));
|
|
266
|
+
const composition = determineProgrammingLanguageComposition(resolvedRoot, { languages: languageDefinitions });
|
|
263
267
|
const entries = Object.entries(composition);
|
|
264
268
|
if (entries.length === 0) {
|
|
265
269
|
const relativePath = path.join(resolvedRoot, this.relPathToProjectYml());
|
|
@@ -126,7 +126,10 @@ function readRegistry() {
|
|
|
126
126
|
function writeRegistry(data) {
|
|
127
127
|
const instancesFile = getInstancesFilePath();
|
|
128
128
|
ensureDirectoryExists(instancesFile);
|
|
129
|
-
|
|
129
|
+
// Atomic write: write to temp file first, then rename
|
|
130
|
+
const tempFile = `${instancesFile}.tmp`;
|
|
131
|
+
fs.writeFileSync(tempFile, JSON.stringify(data, null, 2), 'utf-8');
|
|
132
|
+
fs.renameSync(tempFile, instancesFile);
|
|
130
133
|
}
|
|
131
134
|
function isProcessAlive(pid) {
|
|
132
135
|
try {
|