-
Notifications
You must be signed in to change notification settings - Fork 100
Development
There are two main entry points for development: src/kc_electron
and src/kc_angular
-
kc_electron
contains all of the files for setting up Electron, IPC (inter-process communication) between the main and renderer processes, all functionality that deals directly with the Operating System (OS), and the servers used for the Chrome extension and chatting via the OpenAI API. -
kc_angular
contains all of the Angular (UI) code that runs in the renderer process.
The following steps should be followed closely to ensure a proper development environment. Minor variations in dependency versions are most likely fine, but only those listed below have been tested and verified.
git clone https://github.com/KnowledgeCanvas/knowledge.git
cd knowledge
git clone [email protected]:KnowledgeCanvas/knowledge.git
cd knowledge
The following versions were used at the time of this writing:
Note: starting with Yarn v4, the process for configuring Yarn has changed. Previously, the command to set the appropriate Yarn version was yarn set version berry
. However, with Yarn v4 the same command does not work properly and we now must use yarn set version 3.2.4
. Be sure to use the appropriate command depending on your installed version of Yarn.
After cloning the repo and installing Node.js and Yarn, run the following commands (from the repo root directory) to ensure you have the correct Yarn plugins.
yarn set version 3.2.4
yarn plugin import typescript
yarn plugin import workspace-tools
yarn install
Note: the contents of the file .yarnrc.yml
should be the following:
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.1.1.cjs
However, it has been pointed out that there are issues with Yarn that cause the build to fail. The best way to get around this issue is to remove the original .yarnrc.yml
, run the above commands, then prepend the line nodeLinker: node-modules
before running yarn install
. This is a temporary workaround.
This step is only required if you want to use the Chat feature while running the app in development mode.
Copy the bg_tiktoken.wasm
file from node_modules
to the Resources
folder:
cp ./node_modules/@dqbd/tiktoken/tiktoken_bg.wasm ./Resources/
yarn build
yarn start
This will allow you to refresh the application and see changes in real-time, without having to recompile Electron and Angular code (the watchers auto-compile as files are changed/saved).
- Follow the steps above, up to the build step
- Build, run, and watch the project:
yarn watch-main-dev &
yarn watch-electron-dev &
yarn start &
Note: changes made in kc_electron
require you to restart the app, even when using watchers. This is because, once opened, Electron will not propagate changes to the existing window.
Note: changes made in kc_angular
do not require you to restart the app, you can simply reload the page using CMD+R
(MacOS) or CTRL+R / F5
(Linux/Windows)
You can also choose to run yarn watch-main
and yarn watch-electron
(without the -dev
), but they will take longer to transpile and build, and no source map will be produced.
The following commands provide convenience methods for removing installed dependencies and generated build files. This is useful for ensuring a blank-slate, and are always run before producing distributable binaries.
yarn clean
yarn purge
- Clean and reinstall dependencies, then build the project:
yarn clean
yarn purge
yarn install
yarn build
- Create the distributables:
yarn dist-all