Skip to content

Commit

Permalink
fix: ai native config not work (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain authored Jun 4, 2024
1 parent d77a8fd commit 1b26147
Show file tree
Hide file tree
Showing 13 changed files with 552 additions and 510 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "codeblitzjs",
"main": "index.js",
"engines": {
"opensumi": "3.0.4-next-1716974737.0"
"opensumi": "3.0.5-next-1717491498.0"
},
"scripts": {
"prepare": "husky install",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"opensumi codeblitzjs"
],
"engines": {
"opensumi": "3.0.4-next-1716974737.0",
"opensumi": "3.0.5-next-1717491498.0",
"node": ">=10.0.0"
},
"dependencies": {
"@codeblitzjs/ide-common": "1.0.4",
"@opensumi/ide-extension": "3.0.4-next-1716974737.0",
"@opensumi/ide-extension": "3.0.5-next-1717491498.0",
"async-retry": "^1.3.1",
"await-event": "^2.1.0",
"commander": "^7.2.0",
Expand Down
84 changes: 42 additions & 42 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@
"@codeblitzjs/ide-plugin": "1.0.4",
"@codeblitzjs/ide-registry": "1.0.4",
"@codeblitzjs/ide-sumi-core": "1.0.4",
"@opensumi/ide-addons": "3.0.4-next-1716974737.0",
"@opensumi/ide-ai-native": "3.0.4-next-1716974737.0",
"@opensumi/ide-comments": "3.0.4-next-1716974737.0",
"@opensumi/ide-core-browser": "3.0.4-next-1716974737.0",
"@opensumi/ide-core-common": "3.0.4-next-1716974737.0",
"@opensumi/ide-debug": "3.0.4-next-1716974737.0",
"@opensumi/ide-decoration": "3.0.4-next-1716974737.0",
"@opensumi/ide-design": "3.0.4-next-1716974737.0",
"@opensumi/ide-editor": "3.0.4-next-1716974737.0",
"@opensumi/ide-explorer": "3.0.4-next-1716974737.0",
"@opensumi/ide-express-file-server": "3.0.4-next-1716974737.0",
"@opensumi/ide-extension": "3.0.4-next-1716974737.0",
"@opensumi/ide-extension-storage": "3.0.4-next-1716974737.0",
"@opensumi/ide-file-scheme": "3.0.4-next-1716974737.0",
"@opensumi/ide-file-service": "3.0.4-next-1716974737.0",
"@opensumi/ide-file-tree-next": "3.0.4-next-1716974737.0",
"@opensumi/ide-i18n": "3.0.4-next-1716974737.0",
"@opensumi/ide-keymaps": "3.0.4-next-1716974737.0",
"@opensumi/ide-logs": "3.0.4-next-1716974737.0",
"@opensumi/ide-main-layout": "3.0.4-next-1716974737.0",
"@opensumi/ide-markdown": "3.0.4-next-1716974737.0",
"@opensumi/ide-markers": "3.0.4-next-1716974737.0",
"@opensumi/ide-menu-bar": "3.0.4-next-1716974737.0",
"@opensumi/ide-monaco": "3.0.4-next-1716974737.0",
"@opensumi/ide-monaco-enhance": "3.0.4-next-1716974737.0",
"@opensumi/ide-opened-editor": "3.0.4-next-1716974737.0",
"@opensumi/ide-outline": "3.0.4-next-1716974737.0",
"@opensumi/ide-output": "3.0.4-next-1716974737.0",
"@opensumi/ide-overlay": "3.0.4-next-1716974737.0",
"@opensumi/ide-preferences": "3.0.4-next-1716974737.0",
"@opensumi/ide-quick-open": "3.0.4-next-1716974737.0",
"@opensumi/ide-scm": "3.0.4-next-1716974737.0",
"@opensumi/ide-search": "3.0.4-next-1716974737.0",
"@opensumi/ide-status-bar": "3.0.4-next-1716974737.0",
"@opensumi/ide-storage": "3.0.4-next-1716974737.0",
"@opensumi/ide-testing": "3.0.4-next-1716974737.0",
"@opensumi/ide-theme": "3.0.4-next-1716974737.0",
"@opensumi/ide-toolbar": "3.0.4-next-1716974737.0",
"@opensumi/ide-variable": "3.0.4-next-1716974737.0",
"@opensumi/ide-webview": "3.0.4-next-1716974737.0",
"@opensumi/ide-workspace": "3.0.4-next-1716974737.0",
"@opensumi/ide-workspace-edit": "3.0.4-next-1716974737.0",
"@opensumi/ide-addons": "3.0.5-next-1717491498.0",
"@opensumi/ide-ai-native": "3.0.5-next-1717491498.0",
"@opensumi/ide-comments": "3.0.5-next-1717491498.0",
"@opensumi/ide-core-browser": "3.0.5-next-1717491498.0",
"@opensumi/ide-core-common": "3.0.5-next-1717491498.0",
"@opensumi/ide-debug": "3.0.5-next-1717491498.0",
"@opensumi/ide-decoration": "3.0.5-next-1717491498.0",
"@opensumi/ide-design": "3.0.5-next-1717491498.0",
"@opensumi/ide-editor": "3.0.5-next-1717491498.0",
"@opensumi/ide-explorer": "3.0.5-next-1717491498.0",
"@opensumi/ide-express-file-server": "3.0.5-next-1717491498.0",
"@opensumi/ide-extension": "3.0.5-next-1717491498.0",
"@opensumi/ide-extension-storage": "3.0.5-next-1717491498.0",
"@opensumi/ide-file-scheme": "3.0.5-next-1717491498.0",
"@opensumi/ide-file-service": "3.0.5-next-1717491498.0",
"@opensumi/ide-file-tree-next": "3.0.5-next-1717491498.0",
"@opensumi/ide-i18n": "3.0.5-next-1717491498.0",
"@opensumi/ide-keymaps": "3.0.5-next-1717491498.0",
"@opensumi/ide-logs": "3.0.5-next-1717491498.0",
"@opensumi/ide-main-layout": "3.0.5-next-1717491498.0",
"@opensumi/ide-markdown": "3.0.5-next-1717491498.0",
"@opensumi/ide-markers": "3.0.5-next-1717491498.0",
"@opensumi/ide-menu-bar": "3.0.5-next-1717491498.0",
"@opensumi/ide-monaco": "3.0.5-next-1717491498.0",
"@opensumi/ide-monaco-enhance": "3.0.5-next-1717491498.0",
"@opensumi/ide-opened-editor": "3.0.5-next-1717491498.0",
"@opensumi/ide-outline": "3.0.5-next-1717491498.0",
"@opensumi/ide-output": "3.0.5-next-1717491498.0",
"@opensumi/ide-overlay": "3.0.5-next-1717491498.0",
"@opensumi/ide-preferences": "3.0.5-next-1717491498.0",
"@opensumi/ide-quick-open": "3.0.5-next-1717491498.0",
"@opensumi/ide-scm": "3.0.5-next-1717491498.0",
"@opensumi/ide-search": "3.0.5-next-1717491498.0",
"@opensumi/ide-status-bar": "3.0.5-next-1717491498.0",
"@opensumi/ide-storage": "3.0.5-next-1717491498.0",
"@opensumi/ide-testing": "3.0.5-next-1717491498.0",
"@opensumi/ide-theme": "3.0.5-next-1717491498.0",
"@opensumi/ide-toolbar": "3.0.5-next-1717491498.0",
"@opensumi/ide-variable": "3.0.5-next-1717491498.0",
"@opensumi/ide-webview": "3.0.5-next-1717491498.0",
"@opensumi/ide-workspace": "3.0.5-next-1717491498.0",
"@opensumi/ide-workspace-edit": "3.0.5-next-1717491498.0",
"@opensumi/textmate-languages": "^2.7.0",
"tslib": "^2.2.0"
},
Expand Down
49 changes: 25 additions & 24 deletions packages/core/src/api/createApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import {
FILES_DEFAULTS,
IReporter,
getPreferenceThemeId,
PreferenceProvider,
PreferenceScope,
registerExternalPreferenceProvider,
IClientAppOpts,
} from '@opensumi/ide-core-browser';
import { BoxPanel, SplitPanel } from '@opensumi/ide-core-browser/lib/components';

Expand All @@ -40,6 +36,7 @@ import { IConfig, IAppInstance } from './types';
import { EXT_WORKER_HOST, WEBVIEW_ENDPOINT } from '../core/env';
import { interceptAppOpts } from './opts';
import { appName } from './constants';
import { Injector } from '@opensumi/di';

export { SlotLocation, SlotRenderer, BoxPanel, SplitPanel };

Expand Down Expand Up @@ -96,8 +93,31 @@ export function createApp({ appConfig, runtimeConfig }: IConfig): IAppInstance {
);
}
opts.workspaceDir = makeWorkspaceDir(opts.workspaceDir);
const injector = opts.injector || new Injector();

