@ai-setting/roy-agent-core 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +1647 -0
- package/dist/index.js +12579 -89691
- package/package.json +19 -56
- package/src/config/config-component.test.ts +0 -627
- package/src/config/config-component.ts +0 -906
- package/src/config/config-parser.test.ts +0 -319
- package/src/config/config-parser.ts +0 -203
- package/src/config/decentralized-config.test.ts +0 -740
- package/src/config/env-key.ts +0 -210
- package/src/config/env-source.test.ts +0 -252
- package/src/config/env-source.ts +0 -301
- package/src/config/file-source.test.ts +0 -357
- package/src/config/file-source.ts +0 -421
- package/src/config/index.ts +0 -24
- package/src/config/protocol-resolver.test.ts +0 -217
- package/src/config/protocol-resolver.ts +0 -228
- package/src/env/agent/agent-component.abort.test.ts +0 -511
- package/src/env/agent/agent-component.record-session.test.ts +0 -349
- package/src/env/agent/agent-component.test.ts +0 -1389
- package/src/env/agent/agent-component.tool-error.test.ts +0 -327
- package/src/env/agent/agent-component.ts +0 -1711
- package/src/env/agent/agent-config-registration.test.ts +0 -226
- package/src/env/agent/agent-config-registration.ts +0 -46
- package/src/env/agent/agent-reminder-plugin.integration.test.ts +0 -243
- package/src/env/agent/index.ts +0 -10
- package/src/env/agent/summary-agent.parse-hint.test.ts +0 -360
- package/src/env/agent/summary-agent.ts +0 -508
- package/src/env/agent/types.ts +0 -536
- package/src/env/commands/commands-component.test.ts +0 -364
- package/src/env/commands/commands-component.ts +0 -604
- package/src/env/commands/commands-config-registration.test.ts +0 -198
- package/src/env/commands/commands-config-registration.ts +0 -38
- package/src/env/commands/index.ts +0 -21
- package/src/env/commands/parser.test.ts +0 -203
- package/src/env/commands/parser.ts +0 -115
- package/src/env/commands/types.ts +0 -184
- package/src/env/commands-prompt-integration.test.ts +0 -243
- package/src/env/component-env.test.ts +0 -119
- package/src/env/component.ts +0 -335
- package/src/env/constants.test.ts +0 -72
- package/src/env/constants.ts +0 -123
- package/src/env/debug/debug-component.test.ts +0 -114
- package/src/env/debug/debug-component.ts +0 -547
- package/src/env/debug/formatters/index.ts +0 -9
- package/src/env/debug/formatters/repl-formatter.test.ts +0 -139
- package/src/env/debug/formatters/repl-formatter.ts +0 -358
- package/src/env/debug/formatters/trace-formatter.test.ts +0 -119
- package/src/env/debug/formatters/trace-formatter.ts +0 -191
- package/src/env/debug/formatters/tree-formatter.test.ts +0 -107
- package/src/env/debug/formatters/tree-formatter.ts +0 -325
- package/src/env/debug/index.ts +0 -38
- package/src/env/debug/parser/regex-parser.test.ts +0 -201
- package/src/env/debug/parser/regex-parser.ts +0 -196
- package/src/env/debug/parser/span-builder.test.ts +0 -241
- package/src/env/debug/parser/span-builder.ts +0 -386
- package/src/env/debug/reader/log-reader.test.ts +0 -170
- package/src/env/debug/reader/log-reader.ts +0 -186
- package/src/env/debug/reader/span-db-reader.test.ts +0 -118
- package/src/env/debug/reader/span-db-reader.ts +0 -201
- package/src/env/debug/types.test.ts +0 -187
- package/src/env/debug/types.ts +0 -171
- package/src/env/environment-init.test.ts +0 -183
- package/src/env/environment-lifecycle.test.ts +0 -516
- package/src/env/environment-service.test.ts +0 -332
- package/src/env/environment.handle-query.test.ts +0 -96
- package/src/env/environment.test.ts +0 -232
- package/src/env/environment.ts +0 -708
- package/src/env/errors.test.ts +0 -165
- package/src/env/errors.ts +0 -157
- package/src/env/event-source/event-source-agent-handler.test.ts +0 -193
- package/src/env/event-source/event-source-agent-handler.ts +0 -111
- package/src/env/event-source/event-source-component.process-cleanup.test.ts +0 -236
- package/src/env/event-source/event-source-component.stop.test.ts +0 -346
- package/src/env/event-source/event-source-component.test.ts +0 -1207
- package/src/env/event-source/event-source-component.ts +0 -1379
- package/src/env/event-source/event-source-config-registration.test.ts +0 -242
- package/src/env/event-source/event-source-config-registration.ts +0 -37
- package/src/env/event-source/event-source-integration.test.ts +0 -320
- package/src/env/event-source/event-source-platform.test.ts +0 -630
- package/src/env/event-source/types.ts +0 -298
- package/src/env/hook/global-hook-manager.ts +0 -162
- package/src/env/hook/hook-manager.test.ts +0 -374
- package/src/env/hook/hook-manager.ts +0 -309
- package/src/env/hook/index.ts +0 -38
- package/src/env/hook/types.ts +0 -138
- package/src/env/index.ts +0 -144
- package/src/env/interface.ts +0 -203
- package/src/env/llm/hooks.test.ts +0 -293
- package/src/env/llm/hooks.ts +0 -316
- package/src/env/llm/index.ts +0 -61
- package/src/env/llm/invoke-threshold-check.test.ts +0 -88
- package/src/env/llm/invoke-timeout.test.ts +0 -54
- package/src/env/llm/invoke.test.ts +0 -71
- package/src/env/llm/invoke.ts +0 -1039
- package/src/env/llm/llm-config.test.ts +0 -523
- package/src/env/llm/llm.test.ts +0 -233
- package/src/env/llm/llm.ts +0 -568
- package/src/env/llm/provider.test.ts +0 -182
- package/src/env/llm/provider.ts +0 -108
- package/src/env/llm/transform.test.ts +0 -251
- package/src/env/llm/transform.ts +0 -286
- package/src/env/llm/types.test.ts +0 -580
- package/src/env/llm/types.ts +0 -424
- package/src/env/log-trace/decorator-otel.test.ts +0 -182
- package/src/env/log-trace/decorator.ts +0 -230
- package/src/env/log-trace/index.ts +0 -79
- package/src/env/log-trace/log-trace-component.test.ts +0 -242
- package/src/env/log-trace/log-trace-component.ts +0 -497
- package/src/env/log-trace/log-trace-config-registration.test.ts +0 -348
- package/src/env/log-trace/log-trace-config-registration.ts +0 -45
- package/src/env/log-trace/logger.test.ts +0 -149
- package/src/env/log-trace/logger.ts +0 -522
- package/src/env/log-trace/opentelemetry/cli-propagation.test.ts +0 -147
- package/src/env/log-trace/opentelemetry/cli-propagation.ts +0 -194
- package/src/env/log-trace/opentelemetry/integration.test.ts +0 -668
- package/src/env/log-trace/opentelemetry/mod.ts +0 -25
- package/src/env/log-trace/opentelemetry/propagation-env.test.ts +0 -181
- package/src/env/log-trace/opentelemetry/propagation-env.ts +0 -136
- package/src/env/log-trace/opentelemetry/propagation.test.ts +0 -259
- package/src/env/log-trace/opentelemetry/propagation.ts +0 -215
- package/src/env/log-trace/opentelemetry/tracer-provider-context.test.ts +0 -166
- package/src/env/log-trace/opentelemetry/tracer-provider.test.ts +0 -379
- package/src/env/log-trace/opentelemetry/tracer-provider.ts +0 -612
- package/src/env/log-trace/span-storage.test.ts +0 -145
- package/src/env/log-trace/span-storage.ts +0 -230
- package/src/env/log-trace/trace-context.test.ts +0 -187
- package/src/env/log-trace/trace-context.ts +0 -162
- package/src/env/log-trace/types.test.ts +0 -63
- package/src/env/log-trace/types.ts +0 -172
- package/src/env/mcp/README.md +0 -244
- package/src/env/mcp/__integration__/mcp-component.integration.test.ts +0 -373
- package/src/env/mcp/config.test.ts +0 -74
- package/src/env/mcp/config.ts +0 -116
- package/src/env/mcp/index.ts +0 -41
- package/src/env/mcp/loader.test.ts +0 -161
- package/src/env/mcp/loader.ts +0 -209
- package/src/env/mcp/mcp-component.test.ts +0 -111
- package/src/env/mcp/mcp-component.ts +0 -358
- package/src/env/mcp/mcp-config-registration.test.ts +0 -304
- package/src/env/mcp/mcp-config-registration.ts +0 -50
- package/src/env/mcp/scanner.test.ts +0 -170
- package/src/env/mcp/scanner.ts +0 -246
- package/src/env/mcp/tool/adapter.test.ts +0 -520
- package/src/env/mcp/tool/adapter.ts +0 -521
- package/src/env/mcp/tool/index.ts +0 -5
- package/src/env/mcp/types.test.ts +0 -171
- package/src/env/mcp/types.ts +0 -79
- package/src/env/memory/README.md +0 -177
- package/src/env/memory/built-in/index.ts +0 -59
- package/src/env/memory/built-in/recall-memory.ts +0 -103
- package/src/env/memory/built-in/record-memory.ts +0 -148
- package/src/env/memory/index.ts +0 -20
- package/src/env/memory/memory-component.test.ts +0 -239
- package/src/env/memory/memory-component.ts +0 -503
- package/src/env/memory/memory-config-registration.test.ts +0 -67
- package/src/env/memory/memory-config-registration.ts +0 -48
- package/src/env/memory/memory-config.ts +0 -45
- package/src/env/memory/memory-file.test.ts +0 -268
- package/src/env/memory/plugin/index.ts +0 -48
- package/src/env/memory/plugin/memory-agent.test.ts +0 -249
- package/src/env/memory/plugin/memory-agent.ts +0 -365
- package/src/env/memory/plugin/memory-manager.ts +0 -198
- package/src/env/memory/plugin/memory-plugin-agent.test.ts +0 -145
- package/src/env/memory/plugin/memory-plugin.ts +0 -210
- package/src/env/memory/plugin/plugin-simplified.test.ts +0 -51
- package/src/env/memory/plugin/recall-memory.test.ts +0 -106
- package/src/env/memory/plugin/recall-memory.ts +0 -53
- package/src/env/memory/plugin/types.ts +0 -101
- package/src/env/memory/tools/memory-agent-tools.ts +0 -228
- package/src/env/memory/types.ts +0 -85
- package/src/env/paths.ts +0 -118
- package/src/env/prompt/index.ts +0 -18
- package/src/env/prompt/memory-prompts.test.ts +0 -91
- package/src/env/prompt/prompt-component.test.ts +0 -491
- package/src/env/prompt/prompt-component.ts +0 -619
- package/src/env/prompt/prompt-config-registration.test.ts +0 -213
- package/src/env/prompt/prompt-config-registration.ts +0 -39
- package/src/env/prompt/prompts-index.ts +0 -504
- package/src/env/prompt/renderer.ts +0 -67
- package/src/env/prompt/types.ts +0 -136
- package/src/env/session/hooks.ts +0 -18
- package/src/env/session/index.ts +0 -37
- package/src/env/session/search-query-parser.test.ts +0 -425
- package/src/env/session/search-query-parser.ts +0 -171
- package/src/env/session/session-checkpoint.test.ts +0 -523
- package/src/env/session/session-component.extract-recent-messages.test.ts +0 -209
- package/src/env/session/session-component.test.ts +0 -132
- package/src/env/session/session-component.ts +0 -1249
- package/src/env/session/session-config-registration.test.ts +0 -138
- package/src/env/session/session-config-registration.ts +0 -52
- package/src/env/session/session-message-converter.test.ts +0 -763
- package/src/env/session/session-message-converter.ts +0 -415
- package/src/env/session/session-message-e2e.test.ts +0 -448
- package/src/env/session/session-search.test.ts +0 -391
- package/src/env/session/session-store.test.ts +0 -362
- package/src/env/session/session-store.ts +0 -141
- package/src/env/session/storage/index.ts +0 -6
- package/src/env/session/storage/memory.ts +0 -502
- package/src/env/session/storage/sqlite.ts +0 -794
- package/src/env/session/types.ts +0 -742
- package/src/env/skill/config.ts +0 -39
- package/src/env/skill/index.ts +0 -6
- package/src/env/skill/parser.test.ts +0 -116
- package/src/env/skill/parser.ts +0 -77
- package/src/env/skill/scanner.test.ts +0 -211
- package/src/env/skill/scanner.ts +0 -119
- package/src/env/skill/skill-component.test.ts +0 -234
- package/src/env/skill/skill-component.ts +0 -352
- package/src/env/skill/skill-config-registration.test.ts +0 -60
- package/src/env/skill/skill-config-registration.ts +0 -43
- package/src/env/skill/tool/index.ts +0 -1
- package/src/env/skill/tool/skill-tool.test.ts +0 -100
- package/src/env/skill/tool/skill-tool.ts +0 -72
- package/src/env/skill/types.ts +0 -64
- package/src/env/task/delegate/delegate-tool.test.ts +0 -498
- package/src/env/task/delegate/delegate-tool.ts +0 -1014
- package/src/env/task/delegate/index.ts +0 -18
- package/src/env/task/delegate/stop-tool.test.ts +0 -140
- package/src/env/task/delegate/stop-tool.ts +0 -119
- package/src/env/task/delegate/task-events.test.ts +0 -178
- package/src/env/task/delegate/task-events.ts +0 -143
- package/src/env/task/hooks/contexts.test.ts +0 -92
- package/src/env/task/hooks/contexts.ts +0 -192
- package/src/env/task/hooks/index.ts +0 -23
- package/src/env/task/hooks/task-hook-points.test.ts +0 -32
- package/src/env/task/hooks/task-hook-points.ts +0 -54
- package/src/env/task/index.ts +0 -7
- package/src/env/task/plugins/index.ts +0 -13
- package/src/env/task/plugins/task-plugin.test.ts +0 -74
- package/src/env/task/plugins/task-plugin.ts +0 -89
- package/src/env/task/plugins/task-tag-plugin.test.ts +0 -377
- package/src/env/task/plugins/task-tag-plugin.ts +0 -319
- package/src/env/task/plugins/task-workflow-extractor.integration.test.ts +0 -226
- package/src/env/task/plugins/workflow-extractor-agent.test.ts +0 -107
- package/src/env/task/plugins/workflow-extractor-agent.ts +0 -225
- package/src/env/task/storage/index.ts +0 -6
- package/src/env/task/storage/sqlite-task-store.test.ts +0 -283
- package/src/env/task/storage/sqlite-task-store.ts +0 -903
- package/src/env/task/storage/task-search.test.ts +0 -291
- package/src/env/task/tag-service.test.ts +0 -198
- package/src/env/task/tag-service.ts +0 -264
- package/src/env/task/task-component.test.ts +0 -193
- package/src/env/task/task-component.ts +0 -658
- package/src/env/task/task-config-registration.test.ts +0 -57
- package/src/env/task/task-config-registration.ts +0 -37
- package/src/env/task/task-types.test.ts +0 -137
- package/src/env/task/tools/complete-tool.ts +0 -44
- package/src/env/task/tools/create-tool.ts +0 -49
- package/src/env/task/tools/delete-tool.ts +0 -43
- package/src/env/task/tools/get-tool.ts +0 -59
- package/src/env/task/tools/index.ts +0 -10
- package/src/env/task/tools/list-tool.ts +0 -40
- package/src/env/task/tools/operation/create-tool.ts +0 -48
- package/src/env/task/tools/operation/delete-tool.ts +0 -43
- package/src/env/task/tools/operation/get-tool.ts +0 -43
- package/src/env/task/tools/operation/index.ts +0 -9
- package/src/env/task/tools/operation/list-tool.ts +0 -40
- package/src/env/task/tools/operation/operation-tools.test.ts +0 -274
- package/src/env/task/tools/operation/operation-types.ts +0 -75
- package/src/env/task/tools/operation/update-tool.ts +0 -47
- package/src/env/task/tools/task-tools.test.ts +0 -203
- package/src/env/task/tools/task-types.test.ts +0 -75
- package/src/env/task/tools/task-types.ts +0 -68
- package/src/env/task/tools/update-tool.ts +0 -70
- package/src/env/task/types.ts +0 -160
- package/src/env/tool/built-in/bash.ts +0 -201
- package/src/env/tool/built-in/echo.ts +0 -29
- package/src/env/tool/built-in/edit-file.test.ts +0 -136
- package/src/env/tool/built-in/edit-file.ts +0 -92
- package/src/env/tool/built-in/glob.test.ts +0 -94
- package/src/env/tool/built-in/glob.ts +0 -65
- package/src/env/tool/built-in/grep.test.ts +0 -122
- package/src/env/tool/built-in/grep.ts +0 -108
- package/src/env/tool/built-in/index.ts +0 -44
- package/src/env/tool/built-in/read-file.test.ts +0 -84
- package/src/env/tool/built-in/read-file.ts +0 -75
- package/src/env/tool/built-in/write-file.test.ts +0 -119
- package/src/env/tool/built-in/write-file.ts +0 -68
- package/src/env/tool/index.ts +0 -24
- package/src/env/tool/registry.test.ts +0 -257
- package/src/env/tool/registry.ts +0 -167
- package/src/env/tool/tool-component.test.ts +0 -559
- package/src/env/tool/tool-component.ts +0 -563
- package/src/env/tool/tool-config-registration.test.ts +0 -249
- package/src/env/tool/tool-config-registration.ts +0 -46
- package/src/env/tool/types.ts +0 -267
- package/src/env/tool/validator.test.ts +0 -143
- package/src/env/tool/validator.ts +0 -44
- package/src/env/types.ts +0 -180
- package/src/env/workflow/ask-user-tool-registration.test.ts +0 -216
- package/src/env/workflow/complex-workflow.integration.test.ts +0 -1900
- package/src/env/workflow/decorators/decorator-node.ts +0 -229
- package/src/env/workflow/decorators/decorator.test.ts +0 -196
- package/src/env/workflow/decorators/edge.ts +0 -82
- package/src/env/workflow/decorators/index.ts +0 -31
- package/src/env/workflow/decorators/node-as.ts +0 -98
- package/src/env/workflow/decorators/workflow.ts +0 -54
- package/src/env/workflow/engine/dag-manager.test.ts +0 -570
- package/src/env/workflow/engine/dag-manager.ts +0 -594
- package/src/env/workflow/engine/engine.ts +0 -1422
- package/src/env/workflow/engine/event-bus.test.ts +0 -359
- package/src/env/workflow/engine/event-bus.ts +0 -156
- package/src/env/workflow/engine/executor-agent-session.test.ts +0 -84
- package/src/env/workflow/engine/executor.test.ts +0 -619
- package/src/env/workflow/engine/executor.ts +0 -593
- package/src/env/workflow/engine/index.ts +0 -24
- package/src/env/workflow/engine/node-registry.test.ts +0 -560
- package/src/env/workflow/engine/node-registry.ts +0 -289
- package/src/env/workflow/engine/resume-removed.test.ts +0 -22
- package/src/env/workflow/engine/scheduler.test.ts +0 -715
- package/src/env/workflow/engine/scheduler.ts +0 -318
- package/src/env/workflow/engine/workflow-engine.test.ts +0 -815
- package/src/env/workflow/extractor/workflow-converter.ts +0 -306
- package/src/env/workflow/fixtures.ts +0 -380
- package/src/env/workflow/index.ts +0 -38
- package/src/env/workflow/integration/run-resume-unified.test.ts +0 -186
- package/src/env/workflow/integration/service-integration.test.ts +0 -267
- package/src/env/workflow/metadata/keys.ts +0 -12
- package/src/env/workflow/nodes/agent-component-adapter.test.ts +0 -318
- package/src/env/workflow/nodes/agent-component-adapter.ts +0 -448
- package/src/env/workflow/nodes/agent-node.test.ts +0 -371
- package/src/env/workflow/nodes/agent-node.ts +0 -598
- package/src/env/workflow/nodes/ask-user-node.ts +0 -113
- package/src/env/workflow/nodes/condition-node.ts +0 -200
- package/src/env/workflow/nodes/index.ts +0 -9
- package/src/env/workflow/nodes/merge-node.ts +0 -141
- package/src/env/workflow/nodes/skill-node.test.ts +0 -253
- package/src/env/workflow/nodes/skill-node.ts +0 -393
- package/src/env/workflow/nodes/tool-node.test.ts +0 -251
- package/src/env/workflow/nodes/tool-node.ts +0 -493
- package/src/env/workflow/nodes/workflow-llm-history.test.ts +0 -455
- package/src/env/workflow/nodes/workflow-node.test.ts +0 -315
- package/src/env/workflow/nodes/workflow-node.ts +0 -311
- package/src/env/workflow/service/index.ts +0 -27
- package/src/env/workflow/service/registry.test.ts +0 -133
- package/src/env/workflow/service/registry.ts +0 -71
- package/src/env/workflow/service/workflow-service.test.ts +0 -310
- package/src/env/workflow/service/workflow-service.ts +0 -393
- package/src/env/workflow/storage/index.ts +0 -28
- package/src/env/workflow/storage/mock-repositories.ts +0 -385
- package/src/env/workflow/storage/sqlite.test.ts +0 -179
- package/src/env/workflow/storage/sqlite.ts +0 -163
- package/src/env/workflow/storage/workflow-repo.test.ts +0 -780
- package/src/env/workflow/storage/workflow-repo.ts +0 -342
- package/src/env/workflow/tools/ask-user-tool.ts +0 -82
- package/src/env/workflow/tools/index.ts +0 -26
- package/src/env/workflow/tools/run-workflow.test.ts +0 -352
- package/src/env/workflow/tools/run-workflow.ts +0 -214
- package/src/env/workflow/types/context.ts +0 -18
- package/src/env/workflow/types/decorators-types.ts +0 -198
- package/src/env/workflow/types/event.test.ts +0 -515
- package/src/env/workflow/types/event.ts +0 -193
- package/src/env/workflow/types/index.ts +0 -49
- package/src/env/workflow/types/run.test.ts +0 -437
- package/src/env/workflow/types/run.ts +0 -173
- package/src/env/workflow/types/workflow-hil.ts +0 -114
- package/src/env/workflow/types/workflow-message.test.ts +0 -138
- package/src/env/workflow/types/workflow-message.ts +0 -196
- package/src/env/workflow/types/workflow-session.test.ts +0 -95
- package/src/env/workflow/types/workflow-session.ts +0 -59
- package/src/env/workflow/types/workflow.test.ts +0 -495
- package/src/env/workflow/types/workflow.ts +0 -195
- package/src/env/workflow/types_compat.ts +0 -51
- package/src/env/workflow/utils/create-workflow.ts +0 -47
- package/src/env/workflow/utils/execution-state.ts +0 -245
- package/src/env/workflow/utils/index.ts +0 -18
- package/src/env/workflow/utils/node-registry-helper.ts +0 -58
- package/src/env/workflow/utils/recovery-validator.test.ts +0 -460
- package/src/env/workflow/utils/recovery-validator.ts +0 -377
- package/src/env/workflow/utils/session-parser.test.ts +0 -111
- package/src/env/workflow/utils/session-parser.ts +0 -94
- package/src/env/workflow/utils/session-recovery.test.ts +0 -334
- package/src/env/workflow/utils/session-recovery.ts +0 -188
- package/src/env/workflow/utils/template-resolver.test.ts +0 -258
- package/src/env/workflow/utils/template-resolver.ts +0 -436
- package/src/env/workflow/utils/validation-rules.ts +0 -149
- package/src/env/workflow/workflow-component.ts +0 -544
- package/src/index.ts +0 -422
- package/src/utils/id.ts +0 -21
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Commands Component Types
|
|
3
|
-
*
|
|
4
|
-
* 定义 CommandsComponent 的类型系统(收藏式)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ConfigComponent } from "../../config/config-component";
|
|
8
|
-
|
|
9
|
-
// ============================================================================
|
|
10
|
-
// 配置类型
|
|
11
|
-
// ============================================================================
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* CommandsComponent 配置(通过 options 传递)
|
|
15
|
-
*
|
|
16
|
-
* 配置加载顺序(优先级从低到高):
|
|
17
|
-
* 1. File - 配置文件(通过 configPath 指定)
|
|
18
|
-
* 2. Env - 环境变量(通过 envPrefix 配置前缀)
|
|
19
|
-
* 3. Object - 直接传入的 config 对象(最高优先级)
|
|
20
|
-
*/
|
|
21
|
-
export interface CommandsComponentOptions {
|
|
22
|
-
/** ConfigComponent 实例(必填) */
|
|
23
|
-
configComponent: ConfigComponent;
|
|
24
|
-
|
|
25
|
-
/** 配置文件相对路径(可选,基于 XDG_DATA_HOME) */
|
|
26
|
-
configPath?: string;
|
|
27
|
-
|
|
28
|
-
/** 环境变量前缀(可选,默认 "COMMAND") */
|
|
29
|
-
envPrefix?: string;
|
|
30
|
-
|
|
31
|
-
/** 直接传入的配置对象(可选,优先级最高) */
|
|
32
|
-
config?: Partial<CommandsComponentConfig>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* CommandsComponent 配置
|
|
37
|
-
*/
|
|
38
|
-
export interface CommandsComponentConfig {
|
|
39
|
-
/** User 级别命令目录 */
|
|
40
|
-
userCommandsDir?: string;
|
|
41
|
-
/** 项目级别命令目录 */
|
|
42
|
-
projectCommandsDir?: string;
|
|
43
|
-
/** 描述缓存目录 */
|
|
44
|
-
cacheDir?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// 命令来源
|
|
49
|
-
// ============================================================================
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 命令来源
|
|
53
|
-
*/
|
|
54
|
-
export type CommandSource = 'user' | 'project';
|
|
55
|
-
|
|
56
|
-
// ============================================================================
|
|
57
|
-
// 命令索引
|
|
58
|
-
// ============================================================================
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 命令索引
|
|
62
|
-
*/
|
|
63
|
-
export interface CommandIndex {
|
|
64
|
-
/** 命令名称(文件名) */
|
|
65
|
-
name: string;
|
|
66
|
-
/** 命令路径 */
|
|
67
|
-
path: string;
|
|
68
|
-
/** 来源类型 */
|
|
69
|
-
source: CommandSource;
|
|
70
|
-
/** 简短描述(从 --help 第一行提取) */
|
|
71
|
-
shortDescription: string;
|
|
72
|
-
/** 最后获取描述时间 */
|
|
73
|
-
lastFetched?: number;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ============================================================================
|
|
77
|
-
// 扫描结果
|
|
78
|
-
// ============================================================================
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 来源统计
|
|
82
|
-
*/
|
|
83
|
-
export interface SourceStats {
|
|
84
|
-
/** User 级别命令数 */
|
|
85
|
-
userCount: number;
|
|
86
|
-
/** Project 级别命令数 */
|
|
87
|
-
projectCount: number;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 扫描结果
|
|
92
|
-
*/
|
|
93
|
-
export interface ScanResult {
|
|
94
|
-
/** 命令列表 */
|
|
95
|
-
commands: CommandIndex[];
|
|
96
|
-
/** 来源统计 */
|
|
97
|
-
stats: SourceStats;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ============================================================================
|
|
101
|
-
// 发现选项
|
|
102
|
-
// ============================================================================
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 发现选项
|
|
106
|
-
*/
|
|
107
|
-
export interface DiscoverOptions {
|
|
108
|
-
/** glob 过滤模式 */
|
|
109
|
-
pattern?: string;
|
|
110
|
-
/** 来源过滤 */
|
|
111
|
-
source?: CommandSource;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// ============================================================================
|
|
115
|
-
// 添加选项
|
|
116
|
-
// ============================================================================
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 添加命令选项
|
|
120
|
-
*/
|
|
121
|
-
export interface AddCommandOptions {
|
|
122
|
-
/** 命令名称 */
|
|
123
|
-
name: string;
|
|
124
|
-
/** 目标路径或命令 */
|
|
125
|
-
target: string;
|
|
126
|
-
/** 来源类型 */
|
|
127
|
-
source?: CommandSource;
|
|
128
|
-
/** 功能描述(用于 Prompt 注入) */
|
|
129
|
-
description?: string;
|
|
130
|
-
/** 探索提示(用于 Prompt 注入) */
|
|
131
|
-
tips?: string;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ============================================================================
|
|
135
|
-
// 命令元信息(用于 Prompt 注入)
|
|
136
|
-
// ============================================================================
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* 命令元信息(用于 Prompt 注入)
|
|
140
|
-
*/
|
|
141
|
-
export interface CommandMeta {
|
|
142
|
-
/** 命令名称 */
|
|
143
|
-
name: string;
|
|
144
|
-
/** 功能描述 */
|
|
145
|
-
description: string;
|
|
146
|
-
/** 探索提示 */
|
|
147
|
-
tips?: string;
|
|
148
|
-
/** meta.md 文件路径 */
|
|
149
|
-
filePath: string;
|
|
150
|
-
/** 来源类型 */
|
|
151
|
-
source: CommandSource;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ============================================================================
|
|
155
|
-
// 移除选项
|
|
156
|
-
// ============================================================================
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 移除命令选项
|
|
160
|
-
*/
|
|
161
|
-
export interface RemoveCommandOptions {
|
|
162
|
-
/** 命令名称 */
|
|
163
|
-
name: string;
|
|
164
|
-
/** 来源类型(可选,不指定则尝试两个目录) */
|
|
165
|
-
source?: CommandSource;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ============================================================================
|
|
169
|
-
// 执行结果
|
|
170
|
-
// ============================================================================
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 执行结果
|
|
174
|
-
*/
|
|
175
|
-
export interface ExecutionResult {
|
|
176
|
-
/** 标准输出 */
|
|
177
|
-
stdout: string;
|
|
178
|
-
/** 标准错误 */
|
|
179
|
-
stderr: string;
|
|
180
|
-
/** 退出码 */
|
|
181
|
-
exitCode: number;
|
|
182
|
-
/** 是否成功 */
|
|
183
|
-
success: boolean;
|
|
184
|
-
}
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
2
|
-
import * as fs from "fs/promises";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import * as os from "os";
|
|
5
|
-
import { ConfigComponent } from "../config/config-component";
|
|
6
|
-
import { CommandsComponent } from "./commands/commands-component";
|
|
7
|
-
import { PromptComponent } from "./prompt/prompt-component";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 创建 Mock ConfigComponent
|
|
11
|
-
*
|
|
12
|
-
* 关键:模拟真实的 ConfigComponent 行为:
|
|
13
|
-
* 1. registerComponent 注册默认值
|
|
14
|
-
* 2. load() 后 storage 中应该有值
|
|
15
|
-
* 3. 直接通过 config 设置的值优先级最高
|
|
16
|
-
*/
|
|
17
|
-
function createMockConfigComponent(initialConfig: Record<string, any> = {}): ConfigComponent {
|
|
18
|
-
const storage = new Map<string, any>(Object.entries(initialConfig));
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
get<T = any>(key: string): T | undefined {
|
|
22
|
-
// 如果 storage 中没有值,返回 undefined(让 CommandsComponent 设置默认值)
|
|
23
|
-
// 注意:这里不自动返回默认值,由 CommandsComponent 的 registerConfig 控制
|
|
24
|
-
return storage.get(key);
|
|
25
|
-
},
|
|
26
|
-
set<T = any>(key: string, value: T): void | Promise<void> {
|
|
27
|
-
storage.set(key, value);
|
|
28
|
-
},
|
|
29
|
-
has(key: string): boolean {
|
|
30
|
-
return storage.has(key);
|
|
31
|
-
},
|
|
32
|
-
delete(key: string): boolean {
|
|
33
|
-
return storage.delete(key);
|
|
34
|
-
},
|
|
35
|
-
clear(): void {
|
|
36
|
-
storage.clear();
|
|
37
|
-
},
|
|
38
|
-
getAll(): Record<string, any> {
|
|
39
|
-
return Object.fromEntries(storage);
|
|
40
|
-
},
|
|
41
|
-
registerSource: vi.fn(),
|
|
42
|
-
registerComponent: vi.fn().mockImplementation((registration: any) => {
|
|
43
|
-
// 注册 defaults 到 storage
|
|
44
|
-
if (registration.defaults) {
|
|
45
|
-
for (const [key, value] of Object.entries(registration.defaults)) {
|
|
46
|
-
const fullKey = `${registration.name}.${key}`;
|
|
47
|
-
if (!storage.has(fullKey)) {
|
|
48
|
-
storage.set(fullKey, value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}),
|
|
53
|
-
load: vi.fn().mockResolvedValue(undefined),
|
|
54
|
-
getSources: vi.fn().mockReturnValue([]),
|
|
55
|
-
ensureSourcesCreated: vi.fn(),
|
|
56
|
-
} as unknown as ConfigComponent;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 模拟 registerCommandsPromptHook 的逻辑
|
|
61
|
-
*/
|
|
62
|
-
async function renderDefaultPromptWithCommands(
|
|
63
|
-
promptComponent: PromptComponent,
|
|
64
|
-
commandsComponent: CommandsComponent
|
|
65
|
-
): Promise<string> {
|
|
66
|
-
// 渲染 default prompt
|
|
67
|
-
const content = await promptComponent.getPrompt("default");
|
|
68
|
-
|
|
69
|
-
// 获取命令元信息
|
|
70
|
-
const metaList = await commandsComponent.getCommandsMeta();
|
|
71
|
-
|
|
72
|
-
// 如果有命令,追加命令表格
|
|
73
|
-
if (metaList.length > 0) {
|
|
74
|
-
const sortedMeta = [...metaList].sort((a, b) => a.name.localeCompare(b.name));
|
|
75
|
-
const rows = sortedMeta
|
|
76
|
-
.map(m => `| \`${m.name}\` | ${m.description} |`)
|
|
77
|
-
.join("\n");
|
|
78
|
-
|
|
79
|
-
return content + "\n\n" + `## Your Commands Arsenal
|
|
80
|
-
|
|
81
|
-
You have access to these custom commands:
|
|
82
|
-
|
|
83
|
-
| Command | Description |
|
|
84
|
-
|---------|-------------|
|
|
85
|
-
${rows}
|
|
86
|
-
|
|
87
|
-
Progressive Discovery: Run \`<command> --help\` to explore full capabilities.`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return content;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
describe("Commands Prompt Integration", () => {
|
|
94
|
-
let tempDir: string;
|
|
95
|
-
let configComponent: ConfigComponent;
|
|
96
|
-
let commandsComponent: CommandsComponent;
|
|
97
|
-
let promptComponent: PromptComponent;
|
|
98
|
-
|
|
99
|
-
beforeEach(async () => {
|
|
100
|
-
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "roy-integration-test-"));
|
|
101
|
-
|
|
102
|
-
// 创建 mock ConfigComponent
|
|
103
|
-
configComponent = createMockConfigComponent({
|
|
104
|
-
"command.userCommandsDir": path.join(tempDir, "commands"),
|
|
105
|
-
"command.projectCommandsDir": path.join(tempDir, "project-commands"),
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
commandsComponent = new CommandsComponent();
|
|
109
|
-
await commandsComponent.init({
|
|
110
|
-
name: "commands",
|
|
111
|
-
version: "2.0.0",
|
|
112
|
-
enabled: true,
|
|
113
|
-
options: { configComponent },
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
promptComponent = new PromptComponent();
|
|
117
|
-
await promptComponent.init({
|
|
118
|
-
name: "prompt",
|
|
119
|
-
version: "1.0.0",
|
|
120
|
-
enabled: true,
|
|
121
|
-
options: { configComponent },
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
afterEach(async () => {
|
|
126
|
-
await fs.rm(tempDir, { recursive: true, force: true });
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("renderDefaultPromptWithCommands", () => {
|
|
130
|
-
it("should inject commands into default prompt", async () => {
|
|
131
|
-
// 添加带 meta.md 的命令
|
|
132
|
-
await commandsComponent.add({
|
|
133
|
-
name: "git",
|
|
134
|
-
target: "/usr/bin/git",
|
|
135
|
-
description: "Git version control system",
|
|
136
|
-
tips: "Use 'git --help' to explore",
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// 渲染 prompt
|
|
140
|
-
const prompt = await renderDefaultPromptWithCommands(promptComponent, commandsComponent);
|
|
141
|
-
|
|
142
|
-
expect(prompt).toContain("Your Commands Arsenal");
|
|
143
|
-
expect(prompt).toContain("| `git` | Git version control system |");
|
|
144
|
-
expect(prompt).toContain("Run `<command> --help`");
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("should not inject when no commands exist", async () => {
|
|
148
|
-
const prompt = await renderDefaultPromptWithCommands(promptComponent, commandsComponent);
|
|
149
|
-
|
|
150
|
-
// 应该不包含我们的自定义 commands section
|
|
151
|
-
expect(prompt).not.toContain("Your Commands Arsenal");
|
|
152
|
-
// 原始 prompt 中没有 custom commands 表格
|
|
153
|
-
expect(prompt).not.toContain("| `git` |");
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("should inject multiple commands", async () => {
|
|
157
|
-
await commandsComponent.add({
|
|
158
|
-
name: "git",
|
|
159
|
-
target: "/usr/bin/git",
|
|
160
|
-
description: "Git version control",
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
await commandsComponent.add({
|
|
164
|
-
name: "npm",
|
|
165
|
-
target: "/usr/bin/npm",
|
|
166
|
-
description: "Node package manager",
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
const prompt = await renderDefaultPromptWithCommands(promptComponent, commandsComponent);
|
|
170
|
-
|
|
171
|
-
expect(prompt).toContain("| `git` | Git version control |");
|
|
172
|
-
expect(prompt).toContain("| `npm` | Node package manager |");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("should sort commands alphabetically", async () => {
|
|
176
|
-
await commandsComponent.add({
|
|
177
|
-
name: "zulu",
|
|
178
|
-
target: "/usr/bin/zulu",
|
|
179
|
-
description: "Zulu command",
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
await commandsComponent.add({
|
|
183
|
-
name: "alpha",
|
|
184
|
-
target: "/usr/bin/alpha",
|
|
185
|
-
description: "Alpha command",
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
await commandsComponent.add({
|
|
189
|
-
name: "middle",
|
|
190
|
-
target: "/usr/bin/middle",
|
|
191
|
-
description: "Middle command",
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const prompt = await renderDefaultPromptWithCommands(promptComponent, commandsComponent);
|
|
195
|
-
|
|
196
|
-
// 验证 alpha 在最前面,zulu 在最后面
|
|
197
|
-
const alphaIndex = prompt.indexOf("| `alpha`");
|
|
198
|
-
const middleIndex = prompt.indexOf("| `middle`");
|
|
199
|
-
const zuluIndex = prompt.indexOf("| `zulu`");
|
|
200
|
-
|
|
201
|
-
expect(alphaIndex).toBeLessThan(middleIndex);
|
|
202
|
-
expect(middleIndex).toBeLessThan(zuluIndex);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe("CommandsComponent.getCommandsMeta", () => {
|
|
207
|
-
it("should return empty array when no commands exist", async () => {
|
|
208
|
-
const metaList = await commandsComponent.getCommandsMeta();
|
|
209
|
-
expect(metaList).toEqual([]);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("should return command metadata", async () => {
|
|
213
|
-
await commandsComponent.add({
|
|
214
|
-
name: "test-cmd",
|
|
215
|
-
target: "/usr/bin/echo",
|
|
216
|
-
description: "Test command description",
|
|
217
|
-
tips: "Try with --help",
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
const metaList = await commandsComponent.getCommandsMeta();
|
|
221
|
-
|
|
222
|
-
expect(metaList).toHaveLength(1);
|
|
223
|
-
expect(metaList[0].name).toBe("test-cmd");
|
|
224
|
-
expect(metaList[0].description).toBe("Test command description");
|
|
225
|
-
expect(metaList[0].tips).toBe("Try with --help");
|
|
226
|
-
expect(metaList[0].source).toBe("user");
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("should handle command without description", async () => {
|
|
230
|
-
await commandsComponent.add({
|
|
231
|
-
name: "simple-cmd",
|
|
232
|
-
target: "/usr/bin/true",
|
|
233
|
-
// 不提供 description
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const metaList = await commandsComponent.getCommandsMeta();
|
|
237
|
-
|
|
238
|
-
expect(metaList).toHaveLength(1);
|
|
239
|
-
expect(metaList[0].name).toBe("simple-cmd");
|
|
240
|
-
expect(metaList[0].description).toBe("Command: simple-cmd"); // 默认值
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from "bun:test";
|
|
2
|
-
import { BaseComponent, type ComponentConfig } from "./component";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 测试用 Component
|
|
6
|
-
*/
|
|
7
|
-
class TestComponent extends BaseComponent {
|
|
8
|
-
readonly name = "test-component";
|
|
9
|
-
readonly version = "1.0.0";
|
|
10
|
-
protected initialized = false;
|
|
11
|
-
|
|
12
|
-
getInitialized(): boolean {
|
|
13
|
-
return this.initialized;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
protected async onInit(): Promise<void> {
|
|
17
|
-
this.initialized = true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Mock Environment(实现 Environment 接口的最小实现)
|
|
23
|
-
*/
|
|
24
|
-
const createMockEnv = () => ({
|
|
25
|
-
name: "mock-env",
|
|
26
|
-
version: "1.0.0",
|
|
27
|
-
getConfig: () => ({ name: "mock-env", version: "1.0.0", enabled: true, env: null as any }),
|
|
28
|
-
registerComponent: () => {},
|
|
29
|
-
unregisterComponent: () => {},
|
|
30
|
-
getComponent: () => undefined,
|
|
31
|
-
listComponents: () => [],
|
|
32
|
-
handle_query: async () => "",
|
|
33
|
-
handle_action: async () => ({ success: true, output: "" }),
|
|
34
|
-
subscribe: () => () => {},
|
|
35
|
-
subscribeTo: () => () => {},
|
|
36
|
-
subscribeAll: () => () => {},
|
|
37
|
-
pushEnvEvent: () => {},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe("Component env injection", () => {
|
|
41
|
-
describe("init() env validation", () => {
|
|
42
|
-
it("should init successfully without env (env is optional)", async () => {
|
|
43
|
-
const component = new TestComponent();
|
|
44
|
-
|
|
45
|
-
// env 是可选的,支持组件独立测试场景
|
|
46
|
-
await component.init({
|
|
47
|
-
name: "test",
|
|
48
|
-
version: "1.0.0",
|
|
49
|
-
enabled: true,
|
|
50
|
-
} as ComponentConfig);
|
|
51
|
-
|
|
52
|
-
expect(component.getStatus()).toBe("running");
|
|
53
|
-
expect(component.getInitialized()).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("init() env injection", () => {
|
|
58
|
-
it("should inject env on successful init", async () => {
|
|
59
|
-
const env = createMockEnv();
|
|
60
|
-
const component = new TestComponent();
|
|
61
|
-
|
|
62
|
-
await component.init({
|
|
63
|
-
name: "test",
|
|
64
|
-
version: "1.0.0",
|
|
65
|
-
enabled: true,
|
|
66
|
-
env,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// 验证状态变为 running
|
|
70
|
-
expect(component.getStatus()).toBe("running");
|
|
71
|
-
// 验证 env 被正确注入(通过 as any 访问 protected 属性)
|
|
72
|
-
expect((component as any).env).toBe(env);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("should call onInit after env is set", async () => {
|
|
76
|
-
const env = createMockEnv();
|
|
77
|
-
const component = new TestComponent();
|
|
78
|
-
|
|
79
|
-
await component.init({
|
|
80
|
-
name: "test",
|
|
81
|
-
version: "1.0.0",
|
|
82
|
-
enabled: true,
|
|
83
|
-
env,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(component.getInitialized()).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should store env in protected property", async () => {
|
|
90
|
-
const env = createMockEnv();
|
|
91
|
-
const component = new TestComponent();
|
|
92
|
-
|
|
93
|
-
await component.init({
|
|
94
|
-
name: "test",
|
|
95
|
-
version: "1.0.0",
|
|
96
|
-
enabled: true,
|
|
97
|
-
env,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// 通过 getEnv() 方法访问
|
|
101
|
-
expect(component.getEnv()).toBe(env);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("should allow getting component from env", async () => {
|
|
105
|
-
const mockEnv = createMockEnv();
|
|
106
|
-
const component = new TestComponent();
|
|
107
|
-
|
|
108
|
-
await component.init({
|
|
109
|
-
name: "test",
|
|
110
|
-
version: "1.0.0",
|
|
111
|
-
enabled: true,
|
|
112
|
-
env: mockEnv,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// 验证可以通过 getEnv().getComponent() 获取其他组件
|
|
116
|
-
expect(component.getEnv().getComponent("non-existent")).toBeUndefined();
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|