xtrm-tools 2.3.0 → 2.4.1
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 +132 -111
- package/cli/dist/index.cjs +142 -53
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +1 -1
- package/config/pi/extensions/beads.ts +24 -0
- package/hooks/beads-gate-core.mjs +6 -4
- package/hooks/beads-memory-gate.mjs +12 -5
- package/hooks/hooks.json +126 -0
- package/package.json +3 -1
- package/skills/test-planning/SKILL.md +208 -0
- package/skills/test-planning/evals/evals.json +23 -0
- package/skills/using-xtrm/SKILL.md +5 -27
- package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -103
- package/project-skills/tdd-guard/.claude/settings.json +0 -38
- package/project-skills/tdd-guard/.claude/skills/using-tdd-guard/SKILL.md +0 -79
- package/project-skills/tdd-guard/CLAUDE.md +0 -98
- package/project-skills/tdd-guard/CONTRIBUTING.md +0 -38
- package/project-skills/tdd-guard/DEVELOPMENT.md +0 -127
- package/project-skills/tdd-guard/LICENSE +0 -21
- package/project-skills/tdd-guard/README.md +0 -398
- package/project-skills/tdd-guard/docs/adr/001-claude-session-subdirectory.md +0 -52
- package/project-skills/tdd-guard/docs/adr/002-secure-claude-binary-path.md +0 -56
- package/project-skills/tdd-guard/docs/adr/003-remove-configurable-data-directory.md +0 -56
- package/project-skills/tdd-guard/docs/adr/004-monorepo-architecture.md +0 -64
- package/project-skills/tdd-guard/docs/adr/005-claude-project-dir-support.md +0 -55
- package/project-skills/tdd-guard/docs/adr/006-phpunit-separate-repository.md +0 -93
- package/project-skills/tdd-guard/docs/adr/007-golangci-lint-path-support.md +0 -83
- package/project-skills/tdd-guard/docs/adr/008-storybook-reporter-design.md +0 -182
- package/project-skills/tdd-guard/docs/assets/tdd-guard-demo-screenshot.gif +0 -0
- package/project-skills/tdd-guard/docs/config-migration.md +0 -143
- package/project-skills/tdd-guard/docs/configuration.md +0 -137
- package/project-skills/tdd-guard/docs/custom-instructions.md +0 -43
- package/project-skills/tdd-guard/docs/enforcement.md +0 -46
- package/project-skills/tdd-guard/docs/ignore-patterns.md +0 -81
- package/project-skills/tdd-guard/docs/linting.md +0 -109
- package/project-skills/tdd-guard/docs/quick-commands.md +0 -52
- package/project-skills/tdd-guard/docs/session-management.md +0 -75
- package/project-skills/tdd-guard/docs/storybook-vitest-addon.md +0 -120
- package/project-skills/tdd-guard/docs/validation-model.md +0 -63
- package/project-skills/tdd-guard/eslint.config.mjs +0 -140
- package/project-skills/tdd-guard/package-lock.json +0 -16937
- package/project-skills/tdd-guard/package.json +0 -102
- package/project-skills/tdd-guard/reporters/go/README.md +0 -67
- package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main.go +0 -127
- package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main_test.go +0 -280
- package/project-skills/tdd-guard/reporters/go/go.mod +0 -3
- package/project-skills/tdd-guard/reporters/go/go.sum +0 -0
- package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter.go +0 -126
- package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter_test.go +0 -264
- package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader.go +0 -26
- package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader_test.go +0 -37
- package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader.go +0 -94
- package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader_test.go +0 -198
- package/project-skills/tdd-guard/reporters/go/internal/parser/parser.go +0 -245
- package/project-skills/tdd-guard/reporters/go/internal/parser/parser_test.go +0 -547
- package/project-skills/tdd-guard/reporters/go/internal/storage/storage.go +0 -35
- package/project-skills/tdd-guard/reporters/go/internal/storage/storage_test.go +0 -113
- package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer.go +0 -103
- package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer_test.go +0 -303
- package/project-skills/tdd-guard/reporters/jest/README.md +0 -102
- package/project-skills/tdd-guard/reporters/jest/package.json +0 -38
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test-data.ts +0 -199
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test.ts +0 -302
- package/project-skills/tdd-guard/reporters/jest/src/JestReporter.ts +0 -201
- package/project-skills/tdd-guard/reporters/jest/src/index.ts +0 -4
- package/project-skills/tdd-guard/reporters/jest/src/types.ts +0 -42
- package/project-skills/tdd-guard/reporters/jest/tsconfig.json +0 -11
- package/project-skills/tdd-guard/reporters/phpunit/.php-cs-fixer.php +0 -28
- package/project-skills/tdd-guard/reporters/phpunit/README.md +0 -97
- package/project-skills/tdd-guard/reporters/phpunit/SYNC_README.md +0 -29
- package/project-skills/tdd-guard/reporters/phpunit/composer.json +0 -55
- package/project-skills/tdd-guard/reporters/phpunit/phpunit.xml.dist +0 -19
- package/project-skills/tdd-guard/reporters/phpunit/psalm.xml +0 -44
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/ErroredTestSubscriber.php +0 -28
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/FailedTestSubscriber.php +0 -28
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/IncompleteTestSubscriber.php +0 -28
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/PassedTestSubscriber.php +0 -27
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/SkippedTestSubscriber.php +0 -28
- package/project-skills/tdd-guard/reporters/phpunit/src/Event/TestRunnerFinishedSubscriber.php +0 -24
- package/project-skills/tdd-guard/reporters/phpunit/src/PathValidator.php +0 -88
- package/project-skills/tdd-guard/reporters/phpunit/src/Storage.php +0 -26
- package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardExtension.php +0 -33
- package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardListener.php +0 -158
- package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardSubscriber.php +0 -35
- package/project-skills/tdd-guard/reporters/phpunit/src/TestResultCollector.php +0 -105
- package/project-skills/tdd-guard/reporters/phpunit/tests/PathValidatorTest.php +0 -74
- package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionFailedTest.php +0 -241
- package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionTest.php +0 -84
- package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardStorageLocationTest.php +0 -71
- package/project-skills/tdd-guard/reporters/pytest/README.md +0 -77
- package/project-skills/tdd-guard/reporters/pytest/pyproject.toml +0 -43
- package/project-skills/tdd-guard/reporters/pytest/pytest.ini.example +0 -7
- package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/__init__.py +0 -1
- package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/pytest_reporter.py +0 -134
- package/project-skills/tdd-guard/reporters/pytest/tests/__init__.py +0 -1
- package/project-skills/tdd-guard/reporters/pytest/tests/conftest.py +0 -3
- package/project-skills/tdd-guard/reporters/pytest/tests/helpers.py +0 -293
- package/project-skills/tdd-guard/reporters/pytest/tests/test_config_option.py +0 -38
- package/project-skills/tdd-guard/reporters/pytest/tests/test_path_validation.py +0 -59
- package/project-skills/tdd-guard/reporters/pytest/tests/test_plugin_config.py +0 -32
- package/project-skills/tdd-guard/reporters/pytest/tests/test_project_root.py +0 -296
- package/project-skills/tdd-guard/reporters/pytest/tests/test_pytest_reporter.py +0 -137
- package/project-skills/tdd-guard/reporters/rspec/Gemfile +0 -3
- package/project-skills/tdd-guard/reporters/rust/Cargo.lock +0 -458
- package/project-skills/tdd-guard/reporters/rust/Cargo.toml +0 -33
- package/project-skills/tdd-guard/reporters/rust/Makefile.example +0 -95
- package/project-skills/tdd-guard/reporters/rust/README.md +0 -88
- package/project-skills/tdd-guard/reporters/rust/src/error_parser.rs +0 -309
- package/project-skills/tdd-guard/reporters/rust/src/main.rs +0 -464
- package/project-skills/tdd-guard/reporters/rust/src/parser.rs +0 -225
- package/project-skills/tdd-guard/reporters/rust/src/transformer.rs +0 -409
- package/project-skills/tdd-guard/reporters/storybook/README.md +0 -108
- package/project-skills/tdd-guard/reporters/storybook/package-lock.json +0 -9482
- package/project-skills/tdd-guard/reporters/storybook/package.json +0 -43
- package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test-data.ts +0 -22
- package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test.ts +0 -190
- package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.ts +0 -88
- package/project-skills/tdd-guard/reporters/storybook/src/index.ts +0 -12
- package/project-skills/tdd-guard/reporters/storybook/src/types.ts +0 -37
- package/project-skills/tdd-guard/reporters/storybook/tsconfig.json +0 -11
- package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/go.mod +0 -3
- package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/single_failing_test.go +0 -13
- package/project-skills/tdd-guard/reporters/test/artifacts/go/import/go.mod +0 -3
- package/project-skills/tdd-guard/reporters/test/artifacts/go/import/single_import_error_test.go +0 -17
- package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/go.mod +0 -3
- package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/single_passing_test.go +0 -13
- package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-failing.test.js +0 -5
- package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-import-error.test.js +0 -8
- package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-passing.test.js +0 -5
- package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleFailingTest.php +0 -11
- package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleImportErrorTest.php +0 -14
- package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SinglePassingTest.php +0 -11
- package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_failing.py +0 -3
- package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_import_error.py +0 -6
- package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_passing.py +0 -3
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.lock +0 -7
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.toml +0 -4
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/src/lib.rs +0 -14
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.lock +0 -7
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.toml +0 -4
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/src/lib.rs +0 -13
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.lock +0 -7
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.toml +0 -4
- package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/src/lib.rs +0 -14
- package/project-skills/tdd-guard/reporters/test/artifacts/storybook/Calculator.js +0 -4
- package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-failing.stories.js +0 -15
- package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-import-error.stories.js +0 -14
- package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-passing.stories.js +0 -15
- package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-failing.test.js +0 -7
- package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-import-error.test.js +0 -9
- package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-passing.test.js +0 -7
- package/project-skills/tdd-guard/reporters/test/factories/go.ts +0 -59
- package/project-skills/tdd-guard/reporters/test/factories/helpers.ts +0 -48
- package/project-skills/tdd-guard/reporters/test/factories/index.ts +0 -7
- package/project-skills/tdd-guard/reporters/test/factories/jest.ts +0 -51
- package/project-skills/tdd-guard/reporters/test/factories/phpunit.ts +0 -63
- package/project-skills/tdd-guard/reporters/test/factories/pytest.ts +0 -41
- package/project-skills/tdd-guard/reporters/test/factories/rust.ts +0 -158
- package/project-skills/tdd-guard/reporters/test/factories/storybook.ts +0 -198
- package/project-skills/tdd-guard/reporters/test/factories/vitest.ts +0 -51
- package/project-skills/tdd-guard/reporters/test/reporters.integration.test.ts +0 -735
- package/project-skills/tdd-guard/reporters/test/types.ts +0 -28
- package/project-skills/tdd-guard/reporters/vitest/README.md +0 -64
- package/project-skills/tdd-guard/reporters/vitest/package.json +0 -35
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test-data.ts +0 -85
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test.ts +0 -446
- package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.ts +0 -110
- package/project-skills/tdd-guard/reporters/vitest/src/index.ts +0 -4
- package/project-skills/tdd-guard/reporters/vitest/src/types.ts +0 -39
- package/project-skills/tdd-guard/reporters/vitest/tsconfig.json +0 -11
- package/project-skills/tdd-guard/src/cli/buildContext.test.ts +0 -200
- package/project-skills/tdd-guard/src/cli/buildContext.ts +0 -48
- package/project-skills/tdd-guard/src/cli/tdd-guard.test.ts +0 -159
- package/project-skills/tdd-guard/src/cli/tdd-guard.ts +0 -48
- package/project-skills/tdd-guard/src/config/Config.test.ts +0 -538
- package/project-skills/tdd-guard/src/config/Config.ts +0 -172
- package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.test.ts +0 -58
- package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.ts +0 -8
- package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.test.ts +0 -347
- package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.ts +0 -61
- package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.test.ts +0 -24
- package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.ts +0 -7
- package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.test.ts +0 -377
- package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.ts +0 -75
- package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.test.ts +0 -563
- package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.ts +0 -140
- package/project-skills/tdd-guard/src/contracts/types/ClientType.ts +0 -1
- package/project-skills/tdd-guard/src/contracts/types/ConfigOptions.ts +0 -12
- package/project-skills/tdd-guard/src/contracts/types/Context.ts +0 -16
- package/project-skills/tdd-guard/src/contracts/types/ModelClient.ts +0 -3
- package/project-skills/tdd-guard/src/contracts/types/ValidationResult.ts +0 -6
- package/project-skills/tdd-guard/src/guard/GuardManager.test.ts +0 -336
- package/project-skills/tdd-guard/src/guard/GuardManager.ts +0 -83
- package/project-skills/tdd-guard/src/hooks/HookEvents.test.ts +0 -107
- package/project-skills/tdd-guard/src/hooks/HookEvents.ts +0 -39
- package/project-skills/tdd-guard/src/hooks/fileTypeDetection.ts +0 -16
- package/project-skills/tdd-guard/src/hooks/postToolLint.test.ts +0 -327
- package/project-skills/tdd-guard/src/hooks/postToolLint.ts +0 -165
- package/project-skills/tdd-guard/src/hooks/processHookData.test.ts +0 -465
- package/project-skills/tdd-guard/src/hooks/processHookData.ts +0 -203
- package/project-skills/tdd-guard/src/hooks/sessionHandler.test.ts +0 -136
- package/project-skills/tdd-guard/src/hooks/sessionHandler.ts +0 -31
- package/project-skills/tdd-guard/src/hooks/userPromptHandler.test.ts +0 -131
- package/project-skills/tdd-guard/src/hooks/userPromptHandler.ts +0 -55
- package/project-skills/tdd-guard/src/index.ts +0 -19
- package/project-skills/tdd-guard/src/linters/Linter.ts +0 -5
- package/project-skills/tdd-guard/src/linters/eslint/ESLint.test.ts +0 -183
- package/project-skills/tdd-guard/src/linters/eslint/ESLint.ts +0 -82
- package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.test.ts +0 -170
- package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.ts +0 -148
- package/project-skills/tdd-guard/src/processors/index.ts +0 -1
- package/project-skills/tdd-guard/src/processors/lintProcessor.ts +0 -77
- package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.test.ts +0 -303
- package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.ts +0 -255
- package/project-skills/tdd-guard/src/providers/LinterProvider.test.ts +0 -43
- package/project-skills/tdd-guard/src/providers/LinterProvider.ts +0 -20
- package/project-skills/tdd-guard/src/providers/ModelClientProvider.test.ts +0 -68
- package/project-skills/tdd-guard/src/providers/ModelClientProvider.ts +0 -22
- package/project-skills/tdd-guard/src/storage/FileStorage.test.ts +0 -76
- package/project-skills/tdd-guard/src/storage/FileStorage.ts +0 -108
- package/project-skills/tdd-guard/src/storage/MemoryStorage.ts +0 -57
- package/project-skills/tdd-guard/src/storage/Storage.test.ts +0 -227
- package/project-skills/tdd-guard/src/storage/Storage.ts +0 -17
- package/project-skills/tdd-guard/src/validation/context/context.test.ts +0 -364
- package/project-skills/tdd-guard/src/validation/context/context.ts +0 -155
- package/project-skills/tdd-guard/src/validation/models/AnthropicApi.test.ts +0 -171
- package/project-skills/tdd-guard/src/validation/models/AnthropicApi.ts +0 -49
- package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.test.ts +0 -167
- package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.ts +0 -54
- package/project-skills/tdd-guard/src/validation/models/ClaudeCli.test.ts +0 -239
- package/project-skills/tdd-guard/src/validation/models/ClaudeCli.ts +0 -57
- package/project-skills/tdd-guard/src/validation/prompts/file-types.ts +0 -52
- package/project-skills/tdd-guard/src/validation/prompts/operations/edit.ts +0 -58
- package/project-skills/tdd-guard/src/validation/prompts/operations/multi-edit.ts +0 -54
- package/project-skills/tdd-guard/src/validation/prompts/operations/write.ts +0 -54
- package/project-skills/tdd-guard/src/validation/prompts/response.ts +0 -40
- package/project-skills/tdd-guard/src/validation/prompts/rules.ts +0 -51
- package/project-skills/tdd-guard/src/validation/prompts/system-prompt.ts +0 -10
- package/project-skills/tdd-guard/src/validation/prompts/tools/lint-results.ts +0 -15
- package/project-skills/tdd-guard/src/validation/prompts/tools/test-output.ts +0 -14
- package/project-skills/tdd-guard/src/validation/prompts/tools/todos.ts +0 -9
- package/project-skills/tdd-guard/src/validation/validator.test.ts +0 -268
- package/project-skills/tdd-guard/src/validation/validator.ts +0 -159
- package/project-skills/tdd-guard/test/artifacts/go/.golangci.yml +0 -6
- package/project-skills/tdd-guard/test/artifacts/go/with-issues/file-with-issues.go +0 -12
- package/project-skills/tdd-guard/test/artifacts/go/with-issues/go.mod +0 -3
- package/project-skills/tdd-guard/test/artifacts/go/without-issues/file-without-issues.go +0 -7
- package/project-skills/tdd-guard/test/artifacts/go/without-issues/go.mod +0 -3
- package/project-skills/tdd-guard/test/artifacts/javascript/eslint.config.js +0 -20
- package/project-skills/tdd-guard/test/artifacts/javascript/file-with-issues.js +0 -12
- package/project-skills/tdd-guard/test/artifacts/javascript/file-without-issues.js +0 -10
- package/project-skills/tdd-guard/test/hooks/fileTypeDetection.test.ts +0 -26
- package/project-skills/tdd-guard/test/hooks/processHookData.fileType.test.ts +0 -46
- package/project-skills/tdd-guard/test/hooks/processHookData.python.test.ts +0 -68
- package/project-skills/tdd-guard/test/integration/test-context.test.ts +0 -66
- package/project-skills/tdd-guard/test/integration/validator.core.test.ts +0 -96
- package/project-skills/tdd-guard/test/integration/validator.scenarios.test.ts +0 -497
- package/project-skills/tdd-guard/test/utils/assertions.ts +0 -29
- package/project-skills/tdd-guard/test/utils/factories/contextFactory.ts +0 -30
- package/project-skills/tdd-guard/test/utils/factories/editFactory.ts +0 -82
- package/project-skills/tdd-guard/test/utils/factories/helpers.test.ts +0 -46
- package/project-skills/tdd-guard/test/utils/factories/helpers.ts +0 -46
- package/project-skills/tdd-guard/test/utils/factories/lintFactory.ts +0 -352
- package/project-skills/tdd-guard/test/utils/factories/modelClientProviderFactory.ts +0 -21
- package/project-skills/tdd-guard/test/utils/factories/multiEditFactory.ts +0 -79
- package/project-skills/tdd-guard/test/utils/factories/operations.ts +0 -57
- package/project-skills/tdd-guard/test/utils/factories/reporterFactory.ts +0 -55
- package/project-skills/tdd-guard/test/utils/factories/scenarios/index.ts +0 -22
- package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/python.ts +0 -745
- package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/typescript.ts +0 -767
- package/project-skills/tdd-guard/test/utils/factories/scenarios/types.ts +0 -77
- package/project-skills/tdd-guard/test/utils/factories/scenarios/utils.ts +0 -15
- package/project-skills/tdd-guard/test/utils/factories/sessionStartFactory.ts +0 -36
- package/project-skills/tdd-guard/test/utils/factories/testDefaults.ts +0 -90
- package/project-skills/tdd-guard/test/utils/factories/testResultsFactory.ts +0 -234
- package/project-skills/tdd-guard/test/utils/factories/todoFactory.ts +0 -99
- package/project-skills/tdd-guard/test/utils/factories/userPromptSubmitFactory.ts +0 -39
- package/project-skills/tdd-guard/test/utils/factories/writeFactory.ts +0 -70
- package/project-skills/tdd-guard/test/utils/index.ts +0 -131
- package/project-skills/tdd-guard/tsconfig.build.json +0 -16
- package/project-skills/tdd-guard/tsconfig.eslint.json +0 -17
- package/project-skills/tdd-guard/tsconfig.json +0 -32
- package/project-skills/tdd-guard/tsconfig.node.json +0 -10
- package/project-skills/tdd-guard/vitest.config.ts +0 -85
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { Context } from '../contracts/types/Context'
|
|
2
|
-
import { ValidationResult } from '../contracts/types/ValidationResult'
|
|
3
|
-
import { IModelClient } from '../contracts/types/ModelClient'
|
|
4
|
-
import { describe, test, expect, vi, beforeEach } from 'vitest'
|
|
5
|
-
import { validator } from './validator'
|
|
6
|
-
import { generateDynamicContext } from './context/context'
|
|
7
|
-
import { testData } from '@testUtils'
|
|
8
|
-
|
|
9
|
-
vi.mock('./context/context', () => ({
|
|
10
|
-
generateDynamicContext: vi.fn(),
|
|
11
|
-
}))
|
|
12
|
-
|
|
13
|
-
describe('validator with mock model', () => {
|
|
14
|
-
const mockGenerateDynamicContext = vi.mocked(generateDynamicContext)
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.clearAllMocks()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe('simplified interface', () => {
|
|
21
|
-
test('should only pass prompt to model client without context', async () => {
|
|
22
|
-
const { result, mockModelClient, context } = await runValidator(
|
|
23
|
-
JSON.stringify({ decision: null, reason: 'ok' }),
|
|
24
|
-
{ prompt: 'complete prompt with all context included' }
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
expect(mockGenerateDynamicContext).toHaveBeenCalledWith(context)
|
|
28
|
-
// Should only pass the prompt, not the context
|
|
29
|
-
expect(mockModelClient.ask).toHaveBeenCalledWith(
|
|
30
|
-
'complete prompt with all context included'
|
|
31
|
-
)
|
|
32
|
-
expect(result).toEqual({
|
|
33
|
-
decision: undefined,
|
|
34
|
-
reason: 'ok',
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
describe('JSON extraction from model responses', () => {
|
|
40
|
-
const BLOCK_JSON = '{"decision": "block", "reason": "TDD violation"}'
|
|
41
|
-
const PASS_JSON = '{"decision": null, "reason": "ok"}'
|
|
42
|
-
|
|
43
|
-
const testCases = [
|
|
44
|
-
{
|
|
45
|
-
name: 'should extract JSON from markdown code blocks',
|
|
46
|
-
modelResponse: `\`\`\`json\n${BLOCK_JSON}\n\`\`\``,
|
|
47
|
-
expected: { decision: 'block', reason: 'TDD violation' },
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'should handle JSON with extra whitespace in code blocks',
|
|
51
|
-
modelResponse: `\`\`\`json \n\n ${PASS_JSON} \n\n\`\`\``,
|
|
52
|
-
expected: { decision: undefined, reason: 'ok' },
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'should parse raw JSON when no code block present',
|
|
56
|
-
modelResponse: PASS_JSON,
|
|
57
|
-
expected: { decision: undefined, reason: 'ok' },
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'should extract JSON from response with surrounding text',
|
|
61
|
-
modelResponse: `Here is my analysis:\n\`\`\`json\n${BLOCK_JSON}\n\`\`\`\nThat concludes the review.`,
|
|
62
|
-
expected: { decision: 'block', reason: 'TDD violation' },
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'should handle fence blocks without language specification',
|
|
66
|
-
modelResponse: `\`\`\`\n${PASS_JSON}\n\`\`\``,
|
|
67
|
-
expected: { decision: undefined, reason: 'ok' },
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'should ignore fence blocks with txt language',
|
|
71
|
-
modelResponse: `\`\`\`txt\nSome analysis text\n\`\`\`\n${PASS_JSON}`,
|
|
72
|
-
expected: { decision: undefined, reason: 'ok' },
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'should extract the last JSON fence block when multiple exist',
|
|
76
|
-
modelResponse: `First block:\n\`\`\`json\n${BLOCK_JSON}\n\`\`\`\nSecond block:\n\`\`\`json\n${PASS_JSON}\n\`\`\``,
|
|
77
|
-
expected: { decision: undefined, reason: 'ok' },
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'should convert null decision to undefined',
|
|
81
|
-
modelResponse: '{"decision": null, "reason": "No issues found"}',
|
|
82
|
-
expected: { decision: undefined, reason: 'No issues found' },
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'should extract JSON from response with detailed explanation before JSON',
|
|
86
|
-
modelResponse: `Analysis paragraph one explaining the issue.
|
|
87
|
-
|
|
88
|
-
Analysis paragraph two with more details.
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
"decision": "block",
|
|
92
|
-
"reason": "Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time"
|
|
93
|
-
}`,
|
|
94
|
-
expected: {
|
|
95
|
-
decision: 'block',
|
|
96
|
-
reason:
|
|
97
|
-
'Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'should extract JSON with line break before opening brace',
|
|
102
|
-
modelResponse: `Analysis text that gets cut off mid-sentence because it's too lo...
|
|
103
|
-
{
|
|
104
|
-
"decision": "block",
|
|
105
|
-
"reason": "Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time"
|
|
106
|
-
}`,
|
|
107
|
-
expected: {
|
|
108
|
-
decision: 'block',
|
|
109
|
-
reason:
|
|
110
|
-
'Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'should extract JSON when analyzing constructor error',
|
|
115
|
-
modelResponse: `Analysis with code blocks:
|
|
116
|
-
|
|
117
|
-
\`\`\`
|
|
118
|
-
Calculator is not a constructor
|
|
119
|
-
\`\`\`
|
|
120
|
-
|
|
121
|
-
More analysis after the error message.
|
|
122
|
-
|
|
123
|
-
{
|
|
124
|
-
"decision": "block",
|
|
125
|
-
"reason": "Over-implementation: Test fails with 'Calculator is not a constructor' but you're adding both the class AND the add method. Should only create empty class first, then run test again to get proper failure for the add method."
|
|
126
|
-
}`,
|
|
127
|
-
expected: {
|
|
128
|
-
decision: 'block',
|
|
129
|
-
reason:
|
|
130
|
-
"Over-implementation: Test fails with 'Calculator is not a constructor' but you're adding both the class AND the add method. Should only create empty class first, then run test again to get proper failure for the add method.",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: 'should extract JSON when analyzing not defined error with typescript code',
|
|
135
|
-
modelResponse: `Analysis with TypeScript code block:
|
|
136
|
-
|
|
137
|
-
\`\`\`typescript
|
|
138
|
-
export class Calculator {
|
|
139
|
-
add(a: number, b: number): number {
|
|
140
|
-
return a + b;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
\`\`\`
|
|
144
|
-
|
|
145
|
-
Analysis continues after the code block.
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
"decision": "block",
|
|
149
|
-
"reason": "Over-implementation violation. Test fails with 'Calculator is not defined' but implementation adds both class AND add method. Should only create empty class first, then run test to get next failure."
|
|
150
|
-
}`,
|
|
151
|
-
expected: {
|
|
152
|
-
decision: 'block',
|
|
153
|
-
reason:
|
|
154
|
-
"Over-implementation violation. Test fails with 'Calculator is not defined' but implementation adds both class AND add method. Should only create empty class first, then run test to get next failure.",
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: 'should extract JSON when model provides extensive analysis before decision',
|
|
159
|
-
modelResponse: `Extensive analysis with lists:
|
|
160
|
-
|
|
161
|
-
1. First point about the issue
|
|
162
|
-
2. Second point with more detail
|
|
163
|
-
3. Third point explaining the problem
|
|
164
|
-
|
|
165
|
-
This violates TDD principles as explained in the numbered list above.
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
"decision": "block",
|
|
169
|
-
"reason": "Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time"
|
|
170
|
-
}`,
|
|
171
|
-
expected: {
|
|
172
|
-
decision: 'block',
|
|
173
|
-
reason:
|
|
174
|
-
'Multiple test addition violation - adding 2 new tests simultaneously instead of following TDD discipline of one test at a time',
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
]
|
|
178
|
-
|
|
179
|
-
testCases.forEach(({ name, modelResponse, expected }) => {
|
|
180
|
-
test(name, async () => {
|
|
181
|
-
const { result } = await runValidator(modelResponse)
|
|
182
|
-
expect(result).toEqual(expected)
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
describe('prompt generation for different tools', () => {
|
|
188
|
-
test('should send correct prompt for Edit operation', async () => {
|
|
189
|
-
const { result, mockModelClient, context } = await runValidator(
|
|
190
|
-
JSON.stringify({ decision: null, reason: 'ok' }),
|
|
191
|
-
{ prompt: 'mocked prompt with Edit instructions' }
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
expect(mockGenerateDynamicContext).toHaveBeenCalledWith(context)
|
|
195
|
-
expect(mockModelClient.ask).toHaveBeenCalledWith(
|
|
196
|
-
'mocked prompt with Edit instructions'
|
|
197
|
-
)
|
|
198
|
-
expect(result).toEqual({
|
|
199
|
-
decision: undefined,
|
|
200
|
-
reason: 'ok',
|
|
201
|
-
})
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
describe('error handling', () => {
|
|
206
|
-
test('should block when model client throws error', async () => {
|
|
207
|
-
const { result } = await runValidator(
|
|
208
|
-
new Error('Command failed: claude not found')
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
expect(result.decision).toBe('block')
|
|
212
|
-
expect(result.reason).toContain('Error during validation')
|
|
213
|
-
expect(result.reason).toContain('Command failed: claude not found')
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
test('should block when model returns invalid JSON', async () => {
|
|
217
|
-
const { result } = await runValidator(
|
|
218
|
-
`\`\`\`json\ninvalid json content\n\`\`\``
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
expect(result.decision).toBe('block')
|
|
222
|
-
expect(result.reason).toContain('Error during validation')
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test('should provide special message when model returns no response', async () => {
|
|
226
|
-
const { result } = await runValidator('')
|
|
227
|
-
|
|
228
|
-
expect(result.decision).toBe('block')
|
|
229
|
-
expect(result.reason).not.toContain('Error during validation')
|
|
230
|
-
expect(result.reason).toBe('No response from model, try again')
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
// Test helper
|
|
235
|
-
async function runValidator(
|
|
236
|
-
modelResponse: string | Error,
|
|
237
|
-
options?: {
|
|
238
|
-
contextOverrides?: Partial<Context>
|
|
239
|
-
prompt?: string
|
|
240
|
-
}
|
|
241
|
-
): Promise<{
|
|
242
|
-
result: ValidationResult
|
|
243
|
-
mockModelClient: IModelClient
|
|
244
|
-
context: Context
|
|
245
|
-
}> {
|
|
246
|
-
const mockModelClient: IModelClient = {
|
|
247
|
-
ask:
|
|
248
|
-
modelResponse instanceof Error
|
|
249
|
-
? vi.fn().mockRejectedValue(modelResponse)
|
|
250
|
-
: vi.fn().mockResolvedValue(modelResponse),
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const context: Context = {
|
|
254
|
-
modifications: JSON.stringify(testData.editOperation()),
|
|
255
|
-
...options?.contextOverrides,
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
mockGenerateDynamicContext.mockReturnValue(options?.prompt ?? 'test prompt')
|
|
259
|
-
|
|
260
|
-
const result = await validator(context, mockModelClient)
|
|
261
|
-
|
|
262
|
-
return {
|
|
263
|
-
result,
|
|
264
|
-
mockModelClient,
|
|
265
|
-
context,
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
})
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { ValidationResult } from '../contracts/types/ValidationResult'
|
|
2
|
-
import { Context } from '../contracts/types/Context'
|
|
3
|
-
import { IModelClient } from '../contracts/types/ModelClient'
|
|
4
|
-
import { ClaudeCli } from './models/ClaudeCli'
|
|
5
|
-
import { generateDynamicContext } from './context/context'
|
|
6
|
-
|
|
7
|
-
interface ModelResponseJson {
|
|
8
|
-
decision: 'block' | 'approve' | null
|
|
9
|
-
reason: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function validator(
|
|
13
|
-
context: Context,
|
|
14
|
-
modelClient: IModelClient = new ClaudeCli()
|
|
15
|
-
): Promise<ValidationResult> {
|
|
16
|
-
try {
|
|
17
|
-
const prompt = generateDynamicContext(context)
|
|
18
|
-
const response = await modelClient.ask(prompt)
|
|
19
|
-
return parseModelResponse(response)
|
|
20
|
-
} catch (error) {
|
|
21
|
-
const errorMessage =
|
|
22
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
23
|
-
const reason =
|
|
24
|
-
errorMessage === 'No response from model'
|
|
25
|
-
? 'No response from model, try again'
|
|
26
|
-
: `Error during validation: ${errorMessage}`
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
decision: 'block',
|
|
30
|
-
reason,
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function parseModelResponse(response: string): ValidationResult {
|
|
36
|
-
const jsonString = extractJsonString(response)
|
|
37
|
-
const parsed = JSON.parse(jsonString)
|
|
38
|
-
return normalizeValidationResult(parsed)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function extractJsonString(response: string): string {
|
|
42
|
-
// Handle undefined/null responses
|
|
43
|
-
if (!response) {
|
|
44
|
-
throw new Error('No response from model')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const jsonFromCodeBlock = extractFromJsonCodeBlock(response)
|
|
48
|
-
if (jsonFromCodeBlock) {
|
|
49
|
-
return jsonFromCodeBlock
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const jsonFromGenericBlock = extractFromGenericCodeBlock(response)
|
|
53
|
-
if (jsonFromGenericBlock) {
|
|
54
|
-
return jsonFromGenericBlock
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Try to extract plain JSON from text
|
|
58
|
-
const plainJson = extractPlainJson(response)
|
|
59
|
-
if (plainJson) {
|
|
60
|
-
return plainJson
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return response
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function extractFromJsonCodeBlock(response: string): string | null {
|
|
67
|
-
// Find all json code blocks
|
|
68
|
-
const startPattern = '```json'
|
|
69
|
-
const endPattern = '```'
|
|
70
|
-
const blocks: string[] = []
|
|
71
|
-
|
|
72
|
-
let startIndex = 0
|
|
73
|
-
let blockStart = response.indexOf(startPattern, startIndex)
|
|
74
|
-
|
|
75
|
-
while (blockStart !== -1) {
|
|
76
|
-
const contentStart = blockStart + startPattern.length
|
|
77
|
-
const blockEnd = response.indexOf(endPattern, contentStart)
|
|
78
|
-
if (blockEnd === -1) break
|
|
79
|
-
|
|
80
|
-
const content = response.substring(contentStart, blockEnd).trim()
|
|
81
|
-
blocks.push(content)
|
|
82
|
-
startIndex = blockEnd + endPattern.length
|
|
83
|
-
blockStart = response.indexOf(startPattern, startIndex)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (blocks.length > 0) {
|
|
87
|
-
return blocks[blocks.length - 1]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return null
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function extractPlainJson(response: string): string | null {
|
|
94
|
-
// Simple regex to find JSON objects containing both "decision" and "reason" (in any order)
|
|
95
|
-
const pattern =
|
|
96
|
-
/\{[^{}]*"decision"[^{}]*"reason"[^{}]*}|\{[^{}]*"reason"[^{}]*"decision"[^{}]*}/g
|
|
97
|
-
const matches = response.match(pattern)
|
|
98
|
-
|
|
99
|
-
if (!matches) return null
|
|
100
|
-
|
|
101
|
-
// Return the last match (most likely the final decision)
|
|
102
|
-
const lastMatch = matches[matches.length - 1]
|
|
103
|
-
|
|
104
|
-
// Validate it's proper JSON
|
|
105
|
-
if (isValidJson(lastMatch)) {
|
|
106
|
-
return lastMatch
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return null
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function extractFromGenericCodeBlock(response: string): string | null {
|
|
113
|
-
const codeBlock = findCodeBlock(response)
|
|
114
|
-
if (!codeBlock) return null
|
|
115
|
-
|
|
116
|
-
const content = codeBlock.trim()
|
|
117
|
-
return isValidJson(content) ? content : null
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function findCodeBlock(response: string): string | null {
|
|
121
|
-
const startPattern = '```'
|
|
122
|
-
const blockStart = response.indexOf(startPattern)
|
|
123
|
-
if (blockStart === -1) return null
|
|
124
|
-
|
|
125
|
-
const contentStart = skipWhitespace(
|
|
126
|
-
response,
|
|
127
|
-
blockStart + startPattern.length
|
|
128
|
-
)
|
|
129
|
-
const blockEnd = response.indexOf(startPattern, contentStart)
|
|
130
|
-
if (blockEnd === -1) return null
|
|
131
|
-
|
|
132
|
-
return response.substring(contentStart, blockEnd)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function skipWhitespace(text: string, startIndex: number): number {
|
|
136
|
-
let index = startIndex
|
|
137
|
-
while (index < text.length && /\s/.test(text[index])) {
|
|
138
|
-
index++
|
|
139
|
-
}
|
|
140
|
-
return index
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function isValidJson(str: string): boolean {
|
|
144
|
-
try {
|
|
145
|
-
JSON.parse(str)
|
|
146
|
-
return true
|
|
147
|
-
} catch {
|
|
148
|
-
return false
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function normalizeValidationResult(
|
|
153
|
-
parsed: ModelResponseJson
|
|
154
|
-
): ValidationResult {
|
|
155
|
-
return {
|
|
156
|
-
decision: parsed.decision ?? undefined,
|
|
157
|
-
reason: parsed.reason,
|
|
158
|
-
}
|
|
159
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import "fmt"
|
|
4
|
-
|
|
5
|
-
func main() {
|
|
6
|
-
result := 42
|
|
7
|
-
result = 24 // ineffassign: ineffectual assignment
|
|
8
|
-
message := "Hello"
|
|
9
|
-
|
|
10
|
-
fmt.Println(result) // use result to avoid unused var error
|
|
11
|
-
fmt.Println(messag) // typecheck: undefined variable
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module.exports = [
|
|
2
|
-
{
|
|
3
|
-
files: ['**/*.js'],
|
|
4
|
-
rules: {
|
|
5
|
-
'no-unused-vars': 'error',
|
|
6
|
-
'no-var': 'error',
|
|
7
|
-
'semi': ['error', 'always'],
|
|
8
|
-
'quotes': ['error', 'single'],
|
|
9
|
-
'no-duplicate-string': 'off',
|
|
10
|
-
'max-params': ['error', 5]
|
|
11
|
-
},
|
|
12
|
-
languageOptions: {
|
|
13
|
-
ecmaVersion: 2020,
|
|
14
|
-
sourceType: 'module'
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
ignores: ['node_modules/**', 'dist/**', 'coverage/**']
|
|
19
|
-
}
|
|
20
|
-
];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { detectFileType } from '../../src/hooks/fileTypeDetection'
|
|
3
|
-
|
|
4
|
-
describe('detectFileType', () => {
|
|
5
|
-
it('should detect Python files', () => {
|
|
6
|
-
const hookData = {
|
|
7
|
-
tool_input: {
|
|
8
|
-
file_path: 'src/calculator.py'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const result = detectFileType(hookData)
|
|
13
|
-
expect(result).toBe('python')
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('should detect JavaScript files', () => {
|
|
17
|
-
const hookData = {
|
|
18
|
-
tool_input: {
|
|
19
|
-
file_path: 'src/calculator.js'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const result = detectFileType(hookData)
|
|
24
|
-
expect(result).toBe('javascript')
|
|
25
|
-
})
|
|
26
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { processHookData } from '../../src/hooks/processHookData'
|
|
3
|
-
import { MemoryStorage } from '../../src/storage/MemoryStorage'
|
|
4
|
-
|
|
5
|
-
describe('processHookData file type integration', () => {
|
|
6
|
-
it('should use pytest schema for Python files', async () => {
|
|
7
|
-
const storage = new MemoryStorage()
|
|
8
|
-
const pytestResults = {
|
|
9
|
-
testModules: [{
|
|
10
|
-
moduleId: 'test_example.py',
|
|
11
|
-
tests: [{
|
|
12
|
-
name: 'test_passing',
|
|
13
|
-
fullName: 'test_example.py::test_passing',
|
|
14
|
-
state: 'passed'
|
|
15
|
-
}]
|
|
16
|
-
}]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
await storage.saveTest(JSON.stringify(pytestResults))
|
|
20
|
-
|
|
21
|
-
const hookData = {
|
|
22
|
-
hook_event_name: 'PreToolUse',
|
|
23
|
-
tool_input: { file_path: 'test_example.py' }
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const result = await processHookData(JSON.stringify(hookData), { storage })
|
|
27
|
-
|
|
28
|
-
// Should not block when pytest results are valid for Python file
|
|
29
|
-
expect(result.decision).toBeUndefined()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should handle Python file when no test results exist', async () => {
|
|
33
|
-
const storage = new MemoryStorage()
|
|
34
|
-
// No test results stored
|
|
35
|
-
|
|
36
|
-
const hookData = {
|
|
37
|
-
hook_event_name: 'PreToolUse',
|
|
38
|
-
tool_input: { file_path: 'calculator.py' }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const result = await processHookData(JSON.stringify(hookData), { storage })
|
|
42
|
-
|
|
43
|
-
// Should not block when no test results (allows initial implementation)
|
|
44
|
-
expect(result.decision).toBeUndefined()
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { processHookData } from '../../src/hooks/processHookData'
|
|
3
|
-
import { MemoryStorage } from '../../src/storage/MemoryStorage'
|
|
4
|
-
|
|
5
|
-
describe('processHookData python support', () => {
|
|
6
|
-
it('should handle pytest test results format', async () => {
|
|
7
|
-
const storage = new MemoryStorage()
|
|
8
|
-
const pytestResults = {
|
|
9
|
-
testModules: [
|
|
10
|
-
{
|
|
11
|
-
moduleId: 'test_example.py',
|
|
12
|
-
tests: [
|
|
13
|
-
{
|
|
14
|
-
name: 'test_passing',
|
|
15
|
-
fullName: 'test_example.py::test_passing',
|
|
16
|
-
state: 'passed'
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
await storage.saveTest(JSON.stringify(pytestResults))
|
|
24
|
-
|
|
25
|
-
const result = await processHookData('{"hook_event_name": "PreToolUse"}', { storage })
|
|
26
|
-
|
|
27
|
-
expect(result.decision).toBeUndefined()
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('should handle pytest failing test results', async () => {
|
|
31
|
-
const storage = new MemoryStorage()
|
|
32
|
-
const pytestResults = {
|
|
33
|
-
testModules: [
|
|
34
|
-
{
|
|
35
|
-
moduleId: 'test_example.py',
|
|
36
|
-
tests: [
|
|
37
|
-
{
|
|
38
|
-
name: 'test_failing',
|
|
39
|
-
fullName: 'test_example.py::test_failing',
|
|
40
|
-
state: 'failed',
|
|
41
|
-
errors: [{ message: 'AssertionError: 1 != 2' }]
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await storage.saveTest(JSON.stringify(pytestResults))
|
|
49
|
-
|
|
50
|
-
const result = await processHookData('{"hook_event_name": "PreToolUse"}', { storage })
|
|
51
|
-
|
|
52
|
-
expect(result.decision).toBeUndefined()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should detect Python files from hook data', async () => {
|
|
56
|
-
const storage = new MemoryStorage()
|
|
57
|
-
const hookData = {
|
|
58
|
-
hook_event_name: 'PreToolUse',
|
|
59
|
-
tool_input: {
|
|
60
|
-
file_path: 'src/calculator.py'
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const result = await processHookData(JSON.stringify(hookData), { storage })
|
|
65
|
-
|
|
66
|
-
expect(result.decision).toBeUndefined()
|
|
67
|
-
})
|
|
68
|
-
})
|