agent-enderun 1.10.2 → 1.11.0
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/README.md +34 -44
- package/dist/framework-mcp/src/constants.d.ts +47 -0
- package/dist/framework-mcp/src/constants.js +65 -0
- package/dist/framework-mcp/src/constants.js.map +1 -0
- package/dist/framework-mcp/src/index.js +26 -5
- package/dist/framework-mcp/src/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/control_plane/locking.d.ts +3 -9
- package/dist/framework-mcp/src/tools/control_plane/locking.js.map +1 -1
- package/dist/framework-mcp/src/tools/control_plane/registry.d.ts +2 -8
- package/dist/framework-mcp/src/tools/control_plane/registry.js.map +1 -1
- package/dist/framework-mcp/src/tools/dashboard/start_dashboard.d.ts +2 -2
- package/dist/framework-mcp/src/tools/dashboard/start_dashboard.js.map +1 -1
- package/dist/framework-mcp/src/tools/definitions.js +30 -0
- package/dist/framework-mcp/src/tools/definitions.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.d.ts +2 -2
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +12 -4
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/patch_file.d.ts +2 -2
- package/dist/framework-mcp/src/tools/file_system/patch_file.js +6 -2
- package/dist/framework-mcp/src/tools/file_system/patch_file.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/read_file.d.ts +2 -2
- package/dist/framework-mcp/src/tools/file_system/read_file.js +43 -26
- package/dist/framework-mcp/src/tools/file_system/read_file.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/replace_text.d.ts +2 -2
- package/dist/framework-mcp/src/tools/file_system/replace_text.js +7 -3
- package/dist/framework-mcp/src/tools/file_system/replace_text.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/write_file.d.ts +2 -2
- package/dist/framework-mcp/src/tools/file_system/write_file.js +27 -15
- package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/get_status.d.ts +2 -2
- package/dist/framework-mcp/src/tools/framework/get_status.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/orchestrate.d.ts +2 -2
- package/dist/framework-mcp/src/tools/framework/orchestrate.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/run_tests.d.ts +2 -2
- package/dist/framework-mcp/src/tools/framework/run_tests.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/update_contract_hash.d.ts +2 -2
- package/dist/framework-mcp/src/tools/framework/update_contract_hash.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/update_memory.d.ts +2 -2
- package/dist/framework-mcp/src/tools/framework/update_memory.js +1 -1
- package/dist/framework-mcp/src/tools/framework/update_memory.js.map +1 -1
- package/dist/framework-mcp/src/tools/index.d.ts +1 -2
- package/dist/framework-mcp/src/tools/index.js +33 -25
- package/dist/framework-mcp/src/tools/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/messaging/log_action.d.ts +2 -2
- package/dist/framework-mcp/src/tools/messaging/log_action.js.map +1 -1
- package/dist/framework-mcp/src/tools/messaging/send_message.d.ts +2 -2
- package/dist/framework-mcp/src/tools/messaging/send_message.js +14 -1
- package/dist/framework-mcp/src/tools/messaging/send_message.js.map +1 -1
- package/dist/framework-mcp/src/tools/observability/check_ports.d.ts +2 -2
- package/dist/framework-mcp/src/tools/observability/check_ports.js.map +1 -1
- package/dist/framework-mcp/src/tools/quality/check_lint.d.ts +5 -0
- package/dist/framework-mcp/src/tools/quality/check_lint.js +29 -0
- package/dist/framework-mcp/src/tools/quality/check_lint.js.map +1 -0
- package/dist/framework-mcp/src/tools/search/get_gaps.d.ts +2 -2
- package/dist/framework-mcp/src/tools/search/get_gaps.js.map +1 -1
- package/dist/framework-mcp/src/tools/search/get_map.d.ts +2 -2
- package/dist/framework-mcp/src/tools/search/get_map.js +1 -1
- package/dist/framework-mcp/src/tools/search/get_map.js.map +1 -1
- package/dist/framework-mcp/src/tools/search/grep_search.d.ts +2 -2
- package/dist/framework-mcp/src/tools/search/grep_search.js +45 -28
- package/dist/framework-mcp/src/tools/search/grep_search.js.map +1 -1
- package/dist/framework-mcp/src/tools/search/list_dir.d.ts +2 -2
- package/dist/framework-mcp/src/tools/search/list_dir.js.map +1 -1
- package/dist/framework-mcp/src/tools/shell/run_command.d.ts +2 -0
- package/dist/framework-mcp/src/tools/shell/run_command.js +47 -0
- package/dist/framework-mcp/src/tools/shell/run_command.js.map +1 -0
- package/dist/framework-mcp/src/tools/types.d.ts +95 -28
- package/dist/framework-mcp/src/utils/metrics.d.ts +20 -0
- package/dist/framework-mcp/src/utils/metrics.js +24 -6
- package/dist/framework-mcp/src/utils/metrics.js.map +1 -1
- package/dist/framework-mcp/src/utils/security.d.ts +1 -3
- package/dist/framework-mcp/src/utils/security.js +21 -18
- package/dist/framework-mcp/src/utils/security.js.map +1 -1
- package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js +19 -14
- package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js.map +1 -1
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js +1 -1
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js.map +1 -1
- package/dist/framework-mcp/tests/tools/quality/check_lint.test.d.ts +1 -0
- package/dist/framework-mcp/tests/tools/quality/check_lint.test.js +36 -0
- package/dist/framework-mcp/tests/tools/quality/check_lint.test.js.map +1 -0
- package/dist/framework-mcp/tests/tools/shell/run_command.test.d.ts +1 -0
- package/dist/framework-mcp/tests/tools/shell/run_command.test.js +43 -0
- package/dist/framework-mcp/tests/tools/shell/run_command.test.js.map +1 -0
- package/dist/src/cli/adapters/core.d.ts +1 -1
- package/dist/src/cli/adapters/core.js +4 -0
- package/dist/src/cli/adapters/core.js.map +1 -1
- package/dist/src/cli/adapters/index.d.ts +1 -0
- package/dist/src/cli/adapters/index.js +1 -0
- package/dist/src/cli/adapters/index.js.map +1 -1
- package/dist/src/cli/adapters/paths.d.ts +15 -0
- package/dist/src/cli/adapters/paths.js +101 -0
- package/dist/src/cli/adapters/paths.js.map +1 -0
- package/dist/src/cli/adapters/scaffold.d.ts +1 -1
- package/dist/src/cli/adapters/scaffold.js +10 -7
- package/dist/src/cli/adapters/scaffold.js.map +1 -1
- package/dist/src/cli/commands/check.js +15 -36
- package/dist/src/cli/commands/check.js.map +1 -1
- package/dist/src/cli/commands/dashboard/data-service.d.ts +8 -0
- package/dist/src/cli/commands/dashboard/data-service.js +37 -0
- package/dist/src/cli/commands/dashboard/data-service.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-core.d.ts +5 -2
- package/dist/src/cli/commands/init/scaffold-core.js +28 -6
- package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-standards.js +6 -1
- package/dist/src/cli/commands/init/scaffold-standards.js.map +1 -1
- package/dist/src/cli/commands/init.js +30 -6
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/orchestrate.d.ts +11 -6
- package/dist/src/cli/commands/orchestrate.js +148 -128
- package/dist/src/cli/commands/orchestrate.js.map +1 -1
- package/dist/src/cli/commands/plan.d.ts +3 -1
- package/dist/src/cli/commands/plan.js +79 -22
- package/dist/src/cli/commands/plan.js.map +1 -1
- package/dist/src/cli/index.js +11 -15
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/utils/compliance.js +0 -1
- package/dist/src/cli/utils/compliance.js.map +1 -1
- package/dist/src/cli/utils/config-schema.d.ts +7 -7
- package/dist/src/cli/utils/fs.js +1 -1
- package/dist/src/cli/utils/fs.js.map +1 -1
- package/dist/src/cli/utils/memory.d.ts +1 -1
- package/dist/src/cli/utils/memory.js +28 -8
- package/dist/src/cli/utils/memory.js.map +1 -1
- package/dist/src/cli/utils/pkg.d.ts +19 -0
- package/dist/src/cli/utils/pkg.js +29 -5
- package/dist/src/cli/utils/pkg.js.map +1 -1
- package/dist/src/modules/adapters/definitions.js +3 -3
- package/dist/src/modules/adapters/definitions.js.map +1 -1
- package/dist/src/modules/agents/definitions.js +2 -1
- package/dist/src/modules/agents/definitions.js.map +1 -1
- package/dist/src/modules/agents/registry/analyst.js +1 -1
- package/dist/src/modules/agents/registry/analyst.js.map +1 -1
- package/dist/src/modules/agents/registry/architect.js +1 -0
- package/dist/src/modules/agents/registry/architect.js.map +1 -1
- package/dist/src/modules/agents/registry/backend.js +7 -6
- package/dist/src/modules/agents/registry/backend.js.map +1 -1
- package/dist/src/modules/agents/registry/database.js +4 -3
- package/dist/src/modules/agents/registry/database.js.map +1 -1
- package/dist/src/modules/agents/registry/devops.js +1 -1
- package/dist/src/modules/agents/registry/devops.js.map +1 -1
- package/dist/src/modules/agents/registry/git.js +1 -1
- package/dist/src/modules/agents/registry/git.js.map +1 -1
- package/dist/src/modules/agents/registry/manager.js +3 -2
- package/dist/src/modules/agents/registry/manager.js.map +1 -1
- package/dist/src/modules/agents/registry/native.js +1 -1
- package/dist/src/modules/agents/registry/native.js.map +1 -1
- package/dist/src/modules/agents/registry/quality.js +1 -0
- package/dist/src/modules/agents/registry/quality.js.map +1 -1
- package/dist/src/modules/agents/registry/security.js +1 -0
- package/dist/src/modules/agents/registry/security.js.map +1 -1
- package/dist/src/shared/constants.d.ts +113 -0
- package/dist/src/shared/constants.js +178 -0
- package/dist/src/shared/constants.js.map +1 -0
- package/dist/tests/adapters/paths.test.d.ts +1 -0
- package/dist/tests/adapters/paths.test.js +63 -0
- package/dist/tests/adapters/paths.test.js.map +1 -0
- package/dist/tests/approve.test.js +5 -9
- package/dist/tests/approve.test.js.map +1 -1
- package/dist/tests/cli/init/unified_init.test.d.ts +1 -0
- package/dist/tests/cli/init/unified_init.test.js +47 -0
- package/dist/tests/cli/init/unified_init.test.js.map +1 -0
- package/dist/tests/fs-utils.test.js +1 -1
- package/dist/tests/fs-utils.test.js.map +1 -1
- package/dist/tests/memory-utils.test.js +1 -1
- package/dist/tests/memory-utils.test.js.map +1 -1
- package/dist/tests/shared/constants.test.d.ts +1 -0
- package/dist/tests/shared/constants.test.js +17 -0
- package/dist/tests/shared/constants.test.js.map +1 -0
- package/dist/tests/trace.test.js +2 -2
- package/dist/tests/trace.test.js.map +1 -1
- package/framework-mcp/dist/constants.js +64 -0
- package/framework-mcp/dist/index.js +109 -0
- package/framework-mcp/dist/tools/control_plane/locking.js +64 -0
- package/framework-mcp/dist/tools/control_plane/registry.js +34 -0
- package/framework-mcp/dist/tools/dashboard/start_dashboard.js +29 -0
- package/framework-mcp/dist/tools/definitions.js +300 -0
- package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +59 -0
- package/framework-mcp/dist/tools/file_system/patch_file.js +25 -0
- package/framework-mcp/dist/tools/file_system/read_file.js +51 -0
- package/framework-mcp/dist/tools/file_system/replace_text.js +43 -0
- package/framework-mcp/dist/tools/file_system/write_file.js +38 -0
- package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
- package/framework-mcp/dist/tools/framework/get_status.js +5 -0
- package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
- package/framework-mcp/dist/tools/framework/run_tests.js +25 -0
- package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
- package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
- package/framework-mcp/dist/tools/index.js +62 -0
- package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
- package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
- package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
- package/framework-mcp/dist/tools/messaging/send_message.js +87 -0
- package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
- package/framework-mcp/dist/tools/observability/get_health.js +19 -0
- package/framework-mcp/dist/tools/quality/check_lint.js +28 -0
- package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
- package/framework-mcp/dist/tools/search/get_map.js +43 -0
- package/framework-mcp/dist/tools/search/grep_search.js +76 -0
- package/framework-mcp/dist/tools/search/list_dir.js +28 -0
- package/framework-mcp/dist/tools/shell/run_command.js +46 -0
- package/framework-mcp/dist/tools/types.js +1 -0
- package/framework-mcp/dist/utils/cli.js +20 -0
- package/framework-mcp/dist/utils/compliance.js +29 -0
- package/framework-mcp/dist/utils/fs.js +44 -0
- package/framework-mcp/dist/utils/metrics.js +56 -0
- package/framework-mcp/dist/utils/security.js +60 -0
- package/framework-mcp/package.json +19 -0
- package/framework-mcp/src/constants.ts +78 -0
- package/framework-mcp/src/declarations.d.ts +17 -0
- package/framework-mcp/src/index.ts +132 -0
- package/framework-mcp/src/tools/control_plane/locking.ts +71 -0
- package/framework-mcp/src/tools/control_plane/registry.ts +38 -0
- package/framework-mcp/src/tools/dashboard/start_dashboard.ts +33 -0
- package/framework-mcp/src/tools/definitions.ts +302 -0
- package/framework-mcp/src/tools/file_system/batch_surgical_edit.ts +79 -0
- package/framework-mcp/src/tools/file_system/patch_file.ts +33 -0
- package/framework-mcp/src/tools/file_system/read_file.ts +58 -0
- package/framework-mcp/src/tools/file_system/replace_text.ts +52 -0
- package/framework-mcp/src/tools/file_system/write_file.ts +45 -0
- package/framework-mcp/src/tools/framework/audit_deps.ts +49 -0
- package/framework-mcp/src/tools/framework/get_status.ts +7 -0
- package/framework-mcp/src/tools/framework/orchestrate.ts +7 -0
- package/framework-mcp/src/tools/framework/run_tests.ts +28 -0
- package/framework-mcp/src/tools/framework/update_contract_hash.ts +7 -0
- package/framework-mcp/src/tools/framework/update_memory.ts +10 -0
- package/framework-mcp/src/tools/index.ts +66 -0
- package/framework-mcp/src/tools/memory/get_insights.ts +41 -0
- package/framework-mcp/src/tools/memory/read_memory.ts +31 -0
- package/framework-mcp/src/tools/messaging/log_action.ts +28 -0
- package/framework-mcp/src/tools/messaging/send_message.ts +89 -0
- package/framework-mcp/src/tools/observability/check_ports.ts +30 -0
- package/framework-mcp/src/tools/observability/get_health.ts +24 -0
- package/framework-mcp/src/tools/quality/check_lint.ts +33 -0
- package/framework-mcp/src/tools/search/get_gaps.ts +54 -0
- package/framework-mcp/src/tools/search/get_map.ts +48 -0
- package/framework-mcp/src/tools/search/grep_search.ts +76 -0
- package/framework-mcp/src/tools/search/list_dir.ts +34 -0
- package/framework-mcp/src/tools/shell/run_command.ts +56 -0
- package/framework-mcp/src/tools/types.ts +89 -0
- package/framework-mcp/src/utils/cli.ts +20 -0
- package/framework-mcp/src/utils/compliance.ts +37 -0
- package/framework-mcp/src/utils/fs.ts +45 -0
- package/framework-mcp/src/utils/metrics.ts +73 -0
- package/framework-mcp/src/utils/security.ts +66 -0
- package/framework-mcp/tests/tools/file_system/file_system_tools.test.ts +212 -0
- package/framework-mcp/tests/tools/messaging/send_message.test.ts +136 -0
- package/framework-mcp/tests/tools/quality/check_lint.test.ts +46 -0
- package/framework-mcp/tests/tools/shell/run_command.test.ts +55 -0
- package/framework-mcp/tsconfig.json +14 -0
- package/package.json +9 -7
- package/src/cli/adapters/core.ts +7 -1
- package/src/cli/adapters/index.ts +1 -0
- package/src/cli/adapters/paths.ts +134 -0
- package/src/cli/adapters/scaffold.ts +17 -7
- package/src/cli/commands/check.ts +16 -38
- package/src/cli/commands/dashboard/data-service.ts +48 -0
- package/src/cli/commands/init/scaffold-core.ts +45 -6
- package/src/cli/commands/init/scaffold-standards.ts +6 -1
- package/src/cli/commands/init.ts +32 -6
- package/src/cli/commands/orchestrate.ts +151 -127
- package/src/cli/commands/plan.ts +89 -23
- package/src/cli/index.ts +14 -19
- package/src/cli/utils/compliance.ts +8 -9
- package/src/cli/utils/fs.ts +1 -1
- package/src/cli/utils/memory.ts +32 -7
- package/src/cli/utils/pkg.ts +42 -13
- package/src/modules/adapters/definitions.ts +4 -3
- package/src/modules/agents/definitions.ts +2 -1
- package/src/modules/agents/registry/analyst.ts +1 -1
- package/src/modules/agents/registry/architect.ts +1 -0
- package/src/modules/agents/registry/backend.ts +7 -6
- package/src/modules/agents/registry/database.ts +4 -3
- package/src/modules/agents/registry/devops.ts +1 -1
- package/src/modules/agents/registry/git.ts +1 -1
- package/src/modules/agents/registry/manager.ts +3 -2
- package/src/modules/agents/registry/native.ts +1 -1
- package/src/modules/agents/registry/quality.ts +1 -0
- package/src/modules/agents/registry/security.ts +1 -0
- package/src/shared/constants.ts +212 -0
- package/templates/prompts/bug-fix-recipe.md +20 -0
- package/templates/prompts/contract-design-recipe.md +21 -0
- package/templates/prompts/db-management-recipe.md +25 -0
- package/templates/prompts/deployment-recipe.md +23 -0
- package/templates/prompts/new-feature-recipe.md +19 -0
- package/templates/prompts/performance-optimization-recipe.md +23 -0
- package/templates/prompts/pull-request-template.md +21 -0
- package/templates/prompts/refactoring-recipe.md +21 -0
- package/templates/prompts/security-audit-recipe.md +20 -0
- package/templates/standards/architecture-standards.md +23 -0
- package/templates/standards/auth-standards.md +125 -0
- package/templates/standards/crud-governance.md +21 -0
- package/templates/standards/deployment-standards.md +21 -0
- package/templates/standards/frontend-standards.md +37 -0
- package/templates/standards/github-actions-standards.md +43 -0
- package/templates/standards/i18n-standards.md +17 -0
- package/templates/standards/kysely-standards.md +47 -0
- package/templates/standards/llm-governance.md +15 -0
- package/templates/standards/logging-and-secrets.md +34 -0
- package/templates/standards/mobile-standards.md +23 -0
- package/templates/standards/observability-standards.md +15 -0
- package/templates/standards/performance-standards.md +15 -0
- package/templates/standards/pino-standards.md +46 -0
- package/templates/standards/playwright-standards.md +54 -0
- package/templates/standards/quality-standards.md +31 -0
- package/templates/standards/react-query-standards.md +72 -0
- package/templates/standards/react-router-standards.md +62 -0
- package/templates/standards/security-audit-standards.md +16 -0
- package/templates/standards/security-standards.md +21 -0
- package/templates/standards/swagger-standards.md +50 -0
- package/templates/standards/tailwind-standards.md +20 -0
- package/templates/standards/testing-standards.md +31 -0
- package/templates/standards/typeorm-standards.md +49 -0
- package/templates/standards/vitest-standards.md +110 -0
- package/bin/validate-agent-army.js +0 -148
- package/src/cli/commands/app.ts +0 -56
- package/src/cli/utils/app-backend.ts +0 -257
- package/src/cli/utils/app-docs.ts +0 -83
- package/src/cli/utils/app-frontend.ts +0 -263
- package/src/cli/utils/app-inferrer.ts +0 -63
- package/src/cli/utils/app-mobile.ts +0 -113
- package/src/cli/utils/app-types.ts +0 -248
- package/src/cli/utils/app.ts +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_map.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools/search/get_map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"get_map.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools/search/get_map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB,EAAE,IAAuB;IAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,KAAK,KAAK,CAAC;IAEjD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,KAAa,EAAY,EAAE;QACvD,IAAI,KAAK,GAAG,QAAQ;YAAE,OAAO,EAAE,CAAC;QAEhC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAElC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,OAAO;YAElG,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACtC,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAElC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YACpD,CAAC;iBAAM,IAAI,YAAY,EAAE,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;YACxC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IAEF,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACvC,OAAO;YACH,OAAO,EAAE,CAAC;oBACN,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,6BAA6B,QAAQ,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;iBACzE,CAAC;SACL,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACvG,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GrepSearchArgs, ToolResult } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Searches for a regex pattern within files in the project.
|
|
4
4
|
*/
|
|
5
|
-
export declare function handleGrepSearch(projectRoot: string, args:
|
|
5
|
+
export declare function handleGrepSearch(projectRoot: string, args: GrepSearchArgs): ToolResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { Metrics } from "../../utils/metrics.js";
|
|
3
4
|
/**
|
|
4
5
|
* Searches for a regex pattern within files in the project.
|
|
5
6
|
*/
|
|
@@ -8,46 +9,62 @@ export function handleGrepSearch(projectRoot, args) {
|
|
|
8
9
|
const includePattern = args.includePattern || ""; // e.g., ".ts"
|
|
9
10
|
const excludePattern = args.excludePattern || "node_modules";
|
|
10
11
|
if (!pattern) {
|
|
11
|
-
|
|
12
|
+
const err = "Search pattern is required.";
|
|
13
|
+
Metrics.logError(projectRoot, "@mcp", "grep_search", err);
|
|
14
|
+
return { isError: true, content: [{ type: "text", text: `❌ ${err}` }] };
|
|
12
15
|
}
|
|
13
16
|
const results = [];
|
|
14
|
-
|
|
17
|
+
let regex;
|
|
18
|
+
try {
|
|
19
|
+
regex = new RegExp(pattern, "g");
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
const err = `Invalid regex pattern: ${String(e)}`;
|
|
23
|
+
Metrics.logError(projectRoot, "@mcp", "grep_search", err);
|
|
24
|
+
return { isError: true, content: [{ type: "text", text: `❌ ${err}` }] };
|
|
25
|
+
}
|
|
15
26
|
const walk = (dir) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
if (results.length > 100)
|
|
28
|
+
return;
|
|
29
|
+
try {
|
|
30
|
+
const files = fs.readdirSync(dir);
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
if (results.length > 100)
|
|
33
|
+
return;
|
|
34
|
+
const filePath = path.join(dir, file);
|
|
35
|
+
if (excludePattern && filePath.includes(excludePattern)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const stat = fs.statSync(filePath);
|
|
25
39
|
if (stat.isDirectory()) {
|
|
26
|
-
walk(
|
|
40
|
+
walk(filePath);
|
|
27
41
|
}
|
|
28
42
|
else if (stat.isFile()) {
|
|
29
|
-
|
|
30
|
-
if (includePattern && !file.endsWith(includePattern))
|
|
43
|
+
if (includePattern && !filePath.endsWith(includePattern)) {
|
|
31
44
|
continue;
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
regex.lastIndex = 0;
|
|
45
|
+
}
|
|
46
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
47
|
+
// Create a new regex object for each line to avoid state issues with /g
|
|
48
|
+
if (new RegExp(pattern).test(content)) {
|
|
49
|
+
if (results.length < 100) {
|
|
50
|
+
results.push(filePath);
|
|
39
51
|
}
|
|
40
|
-
}
|
|
52
|
+
}
|
|
41
53
|
}
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (results.length > 100)
|
|
47
|
-
break; // Limit results
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
// Ignore directories that cannot be read
|
|
48
58
|
}
|
|
49
59
|
};
|
|
50
|
-
|
|
60
|
+
try {
|
|
61
|
+
walk(projectRoot);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
const err = `Search failed: ${String(e)}`;
|
|
65
|
+
Metrics.logError(projectRoot, "@mcp", "grep_search", err);
|
|
66
|
+
return { isError: true, content: [{ type: "text", text: `❌ ${err}` }] };
|
|
67
|
+
}
|
|
51
68
|
return {
|
|
52
69
|
content: [{
|
|
53
70
|
type: "text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep_search.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools/search/grep_search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"grep_search.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools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AAC,WAAW,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,GAAG,GAAG,kBAAkB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;IAC5E,CAAC;IAED,OAAO;QACH,OAAO,EAAE,CAAC;gBACN,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC;oBACpB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,gBAAgB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC7D,CAAC,CAAC,mBAAmB;aAC5B,CAAC;KACL,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListDirArgs, ToolResult } from "../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Lists the contents of a directory.
|
|
4
4
|
*/
|
|
5
|
-
export declare function handleListDir(projectRoot: string, args:
|
|
5
|
+
export declare function handleListDir(projectRoot: string, args: ListDirArgs): ToolResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_dir.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools/search/list_dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"list_dir.js","sourceRoot":"","sources":["../../../../../fram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,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aAC9E,CAAC;KACL,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { Metrics } from "../../utils/metrics.js";
|
|
3
|
+
const COMMAND_ALLOW_LIST = [
|
|
4
|
+
"npm test",
|
|
5
|
+
"npm run lint",
|
|
6
|
+
"git status",
|
|
7
|
+
"git diff",
|
|
8
|
+
"npx vitest run", // From the audit, this is the test command
|
|
9
|
+
"npm run build", // From the audit
|
|
10
|
+
];
|
|
11
|
+
const TIMEOUT = 30000; // 30 seconds
|
|
12
|
+
export function handleRunCommand(projectRoot, args) {
|
|
13
|
+
const command = args.command;
|
|
14
|
+
const isAllowed = COMMAND_ALLOW_LIST.some(allowedCmd => command.startsWith(allowedCmd));
|
|
15
|
+
if (!isAllowed) {
|
|
16
|
+
const errorMsg = `Command not allowed: "${command}". Only commands starting with the following are allowed: ${COMMAND_ALLOW_LIST.join(", ")}`;
|
|
17
|
+
Metrics.logError(projectRoot, "@mcp", `run_shell_command: ${command} (denied)`, errorMsg);
|
|
18
|
+
return Promise.resolve({
|
|
19
|
+
content: [{ type: "text", text: `ERROR: ${errorMsg}` }],
|
|
20
|
+
isError: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
exec(command, { cwd: projectRoot, timeout: TIMEOUT }, (error, stdout, stderr) => {
|
|
25
|
+
const output = stdout + stderr;
|
|
26
|
+
const tokens = Metrics.estimateTokens(output);
|
|
27
|
+
Metrics.logUsage(projectRoot, "@mcp", `run_shell_command: ${command}`, tokens);
|
|
28
|
+
if (error) {
|
|
29
|
+
const errorMsg = `Command failed with exit code ${error.code}: ${error.message}.`;
|
|
30
|
+
Metrics.logError(projectRoot, "@mcp", `run_shell_command: ${command}`, errorMsg);
|
|
31
|
+
resolve({
|
|
32
|
+
content: [{ type: "text", text: `ERROR: ${errorMsg}. Output: ${output}` }],
|
|
33
|
+
isError: true,
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Truncate long outputs
|
|
38
|
+
const MAX_OUTPUT_LENGTH = 5000;
|
|
39
|
+
let truncatedOutput = output;
|
|
40
|
+
if (output.length > MAX_OUTPUT_LENGTH) {
|
|
41
|
+
truncatedOutput = output.substring(0, MAX_OUTPUT_LENGTH) + "... [TRUNCATED] ..."; // Simplified
|
|
42
|
+
}
|
|
43
|
+
resolve({ content: [{ type: "text", text: truncatedOutput }] });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=run_command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_command.js","sourceRoot":"","sources":["../../../../../framework-mcp/src/tools/shell/run_command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,kBAAkB,GAAG;IACvB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,UAAU;IACV,gBAAgB,EAAE,2CAA2C;IAC7D,eAAe,EAAE,iBAAiB;CACrC,CAAC;AAEF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,aAAa;AAEpC,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,IAAoB;IACtE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAE7B,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IAExF,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,yBAAyB,OAAO,6DAA6D,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9I,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,MAA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GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAC,GAAG,qBAAqB,CAAC,CAAC,aAAa;YACnG,CAAC;YAED,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -7,43 +7,109 @@ export interface ToolDefinition {
|
|
|
7
7
|
required?: string[];
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
name: string;
|
|
13
|
-
arguments?: ToolArgs;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface ToolArgs {
|
|
17
|
-
path?: string;
|
|
18
|
-
content?: string;
|
|
19
|
-
oldText?: string;
|
|
20
|
-
newText?: string;
|
|
10
|
+
export interface ReadFileArgs {
|
|
11
|
+
path: string;
|
|
21
12
|
startLine?: number;
|
|
22
13
|
endLine?: number;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
findings?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface WriteFileArgs {
|
|
16
|
+
path: string;
|
|
17
|
+
content: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ReplaceTextArgs {
|
|
20
|
+
path: string;
|
|
21
|
+
oldText: string;
|
|
22
|
+
newText: string;
|
|
33
23
|
allowMultiple?: boolean;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
}
|
|
25
|
+
export interface PatchFileArgs {
|
|
26
|
+
path: string;
|
|
27
|
+
startLine: number;
|
|
28
|
+
endLine: number;
|
|
29
|
+
newContent: string;
|
|
30
|
+
}
|
|
31
|
+
export interface BatchSurgicalEditArgs {
|
|
32
|
+
edits: Array<{
|
|
33
|
+
path: string;
|
|
34
|
+
oldText: string;
|
|
35
|
+
newText: string;
|
|
36
|
+
allowMultiple?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export interface ListDirArgs {
|
|
40
|
+
path?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface GrepSearchArgs {
|
|
43
|
+
pattern: string;
|
|
39
44
|
includePattern?: string;
|
|
40
45
|
excludePattern?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface GetProjectMapArgs {
|
|
41
48
|
maxDepth?: number;
|
|
42
49
|
includeFiles?: boolean;
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
}
|
|
51
|
+
export interface GetProjectGapsArgs {
|
|
52
|
+
path?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface SendAgentMessageArgs {
|
|
55
|
+
from: string;
|
|
56
|
+
to: string;
|
|
57
|
+
category: "ACTION" | "DELEGATION" | "SUBTASK" | "REPLY" | "ALERT";
|
|
58
|
+
content: string;
|
|
59
|
+
traceId: string;
|
|
60
|
+
parentId?: string;
|
|
61
|
+
priority?: "HIGH" | "NORMAL" | "LOW";
|
|
62
|
+
requiresApproval?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface LogAgentActionArgs {
|
|
65
|
+
agent: string;
|
|
66
|
+
action: string;
|
|
67
|
+
traceId: string;
|
|
68
|
+
status: "SUCCESS" | "FAILURE";
|
|
69
|
+
summary: string;
|
|
70
|
+
findings?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AcquireLockArgs {
|
|
73
|
+
resource: string;
|
|
74
|
+
agent: string;
|
|
75
|
+
ttl?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ReleaseLockArgs {
|
|
78
|
+
resource: string;
|
|
79
|
+
agent: string;
|
|
80
|
+
}
|
|
81
|
+
export interface RegisterAgentArgs {
|
|
82
|
+
agent: string;
|
|
83
|
+
role: string;
|
|
84
|
+
capability?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface StartDashboardArgs {
|
|
87
|
+
port?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface CheckActivePortsArgs {
|
|
45
90
|
filter?: string;
|
|
46
91
|
}
|
|
92
|
+
export interface RunTestsArgs {
|
|
93
|
+
command?: string;
|
|
94
|
+
timeout?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface UpdateProjectMemoryArgs {
|
|
97
|
+
section: string;
|
|
98
|
+
content: string;
|
|
99
|
+
}
|
|
100
|
+
export interface GetStatusArgs {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
}
|
|
103
|
+
export interface OrchestrateArgs {
|
|
104
|
+
timeout?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface UpdateContractHashArgs {
|
|
107
|
+
timeout?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface RunCommandArgs {
|
|
110
|
+
command: string;
|
|
111
|
+
}
|
|
112
|
+
export type ToolArgs = ReadFileArgs | WriteFileArgs | ReplaceTextArgs | PatchFileArgs | BatchSurgicalEditArgs | ListDirArgs | GrepSearchArgs | GetProjectMapArgs | GetProjectGapsArgs | SendAgentMessageArgs | LogAgentActionArgs | AcquireLockArgs | ReleaseLockArgs | RegisterAgentArgs | StartDashboardArgs | CheckActivePortsArgs | RunTestsArgs | UpdateProjectMemoryArgs | GetStatusArgs | OrchestrateArgs | UpdateContractHashArgs;
|
|
47
113
|
export interface ToolResult {
|
|
48
114
|
isError?: boolean;
|
|
49
115
|
content: Array<{
|
|
@@ -51,3 +117,4 @@ export interface ToolResult {
|
|
|
51
117
|
text: string;
|
|
52
118
|
}>;
|
|
53
119
|
}
|
|
120
|
+
export type ToolHandler = (projectRoot: string, args: unknown) => ToolResult | Promise<ToolResult>;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token and Metric Tracker for Agent Enderun.
|
|
3
|
+
* Estimates token usage and logs operational costs.
|
|
4
|
+
*/
|
|
5
|
+
interface MetricEntry {
|
|
6
|
+
timestamp: string;
|
|
7
|
+
agent: string;
|
|
8
|
+
action: string;
|
|
9
|
+
estimatedTokens: number;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
1
12
|
export declare const Metrics: {
|
|
2
13
|
/**
|
|
3
14
|
* Estimates tokens based on character count (rough heuristic: 1 token ~= 4 chars).
|
|
@@ -7,4 +18,13 @@ export declare const Metrics: {
|
|
|
7
18
|
* Logs the token usage and action to the observability metrics file.
|
|
8
19
|
*/
|
|
9
20
|
logUsage: (projectRoot: string, agent: string, action: string, tokens: number) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Logs an error occurrence to the observability metrics file.
|
|
23
|
+
*/
|
|
24
|
+
logError: (projectRoot: string, agent: string, action: string, error: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Internal helper to save metric entries.
|
|
27
|
+
*/
|
|
28
|
+
saveMetric: (projectRoot: string, entry: MetricEntry) => void;
|
|
10
29
|
};
|
|
30
|
+
export {};
|
|
@@ -12,6 +12,29 @@ export const Metrics = {
|
|
|
12
12
|
* Logs the token usage and action to the observability metrics file.
|
|
13
13
|
*/
|
|
14
14
|
logUsage: (projectRoot, agent, action, tokens) => {
|
|
15
|
+
Metrics.saveMetric(projectRoot, {
|
|
16
|
+
timestamp: new Date().toISOString(),
|
|
17
|
+
agent,
|
|
18
|
+
action,
|
|
19
|
+
estimatedTokens: tokens
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Logs an error occurrence to the observability metrics file.
|
|
24
|
+
*/
|
|
25
|
+
logError: (projectRoot, agent, action, error) => {
|
|
26
|
+
Metrics.saveMetric(projectRoot, {
|
|
27
|
+
timestamp: new Date().toISOString(),
|
|
28
|
+
agent,
|
|
29
|
+
action: `ERROR: ${action}`,
|
|
30
|
+
estimatedTokens: 0,
|
|
31
|
+
error
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Internal helper to save metric entries.
|
|
36
|
+
*/
|
|
37
|
+
saveMetric: (projectRoot, entry) => {
|
|
15
38
|
const frameworkDir = resolveFrameworkDir(projectRoot);
|
|
16
39
|
const metricsPath = path.join(projectRoot, frameworkDir, "observability/metrics.json");
|
|
17
40
|
try {
|
|
@@ -22,12 +45,7 @@ export const Metrics = {
|
|
|
22
45
|
if (fs.existsSync(metricsPath)) {
|
|
23
46
|
currentMetrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
|
|
24
47
|
}
|
|
25
|
-
currentMetrics.push(
|
|
26
|
-
timestamp: new Date().toISOString(),
|
|
27
|
-
agent,
|
|
28
|
-
action,
|
|
29
|
-
estimatedTokens: tokens
|
|
30
|
-
});
|
|
48
|
+
currentMetrics.push(entry);
|
|
31
49
|
// Keep only last 100 entries to save space
|
|
32
50
|
if (currentMetrics.length > 100)
|
|
33
51
|
currentMetrics.shift();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAcpD,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB;;OAEG;IACH,cAAc,EAAE,CAAC,IAAY,EAAU,EAAE;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,QAAQ,EAAE,CAAC,WAAmB,EAAE,KAAa,EAAE,MAAc,EAAE,MA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AC,MAAM,GAAG,GAAG;gBAAE,cAAc,CAAC,KAAK,EAAE,CAAC;YAExD,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC;QAAC,MAAM,CAAC,CAAC,uDAAuD,CAAC,CAAC;IACvE,CAAC;CACJ,CAAC"}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
export declare function safePath(projectRoot: string, userPath: string): string;
|
|
6
6
|
/**
|
|
7
7
|
* Resolves the active framework directory.
|
|
8
|
-
* Priority: package.json `enderun.frameworkDir`
|
|
9
|
-
* This ensures the canonical framework directory is always used,
|
|
10
|
-
* even when adapter-specific dirs (e.g. `.gemini`) exist alongside it.
|
|
8
|
+
* Priority: ENDERUN_TEST_DIR (env) -> package.json `enderun.frameworkDir` -> `.enderun` -> other adapter dirs -> global HOME.
|
|
11
9
|
*/
|
|
12
10
|
export declare function resolveFrameworkDir(projectRoot: string): string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
+
import { FRAMEWORK, MCP, UNIFIED_HUB_DIR } from "../constants.js"; // New import
|
|
4
|
+
import os from "os"; // Need os.homedir()
|
|
3
5
|
/**
|
|
4
6
|
* Validates and resolves a user-provided path to prevent path traversal attacks.
|
|
5
7
|
* Ensures the resolved path stays within the project root boundary.
|
|
@@ -14,11 +16,13 @@ export function safePath(projectRoot, userPath) {
|
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Resolves the active framework directory.
|
|
17
|
-
* Priority: package.json `enderun.frameworkDir`
|
|
18
|
-
* This ensures the canonical framework directory is always used,
|
|
19
|
-
* even when adapter-specific dirs (e.g. `.gemini`) exist alongside it.
|
|
19
|
+
* Priority: ENDERUN_TEST_DIR (env) -> package.json `enderun.frameworkDir` -> `.enderun` -> other adapter dirs -> global HOME.
|
|
20
20
|
*/
|
|
21
21
|
export function resolveFrameworkDir(projectRoot) {
|
|
22
|
+
// For test environments, use the explicitly set test directory.
|
|
23
|
+
const testDir = process.env[MCP.TEST_DIR_ENV];
|
|
24
|
+
if (testDir)
|
|
25
|
+
return testDir;
|
|
22
26
|
// 1. Authoritative source: read from package.json if present
|
|
23
27
|
try {
|
|
24
28
|
const pkgPath = path.join(projectRoot, "package.json");
|
|
@@ -26,6 +30,11 @@ export function resolveFrameworkDir(projectRoot) {
|
|
|
26
30
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
27
31
|
const enderunConfig = pkg["enderun"];
|
|
28
32
|
if (enderunConfig && typeof enderunConfig["frameworkDir"] === "string") {
|
|
33
|
+
// Ensure the path is relative if it's within the project, otherwise use as-is.
|
|
34
|
+
const resolvedDir = path.resolve(projectRoot, enderunConfig["frameworkDir"]);
|
|
35
|
+
if (resolvedDir.startsWith(path.resolve(projectRoot))) {
|
|
36
|
+
return path.relative(projectRoot, resolvedDir);
|
|
37
|
+
}
|
|
29
38
|
return enderunConfig["frameworkDir"];
|
|
30
39
|
}
|
|
31
40
|
}
|
|
@@ -33,26 +42,20 @@ export function resolveFrameworkDir(projectRoot) {
|
|
|
33
42
|
catch {
|
|
34
43
|
// ignore — fall through to filesystem scan
|
|
35
44
|
}
|
|
36
|
-
// 2. Filesystem scan
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
".github",
|
|
42
|
-
".grok",
|
|
43
|
-
".windsurf",
|
|
44
|
-
".antigravity",
|
|
45
|
-
".agent",
|
|
46
|
-
".gemini/antigravity-cli",
|
|
47
|
-
".gemini",
|
|
48
|
-
".agents",
|
|
45
|
+
// 2. Filesystem scan in projectRoot for common framework directories
|
|
46
|
+
const localCandidates = [
|
|
47
|
+
FRAMEWORK.CORE_DIR, // .enderun
|
|
48
|
+
UNIFIED_HUB_DIR, // .agents
|
|
49
|
+
// Add other adapter specific directories if needed, or remove if unified is strictly enforced
|
|
49
50
|
];
|
|
50
|
-
for (const candidate of
|
|
51
|
+
for (const candidate of localCandidates) {
|
|
51
52
|
const candidatePath = path.join(projectRoot, candidate);
|
|
52
53
|
if (fs.existsSync(candidatePath)) {
|
|
53
54
|
return candidate;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
// 3. Fallback to global home directory.
|
|
58
|
+
const homeDir = os.homedir();
|
|
59
|
+
return path.join(homeDir, FRAMEWORK.CORE_DIR);
|
|
57
60
|
}
|
|
58
61
|
//# sourceMappingURL=security.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/security.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../framework-mcp/src/utils/security.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC,CAAC,aAAa;AAChF,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,oBAAoB;AAEzC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,WAAmB,EAAE,QAAgB;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;QACjF,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,yBAAyB,CAAC,CAAC;IAC/E,C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ACtC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACxD,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAED,wCAAwC;IACxC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -5,12 +5,17 @@ import { handleReplaceText } from "../../../src/tools/file_system/replace_text.j
|
|
|
5
5
|
import { handlePatchFile } from "../../../src/tools/file_system/patch_file.js";
|
|
6
6
|
import { handleReadFile } from "../../../src/tools/file_system/read_file.js";
|
|
7
7
|
import { handleWriteFile } from "../../../src/tools/file_system/write_file.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import os from "os"; // Need to import os
|
|
9
|
+
let TEST_DIR; // Declare as let
|
|
10
|
+
let TEST_FILE;
|
|
11
|
+
let MEMORY_DIR;
|
|
12
|
+
let MEMORY_FILE;
|
|
12
13
|
beforeEach(() => {
|
|
13
|
-
fs.
|
|
14
|
+
TEST_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "fs-tools-test-")); // Unique temp dir
|
|
15
|
+
fs.mkdirSync(path.join(TEST_DIR, ".enderun"));
|
|
16
|
+
TEST_FILE = path.join(TEST_DIR, "test_file.txt");
|
|
17
|
+
MEMORY_DIR = path.join(TEST_DIR, ".enderun/memory");
|
|
18
|
+
MEMORY_FILE = path.join(MEMORY_DIR, "PROJECT_MEMORY.md");
|
|
14
19
|
});
|
|
15
20
|
afterEach(() => {
|
|
16
21
|
fs.rmSync(TEST_DIR, { recursive: true, force: true });
|
|
@@ -25,8 +30,8 @@ describe("File System Tools", () => {
|
|
|
25
30
|
newText: "there",
|
|
26
31
|
};
|
|
27
32
|
const result = handleReplaceText(TEST_DIR, args);
|
|
28
|
-
expect(result.content[0].text).toContain("✅ Surgical edit successful");
|
|
29
|
-
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there");
|
|
33
|
+
expect(result.content[0].text).toContain("✅ Surgical edit successful in");
|
|
34
|
+
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there\n");
|
|
30
35
|
});
|
|
31
36
|
it("should throw an error if text is not found", () => {
|
|
32
37
|
fs.writeFileSync(TEST_FILE, "hello world", "utf8");
|
|
@@ -56,8 +61,8 @@ describe("File System Tools", () => {
|
|
|
56
61
|
allowMultiple: true,
|
|
57
62
|
};
|
|
58
63
|
const result = handleReplaceText(TEST_DIR, args);
|
|
59
|
-
expect(result.content[0].text).toContain("✅ Surgical edit successful");
|
|
60
|
-
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there there");
|
|
64
|
+
expect(result.content[0].text).toContain("✅ Surgical edit successful in");
|
|
65
|
+
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there there\n");
|
|
61
66
|
});
|
|
62
67
|
it("should log usage to metrics.json upon replace", () => {
|
|
63
68
|
fs.writeFileSync(TEST_FILE, "hello world", "utf8");
|
|
@@ -67,7 +72,7 @@ describe("File System Tools", () => {
|
|
|
67
72
|
newText: "there",
|
|
68
73
|
};
|
|
69
74
|
handleReplaceText(TEST_DIR, args);
|
|
70
|
-
const metricsPath = path.join(TEST_DIR, ".
|
|
75
|
+
const metricsPath = path.join(TEST_DIR, ".enderun/observability/metrics.json");
|
|
71
76
|
expect(fs.existsSync(metricsPath)).toBe(true);
|
|
72
77
|
const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
|
|
73
78
|
expect(metrics[0].action).toContain("replace_text");
|
|
@@ -115,7 +120,7 @@ describe("File System Tools", () => {
|
|
|
115
120
|
newContent: "patched2\npatched3",
|
|
116
121
|
};
|
|
117
122
|
handlePatchFile(TEST_DIR, args);
|
|
118
|
-
const metricsPath = path.join(TEST_DIR, ".
|
|
123
|
+
const metricsPath = path.join(TEST_DIR, ".enderun/observability/metrics.json");
|
|
119
124
|
expect(fs.existsSync(metricsPath)).toBe(true);
|
|
120
125
|
const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
|
|
121
126
|
expect(metrics[0].action).toContain("patch_file");
|
|
@@ -155,8 +160,8 @@ describe("File System Tools", () => {
|
|
|
155
160
|
content: "hello world"
|
|
156
161
|
};
|
|
157
162
|
const result = handleWriteFile(TEST_DIR, args);
|
|
158
|
-
expect(result.content[0].text).toContain("✅ File written");
|
|
159
|
-
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello world");
|
|
163
|
+
expect(result.content[0].text).toContain("✅ File written:");
|
|
164
|
+
expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello world\n");
|
|
160
165
|
});
|
|
161
166
|
it("should write new file and log usage to metrics.json", () => {
|
|
162
167
|
const args = {
|
|
@@ -164,7 +169,7 @@ describe("File System Tools", () => {
|
|
|
164
169
|
content: "hello world"
|
|
165
170
|
};
|
|
166
171
|
handleWriteFile(TEST_DIR, args);
|
|
167
|
-
const metricsPath = path.join(TEST_DIR, ".
|
|
172
|
+
const metricsPath = path.join(TEST_DIR, ".enderun/observability/metrics.json");
|
|
168
173
|
expect(fs.existsSync(metricsPath)).toBe(true);
|
|
169
174
|
const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
|
|
170
175
|
expect(metrics[0].action).toContain("write_file");
|