xtrm-tools 2.3.0 → 2.4.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 +127 -111
- package/cli/dist/index.cjs +107 -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,136 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach } from 'vitest'
|
|
2
|
-
import { SessionHandler } from './sessionHandler'
|
|
3
|
-
import { MemoryStorage } from '../storage/MemoryStorage'
|
|
4
|
-
import { FileStorage } from '../storage/FileStorage'
|
|
5
|
-
import { testData } from '@testUtils'
|
|
6
|
-
import type { SessionStart } from '../contracts/schemas/toolSchemas'
|
|
7
|
-
|
|
8
|
-
describe('SessionHandler', () => {
|
|
9
|
-
let storage: MemoryStorage
|
|
10
|
-
let handler: SessionHandler
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
storage = new MemoryStorage()
|
|
14
|
-
handler = new SessionHandler(storage)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
describe('constructor', () => {
|
|
18
|
-
test('accepts a Storage instance', () => {
|
|
19
|
-
expect(handler['storage']).toBe(storage)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test('creates a default FileStorage if none provided', () => {
|
|
23
|
-
const customHandler = new SessionHandler()
|
|
24
|
-
|
|
25
|
-
expect(customHandler['storage']).toBeInstanceOf(FileStorage)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
describe('processSessionStart', () => {
|
|
30
|
-
describe('transient data clearing', () => {
|
|
31
|
-
beforeEach(async () => {
|
|
32
|
-
await populateAllStorageTypes()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe('when SessionStart event is received', () => {
|
|
36
|
-
beforeEach(async () => {
|
|
37
|
-
const sessionStartData = testData.sessionStart()
|
|
38
|
-
await handler.processSessionStart(JSON.stringify(sessionStartData))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('clears test data', async () => {
|
|
42
|
-
expect(await storage.getTest()).toBeNull()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('clears todo data', async () => {
|
|
46
|
-
expect(await storage.getTodo()).toBeNull()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('clears modifications data', async () => {
|
|
50
|
-
expect(await storage.getModifications()).toBeNull()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('clears lint data', async () => {
|
|
54
|
-
expect(await storage.getLint()).toBeNull()
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('preserves config data', async () => {
|
|
58
|
-
expect(await storage.getConfig()).toBe('config data')
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('when non-SessionStart event is received', () => {
|
|
63
|
-
beforeEach(async () => {
|
|
64
|
-
const nonSessionStartData = testData.editOperation()
|
|
65
|
-
await handler.processSessionStart(JSON.stringify(nonSessionStartData))
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('preserves test data', async () => {
|
|
69
|
-
expect(await storage.getTest()).toBe('test data')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('preserves todo data', async () => {
|
|
73
|
-
expect(await storage.getTodo()).toBe('todo data')
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
test('preserves modifications data', async () => {
|
|
77
|
-
expect(await storage.getModifications()).toBe('modifications data')
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('preserves lint data', async () => {
|
|
81
|
-
expect(await storage.getLint()).toBe('lint data')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('preserves config data', async () => {
|
|
85
|
-
expect(await storage.getConfig()).toBe('config data')
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
describe('custom instructions', () => {
|
|
91
|
-
describe('when no instructions exist', () => {
|
|
92
|
-
test.each(['startup', 'resume', 'clear'] as const)(
|
|
93
|
-
'creates default instructions on %s event',
|
|
94
|
-
async (source) => {
|
|
95
|
-
const instructions = await startAndGetInstructions(source)
|
|
96
|
-
|
|
97
|
-
expect(instructions).toContain('## TDD Fundamentals')
|
|
98
|
-
}
|
|
99
|
-
)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
describe('when instructions already exist', () => {
|
|
103
|
-
const customInstructions = '## My Custom TDD Rules'
|
|
104
|
-
|
|
105
|
-
beforeEach(async () => {
|
|
106
|
-
await storage.saveInstructions(customInstructions)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test.each(['startup', 'resume', 'clear'] as const)(
|
|
110
|
-
'preserves existing instructions on %s event',
|
|
111
|
-
async (source) => {
|
|
112
|
-
const instructions = await startAndGetInstructions(source)
|
|
113
|
-
|
|
114
|
-
expect(instructions).toBe(customInstructions)
|
|
115
|
-
expect(instructions).not.toContain('## Rules')
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
// Test helpers
|
|
123
|
-
async function populateAllStorageTypes() {
|
|
124
|
-
await storage.saveTest('test data')
|
|
125
|
-
await storage.saveTodo('todo data')
|
|
126
|
-
await storage.saveModifications('modifications data')
|
|
127
|
-
await storage.saveLint('lint data')
|
|
128
|
-
await storage.saveConfig('config data')
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async function startAndGetInstructions(source: SessionStart['source']): Promise<string | null> {
|
|
132
|
-
const sessionData = testData.sessionStart({ source })
|
|
133
|
-
await handler.processSessionStart(JSON.stringify(sessionData))
|
|
134
|
-
return storage.getInstructions()
|
|
135
|
-
}
|
|
136
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Storage } from '../storage/Storage'
|
|
2
|
-
import { FileStorage } from '../storage/FileStorage'
|
|
3
|
-
import { SessionStartSchema } from '../contracts/schemas/toolSchemas'
|
|
4
|
-
import { RULES } from '../validation/prompts/rules'
|
|
5
|
-
|
|
6
|
-
export class SessionHandler {
|
|
7
|
-
private readonly storage: Storage
|
|
8
|
-
|
|
9
|
-
constructor(storage?: Storage) {
|
|
10
|
-
this.storage = storage ?? new FileStorage()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async processSessionStart(hookData: string): Promise<void> {
|
|
14
|
-
const parsedData = JSON.parse(hookData)
|
|
15
|
-
const sessionStartResult = SessionStartSchema.safeParse(parsedData)
|
|
16
|
-
|
|
17
|
-
if (!sessionStartResult.success) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
await this.ensureInstructionsExist()
|
|
22
|
-
await this.storage.clearTransientData()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private async ensureInstructionsExist(): Promise<void> {
|
|
26
|
-
const existingInstructions = await this.storage.getInstructions()
|
|
27
|
-
if (!existingInstructions) {
|
|
28
|
-
await this.storage.saveInstructions(RULES)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach } from 'vitest'
|
|
2
|
-
import { UserPromptHandler } from './userPromptHandler'
|
|
3
|
-
import { GuardManager } from '../guard/GuardManager'
|
|
4
|
-
import { MemoryStorage } from '../storage/MemoryStorage'
|
|
5
|
-
import { testData } from '@testUtils'
|
|
6
|
-
|
|
7
|
-
describe('UserPromptHandler', () => {
|
|
8
|
-
let storage: MemoryStorage
|
|
9
|
-
let guardManager: GuardManager
|
|
10
|
-
let handler: UserPromptHandler
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
storage = new MemoryStorage()
|
|
14
|
-
guardManager = new GuardManager(storage)
|
|
15
|
-
handler = new UserPromptHandler(guardManager)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('constructor', () => {
|
|
19
|
-
test('accepts a GuardManager instance', () => {
|
|
20
|
-
expect(handler['guardManager']).toBe(guardManager)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('creates a default GuardManager if none provided', () => {
|
|
24
|
-
const customHandler = new UserPromptHandler()
|
|
25
|
-
|
|
26
|
-
expect(customHandler['guardManager']).toBeInstanceOf(GuardManager)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
describe('processUserCommand', () => {
|
|
31
|
-
test('only processes UserPromptSubmit events', async () => {
|
|
32
|
-
await guardManager.disable() // Ensure guard starts disabled
|
|
33
|
-
const hookData = {
|
|
34
|
-
...testData.userPromptSubmit({ prompt: 'tdd-guard on' }),
|
|
35
|
-
hook_event_name: 'PreToolUse' // Not UserPromptSubmit
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await handler.processUserCommand(JSON.stringify(hookData))
|
|
39
|
-
|
|
40
|
-
expect(await guardManager.isEnabled()).toBe(false) // Should not enable
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('enables guard when prompt is "tdd-guard on"', async () => {
|
|
44
|
-
await guardManager.disable() // Ensure guard starts disabled
|
|
45
|
-
const hookData = testData.userPromptSubmit({ prompt: 'tdd-guard on' })
|
|
46
|
-
|
|
47
|
-
await handler.processUserCommand(JSON.stringify(hookData))
|
|
48
|
-
|
|
49
|
-
expect(await guardManager.isEnabled()).toBe(true)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('disables guard when prompt is "tdd-guard off"', async () => {
|
|
53
|
-
await guardManager.enable() // Ensure guard starts enabled
|
|
54
|
-
const hookData = testData.userPromptSubmit({ prompt: 'tdd-guard off' })
|
|
55
|
-
|
|
56
|
-
await handler.processUserCommand(JSON.stringify(hookData))
|
|
57
|
-
|
|
58
|
-
expect(await guardManager.isEnabled()).toBe(false)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test('enables guard when prompt is "TDD-Guard ON" (mixed case)', async () => {
|
|
62
|
-
await guardManager.disable() // Ensure guard starts disabled
|
|
63
|
-
const hookData = testData.userPromptSubmit({ prompt: 'TDD-Guard ON' })
|
|
64
|
-
|
|
65
|
-
await handler.processUserCommand(JSON.stringify(hookData))
|
|
66
|
-
|
|
67
|
-
expect(await guardManager.isEnabled()).toBe(true)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test('disables guard when prompt is "Tdd-Guard Off" (mixed case)', async () => {
|
|
71
|
-
await guardManager.enable() // Ensure guard starts enabled
|
|
72
|
-
const hookData = testData.userPromptSubmit({ prompt: 'Tdd-Guard Off' })
|
|
73
|
-
|
|
74
|
-
await handler.processUserCommand(JSON.stringify(hookData))
|
|
75
|
-
|
|
76
|
-
expect(await guardManager.isEnabled()).toBe(false)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test('stops operation and prevents "tdd-guard on" command from reaching agent', async () => {
|
|
80
|
-
const hookData = testData.userPromptSubmit({ prompt: 'tdd-guard on' })
|
|
81
|
-
|
|
82
|
-
const result = await handler.processUserCommand(JSON.stringify(hookData))
|
|
83
|
-
|
|
84
|
-
expect(result).toEqual({
|
|
85
|
-
decision: undefined,
|
|
86
|
-
reason: 'TDD Guard enabled',
|
|
87
|
-
continue: false,
|
|
88
|
-
stopReason: 'TDD Guard enabled'
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test('stops operation and prevents "tdd-guard off" command from reaching agent', async () => {
|
|
93
|
-
const hookData = testData.userPromptSubmit({ prompt: 'tdd-guard off' })
|
|
94
|
-
|
|
95
|
-
const result = await handler.processUserCommand(JSON.stringify(hookData))
|
|
96
|
-
|
|
97
|
-
expect(result).toEqual({
|
|
98
|
-
decision: undefined,
|
|
99
|
-
reason: 'TDD Guard disabled',
|
|
100
|
-
continue: false,
|
|
101
|
-
stopReason: 'TDD Guard disabled'
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test('returns undefined for non-guard commands', async () => {
|
|
106
|
-
const hookData = testData.userPromptSubmit({ prompt: 'run tests please' })
|
|
107
|
-
|
|
108
|
-
const result = await handler.processUserCommand(JSON.stringify(hookData))
|
|
109
|
-
|
|
110
|
-
expect(result).toBeUndefined()
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
describe('getDisabledResult', () => {
|
|
115
|
-
test('returns defaultResult when guard is disabled', async () => {
|
|
116
|
-
await guardManager.disable()
|
|
117
|
-
|
|
118
|
-
const result = await handler.getDisabledResult()
|
|
119
|
-
|
|
120
|
-
expect(result).toEqual({ decision: undefined, reason: '' })
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
test('returns undefined when guard is enabled', async () => {
|
|
124
|
-
await guardManager.enable()
|
|
125
|
-
|
|
126
|
-
const result = await handler.getDisabledResult()
|
|
127
|
-
|
|
128
|
-
expect(result).toBeUndefined()
|
|
129
|
-
})
|
|
130
|
-
})
|
|
131
|
-
})
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { GuardManager } from '../guard/GuardManager'
|
|
2
|
-
import { ValidationResult } from '../contracts/types/ValidationResult'
|
|
3
|
-
|
|
4
|
-
export class UserPromptHandler {
|
|
5
|
-
private readonly guardManager: GuardManager
|
|
6
|
-
private readonly GUARD_COMMANDS = {
|
|
7
|
-
ON: 'tdd-guard on',
|
|
8
|
-
OFF: 'tdd-guard off'
|
|
9
|
-
} as const
|
|
10
|
-
|
|
11
|
-
constructor(guardManager?: GuardManager) {
|
|
12
|
-
this.guardManager = guardManager ?? new GuardManager()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async processUserCommand(hookData: string): Promise<ValidationResult | undefined> {
|
|
16
|
-
const data = JSON.parse(hookData)
|
|
17
|
-
|
|
18
|
-
// Only process UserPromptSubmit events
|
|
19
|
-
if (data.hook_event_name !== 'UserPromptSubmit') {
|
|
20
|
-
return undefined
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const command = data.prompt?.toLowerCase()
|
|
24
|
-
|
|
25
|
-
switch (command) {
|
|
26
|
-
case this.GUARD_COMMANDS.ON:
|
|
27
|
-
await this.guardManager.enable()
|
|
28
|
-
return this.createBlockResult('TDD Guard enabled')
|
|
29
|
-
|
|
30
|
-
case this.GUARD_COMMANDS.OFF:
|
|
31
|
-
await this.guardManager.disable()
|
|
32
|
-
return this.createBlockResult('TDD Guard disabled')
|
|
33
|
-
|
|
34
|
-
default:
|
|
35
|
-
return undefined
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private createBlockResult(message: string): ValidationResult {
|
|
40
|
-
return {
|
|
41
|
-
decision: undefined,
|
|
42
|
-
reason: message,
|
|
43
|
-
continue: false,
|
|
44
|
-
stopReason: message
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async getDisabledResult(): Promise<ValidationResult | undefined> {
|
|
49
|
-
const isEnabled = await this.guardManager.isEnabled()
|
|
50
|
-
if (!isEnabled) {
|
|
51
|
-
return { decision: undefined, reason: '' }
|
|
52
|
-
}
|
|
53
|
-
return undefined
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Storage exports
|
|
2
|
-
export { Storage } from './storage/Storage'
|
|
3
|
-
export { FileStorage } from './storage/FileStorage'
|
|
4
|
-
export { MemoryStorage } from './storage/MemoryStorage'
|
|
5
|
-
|
|
6
|
-
// Config exports
|
|
7
|
-
export { Config, DEFAULT_DATA_DIR } from './config/Config'
|
|
8
|
-
export type { ConfigOptions } from './contracts/types/ConfigOptions'
|
|
9
|
-
|
|
10
|
-
// Contract exports - Types
|
|
11
|
-
export type { Context } from './contracts/types/Context'
|
|
12
|
-
export type { IModelClient } from './contracts/types/ModelClient'
|
|
13
|
-
export type { ValidationResult } from './contracts/types/ValidationResult'
|
|
14
|
-
|
|
15
|
-
// Contract exports - Schemas
|
|
16
|
-
export * from './contracts/schemas/toolSchemas'
|
|
17
|
-
export * from './contracts/schemas/reporterSchemas'
|
|
18
|
-
export * from './contracts/schemas/pytestSchemas'
|
|
19
|
-
export * from './contracts/schemas/lintSchemas'
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
-
import { ESLint } from './ESLint'
|
|
3
|
-
import { join } from 'path'
|
|
4
|
-
import { LintResult } from '../../contracts/schemas/lintSchemas'
|
|
5
|
-
import { hasRules, issuesFromFile } from '../../../test/utils/assertions'
|
|
6
|
-
|
|
7
|
-
describe('ESLint', () => {
|
|
8
|
-
let linter: ESLint
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
linter = new ESLint()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('can be instantiated', () => {
|
|
15
|
-
expect(linter).toBeDefined()
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test('implements Linter interface with lint method', async () => {
|
|
19
|
-
const result = await linter.lint([])
|
|
20
|
-
|
|
21
|
-
expect(result).toBeDefined()
|
|
22
|
-
expect(result.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('returns the file paths that were passed in', async () => {
|
|
26
|
-
const filePaths = ['src/file1.ts', 'src/file2.ts']
|
|
27
|
-
const result = await linter.lint(filePaths)
|
|
28
|
-
|
|
29
|
-
expect(result.files).toEqual(filePaths)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
describe('with single file', () => {
|
|
33
|
-
let result: LintResult
|
|
34
|
-
|
|
35
|
-
beforeEach(async () => {
|
|
36
|
-
result = await linter.lint(['src/file.ts'])
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('returns empty issues array', () => {
|
|
40
|
-
expect(result.issues).toEqual([])
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('returns zero error count', () => {
|
|
44
|
-
expect(result.errorCount).toBe(0)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
test('returns zero warning count', () => {
|
|
48
|
-
expect(result.warningCount).toBe(0)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
describe('with files containing special characters', () => {
|
|
53
|
-
test.each([
|
|
54
|
-
['spaces', 'src/my file with spaces.ts'],
|
|
55
|
-
['quotes', 'src/file"with"quotes.ts'],
|
|
56
|
-
['semicolons', 'src/file;name.ts'],
|
|
57
|
-
['backticks', 'src/file`with`backticks.ts'],
|
|
58
|
-
['dollar signs', 'src/file$with$dollar.ts'],
|
|
59
|
-
['pipes', 'src/file|with|pipes.ts'],
|
|
60
|
-
['ampersands', 'src/file&with&ersands.ts'],
|
|
61
|
-
['parentheses', 'src/file(with)parentheses.ts'],
|
|
62
|
-
['command injection attempt', 'file.js"; cat /etc/passwd; echo "'],
|
|
63
|
-
['newlines', 'src/file\nwith\nnewlines.ts'],
|
|
64
|
-
['tabs', 'src/file\twith\ttabs.ts'],
|
|
65
|
-
])('handles file paths with %s correctly', async (_, filePath) => {
|
|
66
|
-
const result = await linter.lint([filePath])
|
|
67
|
-
|
|
68
|
-
expect(result.files).toEqual([filePath])
|
|
69
|
-
expect(result.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test.each([
|
|
73
|
-
['spaces', '/path with spaces/eslint.config.js'],
|
|
74
|
-
['quotes', '/path"with"quotes/eslint.config.js'],
|
|
75
|
-
['special chars', '/path;with&special|chars/eslint.config.js'],
|
|
76
|
-
])('handles config paths with %s correctly', async (_, configPath) => {
|
|
77
|
-
const result = await linter.lint(['src/file.ts'], configPath)
|
|
78
|
-
|
|
79
|
-
expect(result.files).toEqual(['src/file.ts'])
|
|
80
|
-
expect(result.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
describe('platform-specific shell option', () => {
|
|
85
|
-
let originalPlatform: PropertyDescriptor | undefined
|
|
86
|
-
|
|
87
|
-
beforeEach(() => {
|
|
88
|
-
originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform')
|
|
89
|
-
vi.resetModules()
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
afterEach(() => {
|
|
93
|
-
if (originalPlatform) {
|
|
94
|
-
Object.defineProperty(process, 'platform', originalPlatform)
|
|
95
|
-
}
|
|
96
|
-
vi.clearAllMocks()
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test('sets shell option to true on Windows', async () => {
|
|
100
|
-
// Windows needs shell: true to execute 'npx' (.cmd/.bat files)
|
|
101
|
-
await testShellOption('win32', true)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test('sets shell option to false on non-Windows platforms', async () => {
|
|
105
|
-
await testShellOption('darwin', false)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
describe('linter.lint with artifact files', () => {
|
|
110
|
-
const artifactsDir = join(process.cwd(), 'test', 'artifacts', 'javascript')
|
|
111
|
-
const configPath = join(artifactsDir, 'eslint.config.js')
|
|
112
|
-
|
|
113
|
-
test('detects issues in file with lint problems', async () => {
|
|
114
|
-
const filePath = join(artifactsDir, 'file-with-issues.js')
|
|
115
|
-
const result = await linter.lint([filePath], configPath)
|
|
116
|
-
|
|
117
|
-
expect(result.issues.length).toBeGreaterThan(0)
|
|
118
|
-
expect(result.errorCount).toBeGreaterThan(0)
|
|
119
|
-
|
|
120
|
-
// Check for specific rules
|
|
121
|
-
const expectedRules = ['no-unused-vars', 'no-var', 'semi', 'quotes']
|
|
122
|
-
const ruleResults = hasRules(result.issues, expectedRules)
|
|
123
|
-
|
|
124
|
-
ruleResults.forEach((ruleExists) => {
|
|
125
|
-
expect(ruleExists).toBe(true)
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
test('finds no issues in clean file', async () => {
|
|
130
|
-
const filePath = join(artifactsDir, 'file-without-issues.js')
|
|
131
|
-
const result = await linter.lint([filePath], configPath)
|
|
132
|
-
|
|
133
|
-
expect(result.issues.length).toBe(0)
|
|
134
|
-
expect(result.errorCount).toBe(0)
|
|
135
|
-
expect(result.warningCount).toBe(0)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test('processes multiple files correctly', async () => {
|
|
139
|
-
const files = [
|
|
140
|
-
join(artifactsDir, 'file-with-issues.js'),
|
|
141
|
-
join(artifactsDir, 'file-without-issues.js'),
|
|
142
|
-
]
|
|
143
|
-
const result = await linter.lint(files, configPath)
|
|
144
|
-
|
|
145
|
-
expect(result.files).toEqual(files)
|
|
146
|
-
expect(result.issues.length).toBeGreaterThan(0)
|
|
147
|
-
|
|
148
|
-
// Issues should only be from the file with issues
|
|
149
|
-
const cleanFileIssues = issuesFromFile(
|
|
150
|
-
result.issues,
|
|
151
|
-
'file-without-issues.js'
|
|
152
|
-
)
|
|
153
|
-
expect(cleanFileIssues.length).toBe(0)
|
|
154
|
-
})
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
// Test helper function
|
|
159
|
-
async function testShellOption(platform: string, expectedShell: boolean) {
|
|
160
|
-
// Set platform to test platform-specific behavior
|
|
161
|
-
Object.defineProperty(process, 'platform', { value: platform })
|
|
162
|
-
|
|
163
|
-
let capturedOptions: { shell?: boolean } | undefined
|
|
164
|
-
|
|
165
|
-
// Mock util.promisify to capture the options passed to execFile
|
|
166
|
-
vi.doMock('util', () => ({
|
|
167
|
-
promisify:
|
|
168
|
-
() =>
|
|
169
|
-
async (_cmd: string, _args: string[], options?: { shell?: boolean }) => {
|
|
170
|
-
capturedOptions = options
|
|
171
|
-
return { stdout: '[]', stderr: '' }
|
|
172
|
-
},
|
|
173
|
-
}))
|
|
174
|
-
|
|
175
|
-
// Re-import ESLint after mocking
|
|
176
|
-
const { ESLint: MockedESLint } = await import('./ESLint')
|
|
177
|
-
const mockedLinter = new MockedESLint()
|
|
178
|
-
|
|
179
|
-
await mockedLinter.lint(['src/file.ts'])
|
|
180
|
-
|
|
181
|
-
expect(capturedOptions).toBeDefined()
|
|
182
|
-
expect(capturedOptions!.shell).toBe(expectedShell)
|
|
183
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LintResult,
|
|
3
|
-
LintIssue,
|
|
4
|
-
ESLintResult,
|
|
5
|
-
ESLintMessage,
|
|
6
|
-
} from '../../contracts/schemas/lintSchemas'
|
|
7
|
-
import { execFile } from 'child_process'
|
|
8
|
-
import { promisify } from 'util'
|
|
9
|
-
import { Linter } from '../Linter'
|
|
10
|
-
|
|
11
|
-
const execFileAsync = promisify(execFile)
|
|
12
|
-
|
|
13
|
-
export class ESLint implements Linter {
|
|
14
|
-
async lint(filePaths: string[], configPath?: string): Promise<LintResult> {
|
|
15
|
-
const timestamp = new Date().toISOString()
|
|
16
|
-
const args = buildArgs(filePaths, configPath)
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
await execFileAsync('npx', args, { shell: process.platform === 'win32' })
|
|
20
|
-
return createLintData(timestamp, filePaths, [])
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (!isExecError(error)) throw error
|
|
23
|
-
|
|
24
|
-
const results = parseResults(error.stdout)
|
|
25
|
-
return createLintData(timestamp, filePaths, results)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Helper functions
|
|
31
|
-
const buildArgs = (files: string[], configPath?: string): string[] => {
|
|
32
|
-
const args = ['eslint', ...files, '--format', 'json']
|
|
33
|
-
if (configPath) {
|
|
34
|
-
args.push('-c', configPath)
|
|
35
|
-
}
|
|
36
|
-
return args
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const isExecError = (error: unknown): error is Error & { stdout?: string } =>
|
|
40
|
-
error !== null && typeof error === 'object' && 'stdout' in error
|
|
41
|
-
|
|
42
|
-
const parseResults = (stdout?: string): ESLintResult[] => {
|
|
43
|
-
try {
|
|
44
|
-
return JSON.parse(stdout ?? '[]')
|
|
45
|
-
} catch {
|
|
46
|
-
return []
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const createLintData = (
|
|
51
|
-
timestamp: string,
|
|
52
|
-
files: string[],
|
|
53
|
-
results: ESLintResult[]
|
|
54
|
-
): LintResult => {
|
|
55
|
-
const issues = extractIssues(results)
|
|
56
|
-
return {
|
|
57
|
-
timestamp,
|
|
58
|
-
files,
|
|
59
|
-
issues,
|
|
60
|
-
errorCount: countBySeverity(issues, 'error'),
|
|
61
|
-
warningCount: countBySeverity(issues, 'warning'),
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const extractIssues = (results: ESLintResult[]): LintIssue[] =>
|
|
66
|
-
results.flatMap((file) => (file.messages ?? []).map(toIssue(file.filePath)))
|
|
67
|
-
|
|
68
|
-
const toIssue =
|
|
69
|
-
(filePath: string) =>
|
|
70
|
-
(msg: ESLintMessage): LintIssue => ({
|
|
71
|
-
file: filePath,
|
|
72
|
-
line: msg.line ?? 0,
|
|
73
|
-
column: msg.column ?? 0,
|
|
74
|
-
severity: (msg.severity === 2 ? 'error' : 'warning') as 'error' | 'warning',
|
|
75
|
-
message: msg.message,
|
|
76
|
-
rule: msg.ruleId,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const countBySeverity = (
|
|
80
|
-
issues: LintIssue[],
|
|
81
|
-
severity: 'error' | 'warning'
|
|
82
|
-
): number => issues.filter((i) => i.severity === severity).length
|