const app = new ClientApp(opts) as IAppInstance;
// 基于场景的运行时数据
injector.addProviders({
token: RuntimeConfig,
useValue: runtimeConfig,
});

injector.addProviders({
token: IPluginConfig,
useValue: appConfig.plugins,
});

if (runtimeConfig.reporter) {
injector.addProviders({
token: IReporter,
useValue: runtimeConfig.reporter,
override: true,
});
}

const app = new ClientApp({
...opts,
injector,
}) as IAppInstance;

Object.defineProperty(app, 'currentThemeType', {
get() {
Expand All @@ -122,24 +142,5 @@ export function createApp({ appConfig, runtimeConfig }: IConfig): IAppInstance {
app.injector.disposeAll();
};

// 基于场景的运行时数据
app.injector.addProviders({
token: RuntimeConfig,
useValue: runtimeConfig,
});

app.injector.addProviders({
token: IPluginConfig,
useValue: appConfig.plugins,
});

if (runtimeConfig.reporter) {
app.injector.addProviders({
token: IReporter,
useValue: runtimeConfig.reporter,
override: true,
});
}

return app;
}
42 changes: 22 additions & 20 deletions packages/core/src/api/createEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
IReporter,
} from '@opensumi/ide-core-browser';
import { BoxPanel, SplitPanel } from '@opensumi/ide-core-browser/lib/components';
import { Injector } from '@opensumi/di';

import '@opensumi/ide-core-browser/lib/style/entry.less';
import '@opensumi/ide-core-browser/lib/style/codicons/codicon-animations.css';
Expand Down Expand Up @@ -75,7 +76,27 @@ export function createEditor({ appConfig, runtimeConfig }: IConfig): IAppInstanc
}
opts.workspaceDir = makeWorkspaceDir(opts.workspaceDir);

