simplify3x-connect 0.0.0-stage → 0.28.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/LICENSE +21 -0
- package/README.md +117 -3
- package/dist/acText.d.ts +12 -0
- package/dist/acText.d.ts.map +1 -0
- package/dist/acText.js +44 -0
- package/dist/acText.js.map +1 -0
- package/dist/adapters/factory.d.ts +25 -0
- package/dist/adapters/factory.d.ts.map +1 -0
- package/dist/adapters/factory.js +55 -0
- package/dist/adapters/factory.js.map +1 -0
- package/dist/adapters/http.d.ts +62 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/http.js +138 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/adapters/remoteMcp/adapter.d.ts +112 -0
- package/dist/adapters/remoteMcp/adapter.d.ts.map +1 -0
- package/dist/adapters/remoteMcp/adapter.js +259 -0
- package/dist/adapters/remoteMcp/adapter.js.map +1 -0
- package/dist/adapters/simplifyqa/adapter.d.ts +1390 -0
- package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/adapter.js +9126 -0
- package/dist/adapters/simplifyqa/adapter.js.map +1 -0
- package/dist/adapters/simplifyqa/apiFailureReason.d.ts +11 -0
- package/dist/adapters/simplifyqa/apiFailureReason.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/apiFailureReason.js +35 -0
- package/dist/adapters/simplifyqa/apiFailureReason.js.map +1 -0
- package/dist/adapters/simplifyqa/desktopConditions.d.ts +50 -0
- package/dist/adapters/simplifyqa/desktopConditions.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/desktopConditions.js +95 -0
- package/dist/adapters/simplifyqa/desktopConditions.js.map +1 -0
- package/dist/adapters/simplifyqa/executionFailures.d.ts +59 -0
- package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/executionFailures.js +641 -0
- package/dist/adapters/simplifyqa/executionFailures.js.map +1 -0
- package/dist/adapters/simplifyqa/failureCategory.d.ts +26 -0
- package/dist/adapters/simplifyqa/failureCategory.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureCategory.js +208 -0
- package/dist/adapters/simplifyqa/failureCategory.js.map +1 -0
- package/dist/adapters/simplifyqa/failureReport.d.ts +50 -0
- package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureReport.js +383 -0
- package/dist/adapters/simplifyqa/failureReport.js.map +1 -0
- package/dist/adapters/simplifyqa/failureTypes.d.ts +193 -0
- package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/failureTypes.js +8 -0
- package/dist/adapters/simplifyqa/failureTypes.js.map +1 -0
- package/dist/adapters/simplifyqa/flow.d.ts +58 -0
- package/dist/adapters/simplifyqa/flow.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/flow.js +335 -0
- package/dist/adapters/simplifyqa/flow.js.map +1 -0
- package/dist/adapters/simplifyqa/functionMatch.d.ts +53 -0
- package/dist/adapters/simplifyqa/functionMatch.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/functionMatch.js +110 -0
- package/dist/adapters/simplifyqa/functionMatch.js.map +1 -0
- package/dist/adapters/simplifyqa/heal/apply.d.ts +59 -0
- package/dist/adapters/simplifyqa/heal/apply.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/heal/apply.js +213 -0
- package/dist/adapters/simplifyqa/heal/apply.js.map +1 -0
- package/dist/adapters/simplifyqa/heal/diagnose.d.ts +24 -0
- package/dist/adapters/simplifyqa/heal/diagnose.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/heal/diagnose.js +211 -0
- package/dist/adapters/simplifyqa/heal/diagnose.js.map +1 -0
- package/dist/adapters/simplifyqa/heal/index.d.ts +37 -0
- package/dist/adapters/simplifyqa/heal/index.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/heal/index.js +83 -0
- package/dist/adapters/simplifyqa/heal/index.js.map +1 -0
- package/dist/adapters/simplifyqa/heal/plan.d.ts +67 -0
- package/dist/adapters/simplifyqa/heal/plan.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/heal/plan.js +338 -0
- package/dist/adapters/simplifyqa/heal/plan.js.map +1 -0
- package/dist/adapters/simplifyqa/heal/store.d.ts +10 -0
- package/dist/adapters/simplifyqa/heal/store.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/heal/store.js +40 -0
- package/dist/adapters/simplifyqa/heal/store.js.map +1 -0
- package/dist/adapters/simplifyqa/mapLimit.d.ts +3 -0
- package/dist/adapters/simplifyqa/mapLimit.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/mapLimit.js +14 -0
- package/dist/adapters/simplifyqa/mapLimit.js.map +1 -0
- package/dist/adapters/simplifyqa/mapper.d.ts +159 -0
- package/dist/adapters/simplifyqa/mapper.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/mapper.js +1767 -0
- package/dist/adapters/simplifyqa/mapper.js.map +1 -0
- package/dist/adapters/simplifyqa/planTree.d.ts +31 -0
- package/dist/adapters/simplifyqa/planTree.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/planTree.js +110 -0
- package/dist/adapters/simplifyqa/planTree.js.map +1 -0
- package/dist/adapters/simplifyqa/searchEngine.d.ts +254 -0
- package/dist/adapters/simplifyqa/searchEngine.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/searchEngine.js +1248 -0
- package/dist/adapters/simplifyqa/searchEngine.js.map +1 -0
- package/dist/adapters/simplifyqa/searchRegistry.d.ts +117 -0
- package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/searchRegistry.js +1664 -0
- package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -0
- package/dist/adapters/simplifyqa/searchResolve.d.ts +84 -0
- package/dist/adapters/simplifyqa/searchResolve.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/searchResolve.js +319 -0
- package/dist/adapters/simplifyqa/searchResolve.js.map +1 -0
- package/dist/adapters/simplifyqa/stepDiagnostics.d.ts +25 -0
- package/dist/adapters/simplifyqa/stepDiagnostics.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/stepDiagnostics.js +89 -0
- package/dist/adapters/simplifyqa/stepDiagnostics.js.map +1 -0
- package/dist/adapters/simplifyqa/stepRules.d.ts +91 -0
- package/dist/adapters/simplifyqa/stepRules.d.ts.map +1 -0
- package/dist/adapters/simplifyqa/stepRules.js +228 -0
- package/dist/adapters/simplifyqa/stepRules.js.map +1 -0
- package/dist/adapters/types.d.ts +514 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/walnut/actionTypes.d.ts +16 -0
- package/dist/adapters/walnut/actionTypes.d.ts.map +1 -0
- package/dist/adapters/walnut/actionTypes.js +178 -0
- package/dist/adapters/walnut/actionTypes.js.map +1 -0
- package/dist/adapters/walnut/adapter.d.ts +235 -0
- package/dist/adapters/walnut/adapter.d.ts.map +1 -0
- package/dist/adapters/walnut/adapter.js +1120 -0
- package/dist/adapters/walnut/adapter.js.map +1 -0
- package/dist/adapters/walnut/mapper.d.ts +55 -0
- package/dist/adapters/walnut/mapper.d.ts.map +1 -0
- package/dist/adapters/walnut/mapper.js +364 -0
- package/dist/adapters/walnut/mapper.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +38 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +109 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +272 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +105 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +255 -0
- package/dist/connection.js.map +1 -0
- package/dist/domain/heal.d.ts +163 -0
- package/dist/domain/heal.d.ts.map +1 -0
- package/dist/domain/heal.js +55 -0
- package/dist/domain/heal.js.map +1 -0
- package/dist/domain/types.d.ts +1328 -0
- package/dist/domain/types.d.ts.map +1 -0
- package/dist/domain/types.js +8 -0
- package/dist/domain/types.js.map +1 -0
- package/dist/domain/validate.d.ts +3 -0
- package/dist/domain/validate.d.ts.map +1 -0
- package/dist/domain/validate.js +67 -0
- package/dist/domain/validate.js.map +1 -0
- package/dist/drafts/apiPatch.d.ts +9 -0
- package/dist/drafts/apiPatch.d.ts.map +1 -0
- package/dist/drafts/apiPatch.js +27 -0
- package/dist/drafts/apiPatch.js.map +1 -0
- package/dist/drafts/bulk.d.ts +24 -0
- package/dist/drafts/bulk.d.ts.map +1 -0
- package/dist/drafts/bulk.js +44 -0
- package/dist/drafts/bulk.js.map +1 -0
- package/dist/drafts/duplicate.d.ts +12 -0
- package/dist/drafts/duplicate.d.ts.map +1 -0
- package/dist/drafts/duplicate.js +59 -0
- package/dist/drafts/duplicate.js.map +1 -0
- package/dist/drafts/store.d.ts +91 -0
- package/dist/drafts/store.d.ts.map +1 -0
- package/dist/drafts/store.js +244 -0
- package/dist/drafts/store.js.map +1 -0
- package/dist/gateway.d.ts +37 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +71 -0
- package/dist/gateway.js.map +1 -0
- package/dist/httpMain.d.ts +3 -0
- package/dist/httpMain.d.ts.map +1 -0
- package/dist/httpMain.js +20 -0
- package/dist/httpMain.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/initAgents.d.ts +2 -0
- package/dist/initAgents.d.ts.map +1 -0
- package/dist/initAgents.js +508 -0
- package/dist/initAgents.js.map +1 -0
- package/dist/log.d.ts +17 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +49 -0
- package/dist/log.js.map +1 -0
- package/dist/mcpResult.d.ts +39 -0
- package/dist/mcpResult.d.ts.map +1 -0
- package/dist/mcpResult.js +19 -0
- package/dist/mcpResult.js.map +1 -0
- package/dist/mount.d.ts +33 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +213 -0
- package/dist/mount.js.map +1 -0
- package/dist/paramTokens.d.ts +18 -0
- package/dist/paramTokens.d.ts.map +1 -0
- package/dist/paramTokens.js +50 -0
- package/dist/paramTokens.js.map +1 -0
- package/dist/projectStore.d.ts +5 -0
- package/dist/projectStore.d.ts.map +1 -0
- package/dist/projectStore.js +60 -0
- package/dist/projectStore.js.map +1 -0
- package/dist/requestConnection.d.ts +22 -0
- package/dist/requestConnection.d.ts.map +1 -0
- package/dist/requestConnection.js +50 -0
- package/dist/requestConnection.js.map +1 -0
- package/dist/serve.d.ts +10 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +37 -0
- package/dist/serve.js.map +1 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +370 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/actionCatalog.d.ts +24 -0
- package/dist/tools/actionCatalog.d.ts.map +1 -0
- package/dist/tools/actionCatalog.js +56 -0
- package/dist/tools/actionCatalog.js.map +1 -0
- package/dist/tools/attachment.tools.d.ts +15 -0
- package/dist/tools/attachment.tools.d.ts.map +1 -0
- package/dist/tools/attachment.tools.js +104 -0
- package/dist/tools/attachment.tools.js.map +1 -0
- package/dist/tools/backlog.tools.d.ts +13 -0
- package/dist/tools/backlog.tools.d.ts.map +1 -0
- package/dist/tools/backlog.tools.js +690 -0
- package/dist/tools/backlog.tools.js.map +1 -0
- package/dist/tools/connection.tools.d.ts +16 -0
- package/dist/tools/connection.tools.d.ts.map +1 -0
- package/dist/tools/connection.tools.js +120 -0
- package/dist/tools/connection.tools.js.map +1 -0
- package/dist/tools/defects.tools.d.ts +7 -0
- package/dist/tools/defects.tools.d.ts.map +1 -0
- package/dist/tools/defects.tools.js +108 -0
- package/dist/tools/defects.tools.js.map +1 -0
- package/dist/tools/discovery.tools.d.ts +23 -0
- package/dist/tools/discovery.tools.d.ts.map +1 -0
- package/dist/tools/discovery.tools.js +1746 -0
- package/dist/tools/discovery.tools.js.map +1 -0
- package/dist/tools/executionPlan.tools.d.ts +14 -0
- package/dist/tools/executionPlan.tools.d.ts.map +1 -0
- package/dist/tools/executionPlan.tools.js +184 -0
- package/dist/tools/executionPlan.tools.js.map +1 -0
- package/dist/tools/failure.tools.d.ts +14 -0
- package/dist/tools/failure.tools.d.ts.map +1 -0
- package/dist/tools/failure.tools.js +65 -0
- package/dist/tools/failure.tools.js.map +1 -0
- package/dist/tools/formulas.tools.d.ts +7 -0
- package/dist/tools/formulas.tools.d.ts.map +1 -0
- package/dist/tools/formulas.tools.js +84 -0
- package/dist/tools/formulas.tools.js.map +1 -0
- package/dist/tools/functionReuse.d.ts +77 -0
- package/dist/tools/functionReuse.d.ts.map +1 -0
- package/dist/tools/functionReuse.js +384 -0
- package/dist/tools/functionReuse.js.map +1 -0
- package/dist/tools/gapAnalysis.tools.d.ts +31 -0
- package/dist/tools/gapAnalysis.tools.d.ts.map +1 -0
- package/dist/tools/gapAnalysis.tools.js +287 -0
- package/dist/tools/gapAnalysis.tools.js.map +1 -0
- package/dist/tools/heal.tools.d.ts +20 -0
- package/dist/tools/heal.tools.d.ts.map +1 -0
- package/dist/tools/heal.tools.js +268 -0
- package/dist/tools/heal.tools.js.map +1 -0
- package/dist/tools/impactAnalysis.tools.d.ts +17 -0
- package/dist/tools/impactAnalysis.tools.d.ts.map +1 -0
- package/dist/tools/impactAnalysis.tools.js +352 -0
- package/dist/tools/impactAnalysis.tools.js.map +1 -0
- package/dist/tools/markdown.d.ts +13 -0
- package/dist/tools/markdown.d.ts.map +1 -0
- package/dist/tools/markdown.js +145 -0
- package/dist/tools/markdown.js.map +1 -0
- package/dist/tools/objects.tools.d.ts +7 -0
- package/dist/tools/objects.tools.d.ts.map +1 -0
- package/dist/tools/objects.tools.js +458 -0
- package/dist/tools/objects.tools.js.map +1 -0
- package/dist/tools/pipeline.tools.d.ts +11 -0
- package/dist/tools/pipeline.tools.d.ts.map +1 -0
- package/dist/tools/pipeline.tools.js +100 -0
- package/dist/tools/pipeline.tools.js.map +1 -0
- package/dist/tools/preference.tools.d.ts +15 -0
- package/dist/tools/preference.tools.d.ts.map +1 -0
- package/dist/tools/preference.tools.js +114 -0
- package/dist/tools/preference.tools.js.map +1 -0
- package/dist/tools/privileges.tools.d.ts +65 -0
- package/dist/tools/privileges.tools.d.ts.map +1 -0
- package/dist/tools/privileges.tools.js +186 -0
- package/dist/tools/privileges.tools.js.map +1 -0
- package/dist/tools/project.tools.d.ts +13 -0
- package/dist/tools/project.tools.d.ts.map +1 -0
- package/dist/tools/project.tools.js +199 -0
- package/dist/tools/project.tools.js.map +1 -0
- package/dist/tools/query.tools.d.ts +23 -0
- package/dist/tools/query.tools.d.ts.map +1 -0
- package/dist/tools/query.tools.js +368 -0
- package/dist/tools/query.tools.js.map +1 -0
- package/dist/tools/recording.tools.d.ts +58 -0
- package/dist/tools/recording.tools.d.ts.map +1 -0
- package/dist/tools/recording.tools.js +1050 -0
- package/dist/tools/recording.tools.js.map +1 -0
- package/dist/tools/recordingNames.d.ts +3 -0
- package/dist/tools/recordingNames.d.ts.map +1 -0
- package/dist/tools/recordingNames.js +16 -0
- package/dist/tools/recordingNames.js.map +1 -0
- package/dist/tools/report.tools.d.ts +12 -0
- package/dist/tools/report.tools.d.ts.map +1 -0
- package/dist/tools/report.tools.js +104 -0
- package/dist/tools/report.tools.js.map +1 -0
- package/dist/tools/run.tools.d.ts +25 -0
- package/dist/tools/run.tools.d.ts.map +1 -0
- package/dist/tools/run.tools.js +1295 -0
- package/dist/tools/run.tools.js.map +1 -0
- package/dist/tools/schemas.d.ts +860 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +220 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/storySync.tools.d.ts +167 -0
- package/dist/tools/storySync.tools.d.ts.map +1 -0
- package/dist/tools/storySync.tools.js +678 -0
- package/dist/tools/storySync.tools.js.map +1 -0
- package/dist/tools/suiteManage.tools.d.ts +14 -0
- package/dist/tools/suiteManage.tools.d.ts.map +1 -0
- package/dist/tools/suiteManage.tools.js +112 -0
- package/dist/tools/suiteManage.tools.js.map +1 -0
- package/dist/tools/tasks.tools.d.ts +7 -0
- package/dist/tools/tasks.tools.d.ts.map +1 -0
- package/dist/tools/tasks.tools.js +101 -0
- package/dist/tools/tasks.tools.js.map +1 -0
- package/dist/tools/tcEditPublisher.d.ts +29 -0
- package/dist/tools/tcEditPublisher.d.ts.map +1 -0
- package/dist/tools/tcEditPublisher.js +61 -0
- package/dist/tools/tcEditPublisher.js.map +1 -0
- package/dist/tools/testCaseLint.d.ts +5 -0
- package/dist/tools/testCaseLint.d.ts.map +1 -0
- package/dist/tools/testCaseLint.js +112 -0
- package/dist/tools/testCaseLint.js.map +1 -0
- package/dist/tools/testPlan.tools.d.ts +12 -0
- package/dist/tools/testPlan.tools.d.ts.map +1 -0
- package/dist/tools/testPlan.tools.js +104 -0
- package/dist/tools/testPlan.tools.js.map +1 -0
- package/dist/tools/testcase.tools.d.ts +86 -0
- package/dist/tools/testcase.tools.d.ts.map +1 -0
- package/dist/tools/testcase.tools.js +1591 -0
- package/dist/tools/testcase.tools.js.map +1 -0
- package/dist/tools/testdata.tools.d.ts +7 -0
- package/dist/tools/testdata.tools.d.ts.map +1 -0
- package/dist/tools/testdata.tools.js +636 -0
- package/dist/tools/testdata.tools.js.map +1 -0
- package/dist/tools/xlsx.d.ts +8 -0
- package/dist/tools/xlsx.d.ts.map +1 -0
- package/dist/tools/xlsx.js +113 -0
- package/dist/tools/xlsx.js.map +1 -0
- package/dist/vendor/actionSignatures.d.ts +117 -0
- package/dist/vendor/actionSignatures.d.ts.map +1 -0
- package/dist/vendor/actionSignatures.js +420 -0
- package/dist/vendor/actionSignatures.js.map +1 -0
- package/dist/vendor/logger.d.ts +43 -0
- package/dist/vendor/logger.d.ts.map +1 -0
- package/dist/vendor/logger.js +184 -0
- package/dist/vendor/logger.js.map +1 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/dist/versionName.d.ts +21 -0
- package/dist/versionName.d.ts.map +1 -0
- package/dist/versionName.js +48 -0
- package/dist/versionName.js.map +1 -0
- package/package.json +62 -4
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ok, err } from '../mcpResult.js';
|
|
3
|
+
import { latestVersionId, nextVersionName } from '../versionName.js';
|
|
4
|
+
import { splitAcceptanceCriteria } from '../acText.js';
|
|
5
|
+
const NOT_CONNECTED = 'Not connected to a product. Use qa_connect first — story-sync needs a live backend to read ' +
|
|
6
|
+
'the story and its linked test cases.';
|
|
7
|
+
// Jaccard thresholds by sensitivity. T_HIGH = "clearly the same AC as this step".
|
|
8
|
+
// T_LOW = "possible match, likely reworded". Below T_LOW = no match (AC is new / step is stale).
|
|
9
|
+
const THRESHOLDS = {
|
|
10
|
+
strict: { high: 0.5, low: 0.15 },
|
|
11
|
+
normal: { high: 0.6, low: 0.25 },
|
|
12
|
+
loose: { high: 0.7, low: 0.35 },
|
|
13
|
+
};
|
|
14
|
+
// Small stopword set — enough to stop "the/and/a" from dominating token overlap on short ACs.
|
|
15
|
+
// ponytail: hand-picked list, swap for a stemmer if false-positive rate warrants it.
|
|
16
|
+
const STOP = new Set([
|
|
17
|
+
'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'onto', 'when', 'then',
|
|
18
|
+
'should', 'shall', 'must', 'will', 'can', 'may', 'are', 'was', 'were', 'been', 'being',
|
|
19
|
+
'has', 'have', 'had', 'not', 'but', 'user', 'system', 'given', 'verify', 'ensure',
|
|
20
|
+
]);
|
|
21
|
+
function tokenize(s) {
|
|
22
|
+
if (!s)
|
|
23
|
+
return new Set();
|
|
24
|
+
const out = new Set();
|
|
25
|
+
for (const raw of s.toLowerCase().split(/[^a-z0-9]+/)) {
|
|
26
|
+
if (raw.length < 3 || STOP.has(raw))
|
|
27
|
+
continue;
|
|
28
|
+
// Crude plural folding ("accounts" → "account", "loads" → "load"): without it an AC that says
|
|
29
|
+
// "account summary" never matches a step that says "Accounts page", which is most of the misses.
|
|
30
|
+
out.add(raw.length > 3 && raw.endsWith('s') && !raw.endsWith('ss') ? raw.slice(0, -1) : raw);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** Union of the tokens of many strings/steps — used to ask "is this concept ANYWHERE in the flow?" */
|
|
35
|
+
function unionTokens(sets) {
|
|
36
|
+
const out = new Set();
|
|
37
|
+
for (const s of sets)
|
|
38
|
+
for (const t of s)
|
|
39
|
+
out.add(t);
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/** Fraction of `part` that appears in `whole` (containment, not Jaccard). */
|
|
43
|
+
function containment(part, whole) {
|
|
44
|
+
if (part.size === 0)
|
|
45
|
+
return 0;
|
|
46
|
+
let hit = 0;
|
|
47
|
+
for (const t of part)
|
|
48
|
+
if (whole.has(t))
|
|
49
|
+
hit++;
|
|
50
|
+
return hit / part.size;
|
|
51
|
+
}
|
|
52
|
+
function jaccard(a, b) {
|
|
53
|
+
if (a.size === 0 && b.size === 0)
|
|
54
|
+
return 0;
|
|
55
|
+
let inter = 0;
|
|
56
|
+
for (const t of a)
|
|
57
|
+
if (b.has(t))
|
|
58
|
+
inter++;
|
|
59
|
+
const union = a.size + b.size - inter;
|
|
60
|
+
return union === 0 ? 0 : inter / union;
|
|
61
|
+
}
|
|
62
|
+
/** A token set plus the common inflections of each token ("update" → "updated", "display" →
|
|
63
|
+
* "displayed"). Used to recognise a step word as a FORM of an AC word: without it, "the updated
|
|
64
|
+
* picture" in a removed-scenario step looked distinctive just because the remaining AC says
|
|
65
|
+
* "update", and two unrelated steps could be chained into one scenario. */
|
|
66
|
+
function withInflections(tokens) {
|
|
67
|
+
const out = new Set(tokens);
|
|
68
|
+
for (const t of tokens) {
|
|
69
|
+
out.add(`${t}s`);
|
|
70
|
+
out.add(`${t}es`);
|
|
71
|
+
out.add(`${t}d`);
|
|
72
|
+
out.add(`${t}ed`);
|
|
73
|
+
out.add(`${t}ing`);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
function stepTokens(step) {
|
|
78
|
+
const a = tokenize(step.description);
|
|
79
|
+
const b = tokenize(step.expectedResult);
|
|
80
|
+
for (const t of b)
|
|
81
|
+
a.add(t);
|
|
82
|
+
return a;
|
|
83
|
+
}
|
|
84
|
+
// A step "looks AC-derived" if it has an expectedResult or a non-trivial description —
|
|
85
|
+
// used to decide whether an unmatched step is genuinely stale (worth proposing remove_step)
|
|
86
|
+
// vs. a mundane setup step we should leave alone.
|
|
87
|
+
function round2(n) {
|
|
88
|
+
return Math.round(Math.max(0, Math.min(1, n)) * 100) / 100;
|
|
89
|
+
}
|
|
90
|
+
function looksAcDerived(step) {
|
|
91
|
+
return !!step.expectedResult && step.expectedResult.trim().length > 0;
|
|
92
|
+
}
|
|
93
|
+
export function computeDrift(story, tc, sensitivity = 'normal') {
|
|
94
|
+
const { high, low } = THRESHOLDS[sensitivity];
|
|
95
|
+
const signals = [];
|
|
96
|
+
// Ops are collected per KIND and concatenated in an APPLY-SAFE order at the end (see below):
|
|
97
|
+
// updates (indices stable) → removes DESC (no shift can invalidate a later index) → adds (append).
|
|
98
|
+
const updates = [];
|
|
99
|
+
const removes = [];
|
|
100
|
+
const adds = [];
|
|
101
|
+
const unresolved = [];
|
|
102
|
+
// Split HTML/newline blobs HERE too: the story may arrive from a provider that stores the ACs as one
|
|
103
|
+
// blob, and comparing that blob would flag the whole story as new on every TC (US-897 / US-941).
|
|
104
|
+
const acList = splitAcceptanceCriteria(story.acceptanceCriteria);
|
|
105
|
+
// A story with NO criteria cannot be "out of date": never propose removing/obsoleting against an
|
|
106
|
+
// empty AC list.
|
|
107
|
+
if (acList.length === 0) {
|
|
108
|
+
return { testCaseId: tc.id ?? '', title: tc.title, driftScore: 'none', signals: [], proposedOps: [], unresolved: [] };
|
|
109
|
+
}
|
|
110
|
+
const acTokens = acList.map(tokenize);
|
|
111
|
+
const stepTok = tc.steps.map((s) => ({ n: s.n, tokens: stepTokens(s), step: s }));
|
|
112
|
+
// ACs are long Given/When/Then prose and steps are short action lines, so a per-step Jaccard is
|
|
113
|
+
// almost always low even when the flow DOES cover the AC. Ask two different questions instead:
|
|
114
|
+
// • acCovered: do the AC's concepts appear ANYWHERE in the flow? (containment vs the step union)
|
|
115
|
+
// • bestStep : which single step is the closest match? (drives "reworded" vs "new")
|
|
116
|
+
const stepUnion = unionTokens(stepTok.map((s) => s.tokens));
|
|
117
|
+
const acUnion = unionTokens(acTokens);
|
|
118
|
+
// Track which steps got matched by any AC (to detect stale steps).
|
|
119
|
+
const stepMatched = new Set();
|
|
120
|
+
// How many CURRENT ACs this TC still represents. Zero → the whole TC is orphaned (obsolete it).
|
|
121
|
+
let matchedAcCount = 0;
|
|
122
|
+
let appendAt = tc.steps.length + 1; // next free slot for an added AC step (append order)
|
|
123
|
+
acList.forEach((acText, i) => {
|
|
124
|
+
const acTok = acTokens[i];
|
|
125
|
+
let best = { score: 0, n: -1, stepDesc: '' };
|
|
126
|
+
for (const st of stepTok) {
|
|
127
|
+
const score = jaccard(acTok, st.tokens);
|
|
128
|
+
if (score > best.score)
|
|
129
|
+
best = { score, n: st.n, stepDesc: st.step.description };
|
|
130
|
+
}
|
|
131
|
+
// "Represented" needs EITHER a single step matching at >= low, OR the AC's vocabulary being almost
|
|
132
|
+
// entirely present across the whole flow (a long criterion split over several steps). A merely
|
|
133
|
+
// half-overlapping flow is NOT representation — that is how a genuinely new AC used to be swallowed
|
|
134
|
+
// by the union check (its words like "enter/password/click/sign" exist in any login flow).
|
|
135
|
+
const covered = containment(acTok, stepUnion) >= 0.75;
|
|
136
|
+
if (best.score >= high) {
|
|
137
|
+
stepMatched.add(best.n);
|
|
138
|
+
matchedAcCount++;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (covered && best.score < low) {
|
|
142
|
+
stepMatched.add(best.n);
|
|
143
|
+
matchedAcCount++;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (best.score >= low && best.n > 0) {
|
|
147
|
+
stepMatched.add(best.n);
|
|
148
|
+
matchedAcCount++;
|
|
149
|
+
signals.push({ kind: 'ac_reworded', from: best.stepDesc, to: acText, matchingSteps: [best.n] });
|
|
150
|
+
// HINT ONLY — never overwrite the step's wording with the AC prose. A reworded AC usually means
|
|
151
|
+
// "the step is still right, the AC text moved"; auto-replacing the description (and especially
|
|
152
|
+
// the expectedResult) destroys a real, verified expectation.
|
|
153
|
+
updates.push({
|
|
154
|
+
op: 'update_step',
|
|
155
|
+
n: best.n,
|
|
156
|
+
patch: {},
|
|
157
|
+
hint: `AC drift: this step matches the reworded criterion at ${Math.round(best.score * 100)}% — review its wording/expectation against the current AC if needed.`,
|
|
158
|
+
confidence: round2(best.score),
|
|
159
|
+
rationale: `step ${best.n} overlaps the AC at ${Math.round(best.score * 100)}% (reworded)`,
|
|
160
|
+
bucket: 'review',
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// No match: AC is new to this TC. Insert in AC order — a constant index would reverse them.
|
|
165
|
+
const insertAt = appendAt++;
|
|
166
|
+
signals.push({ kind: 'ac_added', text: acText, likelyInsertAt: insertAt });
|
|
167
|
+
adds.push({
|
|
168
|
+
op: 'add_step',
|
|
169
|
+
at: insertAt,
|
|
170
|
+
step: {
|
|
171
|
+
description: acText,
|
|
172
|
+
actionType: 'manualStep',
|
|
173
|
+
stepType: 'web',
|
|
174
|
+
expectedResult: acText,
|
|
175
|
+
},
|
|
176
|
+
confidence: round2(1 - best.score),
|
|
177
|
+
rationale: `no step matches this criterion (best overlap ${Math.round(best.score * 100)}%)`,
|
|
178
|
+
bucket: 'auto',
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
// Stale-step detection -------------------------------------------------
|
|
182
|
+
// A REMOVED SCENARIO shows up as a CONSECUTIVE group of unmatched steps that share a distinctive
|
|
183
|
+
// topic no current AC mentions (e.g. steps 11–15 all talk about the profile PICTURE while the
|
|
184
|
+
// remaining criteria only cover login and the phone number). Only such a group is proposed for
|
|
185
|
+
// removal. An isolated unmatched step ("Click Edit on the details section") is ambiguous — a
|
|
186
|
+
// navigation step, not a deleted scenario — and is reported as a `step_stale` hint instead:
|
|
187
|
+
// deleting a real step is far worse than leaving a review note.
|
|
188
|
+
const unmatched = stepTok
|
|
189
|
+
.filter((st) => !stepMatched.has(st.n) && looksAcDerived(st.step))
|
|
190
|
+
.sort((a, b) => a.n - b.n);
|
|
191
|
+
// Consecutive runs over the unmatched set (a gap means the step in between IS represented).
|
|
192
|
+
const orphanRuns = [];
|
|
193
|
+
for (const st of unmatched) {
|
|
194
|
+
const last = orphanRuns[orphanRuns.length - 1];
|
|
195
|
+
if (last && st.n === last[last.length - 1].n + 1)
|
|
196
|
+
last.push(st);
|
|
197
|
+
else
|
|
198
|
+
orphanRuns.push([st]);
|
|
199
|
+
}
|
|
200
|
+
// Generic UI verbs/nouns — shared by almost every flow, so they must never make two steps look
|
|
201
|
+
// like one scenario. Without this, "Click Save" + "Click Back" would read as a removed scenario.
|
|
202
|
+
const UI_GENERIC = new Set([
|
|
203
|
+
'click', 'open', 'enter', 'select', 'press', 'navigate', 'browse', 'type', 'choose', 'fill',
|
|
204
|
+
'field', 'button', 'form', 'page', 'section', 'screen', 'menu', 'option', 'value', 'input',
|
|
205
|
+
'display', 'displayed', 'shown', 'show', 'new', 'save', 'saved', 'submit', 'close', 'return',
|
|
206
|
+
'wait', 'finish', 'complete', 'edit', 'editable', 'see', 'check', 'confirm', 'success',
|
|
207
|
+
]);
|
|
208
|
+
/** Steps that belong to a removed scenario, inside one consecutive run of unmatched steps.
|
|
209
|
+
*
|
|
210
|
+
* A topic is any token that (a) appears in no current AC and (b) is not a generic UI word. Two
|
|
211
|
+
* steps are linked when they share such a token, so a scenario written with synonyms still sticks
|
|
212
|
+
* together ("picture" / "image" / "avatar" chained through the 5 upload steps). A linked group of
|
|
213
|
+
* TWO OR MORE steps is a removed scenario; a group is also extended over its immediate neighbours
|
|
214
|
+
* that mention NOTHING from a current AC (a "choose the file from disk" step inside the picture
|
|
215
|
+
* scenario). Steps that still talk about a current criterion (a success-toast step) are never
|
|
216
|
+
* swallowed, and a lone step is never deleted. */
|
|
217
|
+
const removedBlock = (run) => {
|
|
218
|
+
const out = new Set();
|
|
219
|
+
if (run.length < 2)
|
|
220
|
+
return out;
|
|
221
|
+
// Distinctive tokens per step: not a form of any AC word, not a generic UI word.
|
|
222
|
+
const acForms = withInflections(acUnion);
|
|
223
|
+
const distinct = run.map((st) => {
|
|
224
|
+
const set = new Set();
|
|
225
|
+
for (const t of st.tokens)
|
|
226
|
+
if (t && !acForms.has(t) && !UI_GENERIC.has(t))
|
|
227
|
+
set.add(t);
|
|
228
|
+
return set;
|
|
229
|
+
});
|
|
230
|
+
// A topic must RECUR through the scenario, not just appear twice. Without a minimum support,
|
|
231
|
+
// one shared incidental word ("details" in "Click Edit on the details section" + "Click Save on
|
|
232
|
+
// the details form", or "reload" in two unrelated steps) turned ordinary steps into a "removed
|
|
233
|
+
// scenario" and deleted them. A 2–3 step run is held to a lower bar so tiny scenarios are still
|
|
234
|
+
// detectable.
|
|
235
|
+
const minSupport = run.length >= 4 ? 3 : 2;
|
|
236
|
+
const support = new Map();
|
|
237
|
+
for (const set of distinct)
|
|
238
|
+
for (const t of set)
|
|
239
|
+
support.set(t, (support.get(t) ?? 0) + 1);
|
|
240
|
+
const eligible = new Set([...support].filter(([, c]) => c >= minSupport).map(([t]) => t));
|
|
241
|
+
// Union-find over "shares at least one distinctive token".
|
|
242
|
+
const parent = run.map((_, i) => i);
|
|
243
|
+
const find = (i) => (parent[i] === i ? i : (parent[i] = find(parent[i])));
|
|
244
|
+
const union = (a, b) => {
|
|
245
|
+
const ra = find(a);
|
|
246
|
+
const rb = find(b);
|
|
247
|
+
if (ra !== rb)
|
|
248
|
+
parent[ra] = rb;
|
|
249
|
+
};
|
|
250
|
+
for (let i = 0; i < run.length; i++) {
|
|
251
|
+
for (let j = i + 1; j < run.length; j++) {
|
|
252
|
+
for (const t of distinct[i]) {
|
|
253
|
+
if (eligible.has(t) && distinct[j].has(t)) {
|
|
254
|
+
union(i, j);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const groups = new Map();
|
|
261
|
+
run.forEach((_, i) => {
|
|
262
|
+
const r = find(i);
|
|
263
|
+
if (!groups.has(r))
|
|
264
|
+
groups.set(r, []);
|
|
265
|
+
groups.get(r).push(i);
|
|
266
|
+
});
|
|
267
|
+
const touchesAc = run.map((st) => containment(st.tokens, acUnion) > 0);
|
|
268
|
+
for (const idxs of groups.values()) {
|
|
269
|
+
if (idxs.length < 2)
|
|
270
|
+
continue; // one step is never evidence of a scenario
|
|
271
|
+
for (const i of idxs) {
|
|
272
|
+
out.add(run[i].n);
|
|
273
|
+
for (let lo = i - 1; lo >= 0 && !touchesAc[lo]; lo--)
|
|
274
|
+
out.add(run[lo].n);
|
|
275
|
+
for (let hi = i + 1; hi < run.length && !touchesAc[hi]; hi++)
|
|
276
|
+
out.add(run[hi].n);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return out.size >= 2 ? out : new Set();
|
|
280
|
+
};
|
|
281
|
+
for (const run of orphanRuns) {
|
|
282
|
+
const block = removedBlock(run);
|
|
283
|
+
for (const st of run) {
|
|
284
|
+
if (!block.has(st.n)) {
|
|
285
|
+
signals.push({ kind: 'step_stale', n: st.n, reason: 'no strong AC match' });
|
|
286
|
+
unresolved.push(`step ${st.n} has weak overlap with all ACs — review whether it's still needed`);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
signals.push({ kind: 'ac_removed', text: st.step.description, matchingSteps: [st.n] });
|
|
290
|
+
removes.push({
|
|
291
|
+
op: 'remove_step',
|
|
292
|
+
n: st.n,
|
|
293
|
+
confidence: 1,
|
|
294
|
+
rationale: `step ${st.n} is part of a scenario removed from the story (${block.size} consecutive steps about a topic no current criterion mentions)`,
|
|
295
|
+
bucket: 'review', // destructive → always needs a human look
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// A TC where NO current AC is represented has nothing left to keep: the scenario it tested was
|
|
300
|
+
// removed from the story. Obsolete it instead of proposing to strip every step (which would leave
|
|
301
|
+
// an empty — but still active — test case).
|
|
302
|
+
const allOrphaned = tc.steps.length > 0 && matchedAcCount === 0;
|
|
303
|
+
if (allOrphaned) {
|
|
304
|
+
signals.push({ kind: 'orphaned', reason: 'no step represents any current acceptance criterion' });
|
|
305
|
+
removes.length = 0; // never propose emptying the TC
|
|
306
|
+
updates.length = 0;
|
|
307
|
+
adds.length = 0;
|
|
308
|
+
}
|
|
309
|
+
// Executable order: updates first (numbering still intact) → ONE remove_steps carrying EVERY
|
|
310
|
+
// orphan → adds last (appended in AC order).
|
|
311
|
+
// Several remove ops in one call would NOT be equivalent: the draft renumbers after each op, so a
|
|
312
|
+
// later `remove_steps [12,13,14]` resolves against the already-shortened list and deletes the
|
|
313
|
+
// wrong steps (seen in the first end-to-end run: 5 + 13,14,15 were removed instead of 5 + 12..14,
|
|
314
|
+
// and the test case kept drifting on the next sync).
|
|
315
|
+
const orphanNumbers = [...new Set(removes.map((r) => r.n))].sort((a, b) => a - b);
|
|
316
|
+
const groupedRemoves = orphanNumbers.length === 0
|
|
317
|
+
? []
|
|
318
|
+
: [{
|
|
319
|
+
op: 'remove_steps',
|
|
320
|
+
numbers: orphanNumbers,
|
|
321
|
+
confidence: Math.min(...removes.map((r) => r.confidence)),
|
|
322
|
+
rationale: `step${orphanNumbers.length > 1 ? 's' : ''} ${orphanNumbers.join(', ')} belong to a scenario removed from the story`,
|
|
323
|
+
bucket: 'review',
|
|
324
|
+
}];
|
|
325
|
+
const proposedOps = allOrphaned
|
|
326
|
+
? []
|
|
327
|
+
: [...updates, ...groupedRemoves, ...adds];
|
|
328
|
+
const hasStructural = signals.some((s) => s.kind === 'ac_added' || s.kind === 'ac_removed');
|
|
329
|
+
// "Drifted" means something would actually CHANGE. A hint-only update_step (empty patch, kept as a
|
|
330
|
+
// review note) or a mere step_stale note is NOT drift: counting it made every sync propose another
|
|
331
|
+
// version forever, so a test case that had just been trimmed still came back as "needs v3.0".
|
|
332
|
+
const actionable = proposedOps.some((o) => o.op !== 'update_step' || Object.keys(o.patch ?? {}).length > 0);
|
|
333
|
+
const driftScore = allOrphaned ? 'major'
|
|
334
|
+
: !actionable ? 'none'
|
|
335
|
+
: hasStructural ? 'major' : 'minor';
|
|
336
|
+
// Structural drift usually means the story's SCOPE moved, which makes the TC title stale. Hint
|
|
337
|
+
// only (no auto-rename op): the title is the human's call.
|
|
338
|
+
if (driftScore === 'major') {
|
|
339
|
+
signals.push({
|
|
340
|
+
kind: 'title_review',
|
|
341
|
+
currentTitle: tc.title,
|
|
342
|
+
hint: 'The story\'s criteria changed — review against current ACs; rename the title only if its scope moved.',
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
testCaseId: tc.id ?? '',
|
|
347
|
+
title: tc.title,
|
|
348
|
+
driftScore,
|
|
349
|
+
signals,
|
|
350
|
+
proposedOps: allOrphaned ? [] : proposedOps,
|
|
351
|
+
unresolved,
|
|
352
|
+
allOrphaned,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* How well an AUTOMATED test case's steps represent the story's acceptance criteria.
|
|
357
|
+
*
|
|
358
|
+
* An automation step is a recorded ACTION ("Click on From field"), so it will never read like an AC
|
|
359
|
+
* ("Given the customer has products in the cart…"). Matching is therefore deliberately loose: an AC
|
|
360
|
+
* counts as covered when ANY step reaches the `low` threshold on token overlap (validations usually
|
|
361
|
+
* carry the AC's text in their expectedResult, which is what makes this usable at all).
|
|
362
|
+
*
|
|
363
|
+
* The purpose is not to prove equivalence — it is to decide whether the story edit is already
|
|
364
|
+
* reflected in the recorded flow (skip, no needless re-record) or not (flag `rerecord`).
|
|
365
|
+
*/
|
|
366
|
+
export function computeAutomationCoverage(story, tc, sensitivity = 'normal') {
|
|
367
|
+
const acList = splitAcceptanceCriteria(story.acceptanceCriteria);
|
|
368
|
+
if (acList.length === 0)
|
|
369
|
+
return { coverage: 1, covered: true, missingAcs: [] };
|
|
370
|
+
// A recorded action ("Click on Sign In") never reads like an AC ("Given the Bank-Admin…"). Measure
|
|
371
|
+
// how much of each AC's vocabulary the WHOLE flow contains; a flow that validates the dashboard and
|
|
372
|
+
// the balance genuinely covers those criteria even though no single step matches textually.
|
|
373
|
+
const threshold = sensitivity === 'strict' ? 0.6 : sensitivity === 'loose' ? 0.4 : 0.5;
|
|
374
|
+
const flowTokens = unionTokens(tc.steps.map((s) => stepTokens(s)));
|
|
375
|
+
const missing = [];
|
|
376
|
+
for (const ac of acList) {
|
|
377
|
+
if (containment(tokenize(ac), flowTokens) < threshold)
|
|
378
|
+
missing.push(ac);
|
|
379
|
+
}
|
|
380
|
+
const coverage = (acList.length - missing.length) / acList.length;
|
|
381
|
+
return { coverage, covered: missing.length === 0, missingAcs: missing };
|
|
382
|
+
}
|
|
383
|
+
/** Numeric suffix of a business key / story ref ("US_897" → 897). */
|
|
384
|
+
function numericSuffix(s) {
|
|
385
|
+
if (!s)
|
|
386
|
+
return undefined;
|
|
387
|
+
const m = s.match(/(\d+)\s*$/);
|
|
388
|
+
return m ? Number.parseInt(m[1], 10) : undefined;
|
|
389
|
+
}
|
|
390
|
+
function moduleOf(tc) {
|
|
391
|
+
const direct = numericSuffix(tc.folderOrModule);
|
|
392
|
+
if (direct !== undefined)
|
|
393
|
+
return direct;
|
|
394
|
+
return undefined;
|
|
395
|
+
}
|
|
396
|
+
/** The technology an automated TC was recorded in — drives which recording tool the agent uses. */
|
|
397
|
+
function technologyOf(tc) {
|
|
398
|
+
const t = tc.technologyType;
|
|
399
|
+
return typeof t === 'string' && t.trim() ? t.trim().toUpperCase() : undefined;
|
|
400
|
+
}
|
|
401
|
+
export function registerStorySyncTools(server, deps) {
|
|
402
|
+
server.registerTool('story_sync_testcases', {
|
|
403
|
+
title: 'Sync a user story with its manual AND automation test cases (drift + recording plan)',
|
|
404
|
+
description: 'Compare a user STORY against every test case linked to it (via storyRef) and return a ' +
|
|
405
|
+
'structured, ORDERED plan for bringing them up to date.\n\n' +
|
|
406
|
+
'MANUAL test cases → textual drift (ac_added / ac_reworded / ac_removed / step_stale) and the ' +
|
|
407
|
+
'exact draft ops (add_step / update_step / remove_step).\n' +
|
|
408
|
+
'AUTOMATION test cases → `action: "rerecord"` (or `"up-to-date"`) plus the recording brief: the ' +
|
|
409
|
+
'acceptance criteria to cover, story/module ids, current steps and testdata seeds. An automated ' +
|
|
410
|
+
'TC cannot be re-texted — it must be re-recorded.\n\n' +
|
|
411
|
+
'HOW TO APPLY (one item at a time, in plan order — never in parallel):\n' +
|
|
412
|
+
' MANUAL item:\n' +
|
|
413
|
+
' 1. tc_draft_from_tc({ tcId })\n' +
|
|
414
|
+
' 2. tc_draft_update({ draftId, ops: item.proposedOps })\n' +
|
|
415
|
+
' 3. tc_save_as_new_version({ tcId, fromDraftId: draftId }) ← new version (v1.0 → v2.0)\n' +
|
|
416
|
+
' OBSOLETE item (action === "obsolete") — the scenario this TC tested was REMOVED from the story\n' +
|
|
417
|
+
' and NO step matches any current AC:\n' +
|
|
418
|
+
' ASK the user, then journal_modify({ tcId, ops: [{ op: "set_meta", patch: { obsolete: true } }] }).\n' +
|
|
419
|
+
' Do NOT strip its steps (that leaves an empty, still-active TC) and do NOT delete it.\n' +
|
|
420
|
+
' PARTIAL removal — only SOME steps belonged to the removed scenario:\n' +
|
|
421
|
+
' item.proposedOps carries ONE bulk remove_steps { numbers:[11,12,13,14,15] }; apply the MANUAL\n' +
|
|
422
|
+
' item steps 1-3 above. The result is a NEW VERSION without those steps (v1.0 keeps them).\n' +
|
|
423
|
+
' NEVER obsolete a partially-affected TC.\n' +
|
|
424
|
+
' AUTOMATION item (action === "rerecord"):\n' +
|
|
425
|
+
' 1. ASK the user AI-only or Hybrid, then\n' +
|
|
426
|
+
' core_activate_technology({ technology, testcaseId: item.testCaseId, ' +
|
|
427
|
+
'versionName: item.nextVersionName, testcaseName: item.title, userstoryId: item.brief.userstoryId, ' +
|
|
428
|
+
'moduleId: item.brief.moduleId, recordingMode, recordingModeAskedUser })\n' +
|
|
429
|
+
' The recorder window opens on THAT test case (details + versions, steps cleared) and\n' +
|
|
430
|
+
' shows the pending version in the version dropdown (v1.0 → v2.0, v2.0 → v3.0).\n' +
|
|
431
|
+
' 2. Record the brief.acceptanceCriteria end-to-end (web: web_launch_application → web_snapshot → ' +
|
|
432
|
+
'web_click / web_enter_text / web_validate_text …).\n' +
|
|
433
|
+
' (desktop: desktop_launch_application → desktop_snapshot → desktop_click / desktop_enter_text / ' +
|
|
434
|
+
'desktop_validate_text …; the launch is still the first step.)\n' +
|
|
435
|
+
' 3. SAVE — click Save in the recorder window, OR tc_save({ sessionId }) (it clicks that same\n' +
|
|
436
|
+
' button). Either one writes the re-recorded flow as a NEW VERSION of the SAME TC (story,\n' +
|
|
437
|
+
' module, suite and history preserved) with the recorded test-data formulas.\n' +
|
|
438
|
+
' Do NOT use tc_draft_from_journal / tc_save_as_new_version on this flow — that would save twice.\n' +
|
|
439
|
+
' In-place editing is available with `versionStrategy: "in-place"` (same ops, tc_save instead of a ' +
|
|
440
|
+
'new version) — use it only when the user explicitly does not want a new version.\n\n' +
|
|
441
|
+
'Report-only: this tool writes nothing itself. Pass `testCaseIds` to limit the scan; otherwise the ' +
|
|
442
|
+
'tool walks listTestCases and filters by storyRef (bounded by `scanLimit`, default 200). ' +
|
|
443
|
+
'Test cases that are ALREADY obsolete are skipped (reason "already_obsolete"), so a second run ' +
|
|
444
|
+
'after applying the plan only shows what is still left to do. ' +
|
|
445
|
+
'Requires a live connection.',
|
|
446
|
+
inputSchema: {
|
|
447
|
+
storyId: z.string().describe('Story id or business key (US_123).'),
|
|
448
|
+
testCaseIds: z.array(z.string()).optional().describe('Restrict comparison to these TC ids/keys. Recommended for large projects; otherwise the ' +
|
|
449
|
+
'tool walks up to `scanLimit` TCs.'),
|
|
450
|
+
scope: z.enum(['manual', 'automation', 'both']).optional().describe('Which linked test cases to plan for. Default "both" (manual drift + automation re-record plan).'),
|
|
451
|
+
versionStrategy: z.enum(['new', 'in-place']).optional().describe('How a MANUAL update is written: "new" (default) = new version (v1.0 → v2.0) preserving history; ' +
|
|
452
|
+
'"in-place" = overwrite the current version.'),
|
|
453
|
+
sensitivity: z.enum(['strict', 'normal', 'loose']).optional().describe('Match-strictness for AC↔step overlap. strict=more drift flagged, loose=less. Default normal.'),
|
|
454
|
+
scanLimit: z.number().int().positive().optional().describe('Cap on how many TCs to fetch when `testCaseIds` is omitted. Default 200.'),
|
|
455
|
+
includeTestData: z.boolean().optional().describe('Include the automation brief\'s testdata seeds (default true; costs one extra read per ' +
|
|
456
|
+
'automation TC). Set false for a fast check.'),
|
|
457
|
+
},
|
|
458
|
+
annotations: { readOnlyHint: true },
|
|
459
|
+
}, async ({ storyId, testCaseIds, scope, versionStrategy, sensitivity, scanLimit, includeTestData }) => {
|
|
460
|
+
const adapter = deps.getAdapter();
|
|
461
|
+
if (!adapter)
|
|
462
|
+
return err(NOT_CONNECTED);
|
|
463
|
+
if (!adapter.getStory)
|
|
464
|
+
return err('This product does not expose a user-story backlog.');
|
|
465
|
+
try {
|
|
466
|
+
const story = await adapter.getStory(storyId);
|
|
467
|
+
// Resolve candidate TCs.
|
|
468
|
+
let candidates = [];
|
|
469
|
+
if (testCaseIds && testCaseIds.length > 0) {
|
|
470
|
+
candidates = await Promise.all(testCaseIds.map((id) => adapter.getTestCase(id)));
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
const cap = scanLimit ?? 200;
|
|
474
|
+
const summaries = await adapter.listTestCases({ limit: cap });
|
|
475
|
+
const fetched = await Promise.all(summaries.map((s) => adapter.getTestCase(s.id)));
|
|
476
|
+
candidates = fetched.filter((tc) => tc.storyRef === story.id || tc.storyRef === story.key);
|
|
477
|
+
}
|
|
478
|
+
const sens = sensitivity ?? 'normal';
|
|
479
|
+
const wantManual = (scope ?? 'both') !== 'automation';
|
|
480
|
+
const wantAutomation = (scope ?? 'both') !== 'manual';
|
|
481
|
+
const strategy = versionStrategy ?? 'new';
|
|
482
|
+
const acs = splitAcceptanceCriteria(story.acceptanceCriteria);
|
|
483
|
+
const plan = [];
|
|
484
|
+
const skipped = [];
|
|
485
|
+
let manualConsidered = 0;
|
|
486
|
+
let automationConsidered = 0;
|
|
487
|
+
for (const raw of candidates) {
|
|
488
|
+
if (!raw.id) {
|
|
489
|
+
skipped.push({ testCaseId: '', title: raw.title, reason: 'no_id' });
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
// Compare the NEWEST version, not the default read (versions[0] = v1.0). After an update
|
|
493
|
+
// was saved as v2.0 the default read is stale, and analysing it would re-report drift that
|
|
494
|
+
// is already fixed and hand back the wrong `nextVersionName`.
|
|
495
|
+
const tcId = raw.id;
|
|
496
|
+
let tc = { ...raw, id: tcId };
|
|
497
|
+
const latest = latestVersionId(raw);
|
|
498
|
+
if (latest && latest !== raw.currentVersionId) {
|
|
499
|
+
// Merge over `raw` (not replace): the version read must win for `steps`, but TC-level
|
|
500
|
+
// flags it does not return (e.g. `obsolete`) must not be lost.
|
|
501
|
+
try {
|
|
502
|
+
tc = { ...raw, ...(await adapter.getTestCase(tcId, latest)), id: tcId };
|
|
503
|
+
}
|
|
504
|
+
catch { /* keep the default-version read */ }
|
|
505
|
+
}
|
|
506
|
+
// Already retired by a previous sync: nothing left to plan. Without this the same
|
|
507
|
+
// obsolete item came back on EVERY run and the plan never converged.
|
|
508
|
+
if (tc.obsolete === true) {
|
|
509
|
+
skipped.push({ testCaseId: tc.id, title: tc.title, reason: 'already_obsolete' });
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
const isManual = tc.category === 'manual';
|
|
513
|
+
if (isManual) {
|
|
514
|
+
if (!wantManual) {
|
|
515
|
+
skipped.push({ testCaseId: tc.id, title: tc.title, reason: 'manual_tc_out_of_scope' });
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
manualConsidered++;
|
|
519
|
+
const drift = computeDrift(story, tc, sens);
|
|
520
|
+
plan.push({
|
|
521
|
+
kind: 'manual',
|
|
522
|
+
testCaseId: tc.id,
|
|
523
|
+
title: tc.title,
|
|
524
|
+
driftScore: drift.allOrphaned ? 'major' : drift.driftScore,
|
|
525
|
+
signals: drift.signals,
|
|
526
|
+
proposedOps: drift.proposedOps,
|
|
527
|
+
unresolved: drift.unresolved,
|
|
528
|
+
...(drift.allOrphaned ? { action: 'obsolete' } : {}),
|
|
529
|
+
// A clean item writes nothing, so it must not name a next version either.
|
|
530
|
+
...(drift.allOrphaned || drift.driftScore !== 'none'
|
|
531
|
+
? { nextVersionName: nextVersionName(tc) }
|
|
532
|
+
: {}),
|
|
533
|
+
versionStrategy: strategy,
|
|
534
|
+
});
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
// AUTOMATION
|
|
538
|
+
if (!wantAutomation) {
|
|
539
|
+
skipped.push({ testCaseId: tc.id, title: tc.title, reason: 'automation_tc_out_of_scope' });
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
automationConsidered++;
|
|
543
|
+
const cov = computeAutomationCoverage(story, tc, sens);
|
|
544
|
+
const userstoryId = numericSuffix(tc.storyRef) ?? numericSuffix(story.id);
|
|
545
|
+
const moduleId = moduleOf(tc);
|
|
546
|
+
const technology = technologyOf(tc);
|
|
547
|
+
let testData;
|
|
548
|
+
if (includeTestData !== false && adapter.getDefaultIteration) {
|
|
549
|
+
try {
|
|
550
|
+
const it = await adapter.getDefaultIteration({
|
|
551
|
+
tcId: tc.id,
|
|
552
|
+
...(tc.currentVersionId ? { versionId: tc.currentVersionId } : {}),
|
|
553
|
+
});
|
|
554
|
+
if (it.parameters.length) {
|
|
555
|
+
testData = it.parameters.map((p) => ({
|
|
556
|
+
name: p.name,
|
|
557
|
+
seed: p.seed ?? '',
|
|
558
|
+
...(p.protected ? { protected: true } : {}),
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
// testdata is best-effort — a broken store must not block the plan
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
// Nothing recorded represents any current AC → the recorded scenario was removed; obsolete
|
|
567
|
+
// the TC instead of asking for a re-record with zero criteria.
|
|
568
|
+
const autoOrphaned = tc.steps.length > 0 && cov.coverage === 0;
|
|
569
|
+
plan.push({
|
|
570
|
+
kind: 'automation',
|
|
571
|
+
testCaseId: tc.id,
|
|
572
|
+
title: tc.title,
|
|
573
|
+
action: autoOrphaned ? 'obsolete' : (cov.covered ? 'up-to-date' : 'rerecord'),
|
|
574
|
+
coverage: Math.round(cov.coverage * 100) / 100,
|
|
575
|
+
missingAcs: cov.missingAcs,
|
|
576
|
+
...(autoOrphaned || cov.covered ? {} : { nextVersionName: nextVersionName(tc) }),
|
|
577
|
+
brief: {
|
|
578
|
+
storyId: story.id ?? '',
|
|
579
|
+
...(story.key ? { storyKey: story.key } : {}),
|
|
580
|
+
...(userstoryId !== undefined ? { userstoryId } : {}),
|
|
581
|
+
...(moduleId !== undefined ? { moduleId } : {}),
|
|
582
|
+
testcaseName: tc.title,
|
|
583
|
+
...(technology ? { technology } : {}),
|
|
584
|
+
currentStepCount: tc.steps.length,
|
|
585
|
+
acceptanceCriteria: acs,
|
|
586
|
+
currentSteps: tc.steps.map((s) => s.description),
|
|
587
|
+
...(testData ? { testData } : {}),
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
const manualDrifted = plan.filter((p) => p.kind === 'manual' && p.driftScore !== 'none');
|
|
592
|
+
const manualClean = plan.filter((p) => p.kind === 'manual' && p.driftScore === 'none');
|
|
593
|
+
const autoRerecord = plan.filter((p) => p.kind === 'automation' && p.action === 'rerecord');
|
|
594
|
+
const autoClean = plan.filter((p) => p.kind === 'automation' && p.action === 'up-to-date');
|
|
595
|
+
const lines = [];
|
|
596
|
+
lines.push(`Story **${story.title}**${story.key ? ` · ${story.key}` : ''}`);
|
|
597
|
+
lines.push('');
|
|
598
|
+
lines.push(`${acs.length} acceptance criteri${acs.length === 1 ? 'on' : 'a'} · ` +
|
|
599
|
+
`${manualConsidered} manual TC${manualConsidered === 1 ? '' : 's'} (${manualDrifted.length} drifted, ` +
|
|
600
|
+
`${manualClean.length} clean) · ${automationConsidered} automation TC${automationConsidered === 1 ? '' : 's'} ` +
|
|
601
|
+
`(${autoRerecord.length} to re-record, ${autoClean.length} up-to-date) · ${skipped.length} skipped.`);
|
|
602
|
+
if (acs.length) {
|
|
603
|
+
lines.push('', '**Acceptance criteria**');
|
|
604
|
+
lines.push(acs.map((a, i) => `${i + 1}. ${a}`).join('\n'));
|
|
605
|
+
}
|
|
606
|
+
if (manualDrifted.length) {
|
|
607
|
+
lines.push('', '**Manual — update as a new version**');
|
|
608
|
+
for (const p of manualDrifted) {
|
|
609
|
+
lines.push(`- **${p.title}** (${p.testCaseId}) — ${p.driftScore} · ${p.signals.length} signal(s) · ` +
|
|
610
|
+
`${p.proposedOps.length} op(s) · next version **${p.nextVersionName}**`);
|
|
611
|
+
for (const s of p.signals) {
|
|
612
|
+
if (s.kind === 'ac_added')
|
|
613
|
+
lines.push(` + added AC: ${s.text}`);
|
|
614
|
+
else if (s.kind === 'ac_removed')
|
|
615
|
+
lines.push(` – removed AC: ${s.text}`);
|
|
616
|
+
else if (s.kind === 'ac_reworded')
|
|
617
|
+
lines.push(` ~ reworded: ${s.from} → ${s.to}`);
|
|
618
|
+
else if (s.kind === 'step_stale')
|
|
619
|
+
lines.push(` ? step ${s.n}: ${s.reason}`);
|
|
620
|
+
else if (s.kind === 'title_review')
|
|
621
|
+
lines.push(` ! title review: "${s.currentTitle}" — ${s.hint}`);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
lines.push('', strategy === 'new'
|
|
625
|
+
? 'Apply each: `tc_draft_from_tc({ tcId })` → `tc_draft_update({ draftId, ops })` → ' +
|
|
626
|
+
'`tc_save_as_new_version({ tcId, fromDraftId: draftId })`.'
|
|
627
|
+
: 'Apply each in place: `tc_draft_from_tc({ tcId })` → `tc_draft_update({ draftId, ops })` → `tc_save({ draftId })`.');
|
|
628
|
+
}
|
|
629
|
+
else if (manualConsidered) {
|
|
630
|
+
lines.push('', '_No manual drift._');
|
|
631
|
+
}
|
|
632
|
+
if (autoRerecord.length) {
|
|
633
|
+
lines.push('', '**Automation — re-record ONE AT A TIME (each item is a separate recording session)**');
|
|
634
|
+
autoRerecord.forEach((p, i) => {
|
|
635
|
+
lines.push(`${i + 1}. **${p.title}** (${p.testCaseId}) — ${p.missingAcs.length}/${acs.length} AC(s) not ` +
|
|
636
|
+
`represented (coverage ${Math.round(p.coverage * 100)}%) · next version **${p.nextVersionName}**`);
|
|
637
|
+
lines.push(` activate: technology=${p.brief.technology ?? 'WEB'}, testcaseName="${p.brief.testcaseName}", ` +
|
|
638
|
+
`userstoryId=${p.brief.userstoryId ?? '?'}, moduleId=${p.brief.moduleId ?? '?'}`);
|
|
639
|
+
lines.push(` current steps: ${p.brief.currentStepCount}`);
|
|
640
|
+
if (p.missingAcs.length) {
|
|
641
|
+
lines.push(` cover: ${p.missingAcs.map((a) => `"${a}"`).join(' · ')}`);
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
lines.push('', 'After each recording: `core_close_session()` → ask the user to review → ' +
|
|
645
|
+
'`tc_draft_from_journal({ sessionId })` → `tc_save_as_new_version({ tcId, fromDraftId, tdCopy })`. ' +
|
|
646
|
+
'Do NOT click Save in the recorder window for this flow (it creates a separate new TC).');
|
|
647
|
+
}
|
|
648
|
+
else if (automationConsidered) {
|
|
649
|
+
lines.push('', '_All linked automation TCs already cover the acceptance criteria._');
|
|
650
|
+
}
|
|
651
|
+
if (skipped.length) {
|
|
652
|
+
lines.push('', '_Skipped:_');
|
|
653
|
+
for (const s of skipped)
|
|
654
|
+
lines.push(`- ${s.title} (${s.testCaseId || '—'}): ${s.reason}`);
|
|
655
|
+
}
|
|
656
|
+
return ok(lines.join('\n'), {
|
|
657
|
+
story,
|
|
658
|
+
acceptanceCriteria: acs,
|
|
659
|
+
plan,
|
|
660
|
+
next: plan.find((p) => (p.kind === 'manual'
|
|
661
|
+
? (p.action === 'obsolete' || p.driftScore !== 'none')
|
|
662
|
+
: p.action !== 'up-to-date')) ?? null,
|
|
663
|
+
skipped,
|
|
664
|
+
counts: {
|
|
665
|
+
manual: manualConsidered,
|
|
666
|
+
manualDrifted: manualDrifted.length,
|
|
667
|
+
automation: automationConsidered,
|
|
668
|
+
automationRerecord: autoRerecord.length,
|
|
669
|
+
obsolete: plan.filter((p) => p.action === 'obsolete').length,
|
|
670
|
+
},
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
catch (e) {
|
|
674
|
+
return err(e instanceof Error ? e.message : String(e));
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
//# sourceMappingURL=storySync.tools.js.map
|