@nogataka/smart-edit 0.0.16 → 0.3.0
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.
- package/LICENSE +0 -1
- package/README.md +144 -67
- package/dist/cli.js +2 -2
- package/dist/devtools/generate_prompt_factory.js +5 -5
- package/dist/index.d.ts +33 -34
- package/dist/index.js +33 -34
- package/dist/interprompt/multilang_prompt.js +2 -2
- package/dist/interprompt/prompt_factory.js +2 -2
- package/dist/interprompt/util/class_decorators.d.ts +1 -1
- package/dist/interprompt/util/class_decorators.js +1 -1
- package/dist/{serena → smart-edit}/agent.d.ts +20 -20
- package/dist/{serena → smart-edit}/agent.js +43 -43
- package/dist/{serena → smart-edit}/analytics.d.ts +1 -1
- package/dist/{serena → smart-edit}/analytics.js +3 -3
- package/dist/smart-edit/cli.d.ts +9 -0
- package/dist/{serena → smart-edit}/cli.js +49 -99
- package/dist/{serena → smart-edit}/code_editor.d.ts +7 -7
- package/dist/{serena → smart-edit}/config/context_mode.d.ts +13 -13
- package/dist/{serena → smart-edit}/config/context_mode.js +12 -12
- package/dist/{serena/config/serena_config.d.ts → smart-edit/config/smart_edit_config.d.ts} +14 -14
- package/dist/{serena/config/serena_config.js → smart-edit/config/smart_edit_config.js} +31 -31
- package/dist/smart-edit/constants.d.ts +18 -0
- package/dist/smart-edit/constants.js +27 -0
- package/dist/{serena → smart-edit}/dashboard.d.ts +3 -3
- package/dist/{serena → smart-edit}/dashboard.js +10 -10
- package/dist/{serena → smart-edit}/gui_log_viewer.js +6 -6
- package/dist/{serena → smart-edit}/mcp.d.ts +40 -40
- package/dist/{serena → smart-edit}/mcp.js +38 -38
- package/dist/{serena → smart-edit}/project.d.ts +7 -7
- package/dist/{serena → smart-edit}/project.js +18 -18
- package/dist/{serena → smart-edit}/prompt_factory.d.ts +3 -3
- package/dist/{serena → smart-edit}/prompt_factory.js +1 -1
- package/dist/{serena → smart-edit}/resources/config/contexts/codex.yml +2 -2
- package/dist/{serena → smart-edit}/resources/config/contexts/context.template.yml +1 -1
- package/dist/{serena → smart-edit}/resources/config/contexts/ide-assistant.yml +2 -2
- package/dist/{serena → smart-edit}/resources/config/modes/mode.template.yml +1 -1
- package/dist/{serena → smart-edit}/resources/config/prompt_templates/simple_tool_outputs.yml +1 -1
- package/dist/smart-edit/resources/dashboard/dashboard.js +13 -0
- package/dist/smart-edit/resources/dashboard/index.css +1 -0
- package/dist/smart-edit/resources/dashboard/index.html +13 -0
- package/dist/{serena → smart-edit}/resources/project.template.yml +6 -6
- package/dist/{serena/resources/serena_config.template.yml → smart-edit/resources/smart_edit_config.template.yml} +14 -14
- package/dist/{serena → smart-edit}/symbol.d.ts +7 -7
- package/dist/{serena → smart-edit}/symbol.js +2 -2
- package/dist/{serena → smart-edit}/text_utils.js +2 -2
- package/dist/{serena → smart-edit}/tools/config_tools.d.ts +1 -1
- package/dist/{serena → smart-edit}/tools/config_tools.js +6 -6
- package/dist/{serena → smart-edit}/tools/memory_tools.d.ts +4 -4
- package/dist/{serena → smart-edit}/tools/memory_tools.js +5 -5
- package/dist/{serena → smart-edit}/tools/tools_base.d.ts +15 -15
- package/dist/{serena → smart-edit}/tools/tools_base.js +7 -7
- package/dist/{serena → smart-edit}/util/exception.d.ts +2 -2
- package/dist/{serena → smart-edit}/util/exception.js +2 -2
- package/dist/{serena → smart-edit}/util/file_system.js +3 -3
- package/dist/{serena → smart-edit}/util/git.js +3 -3
- package/dist/{serena → smart-edit}/util/inspection.d.ts +3 -3
- package/dist/{serena → smart-edit}/util/inspection.js +3 -3
- package/dist/{serena → smart-edit}/util/logging.d.ts +6 -6
- package/dist/{serena → smart-edit}/util/logging.js +7 -7
- package/dist/{serena → smart-edit}/util/shell.js +1 -1
- package/dist/smart-edit/version.d.ts +1 -0
- package/dist/{serena → smart-edit}/version.js +3 -3
- package/dist/{solidlsp → smart-lsp}/language_servers/autoload.js +1 -1
- package/dist/smart-lsp/language_servers/bash_language_server.d.ts +10 -0
- package/dist/{solidlsp → smart-lsp}/language_servers/bash_language_server.js +8 -8
- package/dist/{solidlsp → smart-lsp}/language_servers/clangd_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/clangd_language_server.js +9 -9
- package/dist/{solidlsp → smart-lsp}/language_servers/clojure_lsp.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/clojure_lsp.js +9 -9
- package/dist/{solidlsp → smart-lsp}/language_servers/common.d.ts +2 -2
- package/dist/{solidlsp → smart-lsp}/language_servers/common.js +1 -1
- package/dist/{solidlsp → smart-lsp}/language_servers/csharp_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/csharp_language_server.js +12 -12
- package/dist/smart-lsp/language_servers/dart_language_server.d.ts +10 -0
- package/dist/{solidlsp → smart-lsp}/language_servers/dart_language_server.js +13 -13
- package/dist/{solidlsp → smart-lsp}/language_servers/eclipse_jdtls.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/eclipse_jdtls.js +12 -12
- package/dist/{solidlsp → smart-lsp}/language_servers/erlang_language_server.d.ts +3 -3
- package/dist/{solidlsp → smart-lsp}/language_servers/erlang_language_server.js +6 -6
- package/dist/{solidlsp → smart-lsp}/language_servers/gopls.d.ts +3 -3
- package/dist/{solidlsp → smart-lsp}/language_servers/gopls.js +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/intelephense.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/intelephense.js +11 -11
- package/dist/{solidlsp → smart-lsp}/language_servers/jedi_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/jedi_server.js +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/kotlin_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/kotlin_language_server.js +9 -9
- package/dist/{solidlsp → smart-lsp}/language_servers/lua_ls.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/lua_ls.js +10 -10
- package/dist/{solidlsp → smart-lsp}/language_servers/nixd_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/nixd_language_server.js +7 -7
- package/dist/{solidlsp → smart-lsp}/language_servers/pyright_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/pyright_server.js +3 -3
- package/dist/{solidlsp → smart-lsp}/language_servers/r_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/r_language_server.js +5 -5
- package/dist/smart-lsp/language_servers/ruby_common.d.ts +10 -0
- package/dist/{solidlsp → smart-lsp}/language_servers/ruby_common.js +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/ruby_lsp.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/ruby_lsp.js +10 -10
- package/dist/{solidlsp → smart-lsp}/language_servers/rust_analyzer.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/rust_analyzer.js +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/solargraph.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/solargraph.js +10 -10
- package/dist/{solidlsp → smart-lsp}/language_servers/sourcekit_lsp.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/sourcekit_lsp.js +7 -7
- package/dist/{solidlsp → smart-lsp}/language_servers/terraform_ls.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/terraform_ls.js +14 -14
- package/dist/{solidlsp → smart-lsp}/language_servers/typescript_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/typescript_language_server.js +11 -11
- package/dist/{solidlsp → smart-lsp}/language_servers/vts_language_server.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/vts_language_server.js +10 -10
- package/dist/{solidlsp → smart-lsp}/language_servers/zls.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/language_servers/zls.js +6 -6
- package/dist/{solidlsp → smart-lsp}/ls.d.ts +25 -25
- package/dist/{solidlsp → smart-lsp}/ls.js +19 -19
- package/dist/{solidlsp → smart-lsp}/ls_config.d.ts +0 -5
- package/dist/{solidlsp → smart-lsp}/ls_config.js +0 -5
- package/dist/{solidlsp → smart-lsp}/ls_exceptions.d.ts +1 -1
- package/dist/{solidlsp → smart-lsp}/ls_exceptions.js +2 -2
- package/dist/{solidlsp → smart-lsp}/ls_handler.d.ts +7 -7
- package/dist/{solidlsp → smart-lsp}/ls_handler.js +12 -12
- package/dist/{solidlsp → smart-lsp}/ls_request.d.ts +4 -4
- package/dist/{solidlsp → smart-lsp}/ls_request.js +3 -3
- package/package.json +14 -4
- package/dist/serena/agno.d.ts +0 -111
- package/dist/serena/agno.js +0 -278
- package/dist/serena/cli.d.ts +0 -9
- package/dist/serena/constants.d.ts +0 -18
- package/dist/serena/constants.js +0 -27
- package/dist/serena/resources/dashboard/dashboard.js +0 -815
- package/dist/serena/resources/dashboard/index.html +0 -307
- package/dist/serena/resources/dashboard/jquery.min.js +0 -3
- package/dist/serena/version.d.ts +0 -1
- package/dist/solidlsp/language_servers/bash_language_server.d.ts +0 -10
- package/dist/solidlsp/language_servers/dart_language_server.d.ts +0 -10
- package/dist/solidlsp/language_servers/ruby_common.d.ts +0 -10
- /package/dist/{serena → smart-edit}/code_editor.js +0 -0
- /package/dist/{serena → smart-edit}/generated/generated_prompt_factory.d.ts +0 -0
- /package/dist/{serena → smart-edit}/generated/generated_prompt_factory.js +0 -0
- /package/dist/{serena → smart-edit}/gui_log_viewer.d.ts +0 -0
- /package/dist/{serena → smart-edit}/resources/config/contexts/agent.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/contexts/chatgpt.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/contexts/desktop-app.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/contexts/oaicompat-agent.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/internal_modes/jetbrains.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/editing.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/interactive.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/no-onboarding.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/onboarding.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/one-shot.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/modes/planning.yml +0 -0
- /package/dist/{serena → smart-edit}/resources/config/prompt_templates/system_prompt.yml +0 -0
- /package/dist/{serena/resources/dashboard/serena-icon-16.svg → smart-edit/resources/dashboard/smart-edit-icon-16.svg} +0 -0
- /package/dist/{serena/resources/dashboard/serena-icon-32.svg → smart-edit/resources/dashboard/smart-edit-icon-32.svg} +0 -0
- /package/dist/{serena/resources/dashboard/serena-icon-48.svg → smart-edit/resources/dashboard/smart-edit-icon-48.svg} +0 -0
- /package/dist/{serena/resources/dashboard/serena-logs-dark-mode.svg → smart-edit/resources/dashboard/smart-edit-logs-dark-mode.svg} +0 -0
- /package/dist/{serena/resources/dashboard/serena-logs.svg → smart-edit/resources/dashboard/smart-edit-logs.svg} +0 -0
- /package/dist/{serena → smart-edit}/text_utils.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/cmd_tools.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/cmd_tools.js +0 -0
- /package/dist/{serena → smart-edit}/tools/file_tools.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/file_tools.js +0 -0
- /package/dist/{serena → smart-edit}/tools/index.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/index.js +0 -0
- /package/dist/{serena → smart-edit}/tools/symbol_tools.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/symbol_tools.js +0 -0
- /package/dist/{serena → smart-edit}/tools/workflow_tools.d.ts +0 -0
- /package/dist/{serena → smart-edit}/tools/workflow_tools.js +0 -0
- /package/dist/{serena → smart-edit}/util/class_decorators.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/class_decorators.js +0 -0
- /package/dist/{serena → smart-edit}/util/file_system.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/general.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/general.js +0 -0
- /package/dist/{serena → smart-edit}/util/git.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/shell.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/thread.d.ts +0 -0
- /package/dist/{serena → smart-edit}/util/thread.js +0 -0
- /package/dist/{solidlsp → smart-lsp}/language_servers/autoload.d.ts +0 -0
- /package/dist/{solidlsp → smart-lsp}/ls_types.d.ts +0 -0
- /package/dist/{solidlsp → smart-lsp}/ls_types.js +0 -0
- /package/dist/{solidlsp → smart-lsp}/lsp_protocol_handler/server.d.ts +0 -0
- /package/dist/{solidlsp → smart-lsp}/lsp_protocol_handler/server.js +0 -0
- /package/dist/{solidlsp → smart-lsp}/util/subprocess_util.d.ts +0 -0
- /package/dist/{solidlsp → smart-lsp}/util/subprocess_util.js +0 -0
- /package/dist/{solidlsp → smart-lsp}/util/zip.d.ts +0 -0
- /package/dist/{solidlsp → smart-lsp}/util/zip.js +0 -0
|
@@ -2,15 +2,15 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
|
-
import { ensureDefaultSubprocessOptions } from '../
|
|
5
|
+
import { ensureDefaultSubprocessOptions } from '../smart-lsp/util/subprocess_util.js';
|
|
6
6
|
import { ToolRegistry, ToolMarkerCanEdit, ToolMarkerDoesNotRequireActiveProject, ToolMarkerOptional, ToolMarkerSymbolicEdit, ToolMarkerSymbolicRead } from './tools/tools_base.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { SmartEditConfig, ToolInclusionDefinition, ToolSet, getSmartEditManagedInProjectDir, RegisteredTokenCountEstimator } from './config/smart_edit_config.js';
|
|
8
|
+
import { SmartEditAgentContext, SmartEditAgentMode } from './config/context_mode.js';
|
|
9
|
+
import { createSmartEditLogger, MemoryLogHandler } from './util/logging.js';
|
|
10
|
+
import { SmartEditPromptFactory } from './prompt_factory.js';
|
|
11
|
+
import { SmartEditDashboardAPI } from './dashboard.js';
|
|
12
12
|
import { GuiLogViewer } from './gui_log_viewer.js';
|
|
13
|
-
import {
|
|
13
|
+
import { smartEditVersion } from './version.js';
|
|
14
14
|
import { ToolUsageStats } from './analytics.js';
|
|
15
15
|
import { LanguageServerCodeEditor } from './code_editor.js';
|
|
16
16
|
import { LanguageServerSymbolRetriever } from './symbol.js';
|
|
@@ -21,7 +21,7 @@ import { ReadFileTool, CreateTextFileTool, ListDirTool, FindFileTool, ReplaceReg
|
|
|
21
21
|
import { WriteMemoryTool, ReadMemoryTool, ListMemoriesTool, DeleteMemoryTool } from './tools/memory_tools.js';
|
|
22
22
|
import { RestartLanguageServerTool, GetSymbolsOverviewTool, FindSymbolTool, FindReferencingSymbolsTool, ReplaceSymbolBodyTool, InsertAfterSymbolTool, InsertBeforeSymbolTool } from './tools/symbol_tools.js';
|
|
23
23
|
import { CheckOnboardingPerformedTool, OnboardingTool, ThinkAboutCollectedInformationTool, ThinkAboutTaskAdherenceTool, ThinkAboutWhetherYouAreDoneTool, SummarizeChangesTool, PrepareForNewConversationTool, InitialInstructionsTool } from './tools/workflow_tools.js';
|
|
24
|
-
const { logger: log, memoryHandler: defaultMemoryHandler } =
|
|
24
|
+
const { logger: log, memoryHandler: defaultMemoryHandler } = createSmartEditLogger({
|
|
25
25
|
name: 'smart-edit.agent',
|
|
26
26
|
emitToConsole: true,
|
|
27
27
|
level: 'info'
|
|
@@ -98,7 +98,7 @@ export class LinesRead {
|
|
|
98
98
|
export class MemoriesManager {
|
|
99
99
|
memoryDir;
|
|
100
100
|
constructor(projectRoot) {
|
|
101
|
-
this.memoryDir = path.join(
|
|
101
|
+
this.memoryDir = path.join(getSmartEditManagedInProjectDir(projectRoot), 'memories');
|
|
102
102
|
fs.mkdirSync(this.memoryDir, { recursive: true });
|
|
103
103
|
}
|
|
104
104
|
resolveMemoryPath(name) {
|
|
@@ -197,8 +197,8 @@ class AgentTaskHandleImpl {
|
|
|
197
197
|
return withTimeout(this.promise, timeout, this.taskName);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
export class
|
|
201
|
-
|
|
200
|
+
export class SmartEditAgent {
|
|
201
|
+
smartEditConfig;
|
|
202
202
|
promptFactory;
|
|
203
203
|
languageServer = null;
|
|
204
204
|
memoriesManager = null;
|
|
@@ -221,21 +221,21 @@ export class SerenaAgent {
|
|
|
221
221
|
_toolUsageStats = null;
|
|
222
222
|
disposed = false;
|
|
223
223
|
constructor(options = {}) {
|
|
224
|
-
this.
|
|
224
|
+
this.smartEditConfig = options.smartEditConfig ?? SmartEditConfig.fromConfigFile();
|
|
225
225
|
this.memoryLogHandler = options.memoryLogHandler ?? defaultMemoryHandler ?? new MemoryLogHandler();
|
|
226
226
|
this.projectActivationCallback = options.projectActivationCallback;
|
|
227
|
-
this._context = options.context ??
|
|
228
|
-
this._modes = options.modes ??
|
|
229
|
-
this.promptFactory = new
|
|
227
|
+
this._context = options.context ?? SmartEditAgentContext.loadDefault();
|
|
228
|
+
this._modes = options.modes ?? SmartEditAgentMode.loadDefaultModes();
|
|
229
|
+
this.promptFactory = new SmartEditPromptFactory();
|
|
230
230
|
this.instantiateAllTools();
|
|
231
231
|
this._baseToolSet = this.computeBaseToolSet(options.project ?? null);
|
|
232
232
|
this._exposedTools = new AvailableTools(Array.from(this._allTools.values()).filter((tool) => this._baseToolSet.includesName(tool.getName())));
|
|
233
|
-
if (this.
|
|
234
|
-
this._toolUsageStats = new ToolUsageStats(this.
|
|
233
|
+
if (this.smartEditConfig.recordToolUsageStats) {
|
|
234
|
+
this._toolUsageStats = new ToolUsageStats(this.smartEditConfig.tokenCountEstimator ?? RegisteredTokenCountEstimator.TIKTOKEN_GPT4O);
|
|
235
235
|
log.info(`Will record tool usage statistics with token count estimator: ${this._toolUsageStats.tokenEstimatorName}.`);
|
|
236
236
|
}
|
|
237
|
-
if (this.
|
|
238
|
-
const dashboardApi = new
|
|
237
|
+
if (this.smartEditConfig.webDashboard) {
|
|
238
|
+
const dashboardApi = new SmartEditDashboardAPI(this.memoryLogHandler, this._exposedTools.toolNames, this, {
|
|
239
239
|
shutdownCallback: () => this.dispose(),
|
|
240
240
|
toolUsageStats: this._toolUsageStats
|
|
241
241
|
});
|
|
@@ -245,22 +245,22 @@ export class SerenaAgent {
|
|
|
245
245
|
.then(([thread, port]) => {
|
|
246
246
|
this._dashboardThread = thread;
|
|
247
247
|
this._dashboardPort = port;
|
|
248
|
-
if (this.
|
|
248
|
+
if (this.smartEditConfig.webDashboardOpenOnLaunch && port > 0) {
|
|
249
249
|
this.openDashboard(`http://127.0.0.1:${port}/dashboard/index.html`);
|
|
250
250
|
}
|
|
251
251
|
})
|
|
252
252
|
.catch((error) => {
|
|
253
253
|
this._dashboardApi = null;
|
|
254
|
-
log.warn('Failed to start
|
|
254
|
+
log.warn('Failed to start Smart-Edit dashboard.', error instanceof Error ? error : undefined);
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
-
if (this.
|
|
257
|
+
if (this.smartEditConfig.guiLogWindowEnabled) {
|
|
258
258
|
if (process.platform === 'darwin') {
|
|
259
259
|
log.warn('GUI log window is not supported on macOS');
|
|
260
260
|
}
|
|
261
261
|
else {
|
|
262
262
|
this._guiLogViewer = new GuiLogViewer('dashboard', {
|
|
263
|
-
title: '
|
|
263
|
+
title: 'Smart-Edit Logs',
|
|
264
264
|
memoryLogHandler: this.memoryLogHandler,
|
|
265
265
|
autoOpen: false
|
|
266
266
|
});
|
|
@@ -270,9 +270,9 @@ export class SerenaAgent {
|
|
|
270
270
|
this._guiLogViewer.setToolNames(this._exposedTools.toolNames);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
log.info(`Starting
|
|
274
|
-
log.info(`Configuration file: ${this.
|
|
275
|
-
log.info(`Available projects: ${this.
|
|
273
|
+
log.info(`Starting Smart-Edit server (version=${smartEditVersion()}, process id=${process.pid}, parent process id=${process.ppid})`);
|
|
274
|
+
log.info(`Configuration file: ${this.smartEditConfig.configFilePath ?? '(not persisted)'}`);
|
|
275
|
+
log.info(`Available projects: ${this.smartEditConfig.projectNames.join(', ') || '(none)'}`);
|
|
276
276
|
log.info(`Loaded tools (${this._allTools.size}): ${Array.from(this._allTools.values())
|
|
277
277
|
.map((tool) => tool.getName())
|
|
278
278
|
.join(', ')}`);
|
|
@@ -360,13 +360,13 @@ export class SerenaAgent {
|
|
|
360
360
|
return future.result();
|
|
361
361
|
}
|
|
362
362
|
isUsingLanguageServer() {
|
|
363
|
-
return !this.
|
|
363
|
+
return !this.smartEditConfig.jetbrains;
|
|
364
364
|
}
|
|
365
365
|
isLanguageServerRunning() {
|
|
366
366
|
return this.languageServer?.isRunning() ?? false;
|
|
367
367
|
}
|
|
368
368
|
resetLanguageServer() {
|
|
369
|
-
const toolTimeout = this.
|
|
369
|
+
const toolTimeout = this.smartEditConfig.toolTimeout;
|
|
370
370
|
const lsTimeout = toolTimeout === undefined || toolTimeout === null || toolTimeout < 0
|
|
371
371
|
? null
|
|
372
372
|
: toolTimeout < 10
|
|
@@ -381,10 +381,10 @@ export class SerenaAgent {
|
|
|
381
381
|
}
|
|
382
382
|
const project = this.getActiveProjectOrThrow();
|
|
383
383
|
this.languageServer = project.createLanguageServer({
|
|
384
|
-
logLevel: this.
|
|
384
|
+
logLevel: this.smartEditConfig.logLevel,
|
|
385
385
|
lsTimeout,
|
|
386
|
-
traceLspCommunication: this.
|
|
387
|
-
lsSpecificSettings: this.
|
|
386
|
+
traceLspCommunication: this.smartEditConfig.traceLspCommunication,
|
|
387
|
+
lsSpecificSettings: this.smartEditConfig.lsSpecificSettings
|
|
388
388
|
});
|
|
389
389
|
log.info(`Starting the language server for ${resolveProjectName(project)}`);
|
|
390
390
|
this.languageServer.start();
|
|
@@ -395,7 +395,7 @@ export class SerenaAgent {
|
|
|
395
395
|
activateProjectFromPathOrName(projectRootOrName) {
|
|
396
396
|
const project = this.loadProjectFromPathOrName(projectRootOrName, true);
|
|
397
397
|
if (!project) {
|
|
398
|
-
throw new ProjectNotFoundError(`Project '${projectRootOrName}' not found: Not a valid project name or directory. Existing project names: ${this.
|
|
398
|
+
throw new ProjectNotFoundError(`Project '${projectRootOrName}' not found: Not a valid project name or directory. Existing project names: ${this.smartEditConfig.projectNames.join(', ')}`);
|
|
399
399
|
}
|
|
400
400
|
this.activateProject(project);
|
|
401
401
|
return Promise.resolve(project);
|
|
@@ -416,8 +416,8 @@ export class SerenaAgent {
|
|
|
416
416
|
getCurrentConfigOverview() {
|
|
417
417
|
const lines = [];
|
|
418
418
|
lines.push('Current configuration:');
|
|
419
|
-
lines.push(`
|
|
420
|
-
lines.push(`Loglevel: ${this.
|
|
419
|
+
lines.push(`Smart-Edit version: ${smartEditVersion()}`);
|
|
420
|
+
lines.push(`Loglevel: ${this.smartEditConfig.logLevel}, trace_lsp_communication=${this.smartEditConfig.traceLspCommunication}`);
|
|
421
421
|
const project = this.getActiveProject();
|
|
422
422
|
if (project) {
|
|
423
423
|
lines.push(`Active project: ${resolveProjectName(project)}`);
|
|
@@ -425,11 +425,11 @@ export class SerenaAgent {
|
|
|
425
425
|
else {
|
|
426
426
|
lines.push('No active project');
|
|
427
427
|
}
|
|
428
|
-
lines.push(`Available projects:\n${this.
|
|
428
|
+
lines.push(`Available projects:\n${this.smartEditConfig.projectNames.join('\n') || '(none)'}`);
|
|
429
429
|
lines.push(`Active context: ${this._context.name}`);
|
|
430
430
|
const activeModeNames = this.getActiveModes().map((mode) => mode.name);
|
|
431
431
|
lines.push(`Active modes: ${activeModeNames.join(', ') || '(none)'}`);
|
|
432
|
-
const inactiveModes =
|
|
432
|
+
const inactiveModes = SmartEditAgentMode.listRegisteredModeNames().filter((name) => !activeModeNames.includes(name));
|
|
433
433
|
if (inactiveModes.length > 0) {
|
|
434
434
|
lines.push(`Available but not active modes: ${inactiveModes.join(', ')}`);
|
|
435
435
|
}
|
|
@@ -477,7 +477,7 @@ export class SerenaAgent {
|
|
|
477
477
|
return;
|
|
478
478
|
}
|
|
479
479
|
this.disposed = true;
|
|
480
|
-
log.info('
|
|
480
|
+
log.info('SmartEditAgent is shutting down ...');
|
|
481
481
|
if (this.languageServer?.isRunning()) {
|
|
482
482
|
log.info('Stopping the language server ...');
|
|
483
483
|
this.languageServer.saveCache();
|
|
@@ -502,12 +502,12 @@ export class SerenaAgent {
|
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
computeBaseToolSet(initialProject) {
|
|
505
|
-
const definitions = [this.
|
|
505
|
+
const definitions = [this.smartEditConfig, this._context];
|
|
506
506
|
if (this._context.name === IDE_ASSISTANT_CONTEXT_NAME) {
|
|
507
507
|
definitions.push(...this.ideAssistantContextToolInclusionDefinitions(initialProject));
|
|
508
508
|
}
|
|
509
|
-
if (this.
|
|
510
|
-
definitions.push(
|
|
509
|
+
if (this.smartEditConfig.jetbrains) {
|
|
510
|
+
definitions.push(SmartEditAgentMode.fromNameInternal('jetbrains'));
|
|
511
511
|
}
|
|
512
512
|
return ToolSet.default().apply(...definitions);
|
|
513
513
|
}
|
|
@@ -543,13 +543,13 @@ export class SerenaAgent {
|
|
|
543
543
|
return materializeProject(registered);
|
|
544
544
|
}
|
|
545
545
|
if (autogenerate && fs.existsSync(projectRootOrName) && fs.statSync(projectRootOrName).isDirectory()) {
|
|
546
|
-
const newProject = this.
|
|
546
|
+
const newProject = this.smartEditConfig.addProjectFromPath(projectRootOrName);
|
|
547
547
|
return materializeProject(newProject);
|
|
548
548
|
}
|
|
549
549
|
return null;
|
|
550
550
|
}
|
|
551
551
|
resolveRegisteredProject(projectRootOrName) {
|
|
552
|
-
const byName = this.
|
|
552
|
+
const byName = this.smartEditConfig.projects.filter((project) => project.projectName === projectRootOrName);
|
|
553
553
|
if (byName.length === 1) {
|
|
554
554
|
return byName[0];
|
|
555
555
|
}
|
|
@@ -559,7 +559,7 @@ export class SerenaAgent {
|
|
|
559
559
|
.join(', ')}`);
|
|
560
560
|
}
|
|
561
561
|
const resolved = path.resolve(projectRootOrName);
|
|
562
|
-
for (const project of this.
|
|
562
|
+
for (const project of this.smartEditConfig.projects) {
|
|
563
563
|
if (project.matchesRootPath(resolved)) {
|
|
564
564
|
return project;
|
|
565
565
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { encoding_for_model } from '@dqbd/tiktoken';
|
|
2
|
-
import {
|
|
3
|
-
import { RegisteredTokenCountEstimator } from './config/
|
|
4
|
-
const { logger } =
|
|
2
|
+
import { createSmartEditLogger } from './util/logging.js';
|
|
3
|
+
import { RegisteredTokenCountEstimator } from './config/smart_edit_config.js';
|
|
4
|
+
const { logger } = createSmartEditLogger({ name: 'smart-edit.analytics', emitToConsole: false, level: 'info' });
|
|
5
5
|
const DEFAULT_TIKTOKEN_MODEL = 'gpt-4o';
|
|
6
6
|
class ApproximateTokenCountEstimator {
|
|
7
7
|
estimateTokenCount(text) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
interface CreateCliOptions {
|
|
3
|
+
writeOut?: (str: string) => void;
|
|
4
|
+
writeErr?: (str: string) => void;
|
|
5
|
+
enableExitOverride?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function createSmartEditCli(options?: CreateCliOptions): Command;
|
|
8
|
+
export declare function runSmartEditCli(argv?: readonly string[]): Promise<void>;
|
|
9
|
+
export default runSmartEditCli;
|
|
@@ -3,15 +3,15 @@ import path from 'node:path';
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
5
|
import { Command, Option } from 'commander';
|
|
6
|
-
import { DEFAULT_CONTEXT, DEFAULT_MODES, PROMPT_TEMPLATES_DIR_IN_USER_HOME, PROMPT_TEMPLATES_DIR_INTERNAL,
|
|
7
|
-
import {
|
|
8
|
-
import { ProjectConfig,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { DEFAULT_CONTEXT, DEFAULT_MODES, PROMPT_TEMPLATES_DIR_IN_USER_HOME, PROMPT_TEMPLATES_DIR_INTERNAL, SMART_EDIT_MANAGED_DIR_IN_HOME, SMART_EDITS_OWN_CONTEXT_YAMLS_DIR, SMART_EDITS_OWN_MODE_YAMLS_DIR, SMART_EDIT_LOG_FORMAT, USER_CONTEXT_YAMLS_DIR, USER_MODE_YAMLS_DIR } from './constants.js';
|
|
7
|
+
import { SmartEditAgentContext, SmartEditAgentMode } from './config/context_mode.js';
|
|
8
|
+
import { ProjectConfig, SmartEditConfig, SmartEditPaths } from './config/smart_edit_config.js';
|
|
9
|
+
import { createSmartEditLogger, setConsoleLoggingEnabled } from './util/logging.js';
|
|
10
|
+
import { SmartEditAgent } from './agent.js';
|
|
11
|
+
import { SmartEditMCPFactorySingleProcess, createSmartEditHttpServer, createSmartEditStdioServer } from './mcp.js';
|
|
12
12
|
import { ToolRegistry } from './tools/tools_base.js';
|
|
13
|
-
import { coerceLanguage } from '../
|
|
14
|
-
import { ensureDefaultSubprocessOptions } from '../
|
|
13
|
+
import { coerceLanguage } from '../smart-lsp/ls_config.js';
|
|
14
|
+
import { ensureDefaultSubprocessOptions } from '../smart-lsp/util/subprocess_util.js';
|
|
15
15
|
const LOG_LEVEL_NAMES = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'];
|
|
16
16
|
function isNonEmptyString(value) {
|
|
17
17
|
return typeof value === 'string' && value.length > 0;
|
|
@@ -133,7 +133,7 @@ function normalizeProjectArgument(value) {
|
|
|
133
133
|
return value;
|
|
134
134
|
}
|
|
135
135
|
async function openInEditor(targetPath) {
|
|
136
|
-
if (process.env.
|
|
136
|
+
if (process.env.SMART_EDIT_SKIP_EDITOR === '1') {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
const run = (command, args, options = {}) => new Promise((resolve, reject) => {
|
|
@@ -167,12 +167,12 @@ async function openInEditor(targetPath) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
function setupCliLogging(prefix, options) {
|
|
170
|
-
const { logger, memoryHandler } =
|
|
170
|
+
const { logger, memoryHandler } = createSmartEditLogger({
|
|
171
171
|
level: 'info',
|
|
172
172
|
emitToConsole: options.emitToConsole,
|
|
173
173
|
name: `smart-edit.cli.${prefix}`
|
|
174
174
|
});
|
|
175
|
-
const paths = new
|
|
175
|
+
const paths = new SmartEditPaths();
|
|
176
176
|
const logFilePath = paths.getNextLogFilePath(prefix);
|
|
177
177
|
const stream = fs.createWriteStream(logFilePath, { encoding: 'utf-8', flags: 'w' });
|
|
178
178
|
const callback = (message) => {
|
|
@@ -202,21 +202,21 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
202
202
|
duplicateToStderr: suppressConsoleLogs
|
|
203
203
|
});
|
|
204
204
|
const { logger } = cliLog;
|
|
205
|
-
logger.info('Initializing
|
|
205
|
+
logger.info('Initializing Smart-Edit MCP server');
|
|
206
206
|
logger.info(`Storing logs in ${cliLog.logFilePath}`);
|
|
207
|
-
logger.info(`
|
|
207
|
+
logger.info(`Smart-Edit CLI log format: ${SMART_EDIT_LOG_FORMAT}`);
|
|
208
208
|
const project = normalizeProjectArgument(projectArg ?? options.projectFile ?? options.project ?? null);
|
|
209
209
|
if (projectArg && projectArg !== project) {
|
|
210
210
|
logger.warn('--project 引数の代わりに位置引数を使用する方法は非推奨です (--project を使用してください)。');
|
|
211
211
|
}
|
|
212
212
|
const modes = options.modes.length > 0 ? options.modes : Array.from(DEFAULT_MODES);
|
|
213
|
-
const factory = new
|
|
213
|
+
const factory = new SmartEditMCPFactorySingleProcess({
|
|
214
214
|
context: options.context ?? DEFAULT_CONTEXT,
|
|
215
215
|
project,
|
|
216
216
|
memoryLogHandler: cliLog.memoryHandler,
|
|
217
|
-
agentFactory: (agentOptions) => new
|
|
217
|
+
agentFactory: (agentOptions) => new SmartEditAgent({
|
|
218
218
|
project: agentOptions.project,
|
|
219
|
-
|
|
219
|
+
smartEditConfig: agentOptions.smartEditConfig,
|
|
220
220
|
context: agentOptions.context,
|
|
221
221
|
modes: agentOptions.modes,
|
|
222
222
|
memoryLogHandler: agentOptions.memoryLogHandler ?? undefined
|
|
@@ -236,7 +236,7 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
236
236
|
};
|
|
237
237
|
switch (options.transport) {
|
|
238
238
|
case 'streamable-http': {
|
|
239
|
-
const server = await
|
|
239
|
+
const server = await createSmartEditHttpServer(factory, serverOptions);
|
|
240
240
|
logger.info(`Streamable HTTP MCP server started: ${server.url.href}`);
|
|
241
241
|
logger.info('Press Ctrl+C to exit.');
|
|
242
242
|
await new Promise((resolve) => {
|
|
@@ -255,7 +255,7 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
case 'stdio': {
|
|
258
|
-
const server = await
|
|
258
|
+
const server = await createSmartEditStdioServer(factory, serverOptions);
|
|
259
259
|
logger.info('STDIO MCP server started. Press Ctrl+C to exit.');
|
|
260
260
|
await new Promise((resolve) => {
|
|
261
261
|
let settled = false;
|
|
@@ -294,7 +294,7 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
294
294
|
}
|
|
295
295
|
catch (error) {
|
|
296
296
|
const message = error instanceof Error ? error.message : String(error);
|
|
297
|
-
logger.error(`
|
|
297
|
+
logger.error(`Smart-Edit MCP サーバーの起動に失敗しました: ${message}`);
|
|
298
298
|
throw error;
|
|
299
299
|
}
|
|
300
300
|
finally {
|
|
@@ -303,12 +303,12 @@ async function handleStartMcpServer(options, projectArg) {
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
function formatModeLine(name, yamlPath) {
|
|
306
|
-
const isInternal = isPathInside(yamlPath,
|
|
306
|
+
const isInternal = isPathInside(yamlPath, SMART_EDITS_OWN_MODE_YAMLS_DIR);
|
|
307
307
|
const descriptor = isInternal ? '(internal)' : `(at ${yamlPath})`;
|
|
308
308
|
return `${name} ${descriptor}`;
|
|
309
309
|
}
|
|
310
310
|
function formatContextLine(name, yamlPath) {
|
|
311
|
-
const isInternal = isPathInside(yamlPath,
|
|
311
|
+
const isInternal = isPathInside(yamlPath, SMART_EDITS_OWN_CONTEXT_YAMLS_DIR);
|
|
312
312
|
const descriptor = isInternal ? '(internal)' : `(at ${yamlPath})`;
|
|
313
313
|
return `${name} ${descriptor}`;
|
|
314
314
|
}
|
|
@@ -323,10 +323,10 @@ function handleModeCreate(options) {
|
|
|
323
323
|
const modeName = name ?? fromInternal ?? '';
|
|
324
324
|
const destination = path.join(USER_MODE_YAMLS_DIR, `${modeName}.yml`);
|
|
325
325
|
const source = fromInternal
|
|
326
|
-
? path.join(
|
|
327
|
-
: path.join(
|
|
326
|
+
? path.join(SMART_EDITS_OWN_MODE_YAMLS_DIR, `${fromInternal}.yml`)
|
|
327
|
+
: path.join(SMART_EDITS_OWN_MODE_YAMLS_DIR, 'mode.template.yml');
|
|
328
328
|
if (!fs.existsSync(source)) {
|
|
329
|
-
const available =
|
|
329
|
+
const available = SmartEditAgentMode.listRegisteredModeNames().join(', ');
|
|
330
330
|
throw new Error(`内部モード '${fromInternal ?? ''}' が見つかりません。利用可能なモード: ${available}`);
|
|
331
331
|
}
|
|
332
332
|
ensureDirExists(path.dirname(destination));
|
|
@@ -341,10 +341,10 @@ function handleContextCreate(options) {
|
|
|
341
341
|
const contextName = name ?? fromInternal ?? '';
|
|
342
342
|
const destination = path.join(USER_CONTEXT_YAMLS_DIR, `${contextName}.yml`);
|
|
343
343
|
const source = fromInternal
|
|
344
|
-
? path.join(
|
|
345
|
-
: path.join(
|
|
344
|
+
? path.join(SMART_EDITS_OWN_CONTEXT_YAMLS_DIR, `${fromInternal}.yml`)
|
|
345
|
+
: path.join(SMART_EDITS_OWN_CONTEXT_YAMLS_DIR, 'context.template.yml');
|
|
346
346
|
if (!fs.existsSync(source)) {
|
|
347
|
-
const available =
|
|
347
|
+
const available = SmartEditAgentContext.listRegisteredContextNames().join(', ');
|
|
348
348
|
throw new Error(`内部コンテキスト '${fromInternal ?? ''}' が見つかりません。利用可能なコンテキスト: ${available}`);
|
|
349
349
|
}
|
|
350
350
|
ensureDirExists(path.dirname(destination));
|
|
@@ -364,11 +364,11 @@ function getUserPromptPath(promptYamlName) {
|
|
|
364
364
|
function ensurePromptYamlName(promptYamlName) {
|
|
365
365
|
return promptYamlName.endsWith('.yml') ? promptYamlName : `${promptYamlName}.yml`;
|
|
366
366
|
}
|
|
367
|
-
export function
|
|
368
|
-
const program = new Command('
|
|
367
|
+
export function createSmartEditCli(options = {}) {
|
|
368
|
+
const program = new Command('smart-edit');
|
|
369
369
|
program
|
|
370
|
-
.description('
|
|
371
|
-
.showHelpAfterError('(ヘルプ:
|
|
370
|
+
.description('Smart-Edit CLI commands. 各コマンドの詳細は `<command> --help` を参照してください。')
|
|
371
|
+
.showHelpAfterError('(ヘルプ: smart-edit --help)')
|
|
372
372
|
.configureOutput({
|
|
373
373
|
writeOut: options.writeOut ?? ((str) => process.stdout.write(str)),
|
|
374
374
|
writeErr: options.writeErr ?? ((str) => process.stderr.write(str)),
|
|
@@ -378,7 +378,7 @@ export function createSerenaCli(options = {}) {
|
|
|
378
378
|
program.exitOverride();
|
|
379
379
|
}
|
|
380
380
|
const startMcpServerCommand = new Command('start-mcp-server')
|
|
381
|
-
.description('
|
|
381
|
+
.description('Smart-Edit MCP サーバーを起動します。')
|
|
382
382
|
.option('--project [project]', '起動時にアクティブ化するプロジェクト名またはパス。')
|
|
383
383
|
.option('--project-file [project]', '[非推奨] --project の旧名称。')
|
|
384
384
|
.argument('[project]', '[非推奨] プロジェクトの位置引数。')
|
|
@@ -408,29 +408,17 @@ export function createSerenaCli(options = {}) {
|
|
|
408
408
|
this.error(`${message}\n`, { exitCode: 1 });
|
|
409
409
|
}
|
|
410
410
|
});
|
|
411
|
-
const printSystemPromptCommand = new Command('print-system-prompt')
|
|
412
|
-
.description('プロジェクトに対するシステムプロンプトを表示します。')
|
|
413
|
-
.argument('[project]', 'プロジェクトパス (省略時はカレントディレクトリ)。', process.cwd())
|
|
414
|
-
.option('--log-level <level>', 'プロンプト生成時のログレベル。', 'WARNING')
|
|
415
|
-
.option('--only-instructions', '初期指示部分のみ出力します。')
|
|
416
|
-
.option('--context <context>', 'ビルトインコンテキスト名または YAML パス。', DEFAULT_CONTEXT)
|
|
417
|
-
.addOption(new Option('--mode <mode...>', 'ビルトインモードまたは YAML を複数指定。').default(Array.from(DEFAULT_MODES)))
|
|
418
|
-
.action((projectPath, command) => {
|
|
419
|
-
const err = 'print-system-prompt はエージェント実装が移植され次第サポート予定です。現在は未実装のため利用できません。';
|
|
420
|
-
command.error(`${err}\n`, { exitCode: 1 });
|
|
421
|
-
});
|
|
422
411
|
program.addCommand(startMcpServerCommand);
|
|
423
|
-
program.addCommand(printSystemPromptCommand);
|
|
424
412
|
const modeCommand = new Command('mode')
|
|
425
|
-
.description('
|
|
413
|
+
.description('Smart-Edit モードを管理します。');
|
|
426
414
|
modeCommand
|
|
427
415
|
.command('list')
|
|
428
416
|
.description('利用可能なモードを一覧表示します。')
|
|
429
417
|
.action(() => {
|
|
430
|
-
const modes =
|
|
418
|
+
const modes = SmartEditAgentMode.listRegisteredModeNames();
|
|
431
419
|
const output = modes
|
|
432
420
|
.map((name) => {
|
|
433
|
-
const yamlPath =
|
|
421
|
+
const yamlPath = SmartEditAgentMode.getPath(name);
|
|
434
422
|
return formatModeLine(name, yamlPath);
|
|
435
423
|
})
|
|
436
424
|
.join('\n');
|
|
@@ -464,7 +452,7 @@ export function createSerenaCli(options = {}) {
|
|
|
464
452
|
.action(async (modeName) => {
|
|
465
453
|
const destination = path.join(USER_MODE_YAMLS_DIR, `${modeName}.yml`);
|
|
466
454
|
if (!fs.existsSync(destination)) {
|
|
467
|
-
if (
|
|
455
|
+
if (SmartEditAgentMode.listRegisteredModeNames(false).includes(modeName)) {
|
|
468
456
|
throw new Error(`Mode '${modeName}' は内部モードのため直接編集できません。'mode create --from-internal ${modeName}' を使用してカスタムモードを作成してください。`);
|
|
469
457
|
}
|
|
470
458
|
throw new Error(`カスタムモード '${modeName}' が見つかりません。'mode create --name ${modeName}' を使用してください。`);
|
|
@@ -485,15 +473,15 @@ export function createSerenaCli(options = {}) {
|
|
|
485
473
|
});
|
|
486
474
|
program.addCommand(modeCommand);
|
|
487
475
|
const contextCommand = new Command('context')
|
|
488
|
-
.description('
|
|
476
|
+
.description('Smart-Edit コンテキストを管理します。');
|
|
489
477
|
contextCommand
|
|
490
478
|
.command('list')
|
|
491
479
|
.description('利用可能なコンテキストを一覧表示します。')
|
|
492
480
|
.action(() => {
|
|
493
|
-
const contexts =
|
|
481
|
+
const contexts = SmartEditAgentContext.listRegisteredContextNames();
|
|
494
482
|
const output = contexts
|
|
495
483
|
.map((name) => {
|
|
496
|
-
const yamlPath =
|
|
484
|
+
const yamlPath = SmartEditAgentContext.getPath(name);
|
|
497
485
|
return formatContextLine(name, yamlPath);
|
|
498
486
|
})
|
|
499
487
|
.join('\n');
|
|
@@ -527,7 +515,7 @@ export function createSerenaCli(options = {}) {
|
|
|
527
515
|
.action(async (contextName) => {
|
|
528
516
|
const destination = path.join(USER_CONTEXT_YAMLS_DIR, `${contextName}.yml`);
|
|
529
517
|
if (!fs.existsSync(destination)) {
|
|
530
|
-
if (
|
|
518
|
+
if (SmartEditAgentContext.listRegisteredContextNames(false).includes(contextName)) {
|
|
531
519
|
throw new Error(`Context '${contextName}' は内部コンテキストのため直接編集できません。'context create --from-internal ${contextName}' を使用してカスタムコンテキストを作成してください。`);
|
|
532
520
|
}
|
|
533
521
|
throw new Error(`カスタムコンテキスト '${contextName}' が見つかりません。'context create --name ${contextName}' を使用してください。`);
|
|
@@ -548,21 +536,21 @@ export function createSerenaCli(options = {}) {
|
|
|
548
536
|
});
|
|
549
537
|
program.addCommand(contextCommand);
|
|
550
538
|
const configCommand = new Command('config')
|
|
551
|
-
.description('
|
|
539
|
+
.description('Smart-Edit の設定ファイルを扱います。');
|
|
552
540
|
configCommand
|
|
553
541
|
.command('edit')
|
|
554
|
-
.description('
|
|
542
|
+
.description('smart_edit_config.yml を既定のエディタで開きます。')
|
|
555
543
|
.action(async () => {
|
|
556
|
-
const configPath = path.join(
|
|
544
|
+
const configPath = path.join(SMART_EDIT_MANAGED_DIR_IN_HOME, 'smart_edit_config.yml');
|
|
557
545
|
if (!fs.existsSync(configPath)) {
|
|
558
546
|
ensureDirExists(path.dirname(configPath));
|
|
559
|
-
|
|
547
|
+
SmartEditConfig.generateConfigFile(configPath);
|
|
560
548
|
}
|
|
561
549
|
await openInEditor(configPath);
|
|
562
550
|
});
|
|
563
551
|
program.addCommand(configCommand);
|
|
564
552
|
const projectCommand = new Command('project')
|
|
565
|
-
.description('
|
|
553
|
+
.description('Smart-Edit プロジェクト関連の操作。');
|
|
566
554
|
projectCommand
|
|
567
555
|
.command('generate-yml')
|
|
568
556
|
.description('プロジェクトの project.yml を生成します。')
|
|
@@ -582,39 +570,9 @@ export function createSerenaCli(options = {}) {
|
|
|
582
570
|
throw new Error(message);
|
|
583
571
|
}
|
|
584
572
|
});
|
|
585
|
-
projectCommand
|
|
586
|
-
.command('index')
|
|
587
|
-
.description('プロジェクトのシンボルをインデックスします。')
|
|
588
|
-
.action(() => {
|
|
589
|
-
throw new Error('project index はエージェントおよび SolidLSP モジュール移植後に実装予定です。');
|
|
590
|
-
});
|
|
591
|
-
projectCommand
|
|
592
|
-
.command('index-deprecated')
|
|
593
|
-
.description('project index の旧名称。')
|
|
594
|
-
.action(() => {
|
|
595
|
-
throw new Error('project index-deprecated は TypeScript 版では利用できません。`serena project index` をお待ちください。');
|
|
596
|
-
});
|
|
597
|
-
projectCommand
|
|
598
|
-
.command('is_ignored_path')
|
|
599
|
-
.description('プロジェクト設定で無視されるパスか確認します。')
|
|
600
|
-
.action(() => {
|
|
601
|
-
throw new Error('is_ignored_path は TypeScript 版で未実装です。');
|
|
602
|
-
});
|
|
603
|
-
projectCommand
|
|
604
|
-
.command('index-file')
|
|
605
|
-
.description('単一ファイルのインデックス化を行います。')
|
|
606
|
-
.action(() => {
|
|
607
|
-
throw new Error('index-file は TypeScript 版で未実装です。');
|
|
608
|
-
});
|
|
609
|
-
projectCommand
|
|
610
|
-
.command('health-check')
|
|
611
|
-
.description('プロジェクトのヘルスチェックを実行します。')
|
|
612
|
-
.action(() => {
|
|
613
|
-
throw new Error('health-check は SolidLSP およびエージェント移植後に実装予定です。');
|
|
614
|
-
});
|
|
615
573
|
program.addCommand(projectCommand);
|
|
616
574
|
const toolsCommand = new Command('tools')
|
|
617
|
-
.description('
|
|
575
|
+
.description('Smart-Edit のツール情報を表示します。');
|
|
618
576
|
toolsCommand
|
|
619
577
|
.command('list')
|
|
620
578
|
.description('利用可能なツールの概要を表示します。')
|
|
@@ -642,14 +600,6 @@ export function createSerenaCli(options = {}) {
|
|
|
642
600
|
onlyOptional: options.onlyOptional
|
|
643
601
|
});
|
|
644
602
|
});
|
|
645
|
-
toolsCommand
|
|
646
|
-
.command('description')
|
|
647
|
-
.description('指定したツールの説明を表示します。')
|
|
648
|
-
.argument('<toolName>', 'ツール名')
|
|
649
|
-
.option('--context <context>', 'コンテキスト名または YAML パス。')
|
|
650
|
-
.action(() => {
|
|
651
|
-
throw new Error('tools description はエージェント移植後に実装予定です。');
|
|
652
|
-
});
|
|
653
603
|
program.addCommand(toolsCommand);
|
|
654
604
|
const promptsCommand = new Command('prompts')
|
|
655
605
|
.description('プロンプト関連のコマンド。');
|
|
@@ -724,8 +674,8 @@ export function createSerenaCli(options = {}) {
|
|
|
724
674
|
program.addCommand(promptsCommand);
|
|
725
675
|
return program;
|
|
726
676
|
}
|
|
727
|
-
export async function
|
|
728
|
-
const cli =
|
|
677
|
+
export async function runSmartEditCli(argv = process.argv.slice(2)) {
|
|
678
|
+
const cli = createSmartEditCli();
|
|
729
679
|
await cli.parseAsync(argv, { from: 'user' });
|
|
730
680
|
}
|
|
731
|
-
export default
|
|
681
|
+
export default runSmartEditCli;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PositionInFile } from './symbol.js';
|
|
2
|
-
import type { JetBrainsSymbol, LanguageServerSymbol, LanguageServerSymbolRetriever, Symbol as
|
|
3
|
-
import type {
|
|
2
|
+
import type { JetBrainsSymbol, LanguageServerSymbol, LanguageServerSymbolRetriever, Symbol as SmartEditSymbol } from './symbol.js';
|
|
3
|
+
import type { SmartEditAgent } from './agent.js';
|
|
4
4
|
interface EditedFile {
|
|
5
5
|
getContents(): string;
|
|
6
6
|
deleteTextBetweenPositions(start: PositionInFile, end: PositionInFile): void;
|
|
7
7
|
insertTextAtPosition(position: PositionInFile, text: string): void;
|
|
8
8
|
}
|
|
9
|
-
export declare abstract class CodeEditor<TSymbol extends
|
|
9
|
+
export declare abstract class CodeEditor<TSymbol extends SmartEditSymbol> {
|
|
10
10
|
protected readonly projectRoot: string;
|
|
11
|
-
protected readonly agent:
|
|
12
|
-
constructor(projectRoot: string, agent?:
|
|
11
|
+
protected readonly agent: SmartEditAgent | null;
|
|
12
|
+
constructor(projectRoot: string, agent?: SmartEditAgent | null);
|
|
13
13
|
protected abstract openFile(relativePath: string): Promise<EditedFile>;
|
|
14
14
|
protected abstract findUniqueSymbol(namePath: string, relativeFilePath: string): Promise<TSymbol> | TSymbol;
|
|
15
15
|
protected withEditedFile(relativePath: string, handler: (file: EditedFile) => Promise<void> | void): Promise<void>;
|
|
@@ -30,12 +30,12 @@ export declare abstract class CodeEditor<TSymbol extends SerenaSymbol> {
|
|
|
30
30
|
}
|
|
31
31
|
export declare class LanguageServerCodeEditor extends CodeEditor<LanguageServerSymbol> {
|
|
32
32
|
private readonly symbolRetriever;
|
|
33
|
-
constructor(symbolRetriever: LanguageServerSymbolRetriever, agent?:
|
|
33
|
+
constructor(symbolRetriever: LanguageServerSymbolRetriever, agent?: SmartEditAgent | null);
|
|
34
34
|
protected openFile(relativePath: string): Promise<EditedFile>;
|
|
35
35
|
protected findUniqueSymbol(namePath: string, relativeFilePath: string): LanguageServerSymbol;
|
|
36
36
|
}
|
|
37
37
|
export declare class JetBrainsCodeEditor extends CodeEditor<JetBrainsSymbol> {
|
|
38
|
-
constructor(projectRoot: string, agent?:
|
|
38
|
+
constructor(projectRoot: string, agent?: SmartEditAgent | null);
|
|
39
39
|
protected openFile(_relativePath: string): Promise<EditedFile>;
|
|
40
40
|
protected findUniqueSymbol(_namePath: string, _relativeFilePath: string): JetBrainsSymbol;
|
|
41
41
|
}
|