const app = new ClientApp(opts) as IAppInstance;
const injector = opts.injector || new Injector();
// 基于场景的运行时数据
injector.addProviders({
token: RuntimeConfig,
useValue: runtimeConfig,
});

injector.addProviders({
token: IPluginConfig,
useValue: appConfig.plugins,
});

if (runtimeConfig.reporter) {
injector.addProviders({
token: IReporter,
useValue: runtimeConfig.reporter,
override: true,
});
}

const app = new ClientApp({ ...opts, injector }) as IAppInstance;

const _start = app.start;
app.start = async (container: HTMLElement | IAppRenderer) => {
Expand All @@ -93,24 +114,5 @@ export function createEditor({ appConfig, runtimeConfig }: IConfig): IAppInstanc
app.injector.disposeAll();
};

// 基于场景的运行时数据
app.injector.addProviders({
token: RuntimeConfig,
useValue: runtimeConfig,
});

app.injector.addProviders({
token: IPluginConfig,
useValue: appConfig.plugins,
});

if (runtimeConfig.reporter) {
app.injector.addProviders({
token: IReporter,
useValue: runtimeConfig.reporter,
override: true,
});
}

return app;
}
5 changes: 3 additions & 2 deletions packages/core/src/api/opts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { IAppOpts, RuntimeConfig } from "@codeblitzjs/ide-sumi-core";
import { AINativeModule } from "@opensumi/ide-ai-native/lib/browser";
import { AINativeServerModule, IAppOpts, RuntimeConfig } from '@codeblitzjs/ide-sumi-core';
import { AINativeModule } from '@opensumi/ide-ai-native/lib/browser';

