@serviceme/devtools-core 0.0.3

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.md ADDED
@@ -0,0 +1,46 @@
1
+ SERVICEME Core Package — Commercial License
2
+
3
+ Copyright (c) 2024 Medalsoft Technology Co., Ltd. All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are proprietary
6
+ and confidential to Medalsoft Technology Co., Ltd. ("Medalsoft").
7
+
8
+ GRANT OF LICENSE
9
+ Medalsoft grants authorized users a non-exclusive, non-transferable, limited license
10
+ to use the Software solely for internal business purposes in connection with
11
+ Medalsoft's SERVICEME platform.
12
+
13
+ RESTRICTIONS
14
+ You may not, and may not permit others to:
15
+ 1. Copy, modify, merge, publish, distribute, sublicense, or sell copies of the Software;
16
+ 2. Reverse engineer, decompile, disassemble, or attempt to derive the source code;
17
+ 3. Remove or alter any proprietary notices, labels, or marks on the Software;
18
+ 4. Use the Software for any purpose other than as expressly authorized above;
19
+ 5. Transfer, assign, or sublicense your rights under this license to any third party.
20
+
21
+ INTELLECTUAL PROPERTY
22
+ The Software is protected by copyright laws and international treaties. Medalsoft
23
+ retains all intellectual property rights in and to the Software, including all
24
+ copyright, patent, trade secret, and other proprietary rights.
25
+
26
+ NO WARRANTY
27
+ THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
28
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
29
+ PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
30
+
31
+ LIMITATION OF LIABILITY
32
+ IN NO EVENT SHALL MEDALSOFT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
33
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN CONNECTION WITH THIS
34
+ LICENSE OR THE USE OF THE SOFTWARE.
35
+
36
+ TERMINATION
37
+ This license is effective until terminated. It will terminate automatically if you
38
+ fail to comply with any term or condition. Upon termination, you must destroy all
39
+ copies of the Software in your possession.
40
+
41
+ GOVERNING LAW
42
+ This license shall be governed by and construed in accordance with the laws of
43
+ the People's Republic of China.
44
+
45
+ CONTACT
46
+ For licensing inquiries, contact: marketing@medalsoft.com
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @serviceme/devtools-core
2
+
3
+ Reusable Node.js core implementation for SERVICEME tooling, including JSON processing, environment checks, project helpers, and OpenCode integration primitives.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @serviceme/devtools-core
9
+ ```
10
+
11
+ ## Build
12
+
13
+ ```bash
14
+ pnpm -F @serviceme/devtools-core run build
15
+ ```
@@ -0,0 +1,115 @@
1
+ import { EnvironmentCheckResult, KnownEnvironmentTool, ToolCheckResult, ServiceMeImageValidationResult, ServiceMeImageInfo, ServiceMeImageCompressOptions, ServiceMeImageCompressResult, JsonSortOptions, JsonValidationResult, OpenCodeAgentEvent, OpenCodeRuntimeOptions, OpenCodeServerState, AgentSessionStatus, ServiceMeProjectExtractTemplateInput, ServiceMeProjectExtractTemplateResult, ServiceMeProjectInstallDepsResult, ServiceMeProjectMakeScriptsExecutableResult, ServiceMeProjectGitInitResult, ServiceMeProjectScaffoldPruneResult } from '@serviceme/devtools-protocol';
2
+
3
+ declare class EnvironmentInspector {
4
+ checkEnvironment(): Promise<EnvironmentCheckResult>;
5
+ checkTool(toolName: KnownEnvironmentTool): Promise<ToolCheckResult>;
6
+ private getToolPath;
7
+ private getToolVersion;
8
+ private checkNvm;
9
+ private checkNuget;
10
+ private getVersionCommand;
11
+ private parseVersion;
12
+ private handleToolCheckError;
13
+ }
14
+
15
+ declare class ImageTools {
16
+ getSupportedFormats(): string[];
17
+ validate(filePath: string, sharpModulePath?: string): Promise<ServiceMeImageValidationResult>;
18
+ getInfo(imagePath: string, sharpModulePath?: string): Promise<ServiceMeImageInfo>;
19
+ compress(imagePath: string, options: ServiceMeImageCompressOptions): Promise<ServiceMeImageCompressResult>;
20
+ private compressWithSharp;
21
+ private getOutputPath;
22
+ private pathExists;
23
+ private loadSharp;
24
+ }
25
+ declare function createImageTools(): ImageTools;
26
+
27
+ interface JsonTools {
28
+ sort(text: string, options?: Partial<JsonSortOptions>): string;
29
+ format(text: string, indent?: number): string;
30
+ validate(text: string): JsonValidationResult;
31
+ minify(text: string): string;
32
+ }
33
+ declare function createJsonTools(): JsonTools;
34
+
35
+ interface ServiceMeLogger {
36
+ debug(message: string, ...args: unknown[]): void;
37
+ info(message: string, ...args: unknown[]): void;
38
+ warn(message: string, ...args: unknown[]): void;
39
+ error(message: string, ...args: unknown[]): void;
40
+ }
41
+ declare const noopLogger: ServiceMeLogger;
42
+ declare function createConsoleLogger(prefix?: string): ServiceMeLogger;
43
+
44
+ interface OpenCodePromptInput {
45
+ sessionId: string;
46
+ prompt: string;
47
+ workspaceRoot?: string;
48
+ signal?: AbortSignal;
49
+ onEvent?: (event: OpenCodeAgentEvent) => void;
50
+ }
51
+ interface OpenCodeManagerOptions {
52
+ command?: string;
53
+ installUrl?: string;
54
+ host?: string;
55
+ portMin?: number;
56
+ portMax?: number;
57
+ healthPath?: string;
58
+ sessionPath?: string;
59
+ sessionStatusPath?: string;
60
+ startupPollIntervalMs?: number;
61
+ idleTimeoutMs?: number;
62
+ stdoutLogLimitBytes?: number;
63
+ logger?: ServiceMeLogger;
64
+ }
65
+ declare class OpenCodeManager {
66
+ private readonly options;
67
+ private readonly logger;
68
+ private childProcess;
69
+ private port;
70
+ private startupPromise;
71
+ private idleTimer;
72
+ private stdoutBytes;
73
+ constructor(options?: OpenCodeManagerOptions);
74
+ isAvailable(): Promise<boolean>;
75
+ isRunning(): boolean;
76
+ ensureServer(runtime?: OpenCodeRuntimeOptions): Promise<OpenCodeServerState>;
77
+ getServerState(): Promise<OpenCodeServerState>;
78
+ createSession(runtime?: OpenCodeRuntimeOptions): Promise<{
79
+ sessionId: string;
80
+ title?: string;
81
+ status: AgentSessionStatus;
82
+ }>;
83
+ prompt(input: OpenCodePromptInput): Promise<void>;
84
+ getSessionStatus(sessionId: string, workspaceRoot?: string): Promise<AgentSessionStatus>;
85
+ abortSession(sessionId: string, workspaceRoot?: string): Promise<void>;
86
+ dispose(): Promise<void>;
87
+ private ensureServerStarted;
88
+ private startServerProcess;
89
+ private waitForHealth;
90
+ private isServerHealthy;
91
+ private resetIdleTimer;
92
+ private terminateTrackedProcess;
93
+ private request;
94
+ private createQuery;
95
+ private getLatestAssistantMessage;
96
+ private mapStatus;
97
+ }
98
+
99
+ declare class ProjectTools {
100
+ extractTemplate(zipPath: string, workspacePath: string, tempExtractDir: string, input: ServiceMeProjectExtractTemplateInput): Promise<ServiceMeProjectExtractTemplateResult>;
101
+ installDependencies(workspacePath: string, command?: string): Promise<ServiceMeProjectInstallDepsResult>;
102
+ makeScriptsExecutable(workspacePath: string): Promise<ServiceMeProjectMakeScriptsExecutableResult>;
103
+ initializeGit(workspacePath: string): Promise<ServiceMeProjectGitInitResult>;
104
+ runScaffoldPrune(workspacePath: string, preset?: string): Promise<ServiceMeProjectScaffoldPruneResult>;
105
+ private findScripts;
106
+ private pathExists;
107
+ private selectExtractedDirectory;
108
+ private directoryMatchesProjectPattern;
109
+ }
110
+ declare function createProjectTools(): ProjectTools;
111
+
112
+ declare const unzipFile: (zipPath: string, dest: string) => Promise<void>;
113
+ declare const moveFiles: (sourceDir: string, destDir: string, overwrite?: boolean) => Promise<void>;
114
+
115
+ export { EnvironmentInspector, ImageTools, type JsonTools, OpenCodeManager, type OpenCodeManagerOptions, type OpenCodePromptInput, ProjectTools, type ServiceMeLogger, createConsoleLogger, createImageTools, createJsonTools, createProjectTools, moveFiles, noopLogger, unzipFile };
@@ -0,0 +1,115 @@
1
+ import { EnvironmentCheckResult, KnownEnvironmentTool, ToolCheckResult, ServiceMeImageValidationResult, ServiceMeImageInfo, ServiceMeImageCompressOptions, ServiceMeImageCompressResult, JsonSortOptions, JsonValidationResult, OpenCodeAgentEvent, OpenCodeRuntimeOptions, OpenCodeServerState, AgentSessionStatus, ServiceMeProjectExtractTemplateInput, ServiceMeProjectExtractTemplateResult, ServiceMeProjectInstallDepsResult, ServiceMeProjectMakeScriptsExecutableResult, ServiceMeProjectGitInitResult, ServiceMeProjectScaffoldPruneResult } from '@serviceme/devtools-protocol';
2
+
3
+ declare class EnvironmentInspector {
4
+ checkEnvironment(): Promise<EnvironmentCheckResult>;
5
+ checkTool(toolName: KnownEnvironmentTool): Promise<ToolCheckResult>;
6
+ private getToolPath;
7
+ private getToolVersion;
8
+ private checkNvm;
9
+ private checkNuget;
10
+ private getVersionCommand;
11
+ private parseVersion;
12
+ private handleToolCheckError;
13
+ }
14
+
15
+ declare class ImageTools {
16
+ getSupportedFormats(): string[];
17
+ validate(filePath: string, sharpModulePath?: string): Promise<ServiceMeImageValidationResult>;
18
+ getInfo(imagePath: string, sharpModulePath?: string): Promise<ServiceMeImageInfo>;
19
+ compress(imagePath: string, options: ServiceMeImageCompressOptions): Promise<ServiceMeImageCompressResult>;
20
+ private compressWithSharp;
21
+ private getOutputPath;
22
+ private pathExists;
23
+ private loadSharp;
24
+ }
25
+ declare function createImageTools(): ImageTools;
26
+
27
+ interface JsonTools {
28
+ sort(text: string, options?: Partial<JsonSortOptions>): string;
29
+ format(text: string, indent?: number): string;
30
+ validate(text: string): JsonValidationResult;
31
+ minify(text: string): string;
32
+ }
33
+ declare function createJsonTools(): JsonTools;
34
+
35
+ interface ServiceMeLogger {
36
+ debug(message: string, ...args: unknown[]): void;
37
+ info(message: string, ...args: unknown[]): void;
38
+ warn(message: string, ...args: unknown[]): void;
39
+ error(message: string, ...args: unknown[]): void;
40
+ }
41
+ declare const noopLogger: ServiceMeLogger;
42
+ declare function createConsoleLogger(prefix?: string): ServiceMeLogger;
43
+
44
+ interface OpenCodePromptInput {
45
+ sessionId: string;
46
+ prompt: string;
47
+ workspaceRoot?: string;
48
+ signal?: AbortSignal;
49
+ onEvent?: (event: OpenCodeAgentEvent) => void;
50
+ }
51
+ interface OpenCodeManagerOptions {
52
+ command?: string;
53
+ installUrl?: string;
54
+ host?: string;
55
+ portMin?: number;
56
+ portMax?: number;
57
+ healthPath?: string;
58
+ sessionPath?: string;
59
+ sessionStatusPath?: string;
60
+ startupPollIntervalMs?: number;
61
+ idleTimeoutMs?: number;
62
+ stdoutLogLimitBytes?: number;
63
+ logger?: ServiceMeLogger;
64
+ }
65
+ declare class OpenCodeManager {
66
+ private readonly options;
67
+ private readonly logger;
68
+ private childProcess;
69
+ private port;
70
+ private startupPromise;
71
+ private idleTimer;
72
+ private stdoutBytes;
73
+ constructor(options?: OpenCodeManagerOptions);
74
+ isAvailable(): Promise<boolean>;
75
+ isRunning(): boolean;
76
+ ensureServer(runtime?: OpenCodeRuntimeOptions): Promise<OpenCodeServerState>;
77
+ getServerState(): Promise<OpenCodeServerState>;
78
+ createSession(runtime?: OpenCodeRuntimeOptions): Promise<{
79
+ sessionId: string;
80
+ title?: string;
81
+ status: AgentSessionStatus;
82
+ }>;
83
+ prompt(input: OpenCodePromptInput): Promise<void>;
84
+ getSessionStatus(sessionId: string, workspaceRoot?: string): Promise<AgentSessionStatus>;
85
+ abortSession(sessionId: string, workspaceRoot?: string): Promise<void>;
86
+ dispose(): Promise<void>;
87
+ private ensureServerStarted;
88
+ private startServerProcess;
89
+ private waitForHealth;
90
+ private isServerHealthy;
91
+ private resetIdleTimer;
92
+ private terminateTrackedProcess;
93
+ private request;
94
+ private createQuery;
95
+ private getLatestAssistantMessage;
96
+ private mapStatus;
97
+ }
98
+
99
+ declare class ProjectTools {
100
+ extractTemplate(zipPath: string, workspacePath: string, tempExtractDir: string, input: ServiceMeProjectExtractTemplateInput): Promise<ServiceMeProjectExtractTemplateResult>;
101
+ installDependencies(workspacePath: string, command?: string): Promise<ServiceMeProjectInstallDepsResult>;
102
+ makeScriptsExecutable(workspacePath: string): Promise<ServiceMeProjectMakeScriptsExecutableResult>;
103
+ initializeGit(workspacePath: string): Promise<ServiceMeProjectGitInitResult>;
104
+ runScaffoldPrune(workspacePath: string, preset?: string): Promise<ServiceMeProjectScaffoldPruneResult>;
105
+ private findScripts;
106
+ private pathExists;
107
+ private selectExtractedDirectory;
108
+ private directoryMatchesProjectPattern;
109
+ }
110
+ declare function createProjectTools(): ProjectTools;
111
+
112
+ declare const unzipFile: (zipPath: string, dest: string) => Promise<void>;
113
+ declare const moveFiles: (sourceDir: string, destDir: string, overwrite?: boolean) => Promise<void>;
114
+
115
+ export { EnvironmentInspector, ImageTools, type JsonTools, OpenCodeManager, type OpenCodeManagerOptions, type OpenCodePromptInput, ProjectTools, type ServiceMeLogger, createConsoleLogger, createImageTools, createJsonTools, createProjectTools, moveFiles, noopLogger, unzipFile };