├── .clang-format ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── check_style.yml │ ├── docs.yml │ ├── docs_deploy.yml │ ├── release.yml │ └── test_conan.yml ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── CMakeLists.txt ├── CMakePresets.json ├── COPYING.MIT ├── README.md ├── cmake ├── ClangFormat.cmake ├── install.cmake ├── sc-component-manager-config-version.cmake.in └── tests.cmake ├── conanfile.py ├── docs ├── CONTRIBUTING.md ├── _assets │ ├── main.css │ └── main.js ├── agents.tex ├── build │ ├── build_system.md │ ├── cmake_flags.md │ └── quick_start.md ├── changelog.md ├── images │ ├── cmake_options.png │ ├── components_init_input.png │ ├── components_init_output.png │ ├── components_install_input.png │ ├── components_install_output.png │ ├── components_search_input.png │ ├── components_search_output.png │ ├── gwf │ │ └── agents.gwf │ ├── program_args.png │ ├── specification_storage_addresses.png │ ├── specifications_search_input.png │ └── specifications_search_output.png ├── index.md ├── main.pdf ├── main.tex ├── ostis-logo.png ├── quick_start.md ├── sc-component-manager.tex └── usage │ └── usage.md ├── ellipsis.yaml ├── knowledge-base ├── actions.scs ├── relations.scs ├── specifications.scs └── types.scs ├── mkdocs.yml ├── sc-component-manager.ini ├── scripts └── clang │ ├── check_formatting.sh │ └── format_code.sh └── src ├── CMakeLists.txt ├── manager ├── agents │ ├── CMakeLists.txt │ ├── common-lib │ │ ├── CMakeLists.txt │ │ ├── include │ │ │ └── common │ │ │ │ ├── command_constants.hpp │ │ │ │ ├── common_utils.hpp │ │ │ │ ├── downloader.hpp │ │ │ │ ├── downloader_git.hpp │ │ │ │ ├── downloader_google_drive.hpp │ │ │ │ ├── downloader_handler.hpp │ │ │ │ ├── repository_url_parser.hpp │ │ │ │ ├── sc_component_manager_command.hpp │ │ │ │ ├── sc_component_manager_keynodes.hpp │ │ │ │ └── sc_component_utils.hpp │ │ └── src │ │ │ ├── command_constants.cpp │ │ │ ├── common_utils.cpp │ │ │ ├── downloader_handler.cpp │ │ │ ├── repository_url_parser.cpp │ │ │ └── sc_component_utils.cpp │ ├── init-module │ │ ├── CMakeLists.txt │ │ ├── agent │ │ │ ├── sc_component_manager_agent_init.cpp │ │ │ └── sc_component_manager_agent_init.hpp │ │ ├── module │ │ │ ├── init_module.cpp │ │ │ └── init_module.hpp │ │ ├── test │ │ │ ├── CMakeLists.txt │ │ │ ├── test-structures │ │ │ │ ├── action_components_init.scs │ │ │ │ └── specification.scs │ │ │ └── units │ │ │ │ ├── agent_tests.cpp │ │ │ │ └── sc_agents_test.hpp │ │ └── utils │ │ │ ├── sc_component_manager_command_init.cpp │ │ │ └── sc_component_manager_command_init.hpp │ ├── install-module │ │ ├── CMakeLists.txt │ │ ├── agent │ │ │ ├── sc_component_manager_agent_install.cpp │ │ │ └── sc_component_manager_agent_install.hpp │ │ ├── module │ │ │ ├── install-module.cpp │ │ │ └── install-module.hpp │ │ ├── test │ │ │ ├── CMakeLists.txt │ │ │ ├── test-structures │ │ │ │ ├── action_components_install.scs │ │ │ │ └── specification.scs │ │ │ └── units │ │ │ │ ├── agent_tests.cpp │ │ │ │ └── sc_agents_test.hpp │ │ └── utils │ │ │ ├── sc_component_manager_command_install.cpp │ │ │ └── sc_component_manager_command_install.hpp │ └── search-module │ │ ├── CMakeLists.txt │ │ ├── agent │ │ ├── sc_component_manager_agent_search.cpp │ │ └── sc_component_manager_agent_search.hpp │ │ ├── module │ │ ├── search-module.cpp │ │ └── search-module.hpp │ │ ├── test │ │ ├── CMakeLists.txt │ │ ├── test-structures │ │ │ ├── components-search │ │ │ │ ├── all_arguments_action_components_search.scs │ │ │ │ ├── empty_arguments_action_components_search.scs │ │ │ │ ├── incompatible_authors_action_components_search.scs │ │ │ │ ├── incompatible_classes_action_components_search.scs │ │ │ │ ├── incompatible_explanations_action_components_search.scs │ │ │ │ ├── incompatible_ids_action_components_search.scs │ │ │ │ ├── incompatible_keys_action_components_search.scs │ │ │ │ ├── incompatible_notes_action_components_search.scs │ │ │ │ ├── incompatible_purposes_action_components_search.scs │ │ │ │ ├── one_author_action_components_search.scs │ │ │ │ ├── one_class_action_components_search.scs │ │ │ │ ├── one_explanation_action_components_search.scs │ │ │ │ ├── one_id_action_components_search.scs │ │ │ │ ├── one_key_action_components_search.scs │ │ │ │ ├── one_note_action_components_search.scs │ │ │ │ ├── one_purpose_action_components_search.scs │ │ │ │ ├── specifications.scs │ │ │ │ ├── two_authors_action_components_search.scs │ │ │ │ ├── two_classes_action_components_search.scs │ │ │ │ ├── two_explanations_action_components_search.scs │ │ │ │ ├── two_ids_action_components_search.scs │ │ │ │ ├── two_keys_action_components_search.scs │ │ │ │ ├── two_notes_action_components_search.scs │ │ │ │ ├── two_purposes_action_components_search.scs │ │ │ │ ├── zero_authors_action_components_search.scs │ │ │ │ ├── zero_classes_action_components_search.scs │ │ │ │ ├── zero_explanations_action_components_search.scs │ │ │ │ ├── zero_ids_action_components_search.scs │ │ │ │ ├── zero_keys_action_components_search.scs │ │ │ │ ├── zero_notes_action_components_search.scs │ │ │ │ └── zero_purposes_action_components_search.scs │ │ │ └── specification.scs │ │ └── units │ │ │ ├── agent_tests.cpp │ │ │ └── sc_agents_test.hpp │ │ └── utils │ │ ├── sc_component_manager_command_search.cpp │ │ └── sc_component_manager_command_search.hpp └── console-interface │ ├── CMakeLists.txt │ ├── include │ └── console-interface │ │ ├── sc_component_manager.hpp │ │ ├── sc_component_manager_command_handler.hpp │ │ └── sc_component_manager_command_parser.hpp │ ├── src │ └── sc_component_manager.cpp │ └── test │ ├── CMakeLists.txt │ └── units │ ├── sc_component_manager_test.hpp │ ├── test_command_parser.cpp │ └── test_url_parser.cpp └── module ├── sc_component_manager_module.cpp └── sc_component_manager_module.hpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: Google 4 | AccessModifierOffset: -2 5 | AlignAfterOpenBracket: AlwaysBreak 6 | AlignArrayOfStructures: None 7 | AlignConsecutiveMacros: None 8 | AlignConsecutiveAssignments: None 9 | AlignConsecutiveBitFields: None 10 | AlignConsecutiveDeclarations: None 11 | AlignEscapedNewlines: DontAlign 12 | AlignOperands: Align 13 | AlignTrailingComments: true 14 | AllowAllArgumentsOnNextLine: true 15 | AllowAllConstructorInitializersOnNextLine: false 16 | AllowAllParametersOfDeclarationOnNextLine: false 17 | AllowShortEnumsOnASingleLine: false 18 | AllowShortBlocksOnASingleLine: Never 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortFunctionsOnASingleLine: Empty 21 | AllowShortLambdasOnASingleLine: Empty 22 | AllowShortIfStatementsOnASingleLine: Never 23 | AllowShortLoopsOnASingleLine: false 24 | AlwaysBreakAfterDefinitionReturnType: None 25 | AlwaysBreakAfterReturnType: None 26 | AlwaysBreakBeforeMultilineStrings: true 27 | AlwaysBreakTemplateDeclarations: Yes 28 | AttributeMacros: 29 | - __capability 30 | BinPackArguments: false 31 | BinPackParameters: false 32 | BraceWrapping: 33 | AfterCaseLabel: true 34 | AfterClass: true 35 | AfterControlStatement: Always 36 | AfterEnum: true 37 | AfterFunction: true 38 | AfterNamespace: true 39 | AfterObjCDeclaration: false 40 | AfterStruct: true 41 | AfterUnion: true 42 | AfterExternBlock: true 43 | BeforeCatch: true 44 | BeforeElse: true 45 | BeforeLambdaBody: true 46 | BeforeWhile: true 47 | IndentBraces: false 48 | SplitEmptyFunction: true 49 | SplitEmptyRecord: true 50 | SplitEmptyNamespace: true 51 | BreakBeforeBinaryOperators: NonAssignment 52 | BreakBeforeConceptDeclarations: true 53 | BreakBeforeBraces: Custom 54 | BreakInheritanceList: BeforeComma 55 | BreakBeforeTernaryOperators: true 56 | BreakConstructorInitializersBeforeComma: false 57 | BreakConstructorInitializers: BeforeComma 58 | BreakAfterJavaFieldAnnotations: false 59 | BreakStringLiterals: true 60 | ColumnLimit: 120 61 | CommentPragmas: '^\s*(\*)?\s*\\.+' 62 | QualifierAlignment: Right 63 | CompactNamespaces: false 64 | ConstructorInitializerIndentWidth: 2 65 | ContinuationIndentWidth: 4 66 | Cpp11BracedListStyle: true 67 | DerivePointerAlignment: false 68 | DisableFormat: false 69 | EmptyLineAfterAccessModifier: Never 70 | EmptyLineBeforeAccessModifier: LogicalBlock 71 | ExperimentalAutoDetectBinPacking: false 72 | PackConstructorInitializers: Never 73 | FixNamespaceComments: true 74 | ForEachMacros: 75 | - foreach 76 | - Q_FOREACH 77 | - BOOST_FOREACH 78 | IfMacros: 79 | - KJ_IF_MAYBE 80 | IncludeBlocks: Preserve 81 | IncludeCategories: 82 | - Regex: '^<(gtest|gmock)/.*' 83 | Priority: 10 84 | 85 | - Regex: '^ 22 | Build documentation locally 23 | 24 | ```sh 25 | pip3 install mkdocs mkdocs-material 26 | mkdocs serve 27 | # and open http://127.0.0.1:8004/ in your browser 28 | ``` 29 | 30 | 31 | ## Feedback 32 | 33 | Contributions, bug reports and feature requests are welcome! 34 | Feel free to check our [issues page](https://github.com/ostis-ai/sc-component-manager/issues) and file a new issue (or comment in existing ones). 35 | 36 | ## License 37 | 38 | Distributed under the MIT License. Check [COPYING.MIT](COPYING.MIT) for more information. 39 | -------------------------------------------------------------------------------- /cmake/ClangFormat.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Tomas Zeman 2019-2020. 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | function(prefix_clangformat_setup prefix) 7 | if(NOT CLANGFORMAT_EXECUTABLE) 8 | set(CLANGFORMAT_EXECUTABLE clang-format) 9 | endif() 10 | 11 | if(NOT EXISTS ${CLANGFORMAT_EXECUTABLE}) 12 | find_program(clangformat_executable_tmp ${CLANGFORMAT_EXECUTABLE}) 13 | if(clangformat_executable_tmp) 14 | set(CLANGFORMAT_EXECUTABLE ${clangformat_executable_tmp}) 15 | unset(clangformat_executable_tmp) 16 | else() 17 | message(FATAL_ERROR "ClangFormat: ${CLANGFORMAT_EXECUTABLE} not found! Aborting") 18 | endif() 19 | endif() 20 | 21 | foreach(clangformat_source ${ARGN}) 22 | get_filename_component(clangformat_source ${clangformat_source} ABSOLUTE) 23 | list(APPEND clangformat_sources ${clangformat_source}) 24 | endforeach() 25 | 26 | add_custom_target(${prefix}_clangformat 27 | COMMAND 28 | ${CLANGFORMAT_EXECUTABLE} 29 | -style=file 30 | -fallback-style=none 31 | -i 32 | ${clangformat_sources} 33 | WORKING_DIRECTORY 34 | ${CMAKE_SOURCE_DIR} 35 | COMMENT 36 | "Formatting ${prefix} with ${CLANGFORMAT_EXECUTABLE} ..." 37 | ) 38 | 39 | add_custom_target(${prefix}_clangformat_check 40 | COMMAND 41 | ${CLANGFORMAT_EXECUTABLE} 42 | -style=file 43 | -fallback-style=none 44 | --Werror 45 | --dry-run 46 | ${clangformat_sources} 47 | WORKING_DIRECTORY 48 | ${CMAKE_SOURCE_DIR} 49 | COMMENT 50 | "Check formatting ${prefix} with ${CLANGFORMAT_EXECUTABLE} ..." 51 | ) 52 | 53 | if(TARGET clangformat) 54 | add_dependencies(clangformat ${prefix}_clangformat) 55 | add_dependencies(clangformat_check ${prefix}_clangformat_check) 56 | else() 57 | add_custom_target(clangformat DEPENDS ${prefix}_clangformat) 58 | add_custom_target(clangformat_check DEPENDS ${prefix}_clangformat_check) 59 | endif() 60 | endfunction() 61 | 62 | function(clangformat_setup) 63 | prefix_clangformat_setup(${PROJECT_NAME} ${ARGN}) 64 | endfunction() 65 | 66 | function(target_clangformat_setup target) 67 | get_target_property(target_sources ${target} SOURCES) 68 | list(FILTER target_sources EXCLUDE REGEX \(.*/generated/.*|.*/scs/*.|.*/json/.*\)) 69 | prefix_clangformat_setup(${target} ${target_sources}) 70 | endfunction() 71 | -------------------------------------------------------------------------------- /cmake/install.cmake: -------------------------------------------------------------------------------- 1 | install(TARGETS 2 | init-module install-module search-module sc-component-manager 3 | EXPORT privateExport 4 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/extensions" 5 | ) 6 | 7 | include(CMakePackageConfigHelpers) 8 | 9 | write_basic_package_version_file( 10 | "${CMAKE_CURRENT_BINARY_DIR}/sc-component-manager-config-version.cmake" 11 | VERSION ${PROJECT_VERSION} 12 | COMPATIBILITY AnyNewerVersion 13 | ) 14 | 15 | install(FILES 16 | "${CMAKE_CURRENT_BINARY_DIR}/sc-component-manager-config-version.cmake" 17 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/sc-component-manager 18 | ) 19 | 20 | set(CPACK_PACKAGE_NAME sc-component-manager) 21 | set(CPACK_PACKAGE_VENDOR "OSTIS AI") 22 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Component manager for ostis-systems") 23 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) 24 | set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) 25 | set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) 26 | set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) 27 | set(CPACK_VERBATIM_VARIABLES TRUE) 28 | 29 | if (WIN32) 30 | set(CPACK_GENERATOR ZIP) 31 | else() 32 | set(CPACK_GENERATOR TGZ) 33 | endif() 34 | include(CPack) 35 | -------------------------------------------------------------------------------- /cmake/sc-component-manager-config-version.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@PROJECT_VERSION@") 2 | 3 | if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) 4 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 5 | else() 6 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 7 | endif() 8 | 9 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 10 | set(PACKAGE_VERSION_EXACT TRUE) 11 | else() 12 | set(PACKAGE_VERSION_EXACT FALSE) 13 | endif() 14 | -------------------------------------------------------------------------------- /cmake/tests.cmake: -------------------------------------------------------------------------------- 1 | function(make_tests_from_folder folder) 2 | set(SINGLE_ARGS NAME) 3 | set(MULTI_ARGS DEPENDS INCLUDES ARGUMENTS) 4 | 5 | cmake_parse_arguments(TEST "" "${SINGLE_ARGS}" "${MULTI_ARGS}" ${ARGN}) 6 | 7 | set(target "${TEST_NAME}") 8 | 9 | message(STATUS "Create test ${target}") 10 | 11 | file(GLOB_RECURSE SOURCES 12 | "${folder}/*.cpp" 13 | "${folder}/*.hpp" 14 | ) 15 | 16 | add_executable(${target} ${SOURCES}) 17 | target_link_libraries(${target} GTest::gtest_main ${TEST_DEPENDS}) 18 | target_include_directories(${target} PRIVATE ${TEST_INCLUDES}) 19 | gtest_discover_tests(${target} WORKING_DIRECTORY ${folder}) 20 | endfunction() 21 | -------------------------------------------------------------------------------- /conanfile.py: -------------------------------------------------------------------------------- 1 | from conan import ConanFile, tools 2 | from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain, CMake 3 | 4 | 5 | class sc_component_managerRecipe(ConanFile): 6 | settings = "os", "compiler", "build_type", "arch" 7 | 8 | @property 9 | def _run_tests(self): 10 | return tools.get_env("CONAN_RUN_TESTS", False) 11 | 12 | def requirements(self): 13 | self.requires("sc-machine/0.10.0") 14 | 15 | def build_requirements(self): 16 | self.test_requires("gtest/1.14.0") 17 | 18 | def layout(self): 19 | cmake_layout(self) 20 | 21 | def build(self): 22 | cmake = CMake(self) 23 | cmake.configure() # equivalent to self.run("cmake . ") 24 | cmake.build() 25 | 26 | def generate(self): 27 | deps = CMakeDeps(self) 28 | deps.generate() 29 | tc = CMakeToolchain(self) 30 | tc.user_presets_path = "ConanPresets.json" 31 | tc.generate() 32 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | This page describes rules to contribute changes and features by Pull Requests creating. 2 | 3 | ## Initialize 4 | 5 | To initialize your repo do: 6 | 7 | * Fork `https://github.com/ostis-ai/sc-component-manager`. 8 | * Clone your fork to your machine and prepare (see [Readme](https://github.com/ostis-ai/sc-component-manager)). 9 | 10 | ```sh 11 | git clone git@github.com:yourlogin/sc-component-manager.git 12 | cd sc-component-manager 13 | git remote add upstream git@github.com:ostis-ai/sc-component-manager.git 14 | ``` 15 | 16 | * To update your `main` from `upstream` use: 17 | 18 | ```sh 19 | git fetch upstream 20 | git checkout upstream/main 21 | ``` 22 | 23 | * Use `git rebase` instead of `merge`. See [documentation about this command](https://git-scm.com/docs/git-rebase). To rebase your branch against main use: 24 | 25 | ```sh 26 | git checkout 27 | git rebase upstream/main 28 | ``` 29 | 30 | * If you have any problems, then redo: 31 | 32 | ```sh 33 | git rebase --abort 34 | ``` 35 | 36 | * Or ask in [Element](https://app.element.io/index.html#/room/#ostis_tech_support:matrix.org). 37 | 38 | ## Commits message format 39 | 40 | Each commit message should be formed as: `[tag1]...[tagN] Message text (#issue)`. 41 | 42 | Message text should start from an upper case letter. If commit doesn't fix or implement any #issue, then it shouldn't be pointed in commit message. 43 | 44 | Examples: 45 |
 46 | [kb] Update test components specification
 47 | [init][test] Add unit test for init command
 48 | [utils] Add get specification address util
 49 | 
50 | 51 | Possible tags: 52 | 53 | * `[config]` - changes in configuration files; 54 | * `[init]` - changes in `init` command; 55 | * `[install]` - changes in `install` module; 56 | * `[search]` - changes in `search` module; 57 | * `[utils]` - changes in `utils`; 58 | * `[keynodes]` - changes in `keynodes` module; 59 | * `[kb]` - changes in `kb` module; 60 | * `[downloader]` - changes in `downloader` module; 61 | * `[interface]` - changes in `command line interface` module; 62 | * `[review]` - commits with review fixes; 63 | * `[refactor]` - commits with some code refactoring; 64 | * `[changelog]` - use when you update changelog; 65 | * `[docs]` - use when you update documentation; 66 | * `[scripts]` - updates in the `sc-component_manager/scripts` files; 67 | * `[ci]` - changes in `ci` configuration or scripts; 68 | * `[git]` - changes in `git` configuration; 69 | * `[cmake]` - changes in `cmake` build system; 70 | * `[tests]` - changes in `tests`. 71 | 72 | Each commit in Pull Request should be an atomic. In other words, it should implement or fix one feature. For example: 73 | 74 |
 75 | Last commit
 76 | ...
 77 | [utils][test] Add unit test for get specification address util
 78 | [utils] Add get specification address util
 79 | ...
 80 | Init commit
 81 | 
82 | 83 | *** 84 | Commits should be small in size excluding cases, with: 85 | 86 | * CodeStyle changes; 87 | * Renames; 88 | * Code formatting. 89 | 90 | **Do atomic commits for each changes.** For example if you rename some members in `ClassX` and `ClassY`, then do two commits: 91 | 92 |
 93 | [refactor] Rename members in ClassX according to codestyle
 94 | [refactor] Rename members in ClassY according to codestyle
 95 | 
