Skip to content

Commit

Permalink
Refactor SmartSettings integration across modules
Browse files Browse the repository at this point in the history
- Removed `SmartSettings` references from multiple files, including tests and package.json, to streamline the codebase and improve modularity.
- Added `SmartSettings` import in `smart_env.js` to ensure proper initialization within the Smart Environment.
- Updated `.scignore` to include a new directory for better organization.

These changes enhance code clarity and maintainability by reducing unnecessary dependencies and ensuring consistent integration of settings management.
  • Loading branch information
Brian Joseph Petro committed Dec 24, 2024
1 parent fa8def7 commit 2a739bc
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 27 deletions.
1 change: 1 addition & 0 deletions .scignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
utils/
♻️/
1 change: 0 additions & 1 deletion smart-clusters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"smart-embed-model": "file:../smart-embed-model",
"smart-environment": "file:../smart-environment",
"smart-fs": "file:../smart-fs",
"smart-settings": "file:../smart-settings",
"smart-sources": "file:../smart-sources"
},
"ava": {
Expand Down
3 changes: 0 additions & 3 deletions smart-clusters/test/source_clusters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { execSync } from 'child_process';
import { SmartEnv } from 'smart-environment/smart_env.js';
import { NodeFsSmartFsAdapter } from 'smart-fs/adapters/node_fs.js';
import { SmartFs } from 'smart-fs/smart_fs.js';
import { SmartSettings } from 'smart-settings/smart_settings.js';

import { SmartSources, SmartSource } from 'smart-sources';
import { MarkdownSourceContentAdapter } from 'smart-sources/adapters/markdown_source.js';
Expand Down Expand Up @@ -53,8 +52,6 @@ async function create_integration_env() {
modules: {
// minimal or real FS
smart_fs: { class: SmartFs, adapter: NodeFsSmartFsAdapter },
// basic settings
smart_settings: { class: SmartSettings },
// optional embed model
smart_embed_model: {
class: SmartEmbedModel,
Expand Down
1 change: 0 additions & 1 deletion smart-entities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"smart-blocks": "file:../smart-blocks",
"smart-environment": "file:../smart-environment",
"smart-fs": "file:../smart-fs",
"smart-settings": "file:../smart-settings",
"smart-sources": "file:../smart-sources"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion smart-entities/test/transformers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ test.before(async (t) => {
env_path: contentDir,
modules: {
smart_fs: { class: SmartFs, adapter: NodeFsSmartFsAdapter },
smart_settings: { class: SmartSettings },
smart_embed_model: {
class: SmartEmbedModel,
adapters: {
Expand Down
1 change: 1 addition & 0 deletions smart-environment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"smart-change": "../smart-change",
"smart-embed-model": "../smart-embed-model-v1",
"smart-file-system": "../smart-fs",
"smart-settings": "../smart-settings",
"smart-sources": "../smart-sources",
"smart-view": "../smart-view"
}
Expand Down
3 changes: 2 additions & 1 deletion smart-environment/smart_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import { render as settings_template } from './components/settings.js';
import { SmartSettings } from 'smart-settings/smart_settings.js';

/**
* @class SmartEnv
Expand Down Expand Up @@ -75,7 +76,7 @@ export class SmartEnv {
this.is_init = true;
const main_key = this.init_main(main, main_env_opts);
await this.fs.load_files(); // skips exclusions (smart_sources.fs respects exclusions); runs before smart_settings for detecting env_data_dir
await this.opts.modules.smart_settings.class.create(this);
await SmartSettings.create(this);
await this.load_main(main_key);
this.is_init = false;
return main_key;
Expand Down
3 changes: 1 addition & 2 deletions smart-sources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"ava": "^6.0.1",
"smart-blocks": "file:../smart-blocks",
"smart-environment": "file:../smart-environment",
"smart-fs": "file:../smart-fs",
"smart-settings": "file:../smart-settings"
"smart-fs": "file:../smart-fs"
},
"dependencies": {
"smart-collections": "file:../smart-collections",
Expand Down
4 changes: 0 additions & 4 deletions smart-sources/test/ajson_multi_file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import test from 'ava';
import { SmartEnv } from '../../smart-environment/smart_env.js';
import { SmartFs } from '../../smart-fs/smart_fs.js';
import { NodeFsSmartFsAdapter } from '../../smart-fs/adapters/node_fs.js';
import { SmartSettings } from '../../smart-settings/smart_settings.js';
import { MarkdownSourceContentAdapter } from '../adapters/markdown_source.js';
import { SmartSources } from '../smart_sources.js';
import { SmartSource } from '../smart_source.js';
Expand All @@ -20,9 +19,6 @@ class TestMultiFileSourceMain {
return {
env_path: __dirname + 'test-content',
modules: {
smart_settings: {
class: SmartSettings,
},
smart_fs: {
class: SmartFs,
adapter: NodeFsSmartFsAdapter,
Expand Down
2 changes: 0 additions & 2 deletions smart-sources/test/markdown_source.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { SmartSources } from 'smart-sources/smart_sources.js';
import { SmartSource } from 'smart-sources/smart_source.js';
import { SmartBlocks } from 'smart-blocks/smart_blocks.js';
import { SmartBlock } from 'smart-blocks/smart_block.js';
import { SmartSettings } from 'smart-settings/smart_settings.js';
import { MarkdownSourceContentAdapter } from 'smart-sources/adapters/markdown_source.js';
import { MarkdownBlockContentAdapter } from 'smart-blocks/adapters/markdown_block.js';
import ajson_data_adapter from 'smart-sources/adapters/data/ajson_multi_file.js';
Expand All @@ -58,7 +57,6 @@ async function create_test_env() {
env_path: env_path,
modules: {
smart_fs: { class: SmartFs, adapter: NodeFsSmartFsAdapter },
smart_settings: { class: SmartSettings },
},

collections: {
Expand Down
4 changes: 0 additions & 4 deletions smart-sources/test/old-tests (needs review)/_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { SmartEmbedModel } from '../../smart-embed-model-v1/smart_embed_model.js
import { SmartEmbedTransformersAdapter } from '../../smart-embed-model-v1/adapters/transformers.js';
import { SmartEmbedOpenAIAdapter } from '../../smart-embed-model-v1/adapters/openai.js';
import { SmartFs } from '../../smart-fs/smart_fs.js';
import { SmartSettings } from '../../smart-settings/smart_settings.js';
const __dirname = new URL('.', import.meta.url).pathname;

class TestMain {
Expand All @@ -36,9 +35,6 @@ class TestMain {
class: SmartFs,
adapter: SmartFsTestAdapter,
},
smart_settings: {
class: SmartSettings,
},
},
collections: {
smart_sources: {
Expand Down
4 changes: 0 additions & 4 deletions smart-sources/test/sqlite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import test from 'ava';
import { SmartEnv } from '../../smart-environment/smart_env.js';
import { SmartFs } from '../../smart-fs/smart_fs.js';
import { NodeFsSmartFsAdapter } from '../../smart-fs/adapters/node_fs.js';
import { SmartSettings } from '../../smart-settings/smart_settings.js';
import { MarkdownSourceContentAdapter } from '../adapters/markdown_source.js';
import { SmartSources } from '../smart_sources.js';
import { SmartSource } from '../smart_source.js';
Expand All @@ -20,9 +19,6 @@ class TestMultiFileSourceMain {
return {
env_path: __dirname + 'test-content',
modules: {
smart_settings: {
class: SmartSettings,
},
smart_fs: {
class: SmartFs,
adapter: NodeFsSmartFsAdapter,
Expand Down
4 changes: 0 additions & 4 deletions smart-templates/test/_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SmartEmbedTransformersAdapter } from '../../smart-embed-model-v1/adapte
import { SmartEmbedOpenAIAdapter } from '../../smart-embed-model-v1/adapters/openai.js';
import { SmartFs } from '../../smart-fs/smart_fs.js';
import { SmartFsTestAdapter } from '../../smart-fs/adapters/_test.js';
import { SmartSettings } from '../../smart-settings/smart_settings.js';
import { SmartChatModel } from '../../smart-chat-model/smart_chat_model.js'; // Import SmartChatModel
import { SmartTemplateEjsAdapter } from '../adapters/ejs.js';
import { SmartTemplateMarkdownAdapter } from '../adapters/markdown.js';
Expand Down Expand Up @@ -76,9 +75,6 @@ class TestMain {
class: SmartFs,
adapter: SmartFsTestAdapter,
},
smart_settings: {
class: SmartSettings,
},
smart_chat_model: {
class: MockSmartChatModel, // Use the mocked SmartChatModel
adapters: {}, // Add any necessary adapters if required
Expand Down

0 comments on commit 2a739bc

Please sign in to comment.