@nogataka/smart-edit 0.1.0 → 1.0.1
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 +143 -66
- 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 +17 -3
- 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 -816
- package/dist/serena/resources/dashboard/index.html +0 -312
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ToolInclusionDefinitionInit } from './
|
|
2
|
-
import { ToolInclusionDefinition } from './
|
|
3
|
-
export declare class
|
|
1
|
+
import type { ToolInclusionDefinitionInit } from './smart_edit_config.js';
|
|
2
|
+
import { ToolInclusionDefinition } from './smart_edit_config.js';
|
|
3
|
+
export declare class SmartEditAgentMode extends ToolInclusionDefinition {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly prompt: string;
|
|
6
6
|
readonly description: string;
|
|
@@ -9,17 +9,17 @@ export declare class SerenaAgentMode extends ToolInclusionDefinition {
|
|
|
9
9
|
prompt: string;
|
|
10
10
|
description?: string;
|
|
11
11
|
});
|
|
12
|
-
static fromYaml(yamlPath: string):
|
|
12
|
+
static fromYaml(yamlPath: string): SmartEditAgentMode;
|
|
13
13
|
static getPath(name: string): string;
|
|
14
|
-
static fromName(name: string):
|
|
15
|
-
static fromNameInternal(name: string):
|
|
14
|
+
static fromName(name: string): SmartEditAgentMode;
|
|
15
|
+
static fromNameInternal(name: string): SmartEditAgentMode;
|
|
16
16
|
static listRegisteredModeNames(includeUserModes?: boolean): string[];
|
|
17
17
|
static listCustomModeNames(): string[];
|
|
18
|
-
static loadDefaultModes():
|
|
19
|
-
static load(nameOrPath: string):
|
|
18
|
+
static loadDefaultModes(): SmartEditAgentMode[];
|
|
19
|
+
static load(nameOrPath: string): SmartEditAgentMode;
|
|
20
20
|
printOverview(): void;
|
|
21
21
|
}
|
|
22
|
-
export declare class
|
|
22
|
+
export declare class SmartEditAgentContext extends ToolInclusionDefinition {
|
|
23
23
|
readonly name: string;
|
|
24
24
|
readonly prompt: string;
|
|
25
25
|
readonly description: string;
|
|
@@ -30,12 +30,12 @@ export declare class SerenaAgentContext extends ToolInclusionDefinition {
|
|
|
30
30
|
description?: string;
|
|
31
31
|
toolDescriptionOverrides?: Record<string, string>;
|
|
32
32
|
});
|
|
33
|
-
static fromYaml(yamlPath: string):
|
|
33
|
+
static fromYaml(yamlPath: string): SmartEditAgentContext;
|
|
34
34
|
static getPath(name: string): string;
|
|
35
|
-
static fromName(name: string):
|
|
36
|
-
static load(nameOrPath: string):
|
|
35
|
+
static fromName(name: string): SmartEditAgentContext;
|
|
36
|
+
static load(nameOrPath: string): SmartEditAgentContext;
|
|
37
37
|
static listRegisteredContextNames(includeUserContexts?: boolean): string[];
|
|
38
38
|
static listCustomContextNames(): string[];
|
|
39
|
-
static loadDefault():
|
|
39
|
+
static loadDefault(): SmartEditAgentContext;
|
|
40
40
|
printOverview(): void;
|
|
41
41
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { DEFAULT_CONTEXT, DEFAULT_MODES, INTERNAL_MODE_YAMLS_DIR,
|
|
4
|
+
import { DEFAULT_CONTEXT, DEFAULT_MODES, INTERNAL_MODE_YAMLS_DIR, SMART_EDITS_OWN_CONTEXT_YAMLS_DIR, SMART_EDITS_OWN_MODE_YAMLS_DIR, USER_CONTEXT_YAMLS_DIR, USER_MODE_YAMLS_DIR } from '../constants.js';
|
|
5
5
|
import { loadYaml } from '../util/general.js';
|
|
6
|
-
import { ToolInclusionDefinition } from './
|
|
6
|
+
import { ToolInclusionDefinition } from './smart_edit_config.js';
|
|
7
7
|
const STRING_ARRAY_SCHEMA = z
|
|
8
8
|
.union([z.array(z.union([z.string(), z.number(), z.boolean()])), z.string(), z.number(), z.boolean(), z.null()])
|
|
9
9
|
.optional()
|
|
@@ -69,7 +69,7 @@ const MODE_YAML_SCHEMA = z
|
|
|
69
69
|
const CONTEXT_YAML_SCHEMA = MODE_YAML_SCHEMA.extend({
|
|
70
70
|
tool_description_overrides: TOOL_DESCRIPTION_OVERRIDES_SCHEMA
|
|
71
71
|
});
|
|
72
|
-
export class
|
|
72
|
+
export class SmartEditAgentMode extends ToolInclusionDefinition {
|
|
73
73
|
name;
|
|
74
74
|
prompt;
|
|
75
75
|
description;
|
|
@@ -91,7 +91,7 @@ export class SerenaAgentMode extends ToolInclusionDefinition {
|
|
|
91
91
|
}
|
|
92
92
|
const parsed = parsedResult.data;
|
|
93
93
|
const name = parsed.name ?? path.parse(yamlPath).name;
|
|
94
|
-
return new
|
|
94
|
+
return new SmartEditAgentMode({
|
|
95
95
|
name,
|
|
96
96
|
prompt: parsed.prompt,
|
|
97
97
|
description: parsed.description,
|
|
@@ -105,9 +105,9 @@ export class SerenaAgentMode extends ToolInclusionDefinition {
|
|
|
105
105
|
if (fs.existsSync(custom)) {
|
|
106
106
|
return custom;
|
|
107
107
|
}
|
|
108
|
-
const own = path.join(
|
|
108
|
+
const own = path.join(SMART_EDITS_OWN_MODE_YAMLS_DIR, filename);
|
|
109
109
|
if (!fs.existsSync(own)) {
|
|
110
|
-
throw new Error(`Mode ${name} not found in ${USER_MODE_YAMLS_DIR} or in ${
|
|
110
|
+
throw new Error(`Mode ${name} not found in ${USER_MODE_YAMLS_DIR} or in ${SMART_EDITS_OWN_MODE_YAMLS_DIR}. Available modes:\n${this.listRegisteredModeNames().join(', ')}`);
|
|
111
111
|
}
|
|
112
112
|
return own;
|
|
113
113
|
}
|
|
@@ -123,7 +123,7 @@ export class SerenaAgentMode extends ToolInclusionDefinition {
|
|
|
123
123
|
return this.fromYaml(internalPath);
|
|
124
124
|
}
|
|
125
125
|
static listRegisteredModeNames(includeUserModes = true) {
|
|
126
|
-
const own = listYamlFiles(
|
|
126
|
+
const own = listYamlFiles(SMART_EDITS_OWN_MODE_YAMLS_DIR).filter((file) => file !== 'mode.template');
|
|
127
127
|
const user = includeUserModes ? listYamlFiles(USER_MODE_YAMLS_DIR) : [];
|
|
128
128
|
return Array.from(new Set([...own, ...user])).sort();
|
|
129
129
|
}
|
|
@@ -146,7 +146,7 @@ export class SerenaAgentMode extends ToolInclusionDefinition {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
export class
|
|
149
|
+
export class SmartEditAgentContext extends ToolInclusionDefinition {
|
|
150
150
|
name;
|
|
151
151
|
prompt;
|
|
152
152
|
description;
|
|
@@ -170,7 +170,7 @@ export class SerenaAgentContext extends ToolInclusionDefinition {
|
|
|
170
170
|
}
|
|
171
171
|
const parsed = parsedResult.data;
|
|
172
172
|
const name = parsed.name ?? path.parse(yamlPath).name;
|
|
173
|
-
return new
|
|
173
|
+
return new SmartEditAgentContext({
|
|
174
174
|
name,
|
|
175
175
|
prompt: parsed.prompt,
|
|
176
176
|
description: parsed.description,
|
|
@@ -185,9 +185,9 @@ export class SerenaAgentContext extends ToolInclusionDefinition {
|
|
|
185
185
|
if (fs.existsSync(custom)) {
|
|
186
186
|
return custom;
|
|
187
187
|
}
|
|
188
|
-
const own = path.join(
|
|
188
|
+
const own = path.join(SMART_EDITS_OWN_CONTEXT_YAMLS_DIR, filename);
|
|
189
189
|
if (!fs.existsSync(own)) {
|
|
190
|
-
throw new Error(`Context ${name} not found in ${USER_CONTEXT_YAMLS_DIR} or in ${
|
|
190
|
+
throw new Error(`Context ${name} not found in ${USER_CONTEXT_YAMLS_DIR} or in ${SMART_EDITS_OWN_CONTEXT_YAMLS_DIR}. Available contexts:\n${this.listRegisteredContextNames().join(', ')}`);
|
|
191
191
|
}
|
|
192
192
|
return own;
|
|
193
193
|
}
|
|
@@ -202,7 +202,7 @@ export class SerenaAgentContext extends ToolInclusionDefinition {
|
|
|
202
202
|
return this.fromName(nameOrPath);
|
|
203
203
|
}
|
|
204
204
|
static listRegisteredContextNames(includeUserContexts = true) {
|
|
205
|
-
const own = listYamlFiles(
|
|
205
|
+
const own = listYamlFiles(SMART_EDITS_OWN_CONTEXT_YAMLS_DIR);
|
|
206
206
|
const user = includeUserContexts ? listYamlFiles(USER_CONTEXT_YAMLS_DIR) : [];
|
|
207
207
|
return Array.from(new Set([...own, ...user])).sort();
|
|
208
208
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { YamlDocument, YamlObject } from '../util/general.js';
|
|
2
|
-
import { Language } from '../../
|
|
2
|
+
import { Language } from '../../smart-lsp/ls_config.js';
|
|
3
3
|
export interface ToolInclusionDefinitionInit {
|
|
4
4
|
excludedTools?: Iterable<string>;
|
|
5
5
|
includedOptionalTools?: Iterable<string>;
|
|
@@ -11,14 +11,14 @@ export declare class ToolInclusionDefinition {
|
|
|
11
11
|
protected createNext(options: ToolInclusionDefinitionInit): ToolInclusionDefinition;
|
|
12
12
|
}
|
|
13
13
|
export declare const DEFAULT_TOOL_TIMEOUT = 240;
|
|
14
|
-
declare class
|
|
14
|
+
declare class SmartEditPathsImpl {
|
|
15
15
|
readonly userConfigDir: string;
|
|
16
16
|
constructor();
|
|
17
17
|
getNextLogFilePath(prefix: string): string;
|
|
18
18
|
}
|
|
19
|
-
declare const
|
|
20
|
-
export {
|
|
21
|
-
export type
|
|
19
|
+
declare const SmartEditPathsSingleton: typeof SmartEditPathsImpl;
|
|
20
|
+
export { SmartEditPathsSingleton as SmartEditPaths };
|
|
21
|
+
export type SmartEditPathsInstance = InstanceType<typeof SmartEditPathsImpl>;
|
|
22
22
|
export declare class ToolSet {
|
|
23
23
|
private readonly toolNames;
|
|
24
24
|
constructor(toolNames: Iterable<string>);
|
|
@@ -45,7 +45,7 @@ export declare class ProjectConfig extends ToolInclusionDefinition {
|
|
|
45
45
|
readonly ignoreAllFilesInGitignore: boolean;
|
|
46
46
|
readonly initialPrompt: string;
|
|
47
47
|
readonly encoding: string;
|
|
48
|
-
static readonly
|
|
48
|
+
static readonly SMART_EDIT_DEFAULT_PROJECT_FILE = "project.yml";
|
|
49
49
|
constructor(init: ProjectConfigInit);
|
|
50
50
|
static autogenerate(projectRoot: string, options?: {
|
|
51
51
|
projectName?: string | null;
|
|
@@ -81,7 +81,7 @@ export declare enum RegisteredTokenCountEstimator {
|
|
|
81
81
|
TIKTOKEN_GPT4O = "TIKTOKEN_GPT4O",
|
|
82
82
|
ANTHROPIC_CLAUDE_SONNET_4 = "ANTHROPIC_CLAUDE_SONNET_4"
|
|
83
83
|
}
|
|
84
|
-
export interface
|
|
84
|
+
export interface SmartEditConfigInit extends ToolInclusionDefinitionInit {
|
|
85
85
|
projects?: RegisteredProject[];
|
|
86
86
|
guiLogWindowEnabled?: boolean;
|
|
87
87
|
logLevel?: number;
|
|
@@ -97,7 +97,7 @@ export interface SerenaConfigInit extends ToolInclusionDefinitionInit {
|
|
|
97
97
|
defaultMaxToolAnswerChars?: number;
|
|
98
98
|
lsSpecificSettings?: Record<string, unknown>;
|
|
99
99
|
}
|
|
100
|
-
export declare class
|
|
100
|
+
export declare class SmartEditConfig extends ToolInclusionDefinition {
|
|
101
101
|
projects: RegisteredProject[];
|
|
102
102
|
guiLogWindowEnabled: boolean;
|
|
103
103
|
logLevel: number;
|
|
@@ -112,14 +112,14 @@ export declare class SerenaConfig extends ToolInclusionDefinition {
|
|
|
112
112
|
tokenCountEstimator: RegisteredTokenCountEstimator;
|
|
113
113
|
defaultMaxToolAnswerChars: number;
|
|
114
114
|
lsSpecificSettings: Record<string, unknown>;
|
|
115
|
-
static readonly CONFIG_FILE = "
|
|
116
|
-
static readonly CONFIG_FILE_DOCKER = "
|
|
117
|
-
constructor(init?:
|
|
115
|
+
static readonly CONFIG_FILE = "smart_edit_config.yml";
|
|
116
|
+
static readonly CONFIG_FILE_DOCKER = "smart_edit_config.docker.yml";
|
|
117
|
+
constructor(init?: SmartEditConfigInit);
|
|
118
118
|
static generateConfigFile(configFilePath: string): void;
|
|
119
119
|
private static determineConfigFilePath;
|
|
120
120
|
static fromConfigFile(options?: {
|
|
121
121
|
generateIfMissing?: boolean;
|
|
122
|
-
}):
|
|
122
|
+
}): SmartEditConfig;
|
|
123
123
|
private static migrateOutOfProjectConfigFile;
|
|
124
124
|
get projectPaths(): string[];
|
|
125
125
|
get projectNames(): string[];
|
|
@@ -128,7 +128,7 @@ export declare class SerenaConfig extends ToolInclusionDefinition {
|
|
|
128
128
|
removeProject(projectName: string): void;
|
|
129
129
|
save(): void;
|
|
130
130
|
}
|
|
131
|
-
export declare class
|
|
131
|
+
export declare class SmartEditConfigError extends Error {
|
|
132
132
|
}
|
|
133
|
-
export declare function
|
|
133
|
+
export declare function getSmartEditManagedInProjectDir(projectRoot: string): string;
|
|
134
134
|
export declare function isRunningInDocker(): boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { DEFAULT_ENCODING, PROJECT_TEMPLATE_FILE, REPO_ROOT,
|
|
5
|
-
import {
|
|
4
|
+
import { DEFAULT_ENCODING, PROJECT_TEMPLATE_FILE, REPO_ROOT, SMART_EDIT_CONFIG_TEMPLATE_FILE, SMART_EDIT_MANAGED_DIR_IN_HOME, SMART_EDIT_MANAGED_DIR_NAME } from '../constants.js';
|
|
5
|
+
import { createSmartEditLogger } from '../util/logging.js';
|
|
6
6
|
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 '../../
|
|
11
|
-
const { logger: log } =
|
|
10
|
+
import { Language, coerceLanguage } from '../../smart-lsp/ls_config.js';
|
|
11
|
+
const { logger: log } = createSmartEditLogger({ name: 'smart-edit.config' });
|
|
12
12
|
export class ToolInclusionDefinition {
|
|
13
13
|
excludedTools;
|
|
14
14
|
includedOptionalTools;
|
|
@@ -120,7 +120,7 @@ const PROJECT_CONFIG_YAML_SCHEMA = z
|
|
|
120
120
|
encoding: z.string().optional()
|
|
121
121
|
})
|
|
122
122
|
.passthrough();
|
|
123
|
-
const
|
|
123
|
+
const SMART_EDIT_CONFIG_YAML_SCHEMA = z
|
|
124
124
|
.object({
|
|
125
125
|
gui_log_window: BOOLEAN_INPUT_SCHEMA,
|
|
126
126
|
gui_log_window_enabled: BOOLEAN_INPUT_SCHEMA,
|
|
@@ -138,7 +138,7 @@ const SERENA_CONFIG_YAML_SCHEMA = z
|
|
|
138
138
|
default_max_tool_answer_chars: NUMBER_INPUT_SCHEMA,
|
|
139
139
|
ls_specific_settings: z.record(z.unknown()).optional(),
|
|
140
140
|
projects: z.array(z.string(), {
|
|
141
|
-
required_error: '`projects` key not found in
|
|
141
|
+
required_error: '`projects` key not found in Smart-Edit configuration.',
|
|
142
142
|
invalid_type_error: '`projects` は文字列の配列である必要があります。'
|
|
143
143
|
})
|
|
144
144
|
})
|
|
@@ -153,10 +153,10 @@ function datetimeTag() {
|
|
|
153
153
|
const ss = now.getSeconds().toString().padStart(2, '0');
|
|
154
154
|
return `${yyyy}${mm}${dd}_${hh}${mi}${ss}`;
|
|
155
155
|
}
|
|
156
|
-
class
|
|
156
|
+
class SmartEditPathsImpl {
|
|
157
157
|
userConfigDir;
|
|
158
158
|
constructor() {
|
|
159
|
-
this.userConfigDir =
|
|
159
|
+
this.userConfigDir = SMART_EDIT_MANAGED_DIR_IN_HOME;
|
|
160
160
|
}
|
|
161
161
|
getNextLogFilePath(prefix) {
|
|
162
162
|
const dateDir = path.join(this.userConfigDir, 'logs', new Date().toISOString().slice(0, 10));
|
|
@@ -164,8 +164,8 @@ class SerenaPathsImpl {
|
|
|
164
164
|
return path.join(dateDir, `${prefix}_${datetimeTag()}.txt`);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
const
|
|
168
|
-
export {
|
|
167
|
+
const SmartEditPathsSingleton = singleton(SmartEditPathsImpl);
|
|
168
|
+
export { SmartEditPathsSingleton as SmartEditPaths };
|
|
169
169
|
export class ToolSet {
|
|
170
170
|
toolNames;
|
|
171
171
|
constructor(toolNames) {
|
|
@@ -239,7 +239,7 @@ export class ProjectConfig extends ToolInclusionDefinition {
|
|
|
239
239
|
ignoreAllFilesInGitignore;
|
|
240
240
|
initialPrompt;
|
|
241
241
|
encoding;
|
|
242
|
-
static
|
|
242
|
+
static SMART_EDIT_DEFAULT_PROJECT_FILE = 'project.yml';
|
|
243
243
|
constructor(init) {
|
|
244
244
|
super(init);
|
|
245
245
|
this.projectName = init.projectName;
|
|
@@ -266,7 +266,7 @@ export class ProjectConfig extends ToolInclusionDefinition {
|
|
|
266
266
|
throw new Error([
|
|
267
267
|
`No source files found in ${resolvedRoot}`,
|
|
268
268
|
'',
|
|
269
|
-
'
|
|
269
|
+
'Smart-Edit を利用するには以下のいずれかを行ってください:',
|
|
270
270
|
'1. 対応言語のソースファイルを追加 (Python, JavaScript/TypeScript, Java, C#, Rust, Go, Ruby, C++, PHP, Swift, Elixir, Terraform, Bash)',
|
|
271
271
|
`2. 次の場所に project.yml を手動で作成: ${relativePath}`,
|
|
272
272
|
'',
|
|
@@ -289,7 +289,7 @@ export class ProjectConfig extends ToolInclusionDefinition {
|
|
|
289
289
|
return this.fromDict(plain);
|
|
290
290
|
}
|
|
291
291
|
static relPathToProjectYml() {
|
|
292
|
-
return path.join(
|
|
292
|
+
return path.join(SMART_EDIT_MANAGED_DIR_NAME, this.SMART_EDIT_DEFAULT_PROJECT_FILE);
|
|
293
293
|
}
|
|
294
294
|
static load(projectRoot, autogenerate = false) {
|
|
295
295
|
const resolvedRoot = path.resolve(projectRoot);
|
|
@@ -313,7 +313,7 @@ export class ProjectConfig extends ToolInclusionDefinition {
|
|
|
313
313
|
static fromDict(data) {
|
|
314
314
|
const parsedResult = PROJECT_CONFIG_YAML_SCHEMA.safeParse(data);
|
|
315
315
|
if (!parsedResult.success) {
|
|
316
|
-
throw new
|
|
316
|
+
throw new SmartEditConfigError(formatZodIssues('project.yml', parsedResult.error));
|
|
317
317
|
}
|
|
318
318
|
const parsed = parsedResult.data;
|
|
319
319
|
const projectName = parsed.project_name;
|
|
@@ -376,7 +376,7 @@ export var RegisteredTokenCountEstimator;
|
|
|
376
376
|
RegisteredTokenCountEstimator["TIKTOKEN_GPT4O"] = "TIKTOKEN_GPT4O";
|
|
377
377
|
RegisteredTokenCountEstimator["ANTHROPIC_CLAUDE_SONNET_4"] = "ANTHROPIC_CLAUDE_SONNET_4";
|
|
378
378
|
})(RegisteredTokenCountEstimator || (RegisteredTokenCountEstimator = {}));
|
|
379
|
-
export class
|
|
379
|
+
export class SmartEditConfig extends ToolInclusionDefinition {
|
|
380
380
|
projects;
|
|
381
381
|
guiLogWindowEnabled;
|
|
382
382
|
logLevel;
|
|
@@ -391,8 +391,8 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
391
391
|
tokenCountEstimator;
|
|
392
392
|
defaultMaxToolAnswerChars;
|
|
393
393
|
lsSpecificSettings;
|
|
394
|
-
static CONFIG_FILE = '
|
|
395
|
-
static CONFIG_FILE_DOCKER = '
|
|
394
|
+
static CONFIG_FILE = 'smart_edit_config.yml';
|
|
395
|
+
static CONFIG_FILE_DOCKER = 'smart_edit_config.docker.yml';
|
|
396
396
|
constructor(init = {}) {
|
|
397
397
|
super(init);
|
|
398
398
|
this.projects = [...(init.projects ?? [])];
|
|
@@ -411,19 +411,19 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
411
411
|
this.lsSpecificSettings = { ...(init.lsSpecificSettings ?? {}) };
|
|
412
412
|
}
|
|
413
413
|
static generateConfigFile(configFilePath) {
|
|
414
|
-
log.info(`Auto-generating
|
|
415
|
-
const template = loadYaml(
|
|
414
|
+
log.info(`Auto-generating Smart-Edit configuration file in ${configFilePath}`);
|
|
415
|
+
const template = loadYaml(SMART_EDIT_CONFIG_TEMPLATE_FILE, true);
|
|
416
416
|
saveYaml(configFilePath, template, true);
|
|
417
417
|
}
|
|
418
418
|
static determineConfigFilePath() {
|
|
419
419
|
if (isRunningInDocker()) {
|
|
420
420
|
return path.join(REPO_ROOT, this.CONFIG_FILE_DOCKER);
|
|
421
421
|
}
|
|
422
|
-
const configPath = path.join(
|
|
422
|
+
const configPath = path.join(SMART_EDIT_MANAGED_DIR_IN_HOME, this.CONFIG_FILE);
|
|
423
423
|
if (!fs.existsSync(configPath)) {
|
|
424
424
|
const legacy = path.join(REPO_ROOT, this.CONFIG_FILE);
|
|
425
425
|
if (fs.existsSync(legacy)) {
|
|
426
|
-
log.info(`Moving
|
|
426
|
+
log.info(`Moving Smart-Edit configuration file from ${legacy} to ${configPath}`);
|
|
427
427
|
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
428
428
|
fs.renameSync(legacy, configPath);
|
|
429
429
|
}
|
|
@@ -435,17 +435,17 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
435
435
|
const configFilePath = this.determineConfigFilePath();
|
|
436
436
|
if (!fs.existsSync(configFilePath)) {
|
|
437
437
|
if (!generateIfMissing) {
|
|
438
|
-
throw new Error(`
|
|
438
|
+
throw new Error(`Smart-Edit configuration file not found: ${configFilePath}`);
|
|
439
439
|
}
|
|
440
|
-
log.info(`
|
|
440
|
+
log.info(`Smart-Edit configuration file not found at ${configFilePath}, autogenerating...`);
|
|
441
441
|
this.generateConfigFile(configFilePath);
|
|
442
442
|
}
|
|
443
|
-
log.info(`Loading
|
|
443
|
+
log.info(`Loading Smart-Edit configuration from ${configFilePath}`);
|
|
444
444
|
const loaded = loadYaml(configFilePath, true);
|
|
445
445
|
const data = yamlToObject(loaded);
|
|
446
|
-
const parsedResult =
|
|
446
|
+
const parsedResult = SMART_EDIT_CONFIG_YAML_SCHEMA.safeParse(data);
|
|
447
447
|
if (!parsedResult.success) {
|
|
448
|
-
throw new
|
|
448
|
+
throw new SmartEditConfigError(formatZodIssues(configFilePath, parsedResult.error));
|
|
449
449
|
}
|
|
450
450
|
const parsed = parsedResult.data;
|
|
451
451
|
const projectEntries = parsed.projects;
|
|
@@ -482,7 +482,7 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
482
482
|
log.error(`Failed to load project configuration for ${resolvedPath}`, error);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
const config = new
|
|
485
|
+
const config = new SmartEditConfig({
|
|
486
486
|
projects,
|
|
487
487
|
guiLogWindowEnabled: isRunningInDocker()
|
|
488
488
|
? false
|
|
@@ -584,7 +584,7 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
584
584
|
removeProject(projectName) {
|
|
585
585
|
const index = this.projects.findIndex((project) => project.projectName === projectName);
|
|
586
586
|
if (index === -1) {
|
|
587
|
-
throw new Error(`Project '${projectName}' not found in
|
|
587
|
+
throw new Error(`Project '${projectName}' not found in Smart-Edit configuration; valid project names: ${this.projectNames.join(', ')}`);
|
|
588
588
|
}
|
|
589
589
|
this.projects.splice(index, 1);
|
|
590
590
|
this.save();
|
|
@@ -612,10 +612,10 @@ export class SerenaConfig extends ToolInclusionDefinition {
|
|
|
612
612
|
saveYaml(this.configFilePath, yamlData, isYamlDocument(yamlData));
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
|
-
export class
|
|
615
|
+
export class SmartEditConfigError extends Error {
|
|
616
616
|
}
|
|
617
|
-
export function
|
|
618
|
-
return path.join(projectRoot,
|
|
617
|
+
export function getSmartEditManagedInProjectDir(projectRoot) {
|
|
618
|
+
return path.join(projectRoot, SMART_EDIT_MANAGED_DIR_NAME);
|
|
619
619
|
}
|
|
620
620
|
export function isRunningInDocker() {
|
|
621
621
|
if (fs.existsSync('/.dockerenv')) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const SMART_EDIT_MANAGED_DIR_NAME = ".smart-edit";
|
|
2
|
+
export declare const SMART_EDIT_MANAGED_DIR_IN_HOME: string;
|
|
3
|
+
export declare const REPO_ROOT: string;
|
|
4
|
+
export declare const PROMPT_TEMPLATES_DIR_INTERNAL: string;
|
|
5
|
+
export declare const PROMPT_TEMPLATES_DIR_IN_USER_HOME: string;
|
|
6
|
+
export declare const SMART_EDITS_OWN_CONTEXT_YAMLS_DIR: string;
|
|
7
|
+
export declare const USER_CONTEXT_YAMLS_DIR: string;
|
|
8
|
+
export declare const SMART_EDITS_OWN_MODE_YAMLS_DIR: string;
|
|
9
|
+
export declare const USER_MODE_YAMLS_DIR: string;
|
|
10
|
+
export declare const INTERNAL_MODE_YAMLS_DIR: string;
|
|
11
|
+
export declare const SMART_EDIT_DASHBOARD_DIR: string;
|
|
12
|
+
export declare const SMART_EDIT_ICON_DIR: string;
|
|
13
|
+
export declare const DEFAULT_ENCODING = "utf-8";
|
|
14
|
+
export declare const DEFAULT_CONTEXT = "desktop-app";
|
|
15
|
+
export declare const DEFAULT_MODES: readonly ["interactive", "editing"];
|
|
16
|
+
export declare const PROJECT_TEMPLATE_FILE: string;
|
|
17
|
+
export declare const SMART_EDIT_CONFIG_TEMPLATE_FILE: string;
|
|
18
|
+
export declare const SMART_EDIT_LOG_FORMAT = "%(levelname)-5s %(asctime)-15s [%(threadName)s] %(name)s:%(funcName)s:%(lineno)d - %(message)s";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
const repoRoot = path.resolve(__dirname, '..', '..');
|
|
7
|
+
const smartEditPackageRoot = path.resolve(__dirname);
|
|
8
|
+
const smartEditManagedDirName = '.smart-edit';
|
|
9
|
+
const smartEditManagedDirInHome = path.join(os.homedir(), smartEditManagedDirName);
|
|
10
|
+
export const SMART_EDIT_MANAGED_DIR_NAME = smartEditManagedDirName;
|
|
11
|
+
export const SMART_EDIT_MANAGED_DIR_IN_HOME = smartEditManagedDirInHome;
|
|
12
|
+
export const REPO_ROOT = repoRoot;
|
|
13
|
+
export const PROMPT_TEMPLATES_DIR_INTERNAL = path.join(smartEditPackageRoot, 'resources', 'config', 'prompt_templates');
|
|
14
|
+
export const PROMPT_TEMPLATES_DIR_IN_USER_HOME = path.join(smartEditManagedDirInHome, 'prompt_templates');
|
|
15
|
+
export const SMART_EDITS_OWN_CONTEXT_YAMLS_DIR = path.join(smartEditPackageRoot, 'resources', 'config', 'contexts');
|
|
16
|
+
export const USER_CONTEXT_YAMLS_DIR = path.join(smartEditManagedDirInHome, 'contexts');
|
|
17
|
+
export const SMART_EDITS_OWN_MODE_YAMLS_DIR = path.join(smartEditPackageRoot, 'resources', 'config', 'modes');
|
|
18
|
+
export const USER_MODE_YAMLS_DIR = path.join(smartEditManagedDirInHome, 'modes');
|
|
19
|
+
export const INTERNAL_MODE_YAMLS_DIR = path.join(smartEditPackageRoot, 'resources', 'config', 'internal_modes');
|
|
20
|
+
export const SMART_EDIT_DASHBOARD_DIR = path.join(smartEditPackageRoot, 'resources', 'dashboard');
|
|
21
|
+
export const SMART_EDIT_ICON_DIR = path.join(smartEditPackageRoot, 'resources', 'icons');
|
|
22
|
+
export const DEFAULT_ENCODING = 'utf-8';
|
|
23
|
+
export const DEFAULT_CONTEXT = 'desktop-app';
|
|
24
|
+
export const DEFAULT_MODES = ['interactive', 'editing'];
|
|
25
|
+
export const PROJECT_TEMPLATE_FILE = path.join(smartEditPackageRoot, 'resources', 'project.template.yml');
|
|
26
|
+
export const SMART_EDIT_CONFIG_TEMPLATE_FILE = path.join(smartEditPackageRoot, 'resources', 'smart_edit_config.template.yml');
|
|
27
|
+
export const SMART_EDIT_LOG_FORMAT = '%(levelname)-5s %(asctime)-15s [%(threadName)s] %(name)s:%(funcName)s:%(lineno)d - %(message)s';
|
|
@@ -8,11 +8,11 @@ interface DashboardAgentLike {
|
|
|
8
8
|
export interface DashboardThread {
|
|
9
9
|
stop(): void;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface SmartEditDashboardApiOptions {
|
|
12
12
|
shutdownCallback?: () => void;
|
|
13
13
|
toolUsageStats?: ToolUsageStats | null;
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class SmartEditDashboardAPI {
|
|
16
16
|
private readonly memoryLogHandler;
|
|
17
17
|
private toolNames;
|
|
18
18
|
private readonly agent;
|
|
@@ -25,7 +25,7 @@ export declare class SerenaDashboardAPI {
|
|
|
25
25
|
private logListener?;
|
|
26
26
|
private heartbeatTimer;
|
|
27
27
|
private streamingAttached;
|
|
28
|
-
constructor(memoryLogHandler: MemoryLogHandler, toolNames: string[], agent: DashboardAgentLike, options?:
|
|
28
|
+
constructor(memoryLogHandler: MemoryLogHandler, toolNames: string[], agent: DashboardAgentLike, options?: SmartEditDashboardApiOptions);
|
|
29
29
|
runInThread(): Promise<[DashboardThread, number]>;
|
|
30
30
|
getToolNames(): string[];
|
|
31
31
|
setToolNames(toolNames: string[]): void;
|
|
@@ -5,9 +5,9 @@ import { parse as parseUrl } from 'node:url';
|
|
|
5
5
|
import { promises as fs } from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import process from 'node:process';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
const { logger } =
|
|
8
|
+
import { createSmartEditLogger } from './util/logging.js';
|
|
9
|
+
import { SMART_EDIT_DASHBOARD_DIR } from './constants.js';
|
|
10
|
+
const { logger } = createSmartEditLogger({ name: 'smart-edit.dashboard', emitToConsole: false, level: 'info' });
|
|
11
11
|
const DEFAULT_DASHBOARD_PORT = 0x5eda;
|
|
12
12
|
const DASHBOARD_HOST = '127.0.0.1';
|
|
13
13
|
const SSE_HEARTBEAT_INTERVAL_MS = 15_000;
|
|
@@ -34,7 +34,7 @@ class DashboardHttpThread {
|
|
|
34
34
|
this.stopped = true;
|
|
35
35
|
this.server.close((error) => {
|
|
36
36
|
if (error) {
|
|
37
|
-
logger.warn('Failed to stop
|
|
37
|
+
logger.warn('Failed to stop Smart-Edit dashboard server cleanly.', error);
|
|
38
38
|
}
|
|
39
39
|
this.onStop?.();
|
|
40
40
|
});
|
|
@@ -45,7 +45,7 @@ const SSE_HEADERS = {
|
|
|
45
45
|
'Cache-Control': 'no-cache',
|
|
46
46
|
Connection: 'keep-alive'
|
|
47
47
|
};
|
|
48
|
-
export class
|
|
48
|
+
export class SmartEditDashboardAPI {
|
|
49
49
|
memoryLogHandler;
|
|
50
50
|
toolNames;
|
|
51
51
|
agent;
|
|
@@ -80,7 +80,7 @@ export class SerenaDashboardAPI {
|
|
|
80
80
|
this.listeningPort = null;
|
|
81
81
|
this.detachLogStreaming();
|
|
82
82
|
});
|
|
83
|
-
logger.info(`
|
|
83
|
+
logger.info(`Smart-Edit dashboard listening on http://${DASHBOARD_HOST}:${port}/dashboard/index.html`);
|
|
84
84
|
return [thread, port];
|
|
85
85
|
}
|
|
86
86
|
getToolNames() {
|
|
@@ -133,11 +133,11 @@ export class SerenaDashboardAPI {
|
|
|
133
133
|
candidatePort += 1;
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
|
-
logger.error('Failed to start
|
|
136
|
+
logger.error('Failed to start Smart-Edit dashboard server.', lastError ?? undefined);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
throw new Error(lastError?.message ?? 'Unable to start
|
|
140
|
+
throw new Error(lastError?.message ?? 'Unable to start Smart-Edit dashboard server; no available ports in the configured range.');
|
|
141
141
|
}
|
|
142
142
|
listenOnPort(server, port) {
|
|
143
143
|
return new Promise((resolve, reject) => {
|
|
@@ -368,8 +368,8 @@ export class SerenaDashboardAPI {
|
|
|
368
368
|
async serveDashboardAsset(pathname, res) {
|
|
369
369
|
const relativePath = pathname.replace(/^\/dashboard\/?/, '');
|
|
370
370
|
const safeRelativePath = relativePath.length === 0 ? 'index.html' : relativePath;
|
|
371
|
-
const resolvedPath = path.resolve(
|
|
372
|
-
if (!resolvedPath.startsWith(path.resolve(
|
|
371
|
+
const resolvedPath = path.resolve(SMART_EDIT_DASHBOARD_DIR, decodeURIComponent(safeRelativePath));
|
|
372
|
+
if (!resolvedPath.startsWith(path.resolve(SMART_EDIT_DASHBOARD_DIR))) {
|
|
373
373
|
this.respondNotFound(res);
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
2
|
import { parse as parseUrl } from 'node:url';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
|
-
import { ensureDefaultSubprocessOptions } from '../
|
|
5
|
-
import {
|
|
6
|
-
const { logger } =
|
|
4
|
+
import { ensureDefaultSubprocessOptions } from '../smart-lsp/util/subprocess_util.js';
|
|
5
|
+
import { createSmartEditLogger, MemoryLogHandler } from './util/logging.js';
|
|
6
|
+
const { logger } = createSmartEditLogger({ name: 'smart-edit.gui_log_viewer', emitToConsole: false, level: 'info' });
|
|
7
7
|
const LOG_HISTORY_LIMIT = 500;
|
|
8
8
|
function determineLogLevel(message) {
|
|
9
9
|
const trimmed = message.trimStart().toUpperCase();
|
|
@@ -67,7 +67,7 @@ export class GuiLogViewer {
|
|
|
67
67
|
logSequence = 0;
|
|
68
68
|
constructor(channel, options = {}) {
|
|
69
69
|
this.channel = channel;
|
|
70
|
-
this.title = options.title ?? '
|
|
70
|
+
this.title = options.title ?? 'Smart-Edit Logs';
|
|
71
71
|
this.memoryLogHandler = options.memoryLogHandler;
|
|
72
72
|
this.host = options.host ?? '127.0.0.1';
|
|
73
73
|
this.requestedPort = options.port;
|
|
@@ -323,7 +323,7 @@ export class GuiLogViewer {
|
|
|
323
323
|
</header>
|
|
324
324
|
<main id="log-container" aria-live="polite"></main>
|
|
325
325
|
<footer>
|
|
326
|
-
<span>
|
|
326
|
+
<span>Smart-Edit GUI Log Viewer</span>
|
|
327
327
|
<span id="status">接続中...</span>
|
|
328
328
|
</footer>
|
|
329
329
|
<script type="module">
|
|
@@ -426,7 +426,7 @@ export async function showFatalException(error) {
|
|
|
426
426
|
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
427
427
|
const handler = new MemoryLogHandler();
|
|
428
428
|
const viewer = new GuiLogViewer('error', {
|
|
429
|
-
title: '
|
|
429
|
+
title: 'Smart-Edit Fatal Exception',
|
|
430
430
|
memoryLogHandler: handler,
|
|
431
431
|
autoOpen: true
|
|
432
432
|
});
|