96 | 97 | **Do not mix codestyle changes and any logical fixes in one commit.** 98 | 99 | All commits that not follow these rules should be split according to these rules. Otherwise they will be rejected with Pull Request. 100 | 101 | *** 102 | ## Pull Request 103 | 104 | Each Pull Request with many changes, that not possible to review (excluding codestyle, rename changes), will be rejected. 105 | 106 | ### Pull Request Preparation 107 | 108 | - Read rules to create PR in documentation; 109 | - Update changelog; 110 | - Update documentation; 111 | - Cover new functionality by tests; 112 | - Your code should be written according to a codestyle like in sc-machine (see [Codestyle rules](https://ostis-ai.github.io/sc-machine/dev/codestyle/)). 113 | 114 | ### Pull Request Creation 115 | 116 | - Create PR on GitHub; 117 | - Check that CI checks were passed successfully. 118 | 119 | ### Pull Request Review 120 | 121 | - Reviewer tests code from PR if CI doesn't do it; 122 | - Reviewer submits review as set of conversations; 123 | - Author makes review fixes at `Review fixes` commits; 124 | - Author re-requests review; 125 | - Reviewer resolves conversations and approves PR if conversations were fixed. 126 | -------------------------------------------------------------------------------- /docs/_assets/main.css: -------------------------------------------------------------------------------- 1 | p { 2 | text-align: justify; 3 | } 4 | 5 | .todo { 6 | background-color: #E06C6C; 7 | border: 1px solid #AD3939; 8 | color: #fff; 9 | padding: 5px; 10 | font-size: 14px; 11 | } 12 | 13 | .todo:before { 14 | content: "TODO:"; 15 | font-weight: bold; 16 | width: 100px; 17 | margin-right: 7px; 18 | } 19 | 20 | .scg { 21 | display: block; 22 | } 23 | 24 | .scg content span { 25 | line-height: 1 !important; 26 | font-size: 11px !important; 27 | } 28 | 29 | .invalid { 30 | display: block; 31 | width: 64px; 32 | height: 64px; 33 | background-image: url(warning.svg); 34 | } 35 | 36 | .invalid:after { 37 | content: "Error"; 38 | margin-left: 70px; 39 | margin-right: auto; 40 | margin-top: auto; 41 | margin-bottom: auto; 42 | display: block; 43 | width: 200px; 44 | line-height: 64px; 45 | color: #740600; 46 | } 47 | 48 | /* SCs code */ 49 | .codehilite .c { color: #008000 } /* Comment */ 50 | .codehilite .err { border: 0 } /* Error */ 51 | .codehilite .k { color: #0000ff } /* Keyword */ 52 | .codehilite .ch { color: #008000 } /* Comment.Hashbang */ 53 | .codehilite .cm { color: #008000 } /* Comment.Multiline */ 54 | .codehilite .cp { color: #0000ff } /* Comment.Preproc */ 55 | .codehilite .cpf { color: #008000 } /* Comment.PreprocFile */ 56 | .codehilite .c1 { color: #008000 } /* Comment.Single */ 57 | .codehilite .cs { color: #008000 } /* Comment.Special */ 58 | .codehilite .ge { font-style: italic } /* Generic.Emph */ 59 | .codehilite .gh { font-weight: bold } /* Generic.Heading */ 60 | .codehilite .gp { font-weight: bold } /* Generic.Prompt */ 61 | .codehilite .gs { font-weight: bold } /* Generic.Strong */ 62 | .codehilite .gu { font-weight: bold } /* Generic.Subheading */ 63 | .codehilite .kc { color: #0000ff } /* Keyword.Constant */ 64 | .codehilite .kd { color: #0000ff } /* Keyword.Declaration */ 65 | .codehilite .kn { color: #0000ff } /* Keyword.Namespace */ 66 | .codehilite .kp { color: #0000ff } /* Keyword.Pseudo */ 67 | .codehilite .kr { color: #0000ff } /* Keyword.Reserved */ 68 | .codehilite .kt { color: #2b91af } /* Keyword.Type */ 69 | .codehilite .s { color: #a31515; background-color: #fff0f0 } /* Literal.String */ 70 | .codehilite .nc { color: #2b91af } /* Name.Class */ 71 | .codehilite .ow { color: #0000ff } /* Operator.Word */ 72 | .codehilite .sa { color: #a31515 } /* Literal.String.Affix */ 73 | .codehilite .sb { color: #a31515 } /* Literal.String.Backtick */ 74 | .codehilite .sc { color: #a31515 } /* Literal.String.Char */ 75 | .codehilite .dl { color: #a31515 } /* Literal.String.Delimiter */ 76 | .codehilite .sd { color: #a31515 } /* Literal.String.Doc */ 77 | .codehilite .s2 { color: #a31515 } /* Literal.String.Double */ 78 | .codehilite .se { color: #a31515; font-weight: bold } /* Literal.String.Escape */ 79 | .codehilite .sh { color: #a31515 } /* Literal.String.Heredoc */ 80 | .codehilite .si { color: #a31515 } /* Literal.String.Interpol */ 81 | .codehilite .sx { color: #a31515; text-decoration: underline } /* Literal.String.Other */ 82 | .codehilite .sr { color: #a31515 } /* Literal.String.Regex */ 83 | .codehilite .s1 { color: #a31515 } /* Literal.String.Single */ 84 | .codehilite .ss { color: #a31515 } /* Literal.String.Symbol */ 85 | .codehilite .nv { color: #000080; font-style: italic } /* Name.Variable */ 86 | .codehilite .n.n-Instance { color: #3e61a2; font-style: italic } 87 | .codehilite .no { color: #3e61a2 } 88 | .codehilite .o { color: #000 } 89 | .codehilite .ni { color: #000; background-color: #eee } 90 | .codehilite .nl { color: #2b91af; background-color: #f1f9fb } 91 | -------------------------------------------------------------------------------- /docs/_assets/main.js: -------------------------------------------------------------------------------- 1 | function httpGetAsync(theUrl, callback) 2 | { 3 | var xmlHttp = new XMLHttpRequest(); 4 | xmlHttp.onreadystatechange = function() { 5 | if (xmlHttp.readyState == 4 && xmlHttp.status == 200) 6 | callback(xmlHttp.responseText); 7 | } 8 | xmlHttp.open("GET", theUrl, true); // true for asynchronous 9 | xmlHttp.send(null); 10 | } 11 | 12 | let scgCounter = 0; 13 | function SCgContainer(el) { 14 | // get source 15 | let viewer = null; 16 | const source = el.attributes['src']; 17 | if (!source) { 18 | el.className = 'invalid'; 19 | } else { 20 | const id = `scg-content-${scgCounter}`; 21 | scgCounter++; 22 | el.setAttribute('id', id); 23 | el.className = 'scg'; 24 | viewer = new SCgViewer(id); 25 | httpGetAsync(source.value, function(data) { 26 | viewer.loadFromData(data); 27 | viewer.fitSizeToContent(); 28 | }); 29 | } 30 | 31 | return { 32 | viewer: viewer 33 | } 34 | } 35 | 36 | let views = []; 37 | document.addEventListener('DOMContentLoaded', function() { 38 | const items = document.querySelectorAll('scg'); 39 | items.forEach(function(d) { 40 | views.push(new SCgContainer(d)); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /docs/agents.tex: -------------------------------------------------------------------------------- 1 | \begin{SCn} 2 | 3 | \scnheader{Агент установки спецификаций многократно используемых компонентов} 4 | \scnidtf{sc-агент установки спецификаций многократно используемых компонентов} 5 | \scnrelfrom{команда, вызывающая агент}{components init} 6 | \begin{scnrelfromvector}{задача} 7 | \scnfileitem{Отыскать все спецификаци спецификаций многократно используемых компонентов в базе знаний.} 8 | \scnfileitem{Скачать спецификаций на устройство.} 9 | \end{scnrelfromvector} 10 | \scnrelfrom{пример входной конструкции}{\scnfileimage[20em]{images/components_init_input.png}} 11 | \begin{scnrelfromset}{аргументы агента} 12 | \scnitem{пустое множество} 13 | \end{scnrelfromset} 14 | \scnrelfrom{ответ агента}{ответ агента установки спецификаций многократно используемых компонентов} 15 | \begin{scnindent} 16 | \scntext{примечание}{В результате выполнения агентом поискового действия на устройстве появятся scs-файлы со спецификациями, скаченными по сети. Данные файлы сразу транслируются в sc-память.} 17 | \end{scnindent} 18 | \scnrelfrom{пример выходной конструкции}{\scnfileimage[20em]{images/components_init_output.png}} 19 | 20 | \scnheader{Агент установки компонентов} 21 | \scnidtf{sc-агент установки компонентов} 22 | \scnrelfrom{команда, вызывающая агент}{components install} 23 | \begin{scnrelfromvector}{задача} 24 | \scnfileitem{Поиск спецификации компонента в базе знаний по заданному критерию, если он есть, иначе поиск всех спецификаций компонентов.} 25 | \scnfileitem{Скачивание и установка (опционально) на устройство.} 26 | \end{scnrelfromvector} 27 | \scnrelfrom{пример входной конструкции}{\scnfileimage[20em]{images/components_install_input.png}} 28 | \begin{scnrelfromset}{аргументы агента} 29 | \scnitem{множество компонентов} 30 | \begin{scnindent} 31 | \scntext{примечание}{В этом случае отыскиваются все компоненты, принадлежащие указанному множеству, и скачиваются.} 32 | \end{scnindent} 33 | \scnitem{множество множеств компонентов} 34 | \begin{scnindent} 35 | \scntext{примечание}{В этом случае отыскиваются все компоненты, принадлежащие указанным множествам множества, и скачиваются.} 36 | \end{scnindent} 37 | \end{scnrelfromset} 38 | \scnrelfrom{ответ агента}{ответ агента установки компонентов} 39 | \begin{scnindent} 40 | \scntext{примечание}{В результате выполнения агентом действия по установке компонентов на устройстве появятся компоненты в соответствующих папках со спецификациями, и данные компоненты будут установлены, если это необходимо.} 41 | \end{scnindent} 42 | \scnrelfrom{пример выходной конструкции}{\scnfileimage[20em]{images/components_install_output.png}} 43 | 44 | \scnheader{Агент поиска спецификаций компонентов} 45 | \scnidtf{sc-агент поиска спецификаций компонентов} 46 | \scnrelfrom{команда, вызывающая агент}{components search} 47 | \begin{scnrelfromvector}{задача} 48 | \scnfileitem{Отыскать спецификации компонентов в базе знаний по заданным критериям.} 49 | \end{scnrelfromvector} 50 | \scnrelfrom{пример входной конструкции}{\scnfileimage[20em]{images/components_search_input.png}} 51 | \begin{scnrelfromset}{аргументы агента} 52 | \scnitem{authors} 53 | \begin{scnindent} 54 | \scntext{примечание}{В этом случае отыскивается спецификация компонента по автору, который создал компонент.} 55 | \end{scnindent} 56 | \scnitem{classes} 57 | \begin{scnindent} 58 | \scntext{примечание}{В этом случае отыскивается спецификация компонента по классу, которому принадлежит компонент.} 59 | \end{scnindent} 60 | \scnitem{explanations} 61 | \begin{scnindent} 62 | \scntext{примечание}{В этом случае отыскивается спецификация компонента по его описанию (примечанию), которое в общем случае может являться подстрокой реального примечания компонента, хранящегося в базе знаний.} 63 | \end{scnindent} 64 | \scnitem{пустое множество} 65 | \begin{scnindent} 66 | \scntext{примечание}{В этом случае ничего не будет найдено.} 67 | \end{scnindent} 68 | \end{scnrelfromset} 69 | \scnrelfrom{ответ агента}{ответ агента поиска компонентов} 70 | \begin{scnindent} 71 | \scntext{примечание}{В результате выполнения агентом поискового действия сформируется ответ со множеством найденных компонентов.} 72 | \end{scnindent} 73 | \scnrelfrom{пример выходной конструкции}{\scnfileimage[20em]{images/components_search_output.png}} 74 | 75 | \scnheader{Агент поиска спецификации компонента по компоненту} 76 | \scnidtf{sc-агент поиска спецификации компонента по компоненту} 77 | \begin{scnrelfromvector}{задача} 78 | \scnfileitem{Отыскать спецификацию компонента в базе знаний по заданному компоненту.} 79 | \end{scnrelfromvector} 80 | \scnrelfrom{пример входной конструкции}{\scnfileimage[20em]{images/specifications_search_input.png}} 81 | \begin{scnrelfromvector}{аргументы агента} 82 | \scnitem{component} 83 | \begin{scnindent} 84 | \scntext{примечание}{Узел компонента, для которого необходимо найти спецификацию.} 85 | \end{scnindent} 86 | \end{scnrelfromvector} 87 | \scnrelfrom{ответ агента}{ответ агента поиска спецификации компонента по компоненту} 88 | \begin{scnindent} 89 | \scntext{примечание}{В результате выполнения агентом поискового действия сформируется ответ с найденной спецификацией.} 90 | \end{scnindent} 91 | \scnrelfrom{пример выходной конструкции}{\scnfileimage[20em]{images/specifications_search_output.png}} 92 | \end{SCn} -------------------------------------------------------------------------------- /docs/build/build_system.md: -------------------------------------------------------------------------------- 1 | # Build System 2 | 3 | The sc-component-manager build system is based on the principles of the [sc-machine](https://github.com/ostis-ai/sc-machine) build system. To learn more about them, read [sc-machine build system documentation](https://ostis-ai.github.io/sc-machine/build/build_system/). 4 | 5 | ## Compilation steps 6 | 7 | This project uses CMake presets. These presets help manage different build configurations, making it easier to work with dependencies and streamline the build process. 8 | 9 | If you wish to use CLI instead, you can list all the available configurations in the `CMakePresets.json` file and pick one of the presets: 10 | 11 | ```sh 12 | conan install . -s build_type= --build=missing 13 | cmake --list-presets 14 | ``` 15 | 16 | ### Configure presets 17 | 18 | Configure presets define how the project is configured before building. They specify various settings, including whether to include tests and which dependencies to use. 19 | 20 | | **Name** | **Display Name** | **Description** | **Build location** | 21 | |------------------------------|-----------------------------------------|------------------------------------------------------|--------------------| 22 | | `debug-conan` | Debug config (Conan) | Debug config with tests (Conan dependencies used) | build/Debug | 23 | | `release-conan` | Release config (Conan) | Release config (Conan dependencies used) | build/Release | 24 | | `release-with-tests-conan` | Release config with tests (Conan) | Release config with tests (Conan dependencies used) | build/Release | 25 | 26 | ## Build presets 27 | 28 | Build presets link to the configure presets and specify how to build the project. They determine the output directories based on the selected configuration. 29 | 30 | | **Name** | **Configure Preset** | **Build location** | 31 | |------------|---------------------------------------------|--------------------| 32 | | `debug` | `debug-conan` | build/Debug | 33 | | `release` | `release-conan`, `release-with-tests-conan` | build/Release | 34 | 35 | ## Recommendations 36 | 37 | - For development and debugging, use the **Debug config (Conan)** (`debug-conan`) preset. This configuration includes options for testing and benchmarking. 38 | - For production builds, choose the **Release config (Conan)** (`release-conan`) preset to create optimized builds without debugging information. 39 | - If you need to run tests in a production build, select the **Release config with tests (Conan)** (`release-with-tests-conan`) preset. 40 | 41 | ## Example usage 42 | 43 | To build your project using these presets, you can use the following commands: 44 | 45 | ```sh 46 | # Use pipx to install Conan if not already installed 47 | pipx install conan 48 | ``` 49 | 50 | ```sh 51 | # Install dependencies using Conan with Debug build type 52 | conan install . -s build_type=Debug --build=missing 53 | # Configure using debug-conan preset 54 | cmake --preset debug-conan 55 | # Build using debug preset 56 | cmake --build --preset debug 57 | ``` 58 | 59 | To build your project for release, you can build with tests to ensure everything works as expected: 60 | 61 | ```sh 62 | # Install dependencies using Conan with Debug build type 63 | conan install . -s build_type=Release --build=missing 64 | # Configure using release-with-tests preset 65 | cmake --preset release-with-tests-conan 66 | # Build using release preset 67 | cmake --build --preset release 68 | ``` 69 | 70 | We also define `INSTALL` instructions in our CMake. This routine can be launched by appending `--target install` to the `cmake --build --preset ` folder. The result of this command will reside in `build//install` (our default install folder). Install folder is basically a pack of portable executable files and shared libraries required to get sc-component-manager up and running, this command is intended to create clutter-free archives/folders with our code which you can then use in your own projects. 71 | -------------------------------------------------------------------------------- /docs/build/cmake_flags.md: -------------------------------------------------------------------------------- 1 | # CMake Flags 2 | 3 | ## Build cache 4 | 5 | This project uses ccache automatically if it's available in the system. To disable this, use flag `-DAUTO_CCACHE=OFF`. 6 | 7 | ## Building tests 8 | 9 | ```sh 10 | cmake --preset -DSC_BUILD_TESTS=ON 11 | cmake --build --preset 12 | ``` 13 | 14 | ## Code formatting with CLangFormat 15 | 16 | To check code with CLangFormat run: 17 | ```sh 18 | cmake --preset release-with-tests-conan -DSC_CLANG_FORMAT_CODE=ON 19 | cmake --build --preset release --target clangformat_check 20 | ``` 21 | 22 | or 23 | ```sh 24 | ./scripts/clang/check_formatting.sh 25 | ``` 26 | 27 | To format code with CLangFormat run: 28 | ```sh 29 | cmake --preset release-with-tests-conan -DSC_CLANG_FORMAT_CODE=ON 30 | cmake --build --preset release --target clangformat 31 | ``` 32 | 33 | or 34 | ```sh 35 | ./scripts/clang/format_code.sh 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/build/quick_start.md: -------------------------------------------------------------------------------- 1 | # Quick Start for Contributors 2 | 3 | This guide provides short information for developers to start to work with sc-component-manager quickly. You can always learn more about the sc-component-manager's [build system](build_system.md). 4 | 5 | ## Install project 6 | 7 | Install sc-component-manager via git: 8 | 9 | ```sh 10 | git clone https://github.com/ostis-ai/sc-component-manager 11 | cd sc-component-manager 12 | git submodule update --init --recursive 13 | ``` 14 | 15 | ## Check CMake 16 | 17 | Install pipx first using [**pipx installation guide**](https://pipx.pypa.io/stable/installation/) if not already installed. 18 | 19 | Ensure you are using **CMake version 3.24** or newer. Verify your version with: 20 | 21 | ```sh 22 | cmake --version 23 | ``` 24 | 25 | To upgrade CMake, run: 26 | 27 | ```sh 28 | # Use pipx to install cmake if not already installed 29 | pipx install cmake 30 | pipx ensurepath 31 | # relaunch your shell after installation 32 | exec $SHELL 33 | ``` 34 | 35 | Install Ninja generator for CMake, to use CMake presets: 36 | 37 | ```sh 38 | # Use pipx to install ninja if not already installed 39 | pipx install ninja 40 | pipx ensurepath 41 | # relaunch your shell after installation 42 | exec $SHELL 43 | ``` 44 | 45 | ## Start develop sc-component-manager with Conan 46 | 47 | ### Install Conan 48 | 49 | Install Conan, to build sc-component-manager dependencies with Conan-provided dependencies: 50 | 51 | ```sh 52 | # Use pipx to install conan if not already installed 53 | pipx install conan 54 | pipx ensurepath 55 | # relaunch your shell after installation 56 | exec $SHELL 57 | ``` 58 | 59 | ### Add Conan remote repository 60 | 61 | Add Conan remote repository with the specified URL: 62 | 63 | ```sh 64 | conan remote add ostis-ai https://conan.ostis.net/artifactory/api/conan/ostis-ai-library 65 | ``` 66 | 67 | ### Use sc-component-manager in Debug 68 | 69 | #### Install dependencies with Conan 70 | 71 | sc-component-manager is an extension to sc-machine, so sc-machine is main dependency for sc-component-manager. To install it, run in the root of the project: 72 | 73 | ```sh 74 | conan install . -s build_type=Debug --build=missing 75 | ``` 76 | 77 | #### Build sc-component-manager in Debug 78 | 79 | To build sc-component-manager in debug mode using Conan-provided dependencies, run: 80 | 81 | ```sh 82 | # debug build type 83 | cmake --preset debug-conan 84 | cmake --build --preset debug 85 | ``` 86 | 87 | Note: By default, configure preset `debug` enables building sc-component-manager tests. 88 | 89 | #### Run sc-component-manager tests in Debug 90 | 91 | After that, you can go to `build/Debug` and run tests via `ctest`: 92 | 93 | ```sh 94 | cd build/Debug 95 | ctest -V 96 | ``` 97 | 98 | You can also check code formatting. To learn more, go to the [CMake flags](cmake_flags.md) page. 99 | 100 | ### Use sc-component-manager in Release 101 | 102 | #### Install dependencies with Conan 103 | 104 | To install it, run in the root of the project: 105 | 106 | ```sh 107 | conan install . -s build_type=Release --build=missing 108 | ``` 109 | 110 | #### Build sc-component-manager in Release 111 | 112 | To build sc-component-manager in release mode using Conan-provided dependencies, run: 113 | 114 | ```sh 115 | # release build type without tests 116 | cmake --preset release-conan 117 | cmake --build --preset release 118 | ``` 119 | 120 | To build sc-component-manager with tests in release mode using Conan-provided dependencies, run: 121 | 122 | ```sh 123 | # release build type with tests 124 | cmake --preset release-with-tests-conan 125 | cmake --build --preset release 126 | ``` 127 | 128 | #### Run sc-component-manager tests in Release 129 | 130 | After that, you can run tests: 131 | 132 | ```sh 133 | cd build/Release 134 | ctest -V 135 | ``` 136 | 137 | You can also check code formatting. To learn more, go to the [CMake flags](cmake_flags.md) page. 138 | 139 | ### Run sc-component-manager 140 | 141 | Before launching sc-component-manager, [extract sc-machine from GitHub Releases](https://ostis-ai.github.io/sc-machine/quick_start/#github-releases) or [build it](https://ostis-ai.github.io/sc-machine/build/quick_start/). 142 | 143 | To launch sc-component-manager, run: 144 | 145 | ```sh 146 | ./path/to/sc-machine/binary -s path/to/kb.bin \ 147 | -e "sc-component-manager//lib/extensions;path/to/sc-machine/lib/extensions" 148 | # if several paths to extensions are provided then they should be separated 149 | # by semicolon and wrapped in double quotes 150 | ``` 151 | -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ## [0.2.0] - 09.03.2025 11 | 12 | ### Changed 13 | 14 | - Use generator Ninja in CMakePresets.json 15 | - Rename Conan remote repository url to https://conan.ostis.net/artifactory/api/conan/ostis-ai-library 16 | 17 | ### Fixed 18 | 19 | - Distribute tests by modules 20 | - Make init-lib and console-interface as object libraries to avoid problems of dynamic loading 21 | 22 | ## [0.1.0] - 12.02.2025 23 | 24 | ### Added 25 | 26 | - Intro for sc-component-manager in docs 27 | - CMake flags section in docs 28 | - Quick start section for users in docs 29 | - Quick start section for Contributors in docs 30 | - Describe myself decomposition 31 | - Add components logging 32 | - Update clang-format 33 | - Agents for init, search, install commands 34 | - Documentation of CLion cmake-configuration 35 | - Download components from a separate directory of a repository, not to clone all repository 36 | - Add repository url parser to get information from GitHub repository link 37 | - Add installation of kb/ps/interface components to the relevant directories 38 | - Add quiet installation mode 39 | - Add SCn documentation 40 | - Add SCn documentation environment 41 | - Add contributing document 42 | - Add codestyle document 43 | - Add git workflow 44 | - Add changelog 45 | - Add license 46 | - Add utils 47 | - Add loading for downloaded scs files 48 | - Add logging 49 | - Add components install command 50 | - Add components search command 51 | - Add components init command 52 | - Add storage config and config parser 53 | - Create base environment to run commands 54 | - Add commands redaction 55 | - Add new search flags by note, purpose, main identifier, key sc-element 56 | 57 | ### Changed 58 | 59 | - Build sc-component-manager with conan-provided dependencies 60 | - Install sc-machine with conan 61 | - Rename questions to actions 62 | - Make sc-component-manager as shared library 63 | - Separated envs from envs of sc-machine 64 | - Replace ExecutionResult with bool and update logging. 65 | - Decompose install command to functions 66 | - Move storage configs to kb 67 | 68 | ### Fixed 69 | 70 | - Check console pool for new strings; join thread with getline 71 | - Processing commands with multiple string spaces 72 | - Install a component while running `components install [name]` with no `--idtf` flag 73 | - Exception while running `components search --explanation` with an empty substring 74 | - Use nrel_authors instead of nrel_author 75 | 76 | ### Removed 77 | 78 | - Remove codegen for agents 79 | - Remove svn dependency 80 | - Remove trunk folder when download git repository 81 | - Remove storage parser 82 | -------------------------------------------------------------------------------- /docs/images/cmake_options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/cmake_options.png -------------------------------------------------------------------------------- /docs/images/components_init_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_init_input.png -------------------------------------------------------------------------------- /docs/images/components_init_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_init_output.png -------------------------------------------------------------------------------- /docs/images/components_install_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_install_input.png -------------------------------------------------------------------------------- /docs/images/components_install_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_install_output.png -------------------------------------------------------------------------------- /docs/images/components_search_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_search_input.png -------------------------------------------------------------------------------- /docs/images/components_search_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/components_search_output.png -------------------------------------------------------------------------------- /docs/images/program_args.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/program_args.png -------------------------------------------------------------------------------- /docs/images/specification_storage_addresses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/specification_storage_addresses.png -------------------------------------------------------------------------------- /docs/images/specifications_search_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/specifications_search_input.png -------------------------------------------------------------------------------- /docs/images/specifications_search_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/images/specifications_search_output.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | Welcome to the [sc-component-manager](https://github.com/ostis-ai/sc-component-manager) documentation! This comprehensive guide is designed to help you navigate the features, functionalities, and applications of sc-component-manager, a C++ software package to manage component within the [**OSTIS Technology**](https://github.com/ostis-ai). 4 | 5 | ## What is sc-component-manager? 6 | 7 | sc-component-manager is a **software package** to manage components of systems designed with the **OSTIS Technology**. It extends the capabilities of the [**sc-machine**](https://github.com/ostis-ai/sc-machine), which serves as a tool for creating, searching and distributing components of ostis-systems. 8 | 9 | Table of contents: 10 | 11 | - [Quick Start](quick_start.md) - *get up and running with sc-component-manager quickly* 12 | - [Usage](usage/usage.md) - *how to use sc-component-manager* 13 | - **Build Instructions** - *guidelines for building the project, configuring settings* 14 | * [Quick Start for Contributors](build/quick_start.md) - *get up and start developing sc-component-manager quickly* 15 | * [Build System](build/build_system.md) - *how to build the project and use it as a library* 16 | * [CMake Flags](build/cmake_flags.md) - *description of CMake flags used to configure sc-component-manager* 17 | - **Development** - *guidelines for contributing to development* 18 | * [Contributing Guide](CONTRIBUTING.md) - *guide for those who wants to make contribution to sc-component-manager* 19 | * [Codestyle Guide](https://ostis-ai.github.io/sc-machine/dev/codestyle/) - *guide for those who wants to write code for sc-component-manager* 20 | - [License](https://github.com/ostis-ai/sc-component-manager/blob/main/COPYING.MIT) 21 | - [Changelog](changelog.md) 22 | -------------------------------------------------------------------------------- /docs/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/main.pdf -------------------------------------------------------------------------------- /docs/main.tex: -------------------------------------------------------------------------------- 1 | \makeatletter 2 | \def\input@path{{scn//}} 3 | \makeatother 4 | 5 | 6 | \documentclass{scndocument} 7 | 8 | \usepackage{import} 9 | \usepackage{scn} 10 | \usepackage[english,main=russian]{babel} 11 | 12 | \addbibresource{bibliography/biblio.bib} 13 | 14 | \begin{document} 15 | 16 | \selectlanguage{russian} 17 | 18 | \DeactivateBG 19 | \title{\centering 20 | Документация менеджера многократно используемых компонентов ostis-систем} 21 | \maketitle 22 | 23 | \normalsize 24 | 25 | \setcounter{page}{2} 26 | 27 | \ActivateBG 28 | \begin{SCn} 29 | \input{sc-component-manager} 30 | \input{agents} 31 | \end{SCn} 32 | \end{document} 33 | -------------------------------------------------------------------------------- /docs/ostis-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ostis-ai/sc-component-manager/d8d11d6a10b1c1cbc5c6109d8c3877413c048aef/docs/ostis-logo.png -------------------------------------------------------------------------------- /docs/quick_start.md: -------------------------------------------------------------------------------- 1 | # Quick Start 2 | 3 | ## Use sc-component-manager as an extension to sc-machine 4 | 5 | ### GitHub Releases 6 | 7 | !!! Note 8 | Currently, using sc-component-manager natively on Windows isn't supported. 9 | 10 | 1. Download pre-built artifacts of sc-machine from [GitHub Releases](https://github.com/ostis-ai/sc-machine/releases) and extract it to any location. 11 | 12 | To learn more about how to install and use sc-machine artifacts, see [sc-machine quick start](https://ostis-ai.github.io/sc-machine/quick_start/). 13 | 14 | 2. Download pre-built artifacts of sc-component-manager from [GitHub Releases](https://github.com/ostis-ai/sc-component-manager/releases) and extract it to any location. 15 | 16 | 3. Build component specifications located in `knowledge-base` directory at the root of the project: 17 | 18 | ```sh 19 | ./path/to/sc-builder/binary -i path/to/knowledge-base -o path/to/kb.bin --clear 20 | ``` 21 | 22 | 4. Then specify the folder path to `lib/extensions` from extracted sc-component-manager folder when running the sc-machine binary: 23 | 24 | ```sh 25 | ./path/to/sc-machine/binary -s path/to/kb.bin \ 26 | -e "path/to/extracted/sc-component-manager/lib/extensions;path/to/sc-machine/lib/extensions" \ 27 | -c path/to/sc-component-manager.ini 28 | # if several paths to extensions are provided then they should be separated 29 | # by semicolon and wrapped in double quotes 30 | ``` 31 | 32 | 5. Download component specifications from repositories. Execute the following command in a running terminal: 33 | 34 | ```sh 35 | components init 36 | ``` 37 | 38 | 6. Install components. For example, run: 39 | 40 | ```sh 41 | components install part_ui 42 | ``` 43 | 44 | To learn more about how to use sc-component-manager and to manage components with it, see [this docs](usage/usage.md). 45 | 46 | In case you want to make changes to the project sources, please refer to the [build system docs](build/build_system.md). 47 | 48 | ## Common issues 49 | 50 | - Can't load a whole repo using the command `components install --idtf `. There is only a repository directory without source files. 51 | 52 | **Solution**: please make sure your Git is configured to be able to use `git sparse-checkout`. 53 | ```sh 54 | git config --global core.sparseCheckoutCone true 55 | git config --global core.sparseCheckout true 56 | git config --global index.sparse true 57 | ``` 58 | You can see more in the [official documentation](https://git-scm.com/docs/git-sparse-checkout). 59 | -------------------------------------------------------------------------------- /docs/usage/usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | ## Commands 4 | 5 | | Command | Abbreviation | Description | Flags | 6 | |:---------------------|:-----------------------------------------|:--------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------| 7 | | `components init` | `ci`,
`comp init` | Download specifications from repositories. | | 8 | | `components search` | `cs`,
`comp search`,
`comp s` | Search a component specification in the knowledge base by author, class, key sc-element, explanation, note, purpose, or main identifier substring. | `[--author ]`
`[--class ]`
`[--key ]`
`[--explanation ]`
`[--note ]`
`[--purpose ]`
`[--main-id
]` | 9 | | `components install` | `cinst`,
`comp inst` | Install components by its system identifier or install the set of components. | `[--idtf ]` or `[]` - install by an identifier
`[--set ]` - install the set of components | 10 | 11 | !!! Note 12 | If you are searching a string, you can put this string in quotes. 13 | !!! Note 14 | `knowledge-base/specifications.scs` contains the example of a repository specification. 15 | 16 | ## Debug Logs 17 | 18 | To see sc-component-manager debug logs set `log_level` to `Debug` in `[sc-memory]` section of `sc-component-manager.ini` 19 | 20 | ## Repository and components 21 | 22 | ### Repository specification 23 | 24 | The repository specification describes two primary sections: components and repositories: 25 | 26 | - Components section represents a list of components that have addresses to Github repositories that contain component sources and their specifications. 27 | - Repositories section includes addresses to Github repositories that contain other repository specifications. 28 | 29 | See example: 30 | 31 | ```scs 32 | sc_component_manager_repository 33 | <- concept_repository; 34 | -> rrel_components_specifications: ..components_addresses; 35 | -> rrel_repositories_specifications: ..repositories_addresses;; 36 | 37 | ..components_addresses 38 | <- sc_node_tuple; 39 | -> knowledge_base_ims_specification 40 | (* 41 | <- concept_reusable_component_specification;; 42 | => nrel_alternative_addresses: 43 | ... 44 | (* 45 | <- sc_node_tuple;; 46 | -> rrel_1: 47 | ... 48 | (* 49 | -> [https://github.com/ostis-ai/ims.ostis.kb] 50 | (* 51 | <- concept_github_url;; 52 | *);; 53 | *);; 54 | *);; 55 | *); 56 | -> cat_kb_component_spec 57 | (* 58 | <- concept_reusable_component_specification;; 59 | => nrel_alternative_addresses: 60 | ... 61 | (* 62 | <- sc_node_tuple;; 63 | -> rrel_1: 64 | ... 65 | (* 66 | -> [https://github.com/MksmOrlov/cat-kb-component] 67 | (* 68 | <- concept_github_url;; 69 | *);; 70 | *);; 71 | *);; 72 | *);; 73 | 74 | ..repositories_addresses 75 | -> ... 76 | (* 77 | -> rrel_address: 78 | [https://github.com/MksmOrlov/components-repo-example];; 79 | *);; 80 | ``` 81 | 82 | ### Component specification 83 | 84 | The component specification is a description of reusable component. 85 | 86 | See example: 87 | 88 | ```scs 89 | cat_specification 90 | <- concept_reusable_component_specification;; 91 | 92 | cat_specification = [* 93 | concept_cat 94 | <- concept_reusable_component; 95 | <- concept_atomic_reusable_component; 96 | <- concept_independent_reusable_component; 97 | <- concept_reusable_kb_component; 98 | <- concept_reusable_dynamically_installed_component; 99 | <- concept_reusable_source_code_component; 100 | 101 | => nrel_sc_identifier: [Cat specification](* <- lang_en;; *); 102 | => nrel_key_sc_element: concept_animal; 103 | => nrel_purpose: [Cat specification is needed to design knowledge bases about animal world, pets and zoo.](* <- lang_en;; *); 104 | => nrel_explanation: [Meow meow meow!] (*<- lang_en;; *); 105 | => nrel_authors: ... (* -> Orlov;; *); 106 | => nrel_component_dependencies: ... (* <- empty_set;; *); 107 | 108 | => nrel_component_address: [https://github.com/MksmOrlov/cat-kb-component] (* <- concept_github_url;; *); 109 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 110 | *];; 111 | ``` 112 | -------------------------------------------------------------------------------- /ellipsis.yaml: -------------------------------------------------------------------------------- 1 | version: 1.3 2 | about: 3 | - "sc-component-manager is a software package manager for components within the OSTIS Technology" 4 | - "sc-component-manager allows ostis-systems to install reusable components for intelligent systems made with the OSTIS Technology" 5 | 6 | pr_review: 7 | rules: 8 | - "Code should be DRY (Don't Repeat Yourself)" 9 | - "There should be no secrets or credentials in the code" 10 | - "Extremely Complicated Code Needs Comments" 11 | - "Use Descriptive Variable and Constant Names" 12 | - "Don't log sensitive data" 13 | - "Follow the Single Responsibility Principle" 14 | - "Function and Method Naming Should Follow Consistent Patterns" 15 | summary_rules: 16 | - "Don't mention changes if the change is only whitespace" 17 | - "When a rename occurs, mention the old and new file names, but don't mention every single spot where the file renamed occurred" 18 | auto_review_enabled: true 19 | enable_approve_prs: true 20 | 21 | pr_address_comments: 22 | delivery: "new_commit" 23 | -------------------------------------------------------------------------------- /knowledge-base/actions.scs: -------------------------------------------------------------------------------- 1 | action_components_init 2 | <- sc_node_class; 3 | => nrel_main_idtf: [действие. установить спецификации многократно используемых компонентов] (* <- lang_ru;; *); 4 | => nrel_main_idtf: [action. components init] (* <- lang_en;; *);; 5 | 6 | action_components_install 7 | <- sc_node_class; 8 | => nrel_main_idtf: [действие. установить компоненты] (* <- lang_ru;; *); 9 | => nrel_main_idtf: [action. components install] (* <- lang_en;; *);; 10 | 11 | action_components_search 12 | <- sc_node_class; 13 | => nrel_main_idtf: [действие. найти спецификации компонентов] (* <- lang_ru;; *); 14 | => nrel_main_idtf: [action. components search] (* <- lang_en;; *);; 15 | -------------------------------------------------------------------------------- /knowledge-base/relations.scs: -------------------------------------------------------------------------------- 1 | rrel_identifier 2 | <- sc_node_role_relation; 3 | => nrel_main_idtf: 4 | [идентификатор'] (* <- lang_ru;; *); 5 | [identifier'] (* <- lang_en;; *);; 6 | 7 | rrel_class 8 | <- sc_node_role_relation; 9 | => nrel_main_idtf: 10 | [класс'] (* <- lang_ru;; *); 11 | [class'] (* <- lang_en;; *);; 12 | 13 | rrel_author 14 | <- sc_node_role_relation; 15 | => nrel_main_idtf: 16 | [автор'] (* <- lang_ru;; *); 17 | [author'] (* <- lang_en;; *);; 18 | 19 | rrel_explanation 20 | <- sc_node_role_relation; 21 | => nrel_main_idtf: 22 | [примечание'] (* <- lang_ru;; *); 23 | [explanation'] (* <- lang_en;; *);; 24 | 25 | rrel_note 26 | <- sc_node_role_relation; 27 | => nrel_main_idtf: 28 | [примечание'] (* <- lang_ru;; *); 29 | [note'] (* <- lang_en;; *);; 30 | 31 | rrel_purpose 32 | <- sc_node_role_relation; 33 | => nrel_main_idtf: 34 | [цель'] (* <- lang_ru;; *); 35 | [purpose'] (* <- lang_en;; *);; 36 | 37 | rrel_key_sc_element 38 | <- sc_node_role_relation; 39 | => nrel_main_idtf: 40 | [ключеввой sc-элемент'] (* <- lang_ru;; *); 41 | [key sc-element'] (* <- lang_en;; *);; 42 | 43 | rrel_main_idtf 44 | <- sc_node_role_relation; 45 | => nrel_main_idtf: 46 | [основной идентификатор'] (* <- lang_ru;; *); 47 | [main identifier'] (* <- lang_en;; *);; 48 | -------------------------------------------------------------------------------- /knowledge-base/specifications.scs: -------------------------------------------------------------------------------- 1 | sc_component_manager_repository 2 | <- concept_repository; 3 | -> rrel_components_specifications: ..components_addresses;; 4 | 5 | ..components_addresses 6 | <- sc_node_tuple; 7 | -> cat_reusable_component_specification 8 | (* 9 | <- concept_reusable_component_specification;; 10 | => nrel_alternative_addresses: 11 | ... 12 | (* 13 | <- sc_node_tuple;; 14 | -> rrel_1: 15 | ... 16 | (* 17 | -> [https://github.com/MksmOrlov/cat-kb-component] 18 | (* 19 | <- concept_github_url;; 20 | *);; 21 | *);; 22 | *);; 23 | *); 24 | -> part_methods_tools_specification 25 | (* 26 | <- concept_reusable_component_specification;; 27 | => nrel_alternative_addresses: 28 | ... 29 | (* 30 | <- sc_node_tuple;; 31 | -> rrel_1: 32 | ... 33 | (* 34 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_methods_tools] 35 | (* 36 | <- concept_github_url;; 37 | *);; 38 | *);; 39 | *);; 40 | *); 41 | -> part_platform_specification 42 | (* 43 | <- concept_reusable_component_specification;; 44 | => nrel_alternative_addresses: 45 | ... 46 | (* 47 | <- sc_node_tuple;; 48 | -> rrel_1: 49 | ... 50 | (* 51 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_platform/subdir_platform] 52 | (* 53 | <- concept_github_url;; 54 | *);; 55 | *);; 56 | *);; 57 | *); 58 | -> part_ui_specification 59 | (* 60 | <- concept_reusable_component_specification;; 61 | => nrel_alternative_addresses: 62 | ... 63 | (* 64 | <- sc_node_tuple;; 65 | -> rrel_1: 66 | ... 67 | (* 68 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_ui] 69 | (* 70 | <- concept_github_url;; 71 | *);; 72 | *);; 73 | *);; 74 | *); 75 | -> part_menu_of_logical_inference_specification 76 | (* 77 | <- concept_reusable_component_specification;; 78 | => nrel_alternative_addresses: 79 | ... 80 | (* 81 | <- sc_node_tuple;; 82 | -> rrel_1: 83 | ... 84 | (* 85 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_menu/menu_of_logical_inference] 86 | (* 87 | <- concept_github_url;; 88 | *);; 89 | *);; 90 | *);; 91 | *); 92 | -> part_menu_of_agent_of_finding_intersection_of_sets_specification 93 | (* 94 | <- concept_reusable_component_specification;; 95 | => nrel_alternative_addresses: 96 | ... 97 | (* 98 | <- sc_node_tuple;; 99 | -> rrel_1: 100 | ... 101 | (* 102 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_menu/menu_of_agent_of_finding_intersection_of_sets] 103 | (* 104 | <- concept_github_url;; 105 | *);; 106 | *);; 107 | *);; 108 | *); 109 | -> part_agent_of_finding_intersection_of_sets_specification 110 | (* 111 | <- concept_reusable_component_specification;; 112 | => nrel_alternative_addresses: 113 | ... 114 | (* 115 | <- sc_node_tuple;; 116 | -> rrel_1: 117 | ... 118 | (* 119 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_agents/agent_of_finding_intersection_of_sets] 120 | (* 121 | <- concept_github_url;; 122 | *);; 123 | *);; 124 | *);; 125 | *); 126 | -> part_polygons_specification 127 | (* 128 | <- concept_reusable_component_specification;; 129 | => nrel_alternative_addresses: 130 | ... 131 | (* 132 | <- sc_node_tuple;; 133 | -> rrel_1: 134 | ... 135 | (* 136 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_figure/sd_polygons] 137 | (* 138 | <- concept_github_url;; 139 | *);; 140 | *);; 141 | *);; 142 | *); 143 | -> part_triangles_specification 144 | (* 145 | <- concept_reusable_component_specification;; 146 | => nrel_alternative_addresses: 147 | ... 148 | (* 149 | <- sc_node_tuple;; 150 | -> rrel_1: 151 | ... 152 | (* 153 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_figure/sd_triangles] 154 | (* 155 | <- concept_github_url;; 156 | *);; 157 | *);; 158 | *);; 159 | *); 160 | -> lr_about_isosceles_triangle_specification 161 | (* 162 | <- concept_reusable_component_specification;; 163 | => nrel_alternative_addresses: 164 | ... 165 | (* 166 | <- sc_node_tuple;; 167 | -> rrel_1: 168 | ... 169 | (* 170 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_lr/lr_about_isosceles_triangle] 171 | (* 172 | <- concept_github_url;; 173 | *);; 174 | *);; 175 | *);; 176 | *); 177 | -> lr_about_relation_specification 178 | (* 179 | <- concept_reusable_component_specification;; 180 | => nrel_alternative_addresses: 181 | ... 182 | (* 183 | <- sc_node_tuple;; 184 | -> rrel_1: 185 | ... 186 | (* 187 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_lr/lr_about_relation] 188 | (* 189 | <- concept_github_url;; 190 | *);; 191 | *);; 192 | *);; 193 | *); 194 | -> part_figure 195 | (* 196 | <- concept_reusable_component_specification;; 197 | => nrel_alternative_addresses: 198 | ... 199 | (* 200 | <- sc_node_tuple;; 201 | -> rrel_1: 202 | ... 203 | (* 204 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_figure/part_figure] 205 | (* 206 | <- concept_github_url;; 207 | *);; 208 | *);; 209 | *);; 210 | *); 211 | -> part_lr 212 | (* 213 | <- concept_reusable_component_specification;; 214 | => nrel_alternative_addresses: 215 | ... 216 | (* 217 | <- sc_node_tuple;; 218 | -> rrel_1: 219 | ... 220 | (* 221 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_lr/part_lr] 222 | (* 223 | <- concept_github_url;; 224 | *);; 225 | *);; 226 | *);; 227 | *);; 228 | -------------------------------------------------------------------------------- /knowledge-base/types.scs: -------------------------------------------------------------------------------- 1 | sc_node_non_role_relation 2 | -> nrel_component_address; 3 | -> nrel_installation_method; 4 | -> nrel_sc_identifier; 5 | -> nrel_key_sc_element; 6 | -> nrel_purpose; 7 | -> nrel_explanation; 8 | -> nrel_authors; 9 | -> nrel_component_dependencies; 10 | -> nrel_alternative_addresses; 11 | -> nrel_repository_address;; 12 | 13 | sc_node_role_relation 14 | -> rrel_repositories; 15 | -> rrel_components; 16 | -> rrel_address; 17 | -> rrel_components_specifications; 18 | -> rrel_repositories_specifications;; 19 | 20 | sc_node_class 21 | -> concept_reusable_component; 22 | -> concept_atomic_reusable_component; 23 | -> concept_independent_reusable_component; 24 | -> concept_reusable_kb_component; 25 | -> concept_reusable_ps_component; 26 | -> concept_reusable_ui_component; 27 | -> concept_reusable_embedded_ostis_system; 28 | -> concept_reusable_dynamically_installed_component; 29 | -> concept_reusable_component_requiring_restart; 30 | -> concept_reusable_source_code_component; 31 | -> concept_reusable_component_specification; 32 | -> concept_repository; 33 | -> concept_github_url; 34 | -> concept_google_drive_url; 35 | -> concept_complex_address; 36 | -> concept_single_address; 37 | -> concept_need_to_install_components; 38 | -> sc_model_of_knowledge_base; 39 | -> sc_model_of_problem_solver; 40 | -> sc_model_of_interface; 41 | -> concept_subsystems_set;; 42 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: sc-component-manager 2 | dev_addr: 127.0.0.1:8004 3 | repo_url: https://github.com/ostis-ai/sc-component-manager 4 | edit_uri: edit/main/docs/ 5 | 6 | extra_css: 7 | - _assets/main.css 8 | extra_javascript: 9 | - _assets/main.js 10 | 11 | nav: 12 | - Home: index.md 13 | - Quick Start: quick_start.md 14 | - Usage: usage/usage.md 15 | - Build Instructions: 16 | - Quick Start for Contributors: build/quick_start.md 17 | - Build System: build/build_system.md 18 | - CMake Flags: build/cmake_flags.md 19 | - Development: 20 | - Contributing Guide: CONTRIBUTING.md 21 | - Codestyle Guide: https://ostis-ai.github.io/sc-machine/dev/codestyle/ 22 | - License: https://github.com/ostis-ai/sc-component-manager/blob/main/COPYING.MIT 23 | - Changelog: changelog.md 24 | 25 | plugins: 26 | - search: 27 | lang: en 28 | separator: '[\s\-\.]+' 29 | 30 | theme: 31 | name: material 32 | favicon: ostis-logo.png 33 | logo: ostis-logo.png 34 | palette: # Defines color schemes for light and dark modes 35 | - media: "(prefers-color-scheme: light)" 36 | scheme: default 37 | primary: indigo 38 | accent: indigo 39 | toggle: 40 | icon: material/brightness-7 41 | name: Switch to dark mode 42 | - media: "(prefers-color-scheme: dark)" 43 | scheme: slate 44 | primary: indigo 45 | accent: indigo 46 | toggle: 47 | icon: material/brightness-4 48 | name: Switch to light mode 49 | features: 50 | - navigation.instant # Enables instant loading of pages 51 | - navigation.tracking # Automatically focuses active section in sidebar 52 | - navigation.tabs # Adds top-level sections as tabs 53 | - navigation.sections # Renders top-level sections as groups in sidebar 54 | - navigation.expand # Expands all collapsible sections by default 55 | - navigation.top # Adds a "back to top" button 56 | - search.suggest # Displays search suggestions 57 | - search.highlight # Highlights search terms on result page 58 | - content.action.edit # Adds links to edit doc files 59 | - content.tabs.link # Shares link when clicking on a tab 60 | - content.code.copy # Adds a copy button to code blocks 61 | 62 | markdown_extensions: 63 | - admonition # Allows creation of call-out boxes (e.g., notes, warnings) 64 | - codehilite 65 | - md_in_html # Allows Markdown syntax inside HTML blocks 66 | - pymdownx.highlight: # Enhances code block highlighting 67 | anchor_linenums: true 68 | - pymdownx.inlinehilite # Enables inline code highlighting 69 | - pymdownx.details # Allows creating collapsible elements 70 | - pymdownx.superfences # Enables advanced fenced code blocks 71 | -------------------------------------------------------------------------------- /sc-component-manager.ini: -------------------------------------------------------------------------------- 1 | [sc-memory] 2 | max_loaded_segments = 1000 3 | 4 | limit_max_threads_by_max_physical_cores = true 5 | max_events_and_agents_threads = 32 6 | 7 | dump_memory = false 8 | dump_memory_period = 3600 9 | dump_memory_statistics = false 10 | dump_memory_statistics_period = 1200 11 | 12 | storage = kb.bin 13 | 14 | log_type = Console 15 | log_file = sc-memory.log 16 | log_level = Info 17 | 18 | init_memory_generated_upload = false 19 | init_memory_generated_structure = basic_ontology_structure 20 | 21 | max_strings_channels = 1000 22 | max_strings_channel_size = 100000 23 | max_searchable_string_size = 1000 24 | term_separators = " _" 25 | 26 | [sc-component-manager] 27 | knowledge_base_components_path = knowledge-base 28 | problem_solver_components_path = problem-solver 29 | interface_components_path = interface 30 | -------------------------------------------------------------------------------- /scripts/clang/check_formatting.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | cmake --preset release-with-tests-conan -DSC_CLANG_FORMAT_CODE=ON 5 | cmake --build --preset release --target clangformat_check 6 | -------------------------------------------------------------------------------- /scripts/clang/format_code.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | cmake --preset release-with-tests-conan -DSC_CLANG_FORMAT_CODE=ON 5 | cmake --build --preset release --target clangformat 6 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SC_COMPONENT_MANAGER_SRC "${CMAKE_SOURCE_DIR}/src") 2 | 3 | add_subdirectory(manager/agents) 4 | add_subdirectory(manager/console-interface) 5 | 6 | file(GLOB SOURCES CONFIGURE_DEPENDS "module/*.cpp" "module/*.hpp") 7 | 8 | add_library(sc-component-manager SHARED ${SOURCES}) 9 | target_link_libraries(sc-component-manager 10 | LINK_PRIVATE common-lib 11 | LINK_PRIVATE console-interface 12 | ) 13 | set_target_properties(sc-component-manager PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) 14 | 15 | if(${SC_CLANG_FORMAT_CODE}) 16 | target_clangformat_setup(sc-component-manager) 17 | endif() 18 | -------------------------------------------------------------------------------- /src/manager/agents/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(AGENTS_SRC "${SC_COMPONENT_MANAGER_SRC}/agents") 2 | 3 | add_subdirectory(common-lib) 4 | add_subdirectory(search-module) 5 | add_subdirectory(install-module) 6 | add_subdirectory(init-module) 7 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES CONFIGURE_DEPENDS 2 | "src/*.hpp" "src/*.cpp" 3 | "include/common/*.hpp" "include/common/*.cpp" 4 | ) 5 | 6 | # Define common-lib as an object library instead of a shared library 7 | # because it contains utility functions that are tightly coupled with other parts of the project only. 8 | # This approach avoids the need for dynamic loading and path management. 9 | add_library(common-lib OBJECT ${SOURCES}) 10 | target_link_libraries(common-lib 11 | LINK_PUBLIC sc-machine::sc-agents-common 12 | LINK_PUBLIC sc-machine::sc-builder-lib 13 | LINK_PUBLIC sc-machine::sc-config 14 | ) 15 | target_include_directories(common-lib 16 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src 17 | PUBLIC $ 18 | PUBLIC $ 19 | ) 20 | target_compile_options(common-lib PUBLIC -fPIC) 21 | 22 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ 23 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 24 | ) 25 | 26 | if(${SC_CLANG_FORMAT_CODE}) 27 | target_clangformat_setup(common-lib) 28 | endif() 29 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/command_constants.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | class SpecificationConstants 14 | { 15 | public: 16 | static std::string const SPECIFICATION_FILENAME; 17 | static std::string const SCS_EXTENSION; 18 | static char const DIRECTORY_DELIMITER; 19 | }; 20 | 21 | class GoogleDriveConstants 22 | { 23 | public: 24 | static std::string const GOOGLE_DRIVE_PREFIX; 25 | static std::string const GOOGLE_DRIVE_FILE_PREFIX; 26 | static std::string const GOOGLE_DRIVE_DOWNLOAD_PREFIX; 27 | static std::string const GOOGLE_DRIVE_POSTFIX; 28 | }; 29 | 30 | class GitHubConstants 31 | { 32 | public: 33 | static std::string const GIT_CLONE; 34 | static std::string const FLAG_NO_CHECKOUT; 35 | static std::string const FLAG_DEPTH; 36 | static std::string const FLAG_FILTER_TREE; 37 | static std::string const GIT_SPARSE_CHECKOUT; 38 | static std::string const GIT_CHECKOUT; 39 | static std::string const RAW_GITHUB_PREFIX; 40 | static std::string const GITHUB_PREFIX; 41 | static std::string const TREE; 42 | static std::string const GREP_DEFAULT_BRANCH_COMMAND; 43 | static std::string const GITHUB_DOWNLOAD_FILE_COMMAND_PREFIX; 44 | static std::string const GITHUB_GET_DEFAULT_BRANCH_COMMAND_PREFIX; 45 | }; 46 | 47 | class CommandConstants 48 | { 49 | public: 50 | static std::string const COMPONENTS_COMMAND_PREFIX; 51 | static std::string const COMPONENTS_COMMAND_INIT; 52 | static std::string const COMPONENTS_COMMAND_INSTALL; 53 | static std::string const COMPONENTS_COMMAND_SEARCH; 54 | static std::map COMMAND_MAP; 55 | }; 56 | 57 | class CommandsConstantsFlags 58 | { 59 | public: 60 | static std::string const IDTF; 61 | static std::string const SET; 62 | static std::string const EXPLANATION; 63 | static std::string const AUTHOR; 64 | static std::string const CLASS; 65 | static std::string const NOTE; 66 | static std::string const PURPOSE; 67 | static std::string const KEY; 68 | static std::string const MAIN_ID; 69 | }; 70 | 71 | class PathKeysOfConfigPath 72 | { 73 | public: 74 | static std::string const KB_PATH; 75 | static std::string const PS_PATH; 76 | static std::string const UI_PATH; 77 | }; 78 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/common_utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace common_utils 14 | { 15 | class CommonUtils 16 | { 17 | public: 18 | static std::map managerParametersWithAgentRelations; 19 | static std::map> mainFlagWithSubFlags; 20 | static std::vector> componentsClasses; 21 | 22 | static void InitParametersMap(); 23 | static void ClearParametersMap(); 24 | static bool TranslateFromStringToScMemory( 25 | ScMemoryContext & context, 26 | ScAddr const & actionAddr, 27 | std::map> const & commandParameters); 28 | static ScAddr GetMyselfDecompositionAddr(ScMemoryContext & context); 29 | static void CreateMyselfDecomposition(ScMemoryContext & context); 30 | static ScAddrUnorderedSet GetComponentsToInstall(ScMemoryContext & context, ScAddr const & actionAddr); 31 | static std::map GetSetElements(ScMemoryContext & context, ScAddr const & setAddr); 32 | static std::map GetElementsLinksOfSet(ScMemoryContext & context, ScAddr const & setAddr); 33 | static std::map> GetCommandParameters( 34 | ScMemoryContext & context, 35 | ScAddr const & actionAddr); 36 | static ScAddr GetSubsystemDecompositionAddr(ScMemoryContext & context, ScAddr const & component); 37 | static bool CheckIfInstalled(ScMemoryContext & context, ScAddr const & component); 38 | static ScAddr GetComponentBySpecification(ScMemoryContext & context, ScAddr const & specification); 39 | static bool CheckIfFullMyselfDecompositionExists(ScMemoryContext & context); 40 | }; 41 | } // namespace common_utils 42 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/downloader.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | class Downloader 12 | { 13 | public: 14 | virtual bool DownloadFile( 15 | std::string const & downloadPath, 16 | std::string const & urlAddress, 17 | std::string const & pathPostfix) = 0; 18 | 19 | virtual bool DownloadRepository(std::string const & downloadPath, std::string const & urlAddress) = 0; 20 | 21 | virtual ~Downloader() = default; 22 | }; 23 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/downloader_google_drive.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "common/downloader.hpp" 12 | 13 | class DownloaderGoogleDrive : public Downloader 14 | { 15 | public: 16 | bool DownloadFile(std::string const & urlAddress, std::string const & downloadPath, std::string const & pathPostfix) 17 | override 18 | { 19 | // std::string const gDriveFileId = componentPath.substr( 20 | // GoogleDriveConstants::GOOGLE_DRIVE_FILE_PREFIX.size(), 21 | // componentPath.size() - GoogleDriveConstants::GOOGLE_DRIVE_FILE_PREFIX.size() - 22 | // GoogleDriveConstants::GOOGLE_DRIVE_POSTFIX.size()); 23 | // std::string const gDriveInstallCommandParameter = " -O " + SpecificationConstants::SPECIFICATION_FILENAME; 24 | // std::string const gDriveInstallCommand = "cd " + specificationsPath + " ; wget --no-check-certificate " + "\'" + 25 | // GoogleDriveConstants::GOOGLE_DRIVE_DOWNLOAD_PREFIX + gDriveFileId + "\'" 26 | // + gDriveInstallCommandParameter; 27 | 28 | // ScExec exec{{gDriveInstallCommand}}; 29 | return false; 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/downloader_handler.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "common/sc_component_manager_keynodes.hpp" 15 | #include "common/downloader.hpp" 16 | #include "common/downloader_git.hpp" 17 | #include "common/downloader_google_drive.hpp" 18 | 19 | class DownloaderHandler 20 | { 21 | public: 22 | explicit DownloaderHandler(std::string specificationsPath) 23 | : m_downloadDir(std::move(specificationsPath)) 24 | { 25 | m_downloader = std::make_shared(); 26 | } 27 | 28 | bool DownloadSpecification(ScMemoryContext * context, ScAddr const & componentSpecificationAddr); 29 | bool DownloadComponent(ScMemoryContext * context, ScAddr const & nodeAddr); 30 | 31 | void setDownloadDir(std::string const & downloadDir); 32 | 33 | protected: 34 | std::string m_downloadDir; 35 | std::shared_ptr m_downloader; 36 | 37 | static ScAddr getDownloadableClass(ScMemoryContext * context, ScAddr const & nodeAddr); 38 | static ScAddr getUrlLinkClass(ScMemoryContext * context, ScAddr const & linkAddr); 39 | }; 40 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/repository_url_parser.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "common/command_constants.hpp" 12 | 13 | class RepositoryUrlParser 14 | { 15 | public: 16 | void Parse(std::string const & repositoryUrlAddress); 17 | 18 | std::string GetUrlAddress(); 19 | std::string GetUsername(); 20 | std::string GetRepositoryName(); 21 | std::string GetDirectoryName(); 22 | std::string GetRepositoryUrl(); 23 | std::string GetBranchName(); 24 | 25 | protected: 26 | std::string m_urlAddress; 27 | std::string m_username; 28 | std::string m_repositoryName; 29 | std::string m_directoryName; 30 | std::string m_repositoryUrl; 31 | std::string m_branchName; 32 | 33 | std::string ParseUsername(); 34 | std::string ParseRepositoryName(); 35 | std::string ParseDirectoryName(); 36 | std::string ParseBranchName(); 37 | }; 38 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/sc_component_manager_command.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include "sc-memory/sc_agent_context.hpp" 13 | 14 | using CommandParameters = std::map>; 15 | 16 | class ScComponentManagerCommand 17 | { 18 | public: 19 | virtual ScAddrUnorderedSet Execute(ScAgentContext * context, ScAddr const & actionAddr) = 0; 20 | 21 | virtual ~ScComponentManagerCommand() = default; 22 | }; 23 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/sc_component_manager_keynodes.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace keynodes 12 | { 13 | class ScComponentManagerKeynodes : public ScKeynodes 14 | { 15 | public: 16 | static inline ScKeynode const myself{"myself", ScType::ConstNode}; 17 | 18 | static inline ScKeynode const concept_reusable_component{"concept_reusable_component", ScType::ConstNodeClass}; 19 | 20 | static inline ScKeynode const current_components_to_install{ 21 | "concept_current_components_to_install", 22 | ScType::ConstNode}; 23 | 24 | static inline ScKeynode const concept_reusable_kb_component{"concept_reusable_kb_component", ScType::ConstNodeClass}; 25 | 26 | static inline ScKeynode const concept_reusable_ps_component{"concept_reusable_ps_component", ScType::ConstNodeClass}; 27 | 28 | static inline ScKeynode const concept_reusable_ui_component{"concept_reusable_ui_component", ScType::ConstNodeClass}; 29 | 30 | static inline ScKeynode const concept_reusable_embedded_ostis_system{ 31 | "concept_reusable_embedded_ostis_system", 32 | ScType::ConstNodeClass}; 33 | 34 | static inline ScKeynode const concept_repository{"concept_repository", ScType::ConstNodeClass}; 35 | 36 | static inline ScKeynode const concept_reusable_component_specification{ 37 | "concept_reusable_component_specification", 38 | ScType::ConstNodeClass}; 39 | 40 | static inline ScKeynode const concept_single_address{"concept_single_address", ScType::ConstNodeClass}; 41 | 42 | static inline ScKeynode const concept_complex_address{"concept_complex_address", ScType::ConstNodeClass}; 43 | 44 | static inline ScKeynode const concept_github_url{"concept_github_url", ScType::ConstNodeClass}; 45 | 46 | static inline ScKeynode const concept_need_to_install_components{ 47 | "concept_need_to_install_components", 48 | ScType::ConstNodeClass}; 49 | 50 | static inline ScKeynode const concept_google_drive_url{"concept_google_drive_url", ScType::ConstNodeClass}; 51 | 52 | static inline ScKeynode const sc_model_of_knowledge_base{"sc_model_of_knowledge_base", ScType::ConstNodeClass}; 53 | 54 | static inline ScKeynode const sc_model_of_interface{"sc_model_of_interface", ScType::ConstNodeClass}; 55 | 56 | static inline ScKeynode const sc_model_of_problem_solver{"sc_model_of_problem_solver", ScType::ConstNodeClass}; 57 | 58 | static inline ScKeynode const concept_subsystems_set{"concept_subsystems_set", ScType::ConstNodeClass}; 59 | 60 | static inline ScKeynode const rrel_repositories_specifications{ 61 | "rrel_repositories_specifications", 62 | ScType::ConstNodeRole}; 63 | 64 | static inline ScKeynode const rrel_components_specifications{"rrel_components_specifications", ScType::ConstNodeRole}; 65 | 66 | static inline ScKeynode const nrel_authors{"nrel_authors", ScType::ConstNodeNonRole}; 67 | 68 | static inline ScKeynode const nrel_explanation{"nrel_explanation", ScType::ConstNodeNonRole}; 69 | 70 | static inline ScKeynode const nrel_note{"nrel_note", ScType::ConstNodeNonRole}; 71 | 72 | static inline ScKeynode const nrel_purpose{"nrel_purpose", ScType::ConstNodeNonRole}; 73 | 74 | static inline ScKeynode const nrel_key_sc_element{"nrel_key_sc_element", ScType::ConstNodeNonRole}; 75 | 76 | static inline ScKeynode const nrel_component_address{"nrel_component_address", ScType::ConstNodeNonRole}; 77 | 78 | static inline ScKeynode const nrel_component_dependencies{"nrel_component_dependencies", ScType::ConstNodeNonRole}; 79 | 80 | static inline ScKeynode const nrel_installation_method{"nrel_installation_method", ScType::ConstNodeNonRole}; 81 | 82 | static inline ScKeynode const nrel_alternative_addresses{"nrel_alternative_addresses", ScType::ConstNodeNonRole}; 83 | 84 | static inline ScKeynode const nrel_repository_address{"nrel_repository_address", ScType::ConstNodeNonRole}; 85 | 86 | static inline ScKeynode const nrel_installation_script{"nrel_installation_script", ScType::ConstNodeNonRole}; 87 | 88 | static inline ScKeynode const nrel_decomposition{"nrel_decomposition", ScType::ConstNodeNonRole}; 89 | 90 | static inline ScKeynode const nrel_ostis_system_decomposition{ 91 | "nrel_ostis_system_decomposition", 92 | ScType::ConstNodeNonRole}; 93 | 94 | static inline ScKeynode const action_components_init{"action_components_init", ScType::ConstNodeClass}; 95 | 96 | static inline ScKeynode const action_components_search{"action_components_search", ScType::ConstNodeClass}; 97 | 98 | static inline ScKeynode const action_components_install{"action_components_install", ScType::ConstNodeClass}; 99 | 100 | static inline ScKeynode const rrel_author{"rrel_author", ScType::ConstNodeRole}; 101 | 102 | static inline ScKeynode const rrel_class{"rrel_class", ScType::ConstNodeRole}; 103 | 104 | static inline ScKeynode const rrel_sets{"rrel_sets", ScType::ConstNodeRole}; 105 | 106 | static inline ScKeynode const rrel_components{"rrel_components", ScType::ConstNodeRole}; 107 | 108 | static inline ScKeynode const rrel_explanation{"rrel_explanation", ScType::ConstNodeRole}; 109 | 110 | static inline ScKeynode const rrel_identifier{"rrel_identifier", ScType::ConstNodeRole}; 111 | 112 | static inline ScKeynode const rrel_note{"rrel_note", ScType::ConstNodeRole}; 113 | 114 | static inline ScKeynode const rrel_purpose{"rrel_purpose", ScType::ConstNodeRole}; 115 | 116 | static inline ScKeynode const rrel_main_idtf{"rrel_main_idtf", ScType::ConstNodeRole}; 117 | }; 118 | 119 | } // namespace keynodes 120 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/include/common/sc_component_utils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "common/common_utils.hpp" 12 | 13 | using namespace common_utils; 14 | 15 | namespace componentUtils 16 | { 17 | class SearchUtils 18 | { 19 | public: 20 | static ScAddr GetComponentAddress(ScMemoryContext * context, ScAddr const & componentAddr); 21 | 22 | static ScAddrUnorderedSet GetComponentDependencies(ScMemoryContext * context, ScAddr const & componentAddr); 23 | 24 | static ScAddr GetComponentInstallationMethod(ScMemoryContext * context, ScAddr const & componentAddr); 25 | 26 | static ScAddrVector GetSpecificationAddress(ScMemoryContext * context, ScAddr const & componentSpecificationAddr); 27 | 28 | static ScAddr GetRepositoryAddress(ScMemoryContext * context, ScAddr const & repositoryAddr); 29 | 30 | static ScAddrVector GetNeedToInstallComponents(ScMemoryContext * context); 31 | }; 32 | 33 | class InstallUtils 34 | { 35 | public: 36 | static bool IsReusable(ScMemoryContext * context, ScAddr const & componentAddr); 37 | 38 | static bool IsComponentInstallationMethodValid(ScMemoryContext * context, ScAddr const & componentAddr); 39 | 40 | static std::string GetComponentAddressStr(ScMemoryContext * context, ScAddr const & componentAddr); 41 | 42 | static std::string GetComponentDirName( 43 | ScMemoryContext * context, 44 | ScAddr const & componentAddr, 45 | std::string const & specificationsPath); 46 | 47 | static std::vector GetInstallScripts(ScMemoryContext * context, ScAddr const & componentAddr); 48 | }; 49 | 50 | class LoadUtils 51 | { 52 | public: 53 | static bool LoadScsFilesInDir( 54 | ScMemoryContext * context, 55 | std::string const & dirPath, 56 | std::string const & excludedFiles = ""); 57 | }; 58 | 59 | } // namespace componentUtils 60 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/src/command_constants.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "common/command_constants.hpp" 8 | 9 | std::string const SpecificationConstants::SPECIFICATION_FILENAME = "specification.scs"; 10 | std::string const SpecificationConstants::SCS_EXTENSION = ".scs"; 11 | char const SpecificationConstants::DIRECTORY_DELIMITER = '/'; 12 | 13 | std::string const GitHubConstants::GIT_CLONE = "git clone"; 14 | std::string const GitHubConstants::RAW_GITHUB_PREFIX = "https://raw.githubusercontent.com/"; 15 | std::string const GitHubConstants::GITHUB_PREFIX = "https://github.com/"; 16 | std::string const GitHubConstants::TREE = "tree"; 17 | std::string const GitHubConstants::GREP_DEFAULT_BRANCH_COMMAND = 18 | R"( | grep -w "default_branch" | cut -d ":" -f 2 | tr -d '," ')"; 19 | std::string const GitHubConstants::GITHUB_DOWNLOAD_FILE_COMMAND_PREFIX = 20 | "curl -H 'Accept: application/vnd.github.v3.raw' -o "; 21 | std::string const GitHubConstants::GITHUB_GET_DEFAULT_BRANCH_COMMAND_PREFIX = 22 | "curl -s -H \"Accept: application/vnd.github.v3+json\" https://api.github.com/repos/"; 23 | std::string const GitHubConstants::FLAG_NO_CHECKOUT = "--no-checkout"; 24 | std::string const GitHubConstants::FLAG_DEPTH = "--depth="; 25 | std::string const GitHubConstants::FLAG_FILTER_TREE = "--filter=tree:"; 26 | std::string const GitHubConstants::GIT_SPARSE_CHECKOUT = "git sparse-checkout set --no-cone"; 27 | std::string const GitHubConstants::GIT_CHECKOUT = "git checkout"; 28 | 29 | std::string const GoogleDriveConstants::GOOGLE_DRIVE_PREFIX = "https://drive.google.com/"; 30 | std::string const GoogleDriveConstants::GOOGLE_DRIVE_FILE_PREFIX = "https://drive.google.com/file/d/"; 31 | std::string const GoogleDriveConstants::GOOGLE_DRIVE_DOWNLOAD_PREFIX = "https://docs.google.com/uc?export=download&id="; 32 | std::string const GoogleDriveConstants::GOOGLE_DRIVE_POSTFIX = "/view?usp=sharing"; 33 | 34 | std::map CommandConstants::COMMAND_MAP = { 35 | {"ci", "components init"}, 36 | {"comp init", "components init"}, 37 | {"cs", "components search"}, 38 | {"comp search", "components search"}, 39 | {"comp s", "components search"}, 40 | {"cinst", "components install"}, 41 | {"comp inst", "components install"}}; 42 | std::string const CommandConstants::COMPONENTS_COMMAND_PREFIX = "components"; 43 | std::string const CommandConstants::COMPONENTS_COMMAND_INIT = "init"; 44 | std::string const CommandConstants::COMPONENTS_COMMAND_INSTALL = "install"; 45 | std::string const CommandConstants::COMPONENTS_COMMAND_SEARCH = "search"; 46 | 47 | std::string const CommandsConstantsFlags::IDTF = "idtf"; 48 | std::string const CommandsConstantsFlags::SET = "set"; 49 | std::string const CommandsConstantsFlags::EXPLANATION = "explanation"; 50 | std::string const CommandsConstantsFlags::CLASS = "class"; 51 | std::string const CommandsConstantsFlags::AUTHOR = "author"; 52 | std::string const CommandsConstantsFlags::NOTE = "note"; 53 | std::string const CommandsConstantsFlags::PURPOSE = "purpose"; 54 | std::string const CommandsConstantsFlags::KEY = "key"; 55 | std::string const CommandsConstantsFlags::MAIN_ID = "main-id"; 56 | 57 | std::string const PathKeysOfConfigPath::KB_PATH = "knowledge_base_components_path"; 58 | std::string const PathKeysOfConfigPath::PS_PATH = "problem_solver_components_path"; 59 | std::string const PathKeysOfConfigPath::UI_PATH = "interface_components_path"; 60 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/src/downloader_handler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include 8 | 9 | #include "common/sc_component_utils.hpp" 10 | #include "common/downloader_handler.hpp" 11 | 12 | /** 13 | * @brief Get class of download node 14 | * @param context current sc-memory context 15 | * @param nodeAddr sc-addr of node to download 16 | * @return Sc-addr of node class if it can be downloaded, 17 | * return empty sc-addr if class was not found 18 | */ 19 | ScAddr DownloaderHandler::getDownloadableClass(ScMemoryContext * context, ScAddr const & nodeAddr) 20 | { 21 | ScAddr downloadableClass; 22 | 23 | ScAddrVector const downloadableClasses = { 24 | keynodes::ScComponentManagerKeynodes::concept_repository, 25 | keynodes::ScComponentManagerKeynodes::concept_reusable_component, 26 | keynodes::ScComponentManagerKeynodes::concept_reusable_component_specification}; 27 | 28 | for (ScAddr const & currentClass : downloadableClasses) 29 | { 30 | if (context->CheckConnector(currentClass, nodeAddr, ScType::ConstPermPosArc)) 31 | { 32 | downloadableClass = currentClass; 33 | } 34 | } 35 | 36 | return downloadableClass; 37 | } 38 | 39 | /** 40 | * @brief Get class of address sc-link 41 | * @param context current sc-memory context 42 | * @param linkAddr sc-addr of sc-link with address 43 | * @return Sc-addr of node class in which sc-link is 44 | * and this class is supported for downloading, 45 | * return empty sc-addr if class was not found 46 | */ 47 | ScAddr DownloaderHandler::getUrlLinkClass(ScMemoryContext * context, ScAddr const & linkAddr) 48 | { 49 | ScAddr urlLinkClass; 50 | 51 | ScAddrVector const downloadableUrls = { 52 | keynodes::ScComponentManagerKeynodes::concept_github_url, 53 | keynodes::ScComponentManagerKeynodes::concept_google_drive_url}; 54 | 55 | for (ScAddr const & currentClass : downloadableUrls) 56 | { 57 | if (context->CheckConnector(currentClass, linkAddr, ScType::ConstPermPosArc)) 58 | { 59 | urlLinkClass = currentClass; 60 | } 61 | } 62 | 63 | return urlLinkClass; 64 | } 65 | 66 | bool DownloaderHandler::DownloadSpecification(ScMemoryContext * context, ScAddr const & componentSpecificationAddr) 67 | { 68 | ScAddrVector nodeAddressLinkAddrs; 69 | 70 | try 71 | { 72 | nodeAddressLinkAddrs = componentUtils::SearchUtils::GetSpecificationAddress(context, componentSpecificationAddr); 73 | } 74 | catch (utils::ScException const & exception) 75 | { 76 | SC_LOG_ERROR(exception.Message()); 77 | SC_LOG_ERROR(exception.Description()); 78 | } 79 | 80 | std::string urlAddress; 81 | std::string const & nodeSystemIdentifier = context->GetElementSystemIdentifier(componentSpecificationAddr); 82 | std::string const & downloadPath = m_downloadDir + SpecificationConstants::DIRECTORY_DELIMITER + nodeSystemIdentifier; 83 | for (ScAddr const & currentAddressLinkAddr : nodeAddressLinkAddrs) 84 | { 85 | ScAddr const & linkAddressClassAddr = getUrlLinkClass(context, currentAddressLinkAddr); 86 | if (!context->IsElement(linkAddressClassAddr)) 87 | { 88 | continue; 89 | } 90 | 91 | if (linkAddressClassAddr == keynodes::ScComponentManagerKeynodes::concept_github_url) 92 | { 93 | context->GetLinkContent(currentAddressLinkAddr, urlAddress); 94 | m_downloader->DownloadFile(downloadPath, urlAddress, SpecificationConstants::SPECIFICATION_FILENAME); 95 | } 96 | } 97 | 98 | return true; 99 | } 100 | 101 | bool DownloaderHandler::DownloadComponent(ScMemoryContext * context, ScAddr const & componentAddr) 102 | { 103 | std::string urlAddress; 104 | 105 | ScAddr const & componentAddress = componentUtils::SearchUtils::GetComponentAddress(context, componentAddr); 106 | context->GetLinkContent(componentAddress, urlAddress); 107 | 108 | m_downloader->DownloadRepository(m_downloadDir, urlAddress); 109 | 110 | return true; 111 | } 112 | 113 | void DownloaderHandler::setDownloadDir(std::string const & downloadDir) 114 | { 115 | m_downloadDir = downloadDir; 116 | } 117 | -------------------------------------------------------------------------------- /src/manager/agents/common-lib/src/repository_url_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "common/repository_url_parser.hpp" 8 | 9 | void RepositoryUrlParser::Parse(std::string const & repositoryUrlAddress) 10 | { 11 | m_urlAddress = repositoryUrlAddress; 12 | m_username = ParseUsername(); 13 | m_repositoryName = ParseRepositoryName(); 14 | m_branchName = ParseBranchName(); 15 | m_directoryName = ParseDirectoryName(); 16 | } 17 | 18 | // Get username from the url. For example "MksmOrlov" from https://github.com/MksmOrlov/ostis-kb-lib 19 | std::string RepositoryUrlParser::ParseUsername() 20 | { 21 | std::string username; 22 | size_t const usernameRepositoryNamePosition = 23 | m_urlAddress.find(GitHubConstants::GITHUB_PREFIX) + GitHubConstants::GITHUB_PREFIX.size(); 24 | if (usernameRepositoryNamePosition == std::string::npos) 25 | { 26 | return username; 27 | } 28 | std::string const componentUsernameRepositoryName = m_urlAddress.substr(usernameRepositoryNamePosition); 29 | 30 | size_t const usernameRepositoryNameDelimiter = 31 | componentUsernameRepositoryName.find(SpecificationConstants::DIRECTORY_DELIMITER); 32 | if (usernameRepositoryNameDelimiter == std::string::npos) 33 | { 34 | return username; 35 | } 36 | username = componentUsernameRepositoryName.substr(0, usernameRepositoryNameDelimiter); 37 | return username; 38 | } 39 | 40 | // Get repository name from the url. For example "ostis-kb-lib" from https://github.com/MksmOrlov/ostis-kb-lib 41 | std::string RepositoryUrlParser::ParseRepositoryName() 42 | { 43 | std::string repositoryName; 44 | size_t const usernameStartPosition = m_urlAddress.find(m_username); 45 | if (usernameStartPosition == std::string::npos) 46 | { 47 | return repositoryName; 48 | } 49 | 50 | size_t const repositoryNameStartPosition = 51 | m_urlAddress.find(SpecificationConstants::DIRECTORY_DELIMITER, usernameStartPosition) + 1; 52 | if (repositoryNameStartPosition == std::string::npos || repositoryNameStartPosition == 0) 53 | { 54 | return repositoryName; 55 | } 56 | size_t const repositoryNameEndPosition = 57 | m_urlAddress.find(SpecificationConstants::DIRECTORY_DELIMITER, repositoryNameStartPosition + 1); 58 | m_repositoryUrl = m_urlAddress.substr(0, repositoryNameEndPosition); 59 | 60 | if (repositoryNameEndPosition == std::string::npos) 61 | { 62 | repositoryName = m_urlAddress.substr(repositoryNameStartPosition); 63 | } 64 | else 65 | { 66 | repositoryName = 67 | m_urlAddress.substr(repositoryNameStartPosition, repositoryNameEndPosition - repositoryNameStartPosition); 68 | } 69 | 70 | return repositoryName; 71 | } 72 | 73 | // Get branch name from the url. For example "main" from 74 | // https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_methods_tools 75 | std::string RepositoryUrlParser::ParseBranchName() 76 | { 77 | std::string branchName; 78 | size_t const treeStartPosition = m_urlAddress.find(GitHubConstants::TREE); 79 | if (treeStartPosition == std::string::npos) 80 | { 81 | return branchName; 82 | } 83 | 84 | size_t const branchNameStartPosition = 85 | m_urlAddress.find(SpecificationConstants::DIRECTORY_DELIMITER, treeStartPosition) + 1; 86 | if (branchNameStartPosition == std::string::npos || branchNameStartPosition == 0) 87 | { 88 | return branchName; 89 | } 90 | 91 | size_t const branchNameEndPosition = 92 | m_urlAddress.find(SpecificationConstants::DIRECTORY_DELIMITER, branchNameStartPosition); 93 | if (branchNameEndPosition == std::string::npos || branchNameEndPosition == 0) 94 | { 95 | return branchName; 96 | } 97 | 98 | branchName = m_urlAddress.substr(branchNameStartPosition, branchNameEndPosition - branchNameStartPosition); 99 | return branchName; 100 | } 101 | 102 | // Get directory name from the url. For example "part_methods_tools" from 103 | // https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_methods_tools 104 | std::string RepositoryUrlParser::ParseDirectoryName() 105 | { 106 | std::string directoryName; 107 | size_t const repositoryNameStartPosition = m_urlAddress.find(m_branchName); 108 | if (repositoryNameStartPosition == std::string::npos || repositoryNameStartPosition == 0) 109 | { 110 | return directoryName; 111 | } 112 | 113 | size_t const directoryNameStartPosition = 114 | m_urlAddress.find(SpecificationConstants::DIRECTORY_DELIMITER, repositoryNameStartPosition) + 1; 115 | if (directoryNameStartPosition == std::string::npos || directoryNameStartPosition == 0) 116 | { 117 | return directoryName; 118 | } 119 | 120 | directoryName = m_urlAddress.substr(directoryNameStartPosition); 121 | return directoryName; 122 | } 123 | 124 | std::string RepositoryUrlParser::GetUrlAddress() 125 | { 126 | return m_urlAddress; 127 | } 128 | 129 | std::string RepositoryUrlParser::GetUsername() 130 | { 131 | return m_username; 132 | } 133 | 134 | std::string RepositoryUrlParser::GetRepositoryName() 135 | { 136 | return m_repositoryName; 137 | } 138 | 139 | std::string RepositoryUrlParser::GetDirectoryName() 140 | { 141 | return m_directoryName; 142 | } 143 | 144 | std::string RepositoryUrlParser::GetRepositoryUrl() 145 | { 146 | return m_repositoryUrl; 147 | } 148 | 149 | std::string RepositoryUrlParser::GetBranchName() 150 | { 151 | return m_branchName; 152 | } 153 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES CONFIGURE_DEPENDS 2 | "agent/*.hpp" "agent/*.cpp" 3 | "module/*.hpp" "module/*.cpp" 4 | "utils/*.hpp" "utils/*.cpp" 5 | ) 6 | 7 | add_library(init-module SHARED ${SOURCES}) 8 | target_link_libraries(init-module LINK_PUBLIC common-lib) 9 | target_include_directories(init-module PRIVATE ${CMAKE_CURRENT_LIST_DIR}) 10 | set_target_properties(init-module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) 11 | 12 | if(${SC_CLANG_FORMAT_CODE}) 13 | target_clangformat_setup(init-module) 14 | endif() 15 | 16 | if(${SC_BUILD_TESTS}) 17 | set(INIT_MODULE_SRC ${CMAKE_CURRENT_SOURCE_DIR}) 18 | add_subdirectory(test) 19 | endif() 20 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/agent/sc_component_manager_agent_init.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_component_manager_agent_init.hpp" 8 | 9 | #include 10 | 11 | #include "utils/sc_component_manager_command_init.hpp" 12 | 13 | using namespace initModule; 14 | using namespace keynodes; 15 | 16 | ScResult ScComponentManagerInitAgent::DoProgram(ScAction & action) 17 | { 18 | ScConfig config{ScMemory::ms_configPath, {PathKeysOfConfigPath::KB_PATH}}; 19 | ScConfigGroup configManager = config["sc-component-manager"]; 20 | 21 | ScComponentManagerCommandInit command = ScComponentManagerCommandInit(configManager[PathKeysOfConfigPath::KB_PATH]); 22 | 23 | ScAddrUnorderedSet const & specifications = command.Execute(&m_context, action); 24 | ScStructure result = m_context.GenerateStructure(); 25 | for (auto const & specification : specifications) 26 | result << specification; 27 | action.SetResult(result); 28 | 29 | return action.FinishSuccessfully(); 30 | } 31 | 32 | ScAddr ScComponentManagerInitAgent::GetActionClass() const 33 | { 34 | return keynodes::ScComponentManagerKeynodes::action_components_init; 35 | } 36 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/agent/sc_component_manager_agent_init.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace initModule 12 | { 13 | class ScComponentManagerInitAgent : public ScActionInitiatedAgent 14 | { 15 | public: 16 | ScAddr GetActionClass() const override; 17 | 18 | ScResult DoProgram(ScAction & action) override; 19 | }; 20 | } // namespace initModule 21 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/module/init_module.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "init_module.hpp" 8 | 9 | #include "agent/sc_component_manager_agent_init.hpp" 10 | 11 | using namespace initModule; 12 | 13 | SC_MODULE_REGISTER(InitModule)->Agent(); 14 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/module/init_module.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace initModule 12 | { 13 | class InitModule : public ScModule 14 | { 15 | }; 16 | } // namespace initModule 17 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units 2 | NAME init-module-tests 3 | DEPENDS init-module 4 | INCLUDES ${INIT_MODULE_SRC} 5 | ) 6 | 7 | if(${SC_CLANG_FORMAT_CODE}) 8 | target_clangformat_setup(init-module-tests) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/test/test-structures/action_components_init.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_init;; 4 | 5 | sc_component_manager_repository 6 | <- concept_repository; 7 | -> rrel_components_specifications: ..components_addresses; 8 | -> rrel_repositories_specifications: ..repositories_addresses;; 9 | 10 | ..components_addresses 11 | <- sc_node_tuple; 12 | -> part_platform_spec 13 | (* 14 | <- sc_node_struct;; 15 | <- concept_reusable_component_specification;; 16 | => nrel_alternative_addresses: 17 | ... 18 | (* 19 | <- sc_node_tuple;; 20 | -> rrel_1: 21 | ... 22 | (* 23 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_platform/subdir_platform] 24 | (* 25 | <- concept_github_url;; 26 | *);; 27 | *);; 28 | *);; 29 | *); 30 | -> part_ui_spec 31 | (* 32 | <- sc_node_struct;; 33 | <- concept_reusable_component_specification;; 34 | => nrel_alternative_addresses: 35 | ... 36 | (* 37 | <- sc_node_tuple;; 38 | -> rrel_1: 39 | ... 40 | (* 41 | -> [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_ui] 42 | (* 43 | <- concept_github_url;; 44 | *);; 45 | *);; 46 | *);; 47 | *);; 48 | 49 | ..repositories_addresses 50 | -> ... 51 | (* 52 | -> rrel_address: 53 | [https://github.com/MksmOrlov/components-repo-example];; 54 | *);; 55 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/test/test-structures/specification.scs: -------------------------------------------------------------------------------- 1 | sc_web_specification 2 | <- concept_reusable_component_specification;; 3 | 4 | sc_web_specification = [* 5 | sc_web 6 | <- concept_reusable_component; 7 | <- concept_atomic_reusable_component; 8 | <- concept_independent_reusable_component; 9 | <- concept_reusable_interface_component; 10 | <- concept_reusable_dynamically_installed_component; 11 | <- concept_reusable_source_code_component; 12 | 13 | => nrel_sc_identifier: [SC-web](* <- lang_en;; *); 14 | => nrel_explanation: [SC-Web is an intelligent knowledge base user interface] (*<- lang_en;; *); 15 | => nrel_component_dependencies: ... (* <- empty_set;; *); 16 | 17 | => nrel_installation_script: [/scripts/install.sh]; 18 | => nrel_component_address: [https://github.com/ostis-ai/sc-web] (* <- concept_github_url;; *); 19 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 20 | *];; 21 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/test/units/agent_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_agents_test.hpp" 8 | 9 | #include 10 | 11 | #include "agent/sc_component_manager_agent_init.hpp" 12 | 13 | TEST_F(ScAgentsTest, AgentInit) 14 | { 15 | ScAgentContext & context = *m_ctx; 16 | loader.loadScsFile(context, TEST_FILES_DIR_PATH + "action_components_init.scs"); 17 | ScAddr const & testActionNode = context.SearchElementBySystemIdentifier("test_action_node"); 18 | EXPECT_TRUE(testActionNode.IsValid()); 19 | ScAction testAction = context.ConvertToAction(testActionNode); 20 | 21 | context.SubscribeAgent(); 22 | testAction.InitiateAndWait(WAIT_TIME); 23 | EXPECT_TRUE(testAction.IsFinishedSuccessfully()); 24 | ScStructure result = testAction.GetResult(); 25 | 26 | std::vector namesOfSpecifications = {"part_platform_spec", "part_ui_spec"}; 27 | bool isSpecificationExists = false; 28 | size_t foundSpecifications = 0; 29 | 30 | ScIterator3Ptr const & specificationsIterator = 31 | context.CreateIterator3(result, ScType::ConstPermPosArc, ScType::ConstNodeStructure); 32 | while (specificationsIterator->Next()) 33 | { 34 | std::string const & specificationIdentifier = context.GetElementSystemIdentifier(specificationsIterator->Get(2)); 35 | isSpecificationExists = 36 | std::count(namesOfSpecifications.begin(), namesOfSpecifications.end(), specificationIdentifier); 37 | EXPECT_TRUE(isSpecificationExists) << specificationIdentifier << " is not in action result"; 38 | foundSpecifications += isSpecificationExists; 39 | } 40 | EXPECT_EQ(foundSpecifications, namesOfSpecifications.size()); 41 | context.UnsubscribeAgent(); 42 | } 43 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/test/units/sc_agents_test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | class ScAgentsTest : public testing::Test 20 | { 21 | public: 22 | static inline std::string const & TEST_FILES_DIR_PATH = "../test-structures/"; 23 | static inline std::string const & TEST_KB_BIN_PATH = "../kb.bin/"; 24 | static inline int const WAIT_TIME = 5000; 25 | static inline ScsLoader loader; 26 | 27 | protected: 28 | virtual void SetUp() 29 | { 30 | ScAgentsTest::Initialize(); 31 | m_ctx = std::make_unique(); 32 | } 33 | 34 | virtual void TearDown() 35 | { 36 | if (m_ctx) 37 | m_ctx->Destroy(); 38 | 39 | ScAgentsTest::Shutdown(); 40 | 41 | std::filesystem::remove_all(TEST_KB_BIN_PATH); 42 | } 43 | 44 | static void Initialize() 45 | { 46 | sc_memory_params params; 47 | sc_memory_params_clear(¶ms); 48 | 49 | params.dump_memory = false; 50 | params.dump_memory_statistics = false; 51 | 52 | params.clear = true; 53 | params.storage = TEST_KB_BIN_PATH.c_str(); 54 | 55 | ScMemory::LogMute(); 56 | ScMemory::Initialize(params); 57 | ScMemory::LogUnmute(); 58 | } 59 | 60 | static void Shutdown() 61 | { 62 | ScMemory::LogMute(); 63 | ScMemory::Shutdown(SC_FALSE); 64 | ScMemory::LogUnmute(); 65 | } 66 | 67 | protected: 68 | std::unique_ptr m_ctx; 69 | }; 70 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/utils/sc_component_manager_command_init.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_component_manager_command_init.hpp" 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace common_utils; 16 | 17 | ScAddrUnorderedSet ScComponentManagerCommandInit::Execute(ScAgentContext * context, ScAddr const & actionAddr) 18 | { 19 | ScAddrUnorderedSet specifications; 20 | 21 | ScIterator3Ptr const repositoriesIterator = context->CreateIterator3( 22 | keynodes::ScComponentManagerKeynodes::concept_repository, ScType::ConstPermPosArc, ScType::ConstNode); 23 | 24 | ScAddr repository; 25 | while (repositoriesIterator->Next()) 26 | { 27 | repository = repositoriesIterator->Get(2); 28 | ProcessRepository(context, repository, specifications); 29 | } 30 | 31 | return specifications; 32 | } 33 | 34 | /** 35 | * @brief Download available components specifications from a storage. 36 | * @param context current sc-memory context 37 | * @param repository ScAddr of a repository of components to load 38 | */ 39 | void ScComponentManagerCommandInit::ProcessRepository( 40 | ScMemoryContext * context, 41 | ScAddr & repository, 42 | ScAddrUnorderedSet & specifications) 43 | { 44 | ScAddr const & specificationsSetAddr = utils::IteratorUtils::getAnyByOutRelation( 45 | context, repository, keynodes::ScComponentManagerKeynodes::rrel_components_specifications); 46 | if (!context->IsElement(specificationsSetAddr)) 47 | { 48 | SC_LOG_WARNING( 49 | "ScComponentManagerCommandInit: components specification not found in repository " 50 | << context->GetElementSystemIdentifier(repository)); 51 | return; 52 | } 53 | 54 | ScAddr componentSpecification; 55 | ScAddr component; 56 | ScIterator3Ptr const specificationsIterator = 57 | context->CreateIterator3(specificationsSetAddr, ScType::ConstPermPosArc, ScType::ConstNode); 58 | while (specificationsIterator->Next()) 59 | { 60 | componentSpecification = specificationsIterator->Get(2); 61 | component = CommonUtils::GetComponentBySpecification(*context, componentSpecification); 62 | if (context->IsElement(component)) 63 | { 64 | SC_LOG_WARNING( 65 | "ScComponentManagerCommandInit: Specification is already loaded for component " 66 | << context->GetElementSystemIdentifier(component)); 67 | continue; 68 | } 69 | specifications.insert(componentSpecification); 70 | downloaderHandler->DownloadSpecification(context, componentSpecification); 71 | std::string const specificationPath = m_specificationsPath + SpecificationConstants::DIRECTORY_DELIMITER 72 | + context->GetElementSystemIdentifier(componentSpecification); 73 | componentUtils::LoadUtils::LoadScsFilesInDir(context, specificationPath); 74 | SC_LOG_DEBUG( 75 | "ScComponentManagerCommandInit: loaded specification " 76 | << context->GetElementSystemIdentifier(componentSpecification)); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/manager/agents/init-module/utils/sc_component_manager_command_init.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | class ScComponentManagerCommandInit : public ScComponentManagerCommand 18 | { 19 | public: 20 | explicit ScComponentManagerCommandInit(std::string specificationsPath) 21 | : m_specificationsPath(std::move(specificationsPath)) 22 | , downloaderHandler(std::make_unique(m_specificationsPath)) 23 | { 24 | } 25 | 26 | ScAddrUnorderedSet Execute(ScAgentContext * context, ScAddr const & actionAddr) override; 27 | 28 | void ProcessRepository(ScMemoryContext * context, ScAddr & repositories, ScAddrUnorderedSet & specifications); 29 | 30 | protected: 31 | std::string m_specificationsPath; 32 | std::unique_ptr downloaderHandler; 33 | }; 34 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES CONFIGURE_DEPENDS 2 | "agent/*.hpp" "agent/*.cpp" 3 | "module/*.hpp" "module/*.cpp" 4 | "utils/*.hpp" "utils/*.cpp" 5 | ) 6 | 7 | add_library(install-module SHARED ${SOURCES}) 8 | target_link_libraries(install-module LINK_PUBLIC common-lib) 9 | target_include_directories(install-module PRIVATE ${CMAKE_CURRENT_LIST_DIR}) 10 | set_target_properties(install-module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) 11 | 12 | if(${SC_CLANG_FORMAT_CODE}) 13 | target_clangformat_setup(install-module) 14 | endif() 15 | 16 | if(${SC_BUILD_TESTS}) 17 | set(INSTALL_MODULE_SRC ${CMAKE_CURRENT_SOURCE_DIR}) 18 | add_subdirectory(test) 19 | endif() 20 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/agent/sc_component_manager_agent_install.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_component_manager_agent_install.hpp" 8 | 9 | #include 10 | 11 | #include "utils/sc_component_manager_command_install.hpp" 12 | 13 | using namespace installModule; 14 | using namespace keynodes; 15 | 16 | ScResult ScComponentManagerInstallAgent::DoProgram(ScAction & action) 17 | { 18 | std::map componentWithConfigPath; 19 | 20 | ScConfig config{ 21 | ScMemory::ms_configPath, 22 | {PathKeysOfConfigPath::KB_PATH, PathKeysOfConfigPath::PS_PATH, PathKeysOfConfigPath::UI_PATH}}; 23 | ScConfigGroup configManager = config["sc-component-manager"]; 24 | 25 | componentWithConfigPath.insert( 26 | {keynodes::ScComponentManagerKeynodes::concept_reusable_kb_component, 27 | configManager[PathKeysOfConfigPath::KB_PATH]}); 28 | componentWithConfigPath.insert( 29 | {keynodes::ScComponentManagerKeynodes::concept_reusable_ps_component, 30 | configManager[PathKeysOfConfigPath::PS_PATH]}); 31 | componentWithConfigPath.insert( 32 | {keynodes::ScComponentManagerKeynodes::concept_reusable_ui_component, 33 | configManager[PathKeysOfConfigPath::UI_PATH]}); 34 | 35 | ScComponentManagerCommandInstall command = ScComponentManagerCommandInstall(componentWithConfigPath); 36 | ScAddrUnorderedSet const & identifiersNodesSet = command.Execute(&m_context, action); 37 | bool isSuccess = !identifiersNodesSet.empty(); 38 | ScStructure result = m_context.GenerateStructure(); 39 | for (auto const & identifierNode : identifiersNodesSet) 40 | result << identifierNode; 41 | action.SetResult(result); 42 | 43 | return isSuccess ? action.FinishSuccessfully() : action.FinishUnsuccessfully(); 44 | } 45 | 46 | ScAddr ScComponentManagerInstallAgent::GetActionClass() const 47 | { 48 | return keynodes::ScComponentManagerKeynodes::action_components_install; 49 | } 50 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/agent/sc_component_manager_agent_install.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace installModule 12 | { 13 | class ScComponentManagerInstallAgent : public ScActionInitiatedAgent 14 | { 15 | public: 16 | public: 17 | ScAddr GetActionClass() const override; 18 | 19 | ScResult DoProgram(ScAction & action) override; 20 | }; 21 | } // namespace installModule 22 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/module/install-module.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "install-module.hpp" 8 | 9 | #include "agent/sc_component_manager_agent_install.hpp" 10 | 11 | using namespace installModule; 12 | 13 | SC_MODULE_REGISTER(InstallModule)->Agent(); 14 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/module/install-module.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace installModule 12 | { 13 | class InstallModule : public ScModule 14 | { 15 | }; 16 | } // namespace installModule 17 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units 2 | NAME install-module-tests 3 | DEPENDS install-module 4 | INCLUDES ${INSTALL_MODULE_SRC} 5 | ) 6 | 7 | if(${SC_CLANG_FORMAT_CODE}) 8 | target_clangformat_setup(install-module-tests) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/test/test-structures/action_components_install.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_install; 4 | -> rrel_1: ... (* -> rrel_components: ..components_to_install;; *);; 5 | 6 | ..components_to_install 7 | -> part_ui;; 8 | 9 | part_ui_specification 10 | <- concept_reusable_component_specification;; 11 | 12 | part_ui_specification = [* 13 | part_ui 14 | <- concept_reusable_component; 15 | <- concept_atomic_reusable_component; 16 | <- concept_independent_reusable_component; 17 | <- concept_reusable_kb_component; 18 | <- concept_reusable_dynamically_installed_component; 19 | <- concept_reusable_source_code_component; 20 | 21 | => nrel_sc_identifier: [part_ui specification](* <- lang_en;; *); 22 | => nrel_component_dependencies: ... (* <- empty_set;; *); 23 | 24 | => nrel_component_address: [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_ui] (* <- concept_github_url;; *); 25 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 26 | *];; 27 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/test/test-structures/specification.scs: -------------------------------------------------------------------------------- 1 | sc_web_specification 2 | <- concept_reusable_component_specification;; 3 | 4 | sc_web_specification = [* 5 | sc_web 6 | <- concept_reusable_component; 7 | <- concept_atomic_reusable_component; 8 | <- concept_independent_reusable_component; 9 | <- concept_reusable_interface_component; 10 | <- concept_reusable_dynamically_installed_component; 11 | <- concept_reusable_source_code_component; 12 | 13 | => nrel_sc_identifier: [SC-web](* <- lang_en;; *); 14 | => nrel_explanation: [SC-Web is an intelligent knowledge base user interface] (*<- lang_en;; *); 15 | => nrel_component_dependencies: ... (* <- empty_set;; *); 16 | 17 | => nrel_installation_script: [/scripts/install.sh]; 18 | => nrel_component_address: [https://github.com/ostis-ai/sc-web] (* <- concept_github_url;; *); 19 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 20 | *];; 21 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/test/units/agent_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_agents_test.hpp" 8 | 9 | #include 10 | 11 | #include "agent/sc_component_manager_agent_install.hpp" 12 | 13 | TEST_F(ScAgentsTest, AgentInstall) 14 | { 15 | ScAgentContext & context = *m_ctx; 16 | loader.loadScsFile(context, TEST_FILES_DIR_PATH + "action_components_install.scs"); 17 | ScAddr const & testActionNode = context.SearchElementBySystemIdentifier("test_action_node"); 18 | ScAction testAction = context.ConvertToAction(testActionNode); 19 | 20 | context.SubscribeAgent(); 21 | 22 | testAction.InitiateAndWait(WAIT_TIME); 23 | EXPECT_TRUE(testAction.IsFinishedSuccessfully()); 24 | ScStructure result = testAction.GetResult(); 25 | 26 | ScIterator3Ptr const & componentsIterator = 27 | context.CreateIterator3(result, ScType::ConstPermPosArc, ScType::ConstNode); 28 | EXPECT_TRUE(componentsIterator->Next()); 29 | 30 | EXPECT_EQ("part_ui", context.GetElementSystemIdentifier(componentsIterator->Get(2))); 31 | 32 | context.UnsubscribeAgent(); 33 | } 34 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/test/units/sc_agents_test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | class ScAgentsTest : public testing::Test 20 | { 21 | public: 22 | static inline std::string const & TEST_FILES_DIR_PATH = "../test-structures/"; 23 | static inline std::string const & TEST_KB_BIN_PATH = "../kb.bin/"; 24 | static inline int const WAIT_TIME = 5000; 25 | static inline ScsLoader loader; 26 | 27 | protected: 28 | virtual void SetUp() 29 | { 30 | ScAgentsTest::Initialize(); 31 | m_ctx = std::make_unique(); 32 | } 33 | 34 | virtual void TearDown() 35 | { 36 | if (m_ctx) 37 | m_ctx->Destroy(); 38 | 39 | ScAgentsTest::Shutdown(); 40 | 41 | std::filesystem::remove_all(TEST_KB_BIN_PATH); 42 | } 43 | 44 | static void Initialize() 45 | { 46 | sc_memory_params params; 47 | sc_memory_params_clear(¶ms); 48 | 49 | params.dump_memory = false; 50 | params.dump_memory_statistics = false; 51 | 52 | params.clear = true; 53 | params.storage = TEST_KB_BIN_PATH.c_str(); 54 | 55 | ScMemory::LogMute(); 56 | ScMemory::Initialize(params); 57 | ScMemory::LogUnmute(); 58 | } 59 | 60 | static void Shutdown() 61 | { 62 | ScMemory::LogMute(); 63 | ScMemory::Shutdown(SC_FALSE); 64 | ScMemory::LogUnmute(); 65 | } 66 | 67 | protected: 68 | std::unique_ptr m_ctx; 69 | }; 70 | -------------------------------------------------------------------------------- /src/manager/agents/install-module/utils/sc_component_manager_command_install.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class ScComponentManagerCommandInstall : public ScComponentManagerCommand 19 | { 20 | std::string const PARAMETER_NAME = "idtf"; 21 | 22 | public: 23 | explicit ScComponentManagerCommandInstall(std::map m_componentsPath); 24 | 25 | ScAddrUnorderedSet Execute(ScAgentContext * context, ScAddr const & actionAddr) override; 26 | 27 | protected: 28 | static void ValidateComponent(ScMemoryContext * context, ScAddr const & componentAddr); 29 | 30 | bool DownloadComponent(ScMemoryContext * context, ScAddr const & componentAddr); 31 | 32 | bool InstallDependencies(ScAgentContext * context, ScAddr const & componentAddr); 33 | 34 | static ScAddr CreateSetToInstallStructure(ScMemoryContext * context, ScAddr const & dependenciesSet); 35 | 36 | static ScAddr CheckDependencyDuplication( 37 | ScMemoryContext * context, 38 | ScAddr const & currentInstallationComponentsAddr, 39 | ScAddr const & dependenciesSet); 40 | 41 | static bool EraseTempOutputEdges(ScMemoryContext * context, ScAddr const & node); 42 | 43 | static ScAddrUnorderedSet GetAvailableComponents( 44 | ScMemoryContext * context, 45 | ScAddrUnorderedSet const & componentsToInstallIdentifiers); 46 | 47 | bool InstallComponent(ScMemoryContext * context, ScAddr const & componentAddr); 48 | 49 | // Install components that are in `need to install` set 50 | void QuietInstall(ScMemoryContext * context); 51 | 52 | std::map m_componentsPath; 53 | 54 | std::string m_downloadDir; 55 | }; 56 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES CONFIGURE_DEPENDS 2 | "agent/*.hpp" "agent/*.cpp" 3 | "module/*.hpp" "module/*.cpp" 4 | "utils/*.hpp" "utils/*.cpp" 5 | ) 6 | 7 | add_library(search-module SHARED ${SOURCES}) 8 | target_link_libraries(search-module LINK_PUBLIC common-lib) 9 | target_include_directories(search-module PRIVATE ${CMAKE_CURRENT_LIST_DIR}) 10 | set_target_properties(search-module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${SC_EXTENSIONS_DIRECTORY}) 11 | 12 | if(${SC_CLANG_FORMAT_CODE}) 13 | target_clangformat_setup(search-module) 14 | endif() 15 | 16 | if(${SC_BUILD_TESTS}) 17 | set(SEARCH_MODULE_SRC ${CMAKE_CURRENT_SOURCE_DIR}) 18 | add_subdirectory(test) 19 | endif() 20 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/agent/sc_component_manager_agent_search.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_component_manager_agent_search.hpp" 8 | 9 | #include 10 | #include 11 | 12 | #include "utils/sc_component_manager_command_search.hpp" 13 | 14 | using namespace searchModule; 15 | using namespace keynodes; 16 | 17 | ScResult ScComponentManagerSearchAgent::DoProgram(ScAction & action) 18 | { 19 | ScComponentManagerCommandSearch command = ScComponentManagerCommandSearch(); 20 | ScAddrUnorderedSet components = command.Execute(&m_context, action); 21 | ScStructure result = m_context.GenerateStructure(); 22 | for (auto const & component : components) 23 | result << component; 24 | action.SetResult(result); 25 | 26 | return action.FinishSuccessfully(); 27 | } 28 | 29 | ScAddr ScComponentManagerSearchAgent::GetActionClass() const 30 | { 31 | return keynodes::ScComponentManagerKeynodes::action_components_search; 32 | } 33 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/agent/sc_component_manager_agent_search.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace searchModule 12 | { 13 | class ScComponentManagerSearchAgent : public ScActionInitiatedAgent 14 | { 15 | public: 16 | ScAddr GetActionClass() const override; 17 | 18 | ScResult DoProgram(ScAction & action) override; 19 | }; 20 | } // namespace searchModule 21 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/module/search-module.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "search-module.hpp" 8 | 9 | #include "agent/sc_component_manager_agent_search.hpp" 10 | 11 | using namespace searchModule; 12 | 13 | SC_MODULE_REGISTER(SearchModule)->Agent(); 14 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/module/search-module.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | namespace searchModule 12 | { 13 | class SearchModule : public ScModule 14 | { 15 | }; 16 | } // namespace searchModule 17 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units 2 | NAME search-module-tests 3 | DEPENDS search-module 4 | INCLUDES ${SEARCH_MODULE_SRC} 5 | ) 6 | 7 | if(${SC_CLANG_FORMAT_CODE}) 8 | target_clangformat_setup(search-module-tests) 9 | endif() 10 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/all_arguments_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_class: 5 | { 6 | concept_reusable_ui_component; 7 | concept_reusable_source_code_component 8 | }; 9 | -> rrel_author: 10 | { 11 | author_2 12 | }; 13 | -> rrel_key_sc_element: 14 | { 15 | concept_reusable_component; 16 | concept_reusable_kb_component 17 | }; 18 | -> rrel_note: 19 | { 20 | [another] 21 | }; 22 | -> rrel_explanation: 23 | { 24 | [explanation] 25 | }; 26 | -> rrel_purpose: 27 | { 28 | [2] 29 | }; 30 | -> rrel_main_idtf: 31 | { 32 | [+] 33 | };; 34 | 35 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/empty_arguments_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search;; 4 | 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_authors_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_author: 5 | { 6 | author_1; 7 | this_author_has_no_common_components_with_author_1 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_classes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_class: 5 | { 6 | concept_independent_reusable_component; 7 | concept_dependent_reusable_component 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_explanations_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_explanation: 5 | { 6 | [2]; 7 | [3] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_ids_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_main_idtf: 5 | { 6 | [2]; 7 | [3] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_keys_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_key_sc_element: 5 | { 6 | concept_reusable_kb_component; 7 | concept_reusable_ui_component 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_notes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_note: 5 | { 6 | [2]; 7 | [3] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/incompatible_purposes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_purpose: 5 | { 6 | [2]; 7 | [3] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_author_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_author: 5 | { 6 | author_1 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_class_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_class: 5 | { 6 | concept_reusable_kb_component 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_explanation_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_explanation: 5 | { 6 | [component 1] 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_id_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_main_idtf: 5 | { 6 | [component 1] 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_key_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_key_sc_element: 5 | { 6 | concept_reusable_ui_component 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_note_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_note: 5 | { 6 | [component 2] 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/one_purpose_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_purpose: 5 | { 6 | [component 2] 7 | };; 8 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/specifications.scs: -------------------------------------------------------------------------------- 1 | part_platform_specification 2 | <- concept_reusable_component_specification;; 3 | 4 | part_platform_specification = [* 5 | -> rrel_key_sc_element: 6 | part_platform;; 7 | part_platform 8 | <- concept_reusable_component; 9 | <- concept_atomic_reusable_component; 10 | <- concept_independent_reusable_component; 11 | <- concept_reusable_kb_component; 12 | <- concept_reusable_dynamically_installed_component; 13 | <- concept_reusable_source_code_component; 14 | 15 | => nrel_sc_identifier: [part_platform specification](* <- lang_en;; *); 16 | => nrel_component_dependencies: ... (* <- empty_set;; *); 17 | 18 | => nrel_component_address: [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_platform/subdir_platform] (* <- concept_github_url;; *); 19 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 20 | *];; 21 | 22 | 23 | part_ui_specification 24 | <- concept_reusable_component_specification;; 25 | 26 | part_ui_specification = [* 27 | -> rrel_key_sc_element: 28 | part_ui;; 29 | part_ui 30 | <- concept_reusable_component; 31 | <- concept_atomic_reusable_component; 32 | <- concept_independent_reusable_component; 33 | <- concept_reusable_kb_component; 34 | <- concept_reusable_dynamically_installed_component; 35 | <- concept_reusable_source_code_component; 36 | 37 | => nrel_sc_identifier: [part_ui specification](* <- lang_en;; *); 38 | => nrel_component_dependencies: ... (* <- empty_set;; *); 39 | 40 | => nrel_component_address: [https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_ui] (* <- concept_github_url;; *); 41 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 42 | *];; 43 | 44 | specification_1 45 | <- concept_reusable_component_specification;; 46 | 47 | specification_1 = [* 48 | -> rrel_key_sc_element: 49 | specification_1_component;; 50 | specification_1_component 51 | <- concept_reusable_component; 52 | <- concept_atomic_reusable_component; 53 | <- concept_independent_reusable_component; 54 | <- concept_reusable_ui_component; 55 | <- concept_reusable_dynamically_installed_component; 56 | <- concept_reusable_source_code_component; 57 | 58 | => nrel_main_idtf: [component 1] (* <- lang_en;; *); 59 | 60 | => nrel_authors: ... (* -> author_1;; *); 61 | => nrel_explanation: [component 1 explanation] (* <- lang_en;; *); 62 | => nrel_note: [component 1 note] (*<- lang_en;; *); 63 | => nrel_key_sc_element: concept_reusable_component; 64 | => nrel_purpose: [component 1 purpose mentions component 2](* <- lang_en;; *); 65 | 66 | => nrel_sc_identifier: [component 1](* <- lang_en;; *); 67 | => nrel_component_dependencies: ... (* <- empty_set;; *); 68 | 69 | => nrel_component_address: [https://github.com/user/something/tree/main/component_1] (* <- concept_github_url;; *); 70 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 71 | *];; 72 | 73 | specification_2 74 | <- concept_reusable_component_specification;; 75 | 76 | specification_2 = [* 77 | -> rrel_key_sc_element: 78 | specification_2_component;; 79 | specification_2_component 80 | <- concept_reusable_component; 81 | <- concept_atomic_reusable_component; 82 | <- concept_independent_reusable_component; 83 | <- concept_reusable_ui_component; 84 | <- concept_reusable_dynamically_installed_component; 85 | <- concept_reusable_source_code_component; 86 | 87 | => nrel_main_idtf: [component 1+1] (* <- lang_en;; *); 88 | 89 | => nrel_authors: ... (* -> author_1;; -> author_2;; *); 90 | => nrel_explanation: [component 2 explanation] (* <- lang_en;; *); 91 | => nrel_note: [component 2 note] (*<- lang_en;; *); 92 | => nrel_note: [component 2 another note] (*<- lang_en;; *); 93 | => nrel_key_sc_element: concept_reusable_component; 94 | => nrel_key_sc_element: concept_reusable_kb_component; 95 | => nrel_purpose: [component 2 purpose](* <- lang_en;; *); 96 | 97 | => nrel_sc_identifier: [component 2](* <- lang_en;; *); 98 | => nrel_component_dependencies: ... (* <- empty_set;; *); 99 | 100 | => nrel_component_address: [https://github.com/user/something/tree/main/component_2] (* <- concept_github_url;; *); 101 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 102 | *];; 103 | 104 | specification_3 105 | <- concept_reusable_component_specification;; 106 | 107 | specification_3 = [* 108 | -> rrel_key_sc_element: 109 | specification_3_component;; 110 | specification_3_component 111 | <- concept_reusable_component; 112 | <- concept_atomic_reusable_component; 113 | <- concept_independent_reusable_component; 114 | <- concept_reusable_ui_component; 115 | <- concept_reusable_dynamically_installed_component; 116 | <- concept_reusable_source_code_component; 117 | 118 | => nrel_main_idtf: [component 3] (* <- lang_en;; *); 119 | => nrel_main_idtf: [компонент 3] (* <- lang_ru;; *); 120 | 121 | => nrel_authors: ... (* -> this_author_has_no_common_components_with_author_1;; -> author_2;; *); 122 | => nrel_explanation: [component 3 explanation] (* <- lang_en;; *); 123 | => nrel_explanation: [component 3 another explanation mentions component 1] (* <- lang_en;; *); 124 | => nrel_key_sc_element: concept_reusable_component; 125 | => nrel_key_sc_element: concept_reusable_ui_component; 126 | => nrel_purpose: [component 3 purpose](* <- lang_en;; *); 127 | => nrel_purpose: [component 3 another purpose](* <- lang_en;; *); 128 | 129 | => nrel_sc_identifier: [component 3](* <- lang_en;; *); 130 | => nrel_component_dependencies: ... (* <- empty_set;; *); 131 | 132 | => nrel_component_address: [https://github.com/user/something/tree/main/component_3] (* <- concept_github_url;; *); 133 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 134 | *];; 135 | 136 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_authors_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_author: 5 | { 6 | author_1; 7 | author_2 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_classes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_class: 5 | { 6 | concept_reusable_kb_component; 7 | concept_atomic_reusable_component 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_explanations_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_explanation: 5 | { 6 | [component]; 7 | [2] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_ids_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_main_idtf: 5 | { 6 | [component]; 7 | [3] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_keys_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_key_sc_element: 5 | { 6 | concept_reusable_kb_component; 7 | concept_reusable_component 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_notes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_note: 5 | { 6 | [component]; 7 | [2] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/two_purposes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_purpose: 5 | { 6 | [component]; 7 | [2] 8 | };; 9 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_authors_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_author: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_classes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_class: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_explanations_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_explanation: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_ids_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_main_idtf: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_keys_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_key_sc_element: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_notes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_note: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/components-search/zero_purposes_action_components_search.scs: -------------------------------------------------------------------------------- 1 | test_action_node 2 | <- action; 3 | <- action_components_search; 4 | -> rrel_purpose: ...;; 5 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/test-structures/specification.scs: -------------------------------------------------------------------------------- 1 | sc_web_specification 2 | <- concept_reusable_component_specification;; 3 | 4 | sc_web_specification = [* 5 | sc_web 6 | <- concept_reusable_component; 7 | <- concept_atomic_reusable_component; 8 | <- concept_independent_reusable_component; 9 | <- concept_reusable_interface_component; 10 | <- concept_reusable_dynamically_installed_component; 11 | <- concept_reusable_source_code_component; 12 | 13 | => nrel_sc_identifier: [SC-web](* <- lang_en;; *); 14 | => nrel_explanation: [SC-Web is an intelligent knowledge base user interface] (*<- lang_en;; *); 15 | => nrel_component_dependencies: ... (* <- empty_set;; *); 16 | 17 | => nrel_installation_script: [/scripts/install.sh]; 18 | => nrel_component_address: [https://github.com/ostis-ai/sc-web] (* <- concept_github_url;; *); 19 | => nrel_installation_method: ... (* <- concept_component_dynamically_installed_method;; *);; 20 | *];; 21 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/units/agent_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_agents_test.hpp" 8 | 9 | #include 10 | 11 | #include "agent/sc_component_manager_agent_search.hpp" 12 | 13 | std::unordered_set const ALL_SPECIFICATIONS_FOR_SEARCH = { 14 | "part_platform_specification", 15 | "part_ui_specification", 16 | "specification_1", 17 | "specification_2", 18 | "specification_3", 19 | }; 20 | 21 | void searchComponentsTestBody( 22 | ScAgentContext & context, 23 | std::unordered_set const & expectedFoundSpecifications, 24 | std::string const & filename) 25 | { 26 | ScAgentsTest::loader.loadScsFile(context, ScAgentsTest::TEST_FILES_COMPONENTS_SEARCH_DIR_PATH + "specifications.scs"); 27 | ScAgentsTest::loader.loadScsFile(context, ScAgentsTest::TEST_FILES_COMPONENTS_SEARCH_DIR_PATH + filename); 28 | ScAddr const & testActionNode = context.SearchElementBySystemIdentifier("test_action_node"); 29 | ScAction testAction = context.ConvertToAction(testActionNode); 30 | 31 | context.SubscribeAgent(); 32 | testAction.InitiateAndWait(ScAgentsTest::WAIT_TIME); 33 | EXPECT_TRUE(testAction.IsFinishedSuccessfully()); 34 | 35 | ScStructure result = testAction.GetResult(); 36 | bool isSpecificationExists = false; 37 | size_t foundSpecifications = 0; 38 | 39 | ScIterator3Ptr const & specificationsIterator = 40 | context.CreateIterator3(result, ScType::ConstPermPosArc, ScType::ConstNodeStructure); 41 | while (specificationsIterator->Next()) 42 | { 43 | std::string const & specificationIdentifier = context.GetElementSystemIdentifier(specificationsIterator->Get(2)); 44 | isSpecificationExists = expectedFoundSpecifications.count(specificationIdentifier); 45 | EXPECT_TRUE(isSpecificationExists) << specificationIdentifier << " is not in action result"; 46 | foundSpecifications += isSpecificationExists; 47 | } 48 | EXPECT_EQ(foundSpecifications, expectedFoundSpecifications.size()); 49 | context.UnsubscribeAgent(); 50 | } 51 | 52 | TEST_F(ScAgentsTest, AgentSearchByOneClass) 53 | { 54 | searchComponentsTestBody( 55 | *m_ctx, {"part_platform_specification", "part_ui_specification"}, "one_class_action_components_search.scs"); 56 | } 57 | 58 | TEST_F(ScAgentsTest, AgentSearchByTwoClasses) 59 | { 60 | searchComponentsTestBody( 61 | *m_ctx, {"part_platform_specification", "part_ui_specification"}, "two_classes_action_components_search.scs"); 62 | } 63 | 64 | TEST_F(ScAgentsTest, AgentSearchByZeroClasses) 65 | { 66 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "zero_classes_action_components_search.scs"); 67 | } 68 | 69 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleClasses) 70 | { 71 | searchComponentsTestBody(*m_ctx, {}, "incompatible_classes_action_components_search.scs"); 72 | } 73 | 74 | TEST_F(ScAgentsTest, AgentSearchByOneAuthor) 75 | { 76 | searchComponentsTestBody(*m_ctx, {"specification_1", "specification_2"}, "one_author_action_components_search.scs"); 77 | } 78 | 79 | TEST_F(ScAgentsTest, AgentSearchByTwoAuthors) 80 | { 81 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "two_authors_action_components_search.scs"); 82 | } 83 | 84 | TEST_F(ScAgentsTest, AgentSearchByZeroAuthors) 85 | { 86 | searchComponentsTestBody( 87 | *m_ctx, {"specification_1", "specification_2", "specification_3"}, "zero_authors_action_components_search.scs"); 88 | } 89 | 90 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleAuthor) 91 | { 92 | searchComponentsTestBody(*m_ctx, {}, "incompatible_authors_action_components_search.scs"); 93 | } 94 | 95 | TEST_F(ScAgentsTest, AgentSearchByOneKey) 96 | { 97 | searchComponentsTestBody(*m_ctx, {"specification_3"}, "one_key_action_components_search.scs"); 98 | } 99 | 100 | TEST_F(ScAgentsTest, AgentSearchByTwoKeys) 101 | { 102 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "two_keys_action_components_search.scs"); 103 | } 104 | 105 | TEST_F(ScAgentsTest, AgentSearchByZeroKeys) 106 | { 107 | searchComponentsTestBody( 108 | *m_ctx, {"specification_1", "specification_2", "specification_3"}, "zero_keys_action_components_search.scs"); 109 | } 110 | 111 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleKeys) 112 | { 113 | searchComponentsTestBody(*m_ctx, {}, "incompatible_keys_action_components_search.scs"); 114 | } 115 | 116 | TEST_F(ScAgentsTest, AgentSearchByOneNote) 117 | { 118 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "one_note_action_components_search.scs"); 119 | } 120 | 121 | // disabled because links in action arguments are passed without order so search uses `2 component` instead of 122 | // `component 2` 123 | TEST_F(ScAgentsTest, DISABLED_AgentSearchByTwoNotes) 124 | { 125 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "two_notes_action_components_search.scs"); 126 | } 127 | 128 | TEST_F(ScAgentsTest, AgentSearchByZeroNotes) 129 | { 130 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "zero_notes_action_components_search.scs"); 131 | } 132 | 133 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleNotes) 134 | { 135 | searchComponentsTestBody(*m_ctx, {}, "incompatible_notes_action_components_search.scs"); 136 | } 137 | 138 | TEST_F(ScAgentsTest, AgentSearchByOneExplanation) 139 | { 140 | searchComponentsTestBody( 141 | *m_ctx, {"specification_1", "specification_3"}, "one_explanation_action_components_search.scs"); 142 | } 143 | 144 | // disabled because links in action arguments are passed without order so search uses `2 component` instead of 145 | // `component 2` 146 | TEST_F(ScAgentsTest, DISABLED_AgentSearchByTwoExplanations) 147 | { 148 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "two_explanations_action_components_search.scs"); 149 | } 150 | 151 | TEST_F(ScAgentsTest, AgentSearchByZeroExplanations) 152 | { 153 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "zero_explanations_action_components_search.scs"); 154 | } 155 | 156 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleExplanations) 157 | { 158 | searchComponentsTestBody(*m_ctx, {}, "incompatible_explanations_action_components_search.scs"); 159 | } 160 | 161 | TEST_F(ScAgentsTest, AgentSearchByOnePurpose) 162 | { 163 | searchComponentsTestBody(*m_ctx, {"specification_1", "specification_2"}, "one_purpose_action_components_search.scs"); 164 | } 165 | 166 | // disabled because links in action arguments are passed without order so search uses `2 component` instead of 167 | // `component 2` 168 | TEST_F(ScAgentsTest, DISABLED_AgentSearchByTwoPurposes) 169 | { 170 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "two_purposes_action_components_search.scs"); 171 | } 172 | 173 | TEST_F(ScAgentsTest, AgentSearchByZeroPurposes) 174 | { 175 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "zero_purposes_action_components_search.scs"); 176 | } 177 | 178 | TEST_F(ScAgentsTest, AgentSearchByIncompatiblePurposes) 179 | { 180 | searchComponentsTestBody(*m_ctx, {}, "incompatible_purposes_action_components_search.scs"); 181 | } 182 | 183 | TEST_F(ScAgentsTest, AgentSearchByOneId) 184 | { 185 | searchComponentsTestBody(*m_ctx, {"specification_1", "specification_2"}, "one_id_action_components_search.scs"); 186 | } 187 | 188 | // disabled because links in action arguments are passed without order so search uses `3 component` instead of 189 | // `component 3` 190 | TEST_F(ScAgentsTest, DISABLED_AgentSearchByTwoIds) 191 | { 192 | searchComponentsTestBody(*m_ctx, {"specification_3"}, "two_ids_action_components_search.scs"); 193 | } 194 | 195 | TEST_F(ScAgentsTest, AgentSearchByZeroIds) 196 | { 197 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "zero_ids_action_components_search.scs"); 198 | } 199 | 200 | TEST_F(ScAgentsTest, AgentSearchByIncompatibleIds) 201 | { 202 | searchComponentsTestBody(*m_ctx, {}, "incompatible_ids_action_components_search.scs"); 203 | } 204 | 205 | TEST_F(ScAgentsTest, AgentSearchByAllArguments) 206 | { 207 | searchComponentsTestBody(*m_ctx, {"specification_2"}, "all_arguments_action_components_search.scs"); 208 | } 209 | 210 | TEST_F(ScAgentsTest, AgentSearchWithEmptyArguments) 211 | { 212 | searchComponentsTestBody(*m_ctx, ALL_SPECIFICATIONS_FOR_SEARCH, "empty_arguments_action_components_search.scs"); 213 | } 214 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/test/units/sc_agents_test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | class ScAgentsTest : public testing::Test 20 | { 21 | public: 22 | static inline std::string const & TEST_FILES_DIR_PATH = "../test-structures/"; 23 | static inline std::string const & TEST_FILES_COMPONENTS_SEARCH_DIR_PATH = "../test-structures/components-search/"; 24 | static inline std::string const & TEST_KB_BIN_PATH = "../kb.bin/"; 25 | static inline int const WAIT_TIME = 5000; 26 | static inline ScsLoader loader; 27 | 28 | protected: 29 | virtual void SetUp() 30 | { 31 | ScAgentsTest::Initialize(); 32 | m_ctx = std::make_unique(); 33 | } 34 | 35 | virtual void TearDown() 36 | { 37 | if (m_ctx) 38 | m_ctx->Destroy(); 39 | 40 | ScAgentsTest::Shutdown(); 41 | 42 | std::filesystem::remove_all(TEST_KB_BIN_PATH); 43 | } 44 | 45 | static void Initialize() 46 | { 47 | sc_memory_params params; 48 | sc_memory_params_clear(¶ms); 49 | 50 | params.dump_memory = false; 51 | params.dump_memory_statistics = false; 52 | 53 | params.clear = true; 54 | params.storage = TEST_KB_BIN_PATH.c_str(); 55 | 56 | ScMemory::LogMute(); 57 | ScMemory::Initialize(params); 58 | ScMemory::LogUnmute(); 59 | } 60 | 61 | static void Shutdown() 62 | { 63 | ScMemory::LogMute(); 64 | ScMemory::Shutdown(SC_FALSE); 65 | ScMemory::LogUnmute(); 66 | } 67 | 68 | protected: 69 | std::unique_ptr m_ctx; 70 | }; 71 | -------------------------------------------------------------------------------- /src/manager/agents/search-module/utils/sc_component_manager_command_search.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include "common/sc_component_manager_command.hpp" 12 | #include "common/sc_component_manager_keynodes.hpp" 13 | 14 | class ScComponentManagerCommandSearch : public ScComponentManagerCommand 15 | { 16 | public: 17 | ScComponentManagerCommandSearch() = default; 18 | 19 | ScAddrUnorderedSet Execute(ScAgentContext * context, ScAddr const & actionAddr) override; 20 | 21 | protected: 22 | std::string const SPECIFICATION_ALIAS = "_specification"; 23 | std::string const COMPONENT_ALIAS = "_component"; 24 | std::string const AUTHORS_SET_ALIAS = "_authors"; 25 | std::string const EXPLANATION_LINK_ALIAS = "_explanation"; 26 | std::string const NOTE_LINK_ALIAS = "_note"; 27 | std::string const PURPOSE_LINK_ALIAS = "_purpose"; 28 | std::string const KEY_SET_ALIAS = "_key"; 29 | std::string const MAIN_ID_LINK_ALIAS = "_main-id"; 30 | 31 | std::string const AUTHOR = "author"; 32 | std::string const CLASS = "class"; 33 | std::string const EXPLANATION = "explanation"; 34 | std::string const NOTE = "note"; 35 | std::string const PURPOSE = "purpose"; 36 | std::string const KEY = "key"; 37 | std::string const MAIN_ID = "main-id"; 38 | std::set const possibleSearchParameters = 39 | {AUTHOR, CLASS, EXPLANATION, NOTE, PURPOSE, KEY, MAIN_ID}; // extend to more params 40 | 41 | std::vector> searchByLine = { 42 | {EXPLANATION, keynodes::ScComponentManagerKeynodes::nrel_explanation, EXPLANATION_LINK_ALIAS}, 43 | {NOTE, keynodes::ScComponentManagerKeynodes::nrel_note, NOTE_LINK_ALIAS}, 44 | {PURPOSE, keynodes::ScComponentManagerKeynodes::nrel_purpose, PURPOSE_LINK_ALIAS}, 45 | {MAIN_ID, ScKeynodes::nrel_main_idtf, MAIN_ID_LINK_ALIAS}}; 46 | 47 | std::vector> searchByRelation = { 48 | {KEY, keynodes::ScComponentManagerKeynodes::nrel_key_sc_element, KEY_SET_ALIAS}}; 49 | 50 | std::vector> searchByRelationSet = { 51 | {AUTHOR, keynodes::ScComponentManagerKeynodes::nrel_authors, AUTHORS_SET_ALIAS}}; 52 | 53 | void SearchComponentsByClass( 54 | ScMemoryContext * context, 55 | ScTemplate & searchComponentTemplate, 56 | std::vector const & parameters); 57 | 58 | void SearchComponentsByRelationSet( 59 | ScMemoryContext * context, 60 | ScAddr const & relationAddr, 61 | std::string const & setAlias, 62 | ScTemplate & searchComponentTemplate, 63 | std::vector const & parameters); 64 | 65 | void SearchComponentsByRelation( 66 | ScMemoryContext * context, 67 | ScAddr const & relationAddr, 68 | std::string const & parameterAlias, 69 | ScTemplate & searchComponentTemplate, 70 | std::vector const & parameters); 71 | 72 | ScAddrUnorderedSet SearchComponentsByRelationLink( 73 | ScMemoryContext * context, 74 | ScAddr const & relationAddr, 75 | std::string const & linkAlias, 76 | ScTemplate & searchComponentTemplate, 77 | std::vector & parameters); 78 | 79 | ScAddrUnorderedSet SearchComponentsSpecifications( 80 | ScMemoryContext * context, 81 | ScTemplate & searchComponentTemplate, 82 | std::map const & linksValues); 83 | 84 | ScAddrUnorderedSet SearchComponentsSpecificationsWithoutLinks( 85 | ScMemoryContext * context, 86 | ScTemplateSearchResult const & searchComponentResult); 87 | 88 | ScAddrUnorderedSet SearchComponentsSpecificationsWithLinks( 89 | ScMemoryContext * context, 90 | ScTemplateSearchResult const & searchComponentResult, 91 | std::map const & linksValues); 92 | }; 93 | -------------------------------------------------------------------------------- /src/manager/console-interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(AGENTS_SRC "${SC_COMPONENT_MANAGER_SRC}/manager/agents") 2 | 3 | file(GLOB SOURCES CONFIGURE_DEPENDS 4 | "src/*.hpp" "src/*.cpp" 5 | "include/console-interface/*.hpp" "include/console-interface/*.cpp" 6 | ) 7 | 8 | # Define console-interface as an object library instead of a shared library 9 | # because it contains functions that are tightly coupled with other parts of the project only. 10 | # This approach avoids the need for dynamic loading and path management. 11 | add_library(console-interface OBJECT ${SOURCES}) 12 | target_link_libraries(console-interface 13 | LINK_PUBLIC common-lib 14 | ) 15 | target_include_directories(console-interface 16 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src 17 | PUBLIC $ 18 | PUBLIC $ 19 | PUBLIC $ 20 | ) 21 | 22 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ 23 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 24 | ) 25 | 26 | if(${SC_CLANG_FORMAT_CODE}) 27 | target_clangformat_setup(console-interface) 28 | endif() 29 | 30 | if(${SC_BUILD_TESTS}) 31 | add_subdirectory(test) 32 | endif() 33 | -------------------------------------------------------------------------------- /src/manager/console-interface/include/console-interface/sc_component_manager.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include "sc_component_manager_command_handler.hpp" 17 | 18 | class ScComponentManager 19 | { 20 | public: 21 | explicit ScComponentManager() = default; 22 | 23 | void Run(); 24 | 25 | void Stop(); 26 | 27 | virtual ~ScComponentManager() = default; 28 | 29 | protected: 30 | void Start(); 31 | 32 | sc_bool static HasNewInput(); 33 | 34 | bool Emit(std::string const & command); 35 | 36 | private: 37 | std::thread m_instance; 38 | std::atomic m_isRunning{}; 39 | }; 40 | -------------------------------------------------------------------------------- /src/manager/console-interface/include/console-interface/sc_component_manager_command_handler.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | class ScComponentManagerCommandHandler 20 | { 21 | public: 22 | explicit ScComponentManagerCommandHandler() 23 | { 24 | m_context = new ScAgentContext(); 25 | m_actions = {"init", "search", "install"}; 26 | } 27 | 28 | bool Handle(std::string const & commandType, CommandParameters const & commandParameters) 29 | { 30 | bool executionResult; 31 | m_commandParameters = commandParameters; 32 | auto const & it = m_actions.find(commandType); 33 | if (it != m_actions.end()) 34 | { 35 | ScAddr actionAddrClass; 36 | try 37 | { 38 | actionAddrClass = common_utils::CommonUtils::managerParametersWithAgentRelations.at(*it); 39 | SC_LOG_DEBUG("ScComponentManagerCommandHandler: execute " << *it << " command"); 40 | } 41 | catch (std::out_of_range const & ex) 42 | { 43 | SC_LOG_ERROR(ex.what()); 44 | } 45 | ScAction actionAddr = m_context->GenerateAction(actionAddrClass); 46 | common_utils::CommonUtils::TranslateFromStringToScMemory(*m_context, actionAddr, commandParameters); 47 | 48 | actionAddr.InitiateAndWait(30000); 49 | 50 | executionResult = actionAddr.IsFinishedSuccessfully(); 51 | } 52 | else 53 | { 54 | SC_THROW_EXCEPTION(utils::ExceptionParseError, "Unsupported command type \"" + commandType + "\""); 55 | } 56 | 57 | return executionResult; 58 | } 59 | 60 | ~ScComponentManagerCommandHandler() 61 | { 62 | m_context->Destroy(); 63 | delete m_context; 64 | 65 | m_actions.clear(); 66 | } 67 | 68 | protected: 69 | ScAgentContext * m_context{}; 70 | CommandParameters m_commandParameters; 71 | std::set m_actions; 72 | }; 73 | -------------------------------------------------------------------------------- /src/manager/console-interface/include/console-interface/sc_component_manager_command_parser.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | class ScComponentManagerParser 15 | { 16 | public: 17 | static std::pair Parse(std::string const & command) 18 | { 19 | size_t const COMMAND_KEYWORDS_SIZE = 2; 20 | std::string const fullCommand = GetFullCommand(command); 21 | 22 | std::pair parsedCommand; 23 | std::vector commandTokens; 24 | commandTokens = ParseCommand(fullCommand); 25 | 26 | if (commandTokens.size() < COMMAND_KEYWORDS_SIZE) 27 | SC_THROW_EXCEPTION( 28 | utils::ExceptionParseError, "Incorrect command. Command type not found in \"" + command + "\""); 29 | 30 | if (commandTokens.at(0) != CommandConstants::COMPONENTS_COMMAND_PREFIX) 31 | SC_THROW_EXCEPTION( 32 | utils::ExceptionParseError, 33 | "\"" + command + "\" is not a command. Maybe you mean " + CommandConstants::COMPONENTS_COMMAND_PREFIX + "?"); 34 | 35 | parsedCommand.first = commandTokens.at(1); 36 | CommandParameters commandParameters = GetCommandParameters(commandTokens); 37 | parsedCommand.second = commandParameters; 38 | 39 | return parsedCommand; 40 | } 41 | 42 | protected: 43 | static CommandParameters GetCommandParameters(std::vector const & commandTokens) 44 | { 45 | size_t const COMMAND_KEYWORDS_SIZE = 2; 46 | char const PARAMETER_VALUES_DELIMITER = '-'; 47 | 48 | CommandParameters commandParameters; 49 | std::string parameterName; 50 | std::vector parameterValue; 51 | std::string currentCommandToken; 52 | 53 | for (size_t tokenNumber = COMMAND_KEYWORDS_SIZE; tokenNumber < commandTokens.size(); tokenNumber++) 54 | { 55 | currentCommandToken = commandTokens.at(tokenNumber); 56 | if (commandTokens[0] == CommandConstants::COMPONENTS_COMMAND_PREFIX 57 | && commandTokens[1] == CommandConstants::COMPONENTS_COMMAND_INSTALL && tokenNumber == COMMAND_KEYWORDS_SIZE 58 | && commandTokens[tokenNumber][0] != PARAMETER_VALUES_DELIMITER) 59 | { 60 | parameterName = CommandsConstantsFlags::IDTF; 61 | commandParameters.insert({parameterName, {}}); 62 | } 63 | if (currentCommandToken.at(0) == PARAMETER_VALUES_DELIMITER) 64 | { 65 | if (!parameterValue.empty()) 66 | parameterValue.clear(); 67 | 68 | parameterName = GetParameterNameAfterDelimiter(currentCommandToken, PARAMETER_VALUES_DELIMITER); 69 | if (!parameterName.empty()) 70 | commandParameters.insert({parameterName, {}}); 71 | } 72 | else 73 | { 74 | if (currentCommandToken.at(0) == '\"') 75 | currentCommandToken = currentCommandToken.substr(1, currentCommandToken.size() - 2); 76 | 77 | commandParameters[parameterName].push_back(currentCommandToken); 78 | } 79 | } 80 | 81 | InsertParametersWithoutValues(commandParameters, commandTokens, PARAMETER_VALUES_DELIMITER); 82 | 83 | return commandParameters; 84 | } 85 | 86 | static std::string GetParameterNameAfterDelimiter( 87 | std::string const & currentCommandToken, 88 | char const parameterDelimiter) 89 | { 90 | if (currentCommandToken.size() > 1 && currentCommandToken.at(1) == parameterDelimiter) 91 | return currentCommandToken.substr(2); 92 | else 93 | return currentCommandToken.substr(1); 94 | } 95 | 96 | static void InsertParametersWithoutValues( 97 | CommandParameters & commandParameters, 98 | std::vector const & commandTokens, 99 | char const parameterDelimiter) 100 | { 101 | std::string parameterName; 102 | std::vector commandParametersName; 103 | 104 | for (auto & it : commandParameters) 105 | { 106 | commandParametersName.push_back(it.first); 107 | } 108 | 109 | for (std::string const & commandToken : commandTokens) 110 | { 111 | parameterName = GetParameterName(commandToken, parameterDelimiter); 112 | if (!parameterName.empty()) 113 | { 114 | if (std::find(std::begin(commandParametersName), std::end(commandParametersName), parameterName) 115 | == std::end(commandParametersName)) 116 | commandParameters.insert({parameterName, {}}); 117 | } 118 | } 119 | } 120 | 121 | static std::string GetParameterName(std::string const & commandToken, char const parameterDelimiter) 122 | { 123 | std::string parameterName; 124 | if (commandToken.at(0) == parameterDelimiter) 125 | { 126 | parameterName = GetParameterNameAfterDelimiter(commandToken, parameterDelimiter); 127 | } 128 | 129 | return parameterName; 130 | } 131 | 132 | static std::vector ParseCommand(std::string const & command) 133 | { 134 | std::vector result; 135 | 136 | std::regex regex(R"(("[^"]+"|[^\s"]+))"); 137 | auto commandBegin = std::sregex_iterator(command.begin(), command.end(), regex); 138 | auto commandEnd = std::sregex_iterator(); 139 | for (std::sregex_iterator i = commandBegin; i != commandEnd; ++i) 140 | { 141 | std::smatch const & match = *i; 142 | std::string matchStr = match.str(); 143 | result.push_back(matchStr); 144 | } 145 | 146 | return result; 147 | } 148 | 149 | static std::vector DivideStrIntoLexems(std::string const & command) 150 | { 151 | std::stringstream commandsStream(command); 152 | std::vector tokens; 153 | while (!commandsStream.eof()) 154 | { 155 | std::string substring; 156 | commandsStream >> substring; 157 | tokens.push_back(substring); 158 | } 159 | return tokens; 160 | } 161 | 162 | static std::string DeleteMultipleSpaces(std::string const & command) 163 | { 164 | std::string shortCommand; 165 | for (size_t index = 0; index < command.size() - 1; index++) 166 | { 167 | if (command[index] == ' ' && command[index + 1] != ' ') 168 | { 169 | shortCommand.push_back(command[index]); 170 | continue; 171 | } 172 | 173 | shortCommand.push_back(command[index]); 174 | } 175 | if (command[command.size() - 1] != ' ') 176 | { 177 | shortCommand.push_back(command[command.size() - 1]); 178 | } 179 | 180 | return shortCommand; 181 | } 182 | 183 | static std::string GetFullCommand(std::string const & command) 184 | { 185 | std::string fullCommand = DeleteMultipleSpaces(command); 186 | std::stringstream subCommand; 187 | std::vector tokens = DivideStrIntoLexems(command); 188 | 189 | for (std::string & token : tokens) 190 | { 191 | if (!subCommand.str().empty()) 192 | { 193 | subCommand << " "; 194 | } 195 | subCommand << token; 196 | if (CommandConstants::COMMAND_MAP.count(subCommand.str())) 197 | { 198 | std::stringstream newFullCommand; 199 | newFullCommand << CommandConstants::COMMAND_MAP[subCommand.str()] 200 | << command.substr(subCommand.str().size(), command.size()); 201 | fullCommand = newFullCommand.str(); 202 | break; 203 | } 204 | } 205 | return fullCommand; 206 | } 207 | }; 208 | -------------------------------------------------------------------------------- /src/manager/console-interface/src/sc_component_manager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "console-interface/sc_component_manager.hpp" 14 | #include "console-interface/sc_component_manager_command_parser.hpp" 15 | 16 | static constexpr int STD_INPUT = 0; 17 | static constexpr suseconds_t WAIT_BETWEEN_SELECT_US = 250000L; 18 | 19 | void ScComponentManager::Run() 20 | { 21 | m_isRunning = SC_TRUE; 22 | m_instance = std::thread(&ScComponentManager::Start, this); 23 | } 24 | 25 | void ScComponentManager::Stop() 26 | { 27 | m_isRunning = SC_FALSE; 28 | if (m_instance.joinable()) 29 | m_instance.join(); 30 | } 31 | 32 | void ScComponentManager::Start() 33 | { 34 | std::string command; 35 | while (m_isRunning) 36 | { 37 | if (HasNewInput()) 38 | std::getline(std::cin, command); 39 | 40 | if (command.empty()) 41 | continue; 42 | 43 | try 44 | { 45 | Emit(command); 46 | } 47 | catch (utils::ScException const & exception) 48 | { 49 | SC_LOG_ERROR(exception.Message()); 50 | } 51 | 52 | command.clear(); 53 | } 54 | } 55 | 56 | sc_bool ScComponentManager::HasNewInput() 57 | { 58 | struct timeval waitTime = {0L, WAIT_BETWEEN_SELECT_US}; 59 | fd_set fds; 60 | FD_ZERO(&fds); 61 | FD_SET(STD_INPUT, &fds); 62 | int ready = select(STD_INPUT + 1, &fds, nullptr, nullptr, &waitTime); 63 | return ready > 0; 64 | } 65 | 66 | bool ScComponentManager::Emit(std::string const & command) 67 | { 68 | std::pair const parsedCommand = ScComponentManagerParser::Parse(command); 69 | ScComponentManagerCommandHandler handler; 70 | bool const executionResult = handler.Handle(parsedCommand.first, parsedCommand.second); 71 | 72 | std::string const logMessage = executionResult ? "successfully" : "unsuccessfully"; 73 | 74 | SC_LOG_DEBUG("ScComponentManager: command executed " << logMessage); 75 | 76 | return executionResult; 77 | } 78 | -------------------------------------------------------------------------------- /src/manager/console-interface/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_tests_from_folder(${CMAKE_CURRENT_LIST_DIR}/units 2 | NAME console-interface-tests 3 | DEPENDS common-lib console-interface 4 | ) 5 | 6 | if(${SC_CLANG_FORMAT_CODE}) 7 | target_clangformat_setup(console-interface-tests) 8 | endif() 9 | -------------------------------------------------------------------------------- /src/manager/console-interface/test/units/sc_component_manager_test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | class ScComponentManagerTest : public testing::Test 18 | { 19 | protected: 20 | void SetUp() override 21 | { 22 | m_commandParser = std::make_unique(); 23 | } 24 | 25 | void TearDown() override {} 26 | 27 | protected: 28 | std::unique_ptr m_commandParser; 29 | }; 30 | -------------------------------------------------------------------------------- /src/manager/console-interface/test/units/test_command_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include 8 | 9 | #include "sc_component_manager_test.hpp" 10 | 11 | TEST_F(ScComponentManagerTest, ParseCommandTypes) 12 | { 13 | std::string commandType; 14 | 15 | commandType = m_commandParser->Parse("components init").first; 16 | EXPECT_EQ(commandType, "init"); 17 | 18 | commandType = m_commandParser->Parse("components init -p param").first; 19 | EXPECT_EQ(commandType, "init"); 20 | 21 | commandType = m_commandParser->Parse("components init --parameter param").first; 22 | EXPECT_EQ(commandType, "init"); 23 | 24 | commandType = m_commandParser->Parse("components init -f").first; 25 | EXPECT_EQ(commandType, "init"); 26 | 27 | commandType = m_commandParser->Parse("components search").first; 28 | EXPECT_EQ(commandType, "search"); 29 | 30 | commandType = m_commandParser->Parse("components search -").first; 31 | EXPECT_EQ(commandType, "search"); 32 | 33 | commandType = m_commandParser->Parse("components install").first; 34 | EXPECT_EQ(commandType, "install"); 35 | } 36 | 37 | TEST_F(ScComponentManagerTest, ParseCommandParameters) 38 | { 39 | std::pair parsed = 40 | m_commandParser->Parse("components search --class concept_kb_component"); 41 | EXPECT_EQ(parsed.second.size(), 1u); 42 | EXPECT_EQ(parsed.second.at("class").size(), 1u); 43 | EXPECT_TRUE(parsed.second.at("class").at(0) == "concept_kb_component"); 44 | 45 | parsed = m_commandParser->Parse("components search --class class1 class2 -a author1 -r"); 46 | EXPECT_EQ(parsed.second.size(), 3u); 47 | EXPECT_EQ(parsed.second.at("class").size(), 2u); 48 | EXPECT_EQ(parsed.second.at("a").size(), 1u); 49 | EXPECT_EQ(parsed.second.at("r").size(), 0u); 50 | } 51 | 52 | TEST_F(ScComponentManagerTest, ParseIncorrectCommands) 53 | { 54 | EXPECT_ANY_THROW(m_commandParser->Parse("components")); 55 | EXPECT_ANY_THROW(m_commandParser->Parse("foo init")); 56 | EXPECT_ANY_THROW(m_commandParser->Parse("copmonents init")); 57 | EXPECT_ANY_THROW(m_commandParser->Parse("componentsinit")); 58 | EXPECT_ANY_THROW(m_commandParser->Parse("search components")); 59 | } 60 | 61 | TEST_F(ScComponentManagerTest, ParseInstallCommandsFlag) 62 | { 63 | std::string commandType; 64 | std::map> commandValues; 65 | std::pair>> commandWithValues; 66 | 67 | commandWithValues = m_commandParser->Parse("components install sc_web "); 68 | commandType = commandWithValues.first; 69 | commandValues = commandWithValues.second; 70 | EXPECT_EQ(commandType, "install"); 71 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 72 | EXPECT_EQ(commandValues.size(), 1u); 73 | 74 | commandWithValues = m_commandParser->Parse("components install --idtf sc_web"); 75 | commandType = commandWithValues.first; 76 | commandValues = commandWithValues.second; 77 | EXPECT_EQ(commandType, "install"); 78 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 79 | EXPECT_EQ(commandValues.size(), 1u); 80 | 81 | commandWithValues = m_commandParser->Parse("cinst --idtf sc_web"); 82 | commandType = commandWithValues.first; 83 | commandValues = commandWithValues.second; 84 | EXPECT_EQ(commandType, "install"); 85 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 86 | EXPECT_EQ(1u, commandValues.size()); 87 | 88 | commandWithValues = m_commandParser->Parse("cinst sc_web"); 89 | commandType = commandWithValues.first; 90 | commandValues = commandWithValues.second; 91 | EXPECT_EQ(commandType, "install"); 92 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 93 | EXPECT_EQ(1u, commandValues.size()); 94 | 95 | commandWithValues = m_commandParser->Parse("comp inst --idtf sc_web"); 96 | commandType = commandWithValues.first; 97 | commandValues = commandWithValues.second; 98 | EXPECT_EQ(commandType, "install"); 99 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 100 | EXPECT_EQ(1u, commandValues.size()); 101 | 102 | commandWithValues = m_commandParser->Parse("comp inst sc_web"); 103 | commandType = commandWithValues.first; 104 | commandValues = commandWithValues.second; 105 | EXPECT_EQ(commandType, "install"); 106 | EXPECT_EQ(commandValues["idtf"][0], "sc_web"); 107 | EXPECT_EQ(1u, commandValues.size()); 108 | 109 | commandWithValues = m_commandParser->Parse(" components install"); 110 | commandType = commandWithValues.first; 111 | commandValues = commandWithValues.second; 112 | EXPECT_EQ(commandType, "install"); 113 | EXPECT_EQ(commandValues.size(), 0u); 114 | } 115 | 116 | TEST_F(ScComponentManagerTest, ParseSearchCommandExplanationFlag) 117 | { 118 | std::string commandType; 119 | std::map> commandValues; 120 | std::pair>> commandWithValues; 121 | 122 | commandWithValues = m_commandParser->Parse("components search --explanation SC"); 123 | commandType = commandWithValues.first; 124 | commandValues = commandWithValues.second; 125 | EXPECT_EQ(commandType, "search"); 126 | EXPECT_EQ(commandValues["explanation"][0], "SC"); 127 | EXPECT_EQ(commandValues.size(), 1u); 128 | 129 | commandWithValues = m_commandParser->Parse("components search --explanation \"SC\""); 130 | commandType = commandWithValues.first; 131 | commandValues = commandWithValues.second; 132 | EXPECT_EQ(commandType, "search"); 133 | EXPECT_EQ(commandValues["explanation"][0], "SC"); 134 | EXPECT_EQ(commandValues.size(), 1u); 135 | 136 | EXPECT_NO_THROW(m_commandParser->Parse("components search --explanation")); 137 | commandWithValues = m_commandParser->Parse("components search --explanation"); 138 | commandType = commandWithValues.first; 139 | commandValues = commandWithValues.second; 140 | EXPECT_EQ(commandType, "search"); 141 | EXPECT_EQ(commandValues["explanation"].size(), 0u); 142 | } 143 | -------------------------------------------------------------------------------- /src/manager/console-interface/test/units/test_url_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "sc_component_manager_test.hpp" 12 | 13 | TEST_F(ScComponentManagerTest, ParseRepositoryUrl) 14 | { 15 | std::string const repositoryUrlAddress = "https://github.com/username/repository-name"; 16 | RepositoryUrlParser parser; 17 | parser.Parse(repositoryUrlAddress); 18 | 19 | std::string const urlAddress = parser.GetUrlAddress(); 20 | std::string const username = parser.GetUsername(); 21 | std::string const repositoryName = parser.GetRepositoryName(); 22 | std::string const directoryName = parser.GetDirectoryName(); 23 | std::string const repositoryUrl = parser.GetRepositoryUrl(); 24 | std::string const branchName = parser.GetBranchName(); 25 | 26 | EXPECT_EQ(urlAddress, repositoryUrlAddress); 27 | EXPECT_EQ(username, "username"); 28 | EXPECT_EQ(repositoryName, "repository-name"); 29 | EXPECT_EQ(directoryName, ""); 30 | EXPECT_EQ(repositoryUrl, repositoryUrlAddress); 31 | EXPECT_EQ(branchName, ""); 32 | } 33 | 34 | TEST_F(ScComponentManagerTest, ParseRepositoryRealUrl) 35 | { 36 | std::string const repositoryUrlAddress = "https://github.com/MksmOrlov/ostis-kb-lib"; 37 | RepositoryUrlParser parser; 38 | parser.Parse(repositoryUrlAddress); 39 | 40 | std::string const urlAddress = parser.GetUrlAddress(); 41 | std::string const username = parser.GetUsername(); 42 | std::string const repositoryName = parser.GetRepositoryName(); 43 | std::string const directoryName = parser.GetDirectoryName(); 44 | std::string const repositoryUrl = parser.GetRepositoryUrl(); 45 | std::string const branchName = parser.GetBranchName(); 46 | 47 | EXPECT_EQ(urlAddress, repositoryUrlAddress); 48 | EXPECT_EQ(username, "MksmOrlov"); 49 | EXPECT_EQ(repositoryName, "ostis-kb-lib"); 50 | EXPECT_EQ(directoryName, ""); 51 | EXPECT_EQ(repositoryUrl, repositoryUrlAddress); 52 | EXPECT_EQ(branchName, ""); 53 | } 54 | 55 | TEST_F(ScComponentManagerTest, ParseRepositoryUrlWithDirectory) 56 | { 57 | std::string const repositoryUrlAddress = "https://github.com/MksmOrlov/ostis-kb-lib/tree/main/part_methods_tools"; 58 | RepositoryUrlParser parser; 59 | parser.Parse(repositoryUrlAddress); 60 | 61 | std::string const urlAddress = parser.GetUrlAddress(); 62 | std::string const username = parser.GetUsername(); 63 | std::string const repositoryName = parser.GetRepositoryName(); 64 | std::string const directoryName = parser.GetDirectoryName(); 65 | std::string const repositoryUrl = parser.GetRepositoryUrl(); 66 | std::string const branchName = parser.GetBranchName(); 67 | 68 | EXPECT_EQ(urlAddress, repositoryUrlAddress); 69 | EXPECT_EQ(username, "MksmOrlov"); 70 | EXPECT_EQ(repositoryName, "ostis-kb-lib"); 71 | EXPECT_EQ(directoryName, "part_methods_tools"); 72 | EXPECT_EQ(branchName, "main"); 73 | EXPECT_EQ(repositoryUrl, "https://github.com/MksmOrlov/ostis-kb-lib"); 74 | } 75 | 76 | TEST_F(ScComponentManagerTest, ParseRepositoryUrlWithSubdirectory) 77 | { 78 | std::string const repositoryUrlAddress = 79 | "https://github.com/username/repository-name/tree/main/directory/subdirectory"; 80 | RepositoryUrlParser parser; 81 | parser.Parse(repositoryUrlAddress); 82 | 83 | std::string const urlAddress = parser.GetUrlAddress(); 84 | std::string const username = parser.GetUsername(); 85 | std::string const repositoryName = parser.GetRepositoryName(); 86 | std::string const directoryName = parser.GetDirectoryName(); 87 | std::string const repositoryUrl = parser.GetRepositoryUrl(); 88 | std::string const branchName = parser.GetBranchName(); 89 | 90 | EXPECT_EQ(urlAddress, repositoryUrlAddress); 91 | EXPECT_EQ(username, "username"); 92 | EXPECT_EQ(repositoryName, "repository-name"); 93 | EXPECT_EQ(directoryName, "directory/subdirectory"); 94 | EXPECT_EQ(branchName, "main"); 95 | EXPECT_EQ(repositoryUrl, "https://github.com/username/repository-name"); 96 | } 97 | -------------------------------------------------------------------------------- /src/module/sc_component_manager_module.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #include "sc_component_manager_module.hpp" 8 | 9 | #include 10 | 11 | SC_MODULE_REGISTER(ScComponentManagerModule); 12 | 13 | void ScComponentManagerModule::Initialize(ScMemoryContext * context) 14 | { 15 | std::string const KB_COMPONENTS_PATH = "knowledge_base_components_path"; 16 | std::string const PS_COMPONENTS_PATH = "problem_solver_components_path"; 17 | std::string const INTERFACE_COMPONENTS_PATH = "interface_components_path"; 18 | 19 | // It is backward compatible logic. We should configure platform-dependent components from kb 20 | ScConfig config{ 21 | ScMemory::ms_configPath, 22 | {KB_COMPONENTS_PATH, PS_COMPONENTS_PATH, INTERFACE_COMPONENTS_PATH, "repo_path", "extensions_path", "log_file"}}; 23 | ScConfigGroup managerConfig = config["sc-component-manager"]; 24 | for (std::string const & key : *managerConfig) 25 | m_params.Insert({key, managerConfig[key]}); 26 | 27 | common_utils::CommonUtils::InitParametersMap(); 28 | if (!common_utils::CommonUtils::CheckIfFullMyselfDecompositionExists(*context)) 29 | { 30 | common_utils::CommonUtils::CreateMyselfDecomposition(*context); 31 | } 32 | 33 | try 34 | { 35 | m_scComponentManager = std::make_unique(); 36 | if (!m_scComponentManager) 37 | return; 38 | 39 | m_scComponentManager->Run(); 40 | SC_LOG_INFO("[sc-component-manager] Sc-component-manager run"); 41 | } 42 | catch (utils::ScException const & exception) 43 | { 44 | SC_LOG_ERROR("[sc-component-manager] " << exception.Description()); 45 | ScComponentManagerModule::Shutdown(context); 46 | } 47 | } 48 | 49 | void ScComponentManagerModule::Shutdown(ScMemoryContext * context) 50 | { 51 | common_utils::CommonUtils::ClearParametersMap(); 52 | 53 | if (m_scComponentManager) 54 | m_scComponentManager->Stop(); 55 | SC_LOG_INFO("[sc-component-manager] Sc-component-manager stopped"); 56 | m_scComponentManager.reset(); 57 | } 58 | -------------------------------------------------------------------------------- /src/module/sc_component_manager_module.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source file is part of an OSTIS project. For the latest info, see http://ostis.net 3 | * Distributed under the MIT License 4 | * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | class ScComponentManagerModule : public ScModule 15 | { 16 | public: 17 | void Initialize(ScMemoryContext * context) override; 18 | 19 | void Shutdown(ScMemoryContext * context) override; 20 | 21 | protected: 22 | ScParams m_params; 23 | std::unique_ptr m_scComponentManager; 24 | }; 25 | --------------------------------------------------------------------------------