export function interceptAppOpts(opts: IAppOpts, runtimeConfig: RuntimeConfig) {
const { modules } = opts;

if (runtimeConfig.aiNative?.enable) {
if (modules.indexOf(AINativeModule) === -1) {
modules.push(AINativeModule);
modules.push(AINativeServerModule);
}
}

Expand Down
31 changes: 30 additions & 1 deletion packages/startup/src/startup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as Alex from '@codeblitzjs/ide-core';
import '@codeblitzjs/ide-core/languages';
import { CodeServiceModule } from '@codeblitzjs/ide-code-service';
import { CodeAPIModule, CodePlatform } from '@codeblitzjs/ide-code-api';
import { isFilesystemReady } from '@codeblitzjs/ide-sumi-core';
import { IEditorInlineChat, isFilesystemReady } from '@codeblitzjs/ide-sumi-core';
import { StartupModule } from './startup.module';

import css from '@codeblitzjs/ide-core/extensions/codeblitz.css-language-features-worker';
Expand Down Expand Up @@ -181,6 +181,35 @@ const App = () => (
runtimeConfig={{
scmFileTree: true,
scenario: 'ALEX_TEST',
aiNative: {
enable: true,
providerEditorInlineChat(): IEditorInlineChat[] {
return [
{
operational: {
id: 'test',
name: 'test',
codeAction: {},
title: 'Test',
},
handler: {
execute(editor, ...args) {
editor.getModel()?.pushEditOperations(
[],
[
{
range: editor.getSelection()!,
text: 'test',
},
],
() => null
)
},
}
}
]
},
}
}}
/>
);
Expand Down
16 changes: 8 additions & 8 deletions packages/sumi-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"@codeblitzjs/ide-common": "1.0.4",
"@codeblitzjs/ide-registry": "1.0.4",
"@opensumi/di": "^1.0.0",
"@opensumi/ide-ai-native": "3.0.4-next-1716974737.0",
"@opensumi/ide-core-browser": "3.0.4-next-1716974737.0",
"@opensumi/ide-core-common": "3.0.4-next-1716974737.0",
"@opensumi/ide-debug": "3.0.4-next-1716974737.0",
"@opensumi/ide-extension": "3.0.4-next-1716974737.0",
"@opensumi/ide-file-scheme": "3.0.4-next-1716974737.0",
"@opensumi/ide-file-service": "3.0.4-next-1716974737.0",
"@opensumi/ide-logs": "3.0.4-next-1716974737.0",
"@opensumi/ide-ai-native": "3.0.5-next-1717491498.0",
"@opensumi/ide-core-browser": "3.0.5-next-1717491498.0",
"@opensumi/ide-core-common": "3.0.5-next-1717491498.0",
"@opensumi/ide-debug": "3.0.5-next-1717491498.0",
"@opensumi/ide-extension": "3.0.5-next-1717491498.0",
"@opensumi/ide-file-scheme": "3.0.5-next-1717491498.0",
"@opensumi/ide-file-service": "3.0.5-next-1717491498.0",
"@opensumi/ide-logs": "3.0.5-next-1717491498.0",
"assert": "^2.0.0",
"fs-extra-factory": "^0.2.1",
"iconv-lite-umd": "^0.6.8",
Expand Down
18 changes: 12 additions & 6 deletions packages/sumi-core/src/client/ai-native/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Injector } from "@opensumi/di";
import { AppConfig, RuntimeConfig } from "../../common";
import { Injector } from '@opensumi/di';
import { IAINativeCapabilities } from '@opensumi/ide-core-common';
import { AppConfig, RuntimeConfig } from '../../common';

const codeblitzDefaultCapabilities: IAINativeCapabilities = {
supportsTerminalCommandSuggest: false,
supportsTerminalDetection: false,
};

export const injectAINativePreferences = (injector: Injector): void => {
const runtimeConfig: RuntimeConfig = injector.get(RuntimeConfig);
Expand All @@ -12,8 +18,8 @@ export const injectAINativePreferences = (injector: Injector): void => {
capabilities: {
...appConfig.AINativeConfig?.capabilities,
...aiNativeCaps,
}
}
...codeblitzDefaultCapabilities,
},
};
}

}
};
Loading

0 comments on commit 1b26147

Please sign in to comment.