@dommaker/harness 0.19.0 → 1.1.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/CHANGELOG.md +22 -9
- package/bin/harness.js +136 -557
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +2 -13
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +90 -0
- package/dist/cli/commands/definitions.d.ts.map +1 -0
- package/dist/cli/commands/definitions.js +519 -0
- package/dist/cli/commands/definitions.js.map +1 -0
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/agents-syncer.js +25 -4
- package/dist/cli/commands/sync-docs/agents-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +3 -25
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +3 -93
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts +1 -1
- package/dist/cli/commands/sync-docs/index.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/index.js +4 -4
- package/dist/cli/commands/sync-docs/index.js.map +1 -1
- package/dist/completion-checkers/classify.d.ts +23 -0
- package/dist/completion-checkers/classify.d.ts.map +1 -0
- package/dist/completion-checkers/classify.js +37 -0
- package/dist/completion-checkers/classify.js.map +1 -0
- package/dist/completion-checkers/contract-presence.d.ts +12 -0
- package/dist/completion-checkers/contract-presence.d.ts.map +1 -0
- package/dist/completion-checkers/contract-presence.js +36 -0
- package/dist/completion-checkers/contract-presence.js.map +1 -0
- package/dist/completion-checkers/glob-match.d.ts +13 -0
- package/dist/completion-checkers/glob-match.d.ts.map +1 -0
- package/dist/completion-checkers/glob-match.js +58 -0
- package/dist/completion-checkers/glob-match.js.map +1 -0
- package/dist/completion-checkers/index.d.ts +19 -0
- package/dist/completion-checkers/index.d.ts.map +1 -0
- package/dist/completion-checkers/index.js +47 -0
- package/dist/completion-checkers/index.js.map +1 -0
- package/dist/completion-checkers/phase-format.d.ts +15 -0
- package/dist/completion-checkers/phase-format.d.ts.map +1 -0
- package/dist/completion-checkers/phase-format.js +42 -0
- package/dist/completion-checkers/phase-format.js.map +1 -0
- package/dist/completion-checkers/tdd-chain.d.ts +16 -0
- package/dist/completion-checkers/tdd-chain.d.ts.map +1 -0
- package/dist/completion-checkers/tdd-chain.js +57 -0
- package/dist/completion-checkers/tdd-chain.js.map +1 -0
- package/dist/completion-checkers/types.d.ts +77 -0
- package/dist/completion-checkers/types.d.ts.map +1 -0
- package/dist/completion-checkers/types.js +10 -0
- package/dist/completion-checkers/types.js.map +1 -0
- package/dist/context/index.d.ts +1 -5
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -5
- package/dist/context/index.js.map +1 -1
- package/dist/context/knowledge-injector.d.ts +3 -3
- package/dist/context/knowledge-injector.d.ts.map +1 -1
- package/dist/context/knowledge-injector.js +1 -1
- package/dist/context/session-manager.d.ts +1 -12
- package/dist/context/session-manager.d.ts.map +1 -1
- package/dist/context/session-manager.js +0 -63
- package/dist/context/session-manager.js.map +1 -1
- package/dist/context/types.d.ts +1 -39
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/types.js +2 -15
- package/dist/context/types.js.map +1 -1
- package/dist/core/constraints/agent-prompt-renderer.d.ts +1 -1
- package/dist/core/constraints/agent-prompt-renderer.js +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +17 -2
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +84 -2
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +3 -17
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +7 -47
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts +0 -7
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +1 -8
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.d.ts +0 -2
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -1
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -1
- package/dist/core/constraints/index.d.ts +1 -1
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +2 -3
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/interceptor.d.ts.map +1 -1
- package/dist/core/constraints/interceptor.js +1 -5
- package/dist/core/constraints/interceptor.js.map +1 -1
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +0 -1
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +1 -8
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/dashboard/stats.d.ts.map +1 -1
- package/dist/dashboard/stats.js.map +1 -1
- package/dist/dashboard/types.d.ts +2 -2
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/failure/constraint-handler.d.ts.map +1 -1
- package/dist/failure/constraint-handler.js +0 -2
- package/dist/failure/constraint-handler.js.map +1 -1
- package/dist/gates/acceptance.d.ts +9 -1
- package/dist/gates/acceptance.d.ts.map +1 -1
- package/dist/gates/acceptance.js +21 -0
- package/dist/gates/acceptance.js.map +1 -1
- package/dist/gates/checker-gate.d.ts +23 -0
- package/dist/gates/checker-gate.d.ts.map +1 -0
- package/dist/gates/checker-gate.js +53 -0
- package/dist/gates/checker-gate.js.map +1 -0
- package/dist/gates/command.d.ts +9 -2
- package/dist/gates/command.d.ts.map +1 -1
- package/dist/gates/command.js +10 -0
- package/dist/gates/command.js.map +1 -1
- package/dist/gates/contract.d.ts +8 -2
- package/dist/gates/contract.d.ts.map +1 -1
- package/dist/gates/contract.js +9 -0
- package/dist/gates/contract.js.map +1 -1
- package/dist/gates/decision.d.ts +17 -0
- package/dist/gates/decision.d.ts.map +1 -0
- package/dist/gates/decision.js +25 -0
- package/dist/gates/decision.js.map +1 -0
- package/dist/gates/definitions.d.ts +63 -0
- package/dist/gates/definitions.d.ts.map +1 -0
- package/dist/gates/definitions.js +160 -0
- package/dist/gates/definitions.js.map +1 -0
- package/dist/gates/effective-gates.d.ts +30 -0
- package/dist/gates/effective-gates.d.ts.map +1 -0
- package/dist/gates/effective-gates.js +85 -0
- package/dist/gates/effective-gates.js.map +1 -0
- package/dist/gates/index.d.ts +25 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +37 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/performance.d.ts +8 -2
- package/dist/gates/performance.d.ts.map +1 -1
- package/dist/gates/performance.js +9 -0
- package/dist/gates/performance.js.map +1 -1
- package/dist/gates/registry.d.ts +32 -0
- package/dist/gates/registry.d.ts.map +1 -0
- package/dist/gates/registry.js +90 -0
- package/dist/gates/registry.js.map +1 -0
- package/dist/gates/review.d.ts +8 -2
- package/dist/gates/review.d.ts.map +1 -1
- package/dist/gates/review.js +9 -0
- package/dist/gates/review.js.map +1 -1
- package/dist/gates/runner.d.ts +30 -0
- package/dist/gates/runner.d.ts.map +1 -0
- package/dist/gates/runner.js +38 -0
- package/dist/gates/runner.js.map +1 -0
- package/dist/gates/security.d.ts +8 -2
- package/dist/gates/security.d.ts.map +1 -1
- package/dist/gates/security.js +9 -0
- package/dist/gates/security.js.map +1 -1
- package/dist/gates/types.d.ts +41 -1
- package/dist/gates/types.d.ts.map +1 -1
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +0 -2
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/hooks/config.d.ts +26 -0
- package/dist/hooks/config.d.ts.map +1 -0
- package/dist/hooks/config.js +30 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/registry.d.ts +18 -1
- package/dist/hooks/registry.d.ts.map +1 -1
- package/dist/hooks/registry.js +45 -0
- package/dist/hooks/registry.js.map +1 -1
- package/dist/hooks/types.d.ts +20 -0
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -20
- package/dist/index.js.map +1 -1
- package/dist/knowledge/import.d.ts +2 -2
- package/dist/knowledge/import.d.ts.map +1 -1
- package/dist/knowledge/ingest.js.map +1 -1
- package/dist/knowledge/lifecycle-hooks.d.ts +2 -2
- package/dist/knowledge/lifecycle-hooks.d.ts.map +1 -1
- package/dist/knowledge/types.d.ts +5 -7
- package/dist/knowledge/types.d.ts.map +1 -1
- package/dist/knowledge/types.js +1 -1
- package/dist/knowledge/types.js.map +1 -1
- package/dist/monitoring/constraint-doctor.d.ts +4 -22
- package/dist/monitoring/constraint-doctor.d.ts.map +1 -1
- package/dist/monitoring/constraint-doctor.js +7 -94
- package/dist/monitoring/constraint-doctor.js.map +1 -1
- package/dist/presets/standard.d.ts +1 -1
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +1 -2
- package/dist/presets/standard.js.map +1 -1
- package/dist/pretool-use-hook.d.ts +16 -0
- package/dist/pretool-use-hook.d.ts.map +1 -0
- package/dist/pretool-use-hook.js +68 -0
- package/dist/pretool-use-hook.js.map +1 -0
- package/dist/spec/annotation-checker.d.ts.map +1 -1
- package/dist/spec/annotation-checker.js +6 -26
- package/dist/spec/annotation-checker.js.map +1 -1
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/types/constraint.d.ts +1 -12
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +0 -3
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/project-config.d.ts +0 -2
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/utils/file-walk.d.ts +2 -2
- package/dist/utils/file-walk.js +2 -2
- package/package.json +6 -1
- package/src/CONTEXT.md +15 -0
- package/src/__tests__/checker-extra.test.ts +2 -59
- package/src/__tests__/constraint-doctor.test.ts +1 -140
- package/src/__tests__/constraint-handler.test.ts +0 -4
- package/src/__tests__/pretool-use-hook.test.ts +82 -0
- package/src/__tests__/project-config-loader-extra.test.ts +0 -20
- package/src/__tests__/project-config-loader.test.ts +0 -1
- package/src/cli/commands/CONTEXT.md +15 -7
- package/src/cli/commands/__tests__/check-drift.test.ts +0 -3
- package/src/cli/commands/__tests__/check-skip-output.test.ts +0 -5
- package/src/cli/commands/__tests__/check.test.ts +7 -75
- package/src/cli/commands/__tests__/registry.test.ts +201 -0
- package/src/cli/commands/__tests__/sync-docs-agents.test.ts +55 -0
- package/src/cli/commands/check.ts +2 -14
- package/src/cli/commands/definitions.ts +593 -0
- package/src/cli/commands/knowledge.ts +3 -3
- package/src/cli/commands/sync-docs/agents-syncer.ts +26 -6
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +4 -110
- package/src/cli/commands/sync-docs/index.ts +8 -5
- package/src/completion-checkers/CONTEXT.md +25 -0
- package/src/completion-checkers/__tests__/contract-presence.test.ts +44 -0
- package/src/completion-checkers/__tests__/phase-format.test.ts +60 -0
- package/src/completion-checkers/__tests__/tdd-chain.test.ts +99 -0
- package/src/completion-checkers/classify.ts +47 -0
- package/src/completion-checkers/contract-presence.ts +40 -0
- package/src/completion-checkers/glob-match.ts +54 -0
- package/src/completion-checkers/index.ts +19 -0
- package/src/completion-checkers/phase-format.ts +48 -0
- package/src/completion-checkers/tdd-chain.ts +63 -0
- package/src/completion-checkers/types.ts +84 -0
- package/src/context/CONTEXT.md +2 -7
- package/src/context/__tests__/session-manager.test.ts +0 -91
- package/src/context/index.ts +1 -5
- package/src/context/knowledge-injector.ts +3 -3
- package/src/context/session-manager.ts +0 -74
- package/src/context/types.ts +2 -63
- package/src/core/constraints/__tests__/interceptor.test.ts +0 -2
- package/src/core/constraints/agent-prompt-renderer.ts +1 -1
- package/src/core/constraints/capabilities-parser.ts +95 -2
- package/src/core/constraints/checker.ts +8 -53
- package/src/core/constraints/definitions.ts +0 -8
- package/src/core/constraints/doc-freshness/runner.ts +1 -2
- package/src/core/constraints/index.ts +1 -2
- package/src/core/constraints/interceptor.ts +1 -6
- package/src/core/effective-constraints.ts +0 -1
- package/src/core/project-config-loader.ts +1 -7
- package/src/dashboard/stats.ts +2 -2
- package/src/dashboard/types.ts +2 -2
- package/src/failure/constraint-handler.ts +0 -2
- package/src/gates/CONTEXT.md +16 -13
- package/src/gates/__tests__/checker-gate.test.ts +45 -0
- package/src/gates/__tests__/contract.test.ts +73 -0
- package/src/gates/__tests__/effective-gates.test.ts +82 -0
- package/src/gates/__tests__/gate-interface.test.ts +202 -0
- package/src/gates/__tests__/registry.test.ts +87 -0
- package/src/gates/__tests__/runner.test.ts +81 -0
- package/src/gates/acceptance.ts +24 -1
- package/src/gates/checker-gate.ts +54 -0
- package/src/gates/command.ts +13 -2
- package/src/gates/contract.ts +12 -2
- package/src/gates/decision.ts +27 -0
- package/src/gates/definitions.ts +207 -0
- package/src/gates/effective-gates.ts +106 -0
- package/src/gates/index.ts +38 -0
- package/src/gates/performance.ts +12 -2
- package/src/gates/registry.ts +107 -0
- package/src/gates/review.ts +12 -2
- package/src/gates/runner.ts +57 -0
- package/src/gates/security.ts +12 -2
- package/src/gates/types.ts +48 -1
- package/src/hooks/CONTEXT.md +12 -2
- package/src/hooks/__tests__/bootstrap.test.ts +0 -1
- package/src/hooks/__tests__/config.test.ts +19 -0
- package/src/hooks/__tests__/pipeline.test.ts +79 -0
- package/src/hooks/__tests__/registry.test.ts +67 -0
- package/src/hooks/bootstrap.ts +0 -2
- package/src/hooks/config.ts +29 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/registry.ts +60 -1
- package/src/hooks/types.ts +21 -0
- package/src/index.ts +11 -21
- package/src/knowledge/import.ts +3 -3
- package/src/knowledge/ingest.ts +4 -4
- package/src/knowledge/lifecycle-hooks.ts +3 -3
- package/src/knowledge/types.ts +5 -8
- package/src/monitoring/constraint-doctor.ts +7 -106
- package/src/presets/__tests__/standard.test.ts +0 -2
- package/src/presets/standard.ts +1 -2
- package/src/pretool-use-hook.ts +68 -0
- package/src/spec/__tests__/annotation-checker.test.ts +9 -3
- package/src/spec/annotation-checker.ts +7 -29
- package/src/tools/CONTEXT.md +7 -14
- package/src/tools/index.ts +0 -4
- package/src/types/constraint.ts +1 -14
- package/src/types/project-config.ts +0 -3
- package/src/utils/file-walk.ts +2 -2
- package/dist/architecture/constraint-engine.d.ts +0 -67
- package/dist/architecture/constraint-engine.d.ts.map +0 -1
- package/dist/architecture/constraint-engine.js +0 -295
- package/dist/architecture/constraint-engine.js.map +0 -1
- package/dist/architecture/cross-project-checker.d.ts +0 -54
- package/dist/architecture/cross-project-checker.d.ts.map +0 -1
- package/dist/architecture/cross-project-checker.js +0 -467
- package/dist/architecture/cross-project-checker.js.map +0 -1
- package/dist/cli/commands/index.d.ts +0 -30
- package/dist/cli/commands/index.d.ts.map +0 -1
- package/dist/cli/commands/index.js +0 -91
- package/dist/cli/commands/index.js.map +0 -1
- package/dist/context/file-budget.d.ts +0 -40
- package/dist/context/file-budget.d.ts.map +0 -1
- package/dist/context/file-budget.js +0 -147
- package/dist/context/file-budget.js.map +0 -1
- package/dist/context/progressive-loader.d.ts +0 -109
- package/dist/context/progressive-loader.d.ts.map +0 -1
- package/dist/context/progressive-loader.js +0 -166
- package/dist/context/progressive-loader.js.map +0 -1
- package/dist/context/token-pipeline.d.ts +0 -55
- package/dist/context/token-pipeline.d.ts.map +0 -1
- package/dist/context/token-pipeline.js +0 -220
- package/dist/context/token-pipeline.js.map +0 -1
- package/dist/context/tool-output-budget.d.ts +0 -59
- package/dist/context/tool-output-budget.d.ts.map +0 -1
- package/dist/context/tool-output-budget.js +0 -177
- package/dist/context/tool-output-budget.js.map +0 -1
- package/dist/core/constraints/default-executors.d.ts +0 -10
- package/dist/core/constraints/default-executors.d.ts.map +0 -1
- package/dist/core/constraints/default-executors.js +0 -120
- package/dist/core/constraints/default-executors.js.map +0 -1
- package/dist/llm/adapter.d.ts +0 -36
- package/dist/llm/adapter.d.ts.map +0 -1
- package/dist/llm/adapter.js +0 -118
- package/dist/llm/adapter.js.map +0 -1
- package/dist/llm/index.d.ts +0 -3
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -19
- package/dist/llm/index.js.map +0 -1
- package/dist/llm/types.d.ts +0 -62
- package/dist/llm/types.d.ts.map +0 -1
- package/dist/llm/types.js +0 -8
- package/dist/llm/types.js.map +0 -1
- package/dist/tools/core/index.d.ts +0 -13
- package/dist/tools/core/index.d.ts.map +0 -1
- package/dist/tools/core/index.js +0 -198
- package/dist/tools/core/index.js.map +0 -1
- package/dist/tools/loader.d.ts +0 -21
- package/dist/tools/loader.d.ts.map +0 -1
- package/dist/tools/loader.js +0 -199
- package/dist/tools/loader.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -59
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js +0 -115
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/types.d.ts +0 -38
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js +0 -6
- package/dist/tools/types.js.map +0 -1
- package/src/__tests__/architecture-engine.test.ts +0 -619
- package/src/__tests__/context/progressive-loader.test.ts +0 -131
- package/src/__tests__/cross-project-checker.test.ts +0 -318
- package/src/architecture/CONTEXT.md +0 -22
- package/src/architecture/constraint-engine.ts +0 -351
- package/src/architecture/cross-project-checker.ts +0 -545
- package/src/cli/commands/index.ts +0 -30
- package/src/context/__tests__/file-budget.test.ts +0 -142
- package/src/context/__tests__/progressive-loader.test.ts +0 -264
- package/src/context/__tests__/token-pipeline.test.ts +0 -178
- package/src/context/__tests__/tool-output-budget.test.ts +0 -95
- package/src/context/file-budget.ts +0 -142
- package/src/context/progressive-loader.ts +0 -260
- package/src/context/token-pipeline.ts +0 -265
- package/src/context/tool-output-budget.ts +0 -178
- package/src/core/constraints/__tests__/default-executors.test.ts +0 -57
- package/src/core/constraints/default-executors.ts +0 -92
- package/src/llm/CONTEXT.md +0 -21
- package/src/llm/__tests__/adapter.test.ts +0 -172
- package/src/llm/adapter.ts +0 -149
- package/src/llm/index.ts +0 -2
- package/src/llm/types.ts +0 -81
- package/src/tools/__tests__/loader.test.ts +0 -252
- package/src/tools/__tests__/registry.test.ts +0 -157
- package/src/tools/core/__tests__/core.test.ts +0 -122
- package/src/tools/core/index.ts +0 -201
- package/src/tools/loader.ts +0 -216
- package/src/tools/registry.ts +0 -128
- package/src/tools/types.ts +0 -46
package/dist/llm/adapter.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 默认 LLM 适配器
|
|
4
|
-
*
|
|
5
|
-
* 提供基础实现,使用者可以替换为自己的实现
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.DefaultLLMAdapter = void 0;
|
|
9
|
-
exports.createLLMAdapter = createLLMAdapter;
|
|
10
|
-
/**
|
|
11
|
-
* 创建 LLM 适配器
|
|
12
|
-
*/
|
|
13
|
-
function createLLMAdapter(config) {
|
|
14
|
-
if (config.customAdapter) {
|
|
15
|
-
return config.customAdapter;
|
|
16
|
-
}
|
|
17
|
-
return new DefaultLLMAdapter(config);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 默认 LLM 适配器
|
|
21
|
-
*
|
|
22
|
-
* 使用零 token 成本的结构化方法:
|
|
23
|
-
* - summarize: 基于模板提取关键信息
|
|
24
|
-
* - extract: 基于正则提取结构化数据
|
|
25
|
-
* - complete/chat: 需要注入具体实现
|
|
26
|
-
*/
|
|
27
|
-
class DefaultLLMAdapter {
|
|
28
|
-
config;
|
|
29
|
-
constructor(config) {
|
|
30
|
-
this.config = config;
|
|
31
|
-
}
|
|
32
|
-
async complete(_prompt, options) {
|
|
33
|
-
throw new Error(`LLM complete 未实现。请通过 createLLMAdapter({ customAdapter }) 注入具体实现。` +
|
|
34
|
-
`\n提供商: ${this.config.provider}, 模型: ${options?.model ?? this.config.model ?? '未指定'}`);
|
|
35
|
-
}
|
|
36
|
-
async chat(messages, _options) {
|
|
37
|
-
throw new Error(`LLM chat 未实现。请通过 createLLMAdapter({ customAdapter }) 注入具体实现。` +
|
|
38
|
-
`\n提供商: ${this.config.provider}, 消息数: ${messages.length}`);
|
|
39
|
-
}
|
|
40
|
-
async *streamChat(_messages, _options) {
|
|
41
|
-
throw new Error(`LLM streamChat 未实现。请通过 createLLMAdapter({ customAdapter }) 注入具体实现。`);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 结构化总结(零 token 成本,基于模板)
|
|
45
|
-
*/
|
|
46
|
-
async summarize(messages, config) {
|
|
47
|
-
const parts = [];
|
|
48
|
-
// 提取用户目标
|
|
49
|
-
if (config.preserve.includes('user_goals')) {
|
|
50
|
-
const userMessages = messages.filter(m => m.role === 'user');
|
|
51
|
-
if (userMessages.length > 0) {
|
|
52
|
-
parts.push('## 用户目标');
|
|
53
|
-
for (const msg of userMessages.slice(-3)) {
|
|
54
|
-
parts.push(`- ${msg.content.slice(0, 200)}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// 提取工具调用
|
|
59
|
-
if (config.preserve.includes('tool_calls')) {
|
|
60
|
-
const toolMessages = messages.filter(m => m.role === 'tool');
|
|
61
|
-
if (toolMessages.length > 0) {
|
|
62
|
-
parts.push('\n## 工具调用');
|
|
63
|
-
parts.push(`共 ${toolMessages.length} 次工具调用`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// 提取错误
|
|
67
|
-
if (config.preserve.includes('errors')) {
|
|
68
|
-
const errorMessages = messages.filter(m => m.content.toLowerCase().includes('error') ||
|
|
69
|
-
m.content.toLowerCase().includes('failed'));
|
|
70
|
-
if (errorMessages.length > 0) {
|
|
71
|
-
parts.push('\n## 错误');
|
|
72
|
-
for (const msg of errorMessages.slice(-3)) {
|
|
73
|
-
parts.push(`- ${msg.content.slice(0, 200)}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// 提取决策
|
|
78
|
-
if (config.preserve.includes('decisions')) {
|
|
79
|
-
const decisionMessages = messages.filter(m => m.content.includes('决策') ||
|
|
80
|
-
m.content.includes('decision') ||
|
|
81
|
-
m.content.includes('选择') ||
|
|
82
|
-
m.content.includes('方案'));
|
|
83
|
-
if (decisionMessages.length > 0) {
|
|
84
|
-
parts.push('\n## 决策');
|
|
85
|
-
for (const msg of decisionMessages.slice(-3)) {
|
|
86
|
-
parts.push(`- ${msg.content.slice(0, 200)}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const summary = parts.join('\n');
|
|
91
|
-
return summary.slice(0, config.maxTokens * 4); // 粗略字符/token 比
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 结构化提取(基于正则,零 token 成本)
|
|
95
|
-
*/
|
|
96
|
-
async extract(content, schema) {
|
|
97
|
-
const result = {};
|
|
98
|
-
for (const [key, type] of Object.entries(schema)) {
|
|
99
|
-
if (typeof type === 'string') {
|
|
100
|
-
// 简单类型提取
|
|
101
|
-
const pattern = new RegExp(`${key}[:\\s]+(.+)`, 'i');
|
|
102
|
-
const match = content.match(pattern);
|
|
103
|
-
if (match) {
|
|
104
|
-
result[key] = match[1].trim();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
getProvider() {
|
|
111
|
-
return this.config.provider;
|
|
112
|
-
}
|
|
113
|
-
getModel() {
|
|
114
|
-
return this.config.model;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.DefaultLLMAdapter = DefaultLLMAdapter;
|
|
118
|
-
//# sourceMappingURL=adapter.js.map
|
package/dist/llm/adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/llm/adapter.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAcH,4CAMC;AATD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,MAAwB;IACvD,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,iBAAiB;IACpB,MAAM,CAAmB;IAEjC,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,OAAoB;QAClD,MAAM,IAAI,KAAK,CACb,kEAAkE;YAClE,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,SAAS,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,EAAE,CACtF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAmB,EAAE,QAAqB;QACnD,MAAM,IAAI,KAAK,CACb,8DAA8D;YAC9D,UAAU,IAAI,CAAC,MAAM,CAAC,QAAQ,UAAU,QAAQ,CAAC,MAAM,EAAE,CAC1D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,CAAC,UAAU,CAAC,SAAoB,EAAE,QAAqB;QAC3D,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,QAAmB,EAAE,MAAuB;QAC1D,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B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AC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,MAA+B;QAC5D,MAAM,MAAM,GAA4B,EAAE,CAAC;QAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACjD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,SAAS;gBACT,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,aAAa,EAAE,GAAG,CAAC,CAAC;gBACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACrC,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;CACF;AAlHD,8CAkHC"}
|
package/dist/llm/index.d.ts
DELETED
package/dist/llm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
package/dist/llm/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./adapter"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/llm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B"}
|
package/dist/llm/types.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM 适配器类型定义
|
|
3
|
-
*
|
|
4
|
-
* harness 核心不硬编码 LLM 依赖,通过接口注入
|
|
5
|
-
*/
|
|
6
|
-
export interface Message {
|
|
7
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
8
|
-
content: string;
|
|
9
|
-
toolCallId?: string;
|
|
10
|
-
name?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface LLMOptions {
|
|
13
|
-
/** 模型名称 */
|
|
14
|
-
model?: string;
|
|
15
|
-
/** 温度 */
|
|
16
|
-
temperature?: number;
|
|
17
|
-
/** 最大 token 数 */
|
|
18
|
-
maxTokens?: number;
|
|
19
|
-
/** 停止序列 */
|
|
20
|
-
stop?: string[];
|
|
21
|
-
/** 工具定义(function calling) */
|
|
22
|
-
tools?: LLMToolSpec[];
|
|
23
|
-
}
|
|
24
|
-
export interface LLMToolSpec {
|
|
25
|
-
name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
parameters: Record<string, unknown>;
|
|
28
|
-
}
|
|
29
|
-
export interface SummarizeConfig {
|
|
30
|
-
/** 目标 token 数 */
|
|
31
|
-
maxTokens: number;
|
|
32
|
-
/** 保留的关键信息 */
|
|
33
|
-
preserve: Array<'user_goals' | 'tool_calls' | 'errors' | 'decisions'>;
|
|
34
|
-
}
|
|
35
|
-
export interface ExtractConfig {
|
|
36
|
-
/** 目标 schema */
|
|
37
|
-
schema: Record<string, unknown>;
|
|
38
|
-
/** 是否严格模式 */
|
|
39
|
-
strict?: boolean;
|
|
40
|
-
}
|
|
41
|
-
export interface LLMAdapter {
|
|
42
|
-
/** 对话补全 */
|
|
43
|
-
complete(prompt: string, options?: LLMOptions): Promise<string>;
|
|
44
|
-
/** 多轮对话 */
|
|
45
|
-
chat(messages: Message[], options?: LLMOptions): Promise<string>;
|
|
46
|
-
/** 流式对话 */
|
|
47
|
-
streamChat(messages: Message[], options?: LLMOptions): AsyncIterable<string>;
|
|
48
|
-
/** 总结 */
|
|
49
|
-
summarize(messages: Message[], config: SummarizeConfig): Promise<string>;
|
|
50
|
-
/** 结构化提取 */
|
|
51
|
-
extract(content: string, schema: Record<string, unknown>): Promise<unknown>;
|
|
52
|
-
}
|
|
53
|
-
export type LLMProvider = 'openai' | 'anthropic' | 'local' | 'custom';
|
|
54
|
-
export interface LLMAdapterConfig {
|
|
55
|
-
provider: LLMProvider;
|
|
56
|
-
model?: string;
|
|
57
|
-
apiKey?: string;
|
|
58
|
-
baseUrl?: string;
|
|
59
|
-
/** 自定义适配器实现 */
|
|
60
|
-
customAdapter?: LLMAdapter;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/llm/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
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AE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,WAAW;IACX,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7E,SAAS;IACT,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzE,YAAY;IACZ,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7E;AAID,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B"}
|
package/dist/llm/types.js
DELETED
package/dist/llm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 核心工具定义
|
|
3
|
-
*
|
|
4
|
-
* 内置工具:file / git / npm / shell
|
|
5
|
-
*/
|
|
6
|
-
import type { ToolDefinition } from '../types';
|
|
7
|
-
export declare const FILE_TOOLS: ToolDefinition[];
|
|
8
|
-
export declare const GIT_TOOLS: ToolDefinition[];
|
|
9
|
-
export declare const NPM_TOOLS: ToolDefinition[];
|
|
10
|
-
export declare const SHELL_TOOLS: ToolDefinition[];
|
|
11
|
-
/** 所有核心工具 */
|
|
12
|
-
export declare const CORE_TOOLS: ToolDefinition[];
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,UAAU,EAAE,cAAc,EA8DtC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAAc,EAqDrC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAAc,EA6CrC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,cAAc,EAkBvC,CAAC;AAEF,aAAa;AACb,eAAO,MAAM,UAAU,EAAE,cAAc,EAKtC,CAAC"}
|
package/dist/tools/core/index.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 核心工具定义
|
|
4
|
-
*
|
|
5
|
-
* 内置工具:file / git / npm / shell
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.CORE_TOOLS = exports.SHELL_TOOLS = exports.NPM_TOOLS = exports.GIT_TOOLS = exports.FILE_TOOLS = void 0;
|
|
9
|
-
exports.FILE_TOOLS = [
|
|
10
|
-
{
|
|
11
|
-
id: 'read_file',
|
|
12
|
-
name: 'Read File',
|
|
13
|
-
description: '读取文件内容',
|
|
14
|
-
category: 'core',
|
|
15
|
-
parameters: {
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: {
|
|
18
|
-
path: { type: 'string', description: '文件路径' },
|
|
19
|
-
offset: { type: 'number', description: '起始行号' },
|
|
20
|
-
limit: { type: 'number', description: '读取行数' },
|
|
21
|
-
},
|
|
22
|
-
required: ['path'],
|
|
23
|
-
},
|
|
24
|
-
sandboxLevel: 1,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'write_file',
|
|
28
|
-
name: 'Write File',
|
|
29
|
-
description: '写入文件内容',
|
|
30
|
-
category: 'core',
|
|
31
|
-
parameters: {
|
|
32
|
-
type: 'object',
|
|
33
|
-
properties: {
|
|
34
|
-
path: { type: 'string', description: '文件路径' },
|
|
35
|
-
content: { type: 'string', description: '文件内容' },
|
|
36
|
-
},
|
|
37
|
-
required: ['path', 'content'],
|
|
38
|
-
},
|
|
39
|
-
sandboxLevel: 3,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: 'edit_file',
|
|
43
|
-
name: 'Edit File',
|
|
44
|
-
description: '编辑文件(精确替换)',
|
|
45
|
-
category: 'core',
|
|
46
|
-
parameters: {
|
|
47
|
-
type: 'object',
|
|
48
|
-
properties: {
|
|
49
|
-
path: { type: 'string', description: '文件路径' },
|
|
50
|
-
old_string: { type: 'string', description: '要替换的文本' },
|
|
51
|
-
new_string: { type: 'string', description: '替换后的文本' },
|
|
52
|
-
},
|
|
53
|
-
required: ['path', 'old_string', 'new_string'],
|
|
54
|
-
},
|
|
55
|
-
sandboxLevel: 3,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 'list_directory',
|
|
59
|
-
name: 'List Directory',
|
|
60
|
-
description: '列出目录内容',
|
|
61
|
-
category: 'core',
|
|
62
|
-
parameters: {
|
|
63
|
-
type: 'object',
|
|
64
|
-
properties: {
|
|
65
|
-
path: { type: 'string', description: '目录路径' },
|
|
66
|
-
},
|
|
67
|
-
required: ['path'],
|
|
68
|
-
},
|
|
69
|
-
sandboxLevel: 1,
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
exports.GIT_TOOLS = [
|
|
73
|
-
{
|
|
74
|
-
id: 'git_status',
|
|
75
|
-
name: 'Git Status',
|
|
76
|
-
description: '查看 git 工作区状态',
|
|
77
|
-
category: 'core',
|
|
78
|
-
parameters: { type: 'object', properties: {} },
|
|
79
|
-
sandboxLevel: 1,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: 'git_diff',
|
|
83
|
-
name: 'Git Diff',
|
|
84
|
-
description: '查看 git 差异',
|
|
85
|
-
category: 'core',
|
|
86
|
-
parameters: {
|
|
87
|
-
type: 'object',
|
|
88
|
-
properties: {
|
|
89
|
-
staged: { type: 'boolean', description: '是否查看暂存区' },
|
|
90
|
-
file: { type: 'string', description: '指定文件' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
sandboxLevel: 1,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: 'git_commit',
|
|
97
|
-
name: 'Git Commit',
|
|
98
|
-
description: '创建 git 提交',
|
|
99
|
-
category: 'core',
|
|
100
|
-
parameters: {
|
|
101
|
-
type: 'object',
|
|
102
|
-
properties: {
|
|
103
|
-
message: { type: 'string', description: '提交信息' },
|
|
104
|
-
files: { type: 'array', items: { type: 'string' }, description: '要提交的文件' },
|
|
105
|
-
},
|
|
106
|
-
required: ['message'],
|
|
107
|
-
},
|
|
108
|
-
sandboxLevel: 3,
|
|
109
|
-
requiresConfirmation: true,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
id: 'git_log',
|
|
113
|
-
name: 'Git Log',
|
|
114
|
-
description: '查看 git 提交历史',
|
|
115
|
-
category: 'core',
|
|
116
|
-
parameters: {
|
|
117
|
-
type: 'object',
|
|
118
|
-
properties: {
|
|
119
|
-
limit: { type: 'number', description: '显示条数' },
|
|
120
|
-
file: { type: 'string', description: '指定文件' },
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
sandboxLevel: 1,
|
|
124
|
-
},
|
|
125
|
-
];
|
|
126
|
-
exports.NPM_TOOLS = [
|
|
127
|
-
{
|
|
128
|
-
id: 'npm_install',
|
|
129
|
-
name: 'NPM Install',
|
|
130
|
-
description: '安装依赖',
|
|
131
|
-
category: 'core',
|
|
132
|
-
parameters: {
|
|
133
|
-
type: 'object',
|
|
134
|
-
properties: {
|
|
135
|
-
packages: { type: 'array', items: { type: 'string' }, description: '包名列表' },
|
|
136
|
-
dev: { type: 'boolean', description: '是否为开发依赖' },
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
sandboxLevel: 3,
|
|
140
|
-
rateLimit: 10,
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: 'npm_run',
|
|
144
|
-
name: 'NPM Run',
|
|
145
|
-
description: '执行 npm 脚本',
|
|
146
|
-
category: 'core',
|
|
147
|
-
parameters: {
|
|
148
|
-
type: 'object',
|
|
149
|
-
properties: {
|
|
150
|
-
script: { type: 'string', description: '脚本名称' },
|
|
151
|
-
args: { type: 'array', items: { type: 'string' }, description: '参数' },
|
|
152
|
-
},
|
|
153
|
-
required: ['script'],
|
|
154
|
-
},
|
|
155
|
-
sandboxLevel: 3,
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
id: 'npm_test',
|
|
159
|
-
name: 'NPM Test',
|
|
160
|
-
description: '运行测试',
|
|
161
|
-
category: 'core',
|
|
162
|
-
parameters: {
|
|
163
|
-
type: 'object',
|
|
164
|
-
properties: {
|
|
165
|
-
pattern: { type: 'string', description: '测试文件匹配模式' },
|
|
166
|
-
coverage: { type: 'boolean', description: '是否生成覆盖率报告' },
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
sandboxLevel: 3,
|
|
170
|
-
},
|
|
171
|
-
];
|
|
172
|
-
exports.SHELL_TOOLS = [
|
|
173
|
-
{
|
|
174
|
-
id: 'shell_exec',
|
|
175
|
-
name: 'Shell Execute',
|
|
176
|
-
description: '执行 shell 命令',
|
|
177
|
-
category: 'core',
|
|
178
|
-
parameters: {
|
|
179
|
-
type: 'object',
|
|
180
|
-
properties: {
|
|
181
|
-
command: { type: 'string', description: '命令' },
|
|
182
|
-
cwd: { type: 'string', description: '工作目录' },
|
|
183
|
-
timeout: { type: 'number', description: '超时(ms)' },
|
|
184
|
-
},
|
|
185
|
-
required: ['command'],
|
|
186
|
-
},
|
|
187
|
-
sandboxLevel: 3,
|
|
188
|
-
rateLimit: 30,
|
|
189
|
-
},
|
|
190
|
-
];
|
|
191
|
-
/** 所有核心工具 */
|
|
192
|
-
exports.CORE_TOOLS = [
|
|
193
|
-
...exports.FILE_TOOLS,
|
|
194
|
-
...exports.GIT_TOOLS,
|
|
195
|
-
...exports.NPM_TOOLS,
|
|
196
|
-
...exports.SHELL_TOOLS,
|
|
197
|
-
];
|
|
198
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/core/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIU,QAAA,UAAU,GAAqB;IAC1C;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,QAAQ;QACrB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;gBAC7C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;gBAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;aAC/C;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;QACD,YAAY,EAAE,CAAC;KAChB;IACD;QACE,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,QAAQ;QACrB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;gBAC7C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;aACj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I,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE;gBAC9C,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;gBAC5C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE;aACnD;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;QACD,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,EAAE;KACd;CACF,CAAC;AAEF,aAAa;AACA,QAAA,UAAU,GAAqB;IAC1C,GAAG,kBAAU;IACb,GAAG,iBAAS;IACZ,GAAG,iBAAS;IACZ,GAAG,mBAAW;CACf,CAAC"}
|
package/dist/tools/loader.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ToolDefinition } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Parse a single YAML file into a ToolDefinition.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseToolYaml(yamlContent: string, filePath: string, definitionsDir: string): ToolDefinition;
|
|
6
|
-
/**
|
|
7
|
-
* Load all tool definitions from the definitions directory (core/, std/, ext/).
|
|
8
|
-
*/
|
|
9
|
-
export declare function loadToolsFromDir(definitionsDir: string): ToolDefinition[];
|
|
10
|
-
/**
|
|
11
|
-
* Load the registry.json and fix absolute paths to relative (from definitions dir).
|
|
12
|
-
* Filters out workflow entries, keeping only tool entries.
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadRegistry(registryPath: string): Array<{
|
|
15
|
-
name: string;
|
|
16
|
-
category: string;
|
|
17
|
-
type: string;
|
|
18
|
-
description: string;
|
|
19
|
-
path: string;
|
|
20
|
-
}>;
|
|
21
|
-
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/tools/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAgB,MAAM,SAAS,CAAC;AAwHvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,cAAc,CAmB3G;AAqBD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,cAAc,EAAE,CAoBzE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,KAAK,CAAC;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAcD"}
|