sqlew 4.1.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1862 -1817
- package/README.md +25 -165
- package/assets/claude-md-snippets/plan-mode-integration.md +48 -24
- package/assets/sample-skills/sqlew-decision-format/SKILL.md +73 -0
- package/dist/cli/hooks/check-completion.d.ts.map +1 -1
- package/dist/cli/hooks/check-completion.js +90 -2
- package/dist/cli/hooks/check-completion.js.map +1 -1
- package/dist/cli/hooks/init-hooks.d.ts.map +1 -1
- package/dist/cli/hooks/init-hooks.js +97 -5
- package/dist/cli/hooks/init-hooks.js.map +1 -1
- package/dist/cli/hooks/on-enter-plan.d.ts +22 -0
- package/dist/cli/hooks/on-enter-plan.d.ts.map +1 -0
- package/dist/cli/hooks/on-enter-plan.js +51 -0
- package/dist/cli/hooks/on-enter-plan.js.map +1 -0
- package/dist/cli/hooks/on-exit-plan.d.ts +20 -0
- package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -0
- package/dist/cli/hooks/on-exit-plan.js +66 -0
- package/dist/cli/hooks/on-exit-plan.js.map +1 -0
- package/dist/cli/hooks/on-stop.d.ts +19 -0
- package/dist/cli/hooks/on-stop.d.ts.map +1 -0
- package/dist/cli/hooks/on-stop.js +152 -0
- package/dist/cli/hooks/on-stop.js.map +1 -0
- package/dist/cli/hooks/on-subagent-stop.d.ts +20 -0
- package/dist/cli/hooks/on-subagent-stop.d.ts.map +1 -0
- package/dist/cli/hooks/on-subagent-stop.js +94 -0
- package/dist/cli/hooks/on-subagent-stop.js.map +1 -0
- package/dist/cli/hooks/plan-pattern-extractor.d.ts +87 -0
- package/dist/cli/hooks/plan-pattern-extractor.d.ts.map +1 -0
- package/dist/cli/hooks/plan-pattern-extractor.js +218 -0
- package/dist/cli/hooks/plan-pattern-extractor.js.map +1 -0
- package/dist/cli/hooks/plan-processor.d.ts +43 -0
- package/dist/cli/hooks/plan-processor.d.ts.map +1 -0
- package/dist/cli/hooks/plan-processor.js +115 -0
- package/dist/cli/hooks/plan-processor.js.map +1 -0
- package/dist/cli/hooks/plan-toml-parser.d.ts +42 -0
- package/dist/cli/hooks/plan-toml-parser.d.ts.map +1 -0
- package/dist/cli/hooks/plan-toml-parser.js +178 -0
- package/dist/cli/hooks/plan-toml-parser.js.map +1 -0
- package/dist/cli/hooks/save.d.ts +7 -9
- package/dist/cli/hooks/save.d.ts.map +1 -1
- package/dist/cli/hooks/save.js +50 -25
- package/dist/cli/hooks/save.js.map +1 -1
- package/dist/cli/hooks/stdin-parser.d.ts +66 -2
- package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
- package/dist/cli/hooks/stdin-parser.js +57 -2
- package/dist/cli/hooks/stdin-parser.js.map +1 -1
- package/dist/cli/hooks/suggest.d.ts +8 -4
- package/dist/cli/hooks/suggest.d.ts.map +1 -1
- package/dist/cli/hooks/suggest.js +21 -123
- package/dist/cli/hooks/suggest.js.map +1 -1
- package/dist/cli/hooks/track-plan.d.ts +8 -1
- package/dist/cli/hooks/track-plan.d.ts.map +1 -1
- package/dist/cli/hooks/track-plan.js +64 -66
- package/dist/cli/hooks/track-plan.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +139 -38
- package/dist/cli.js.map +1 -1
- package/dist/config/global-config.d.ts +90 -0
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +86 -1
- package/dist/config/global-config.js.map +1 -1
- package/dist/database/initialization/init.js +3 -3
- package/dist/database/initialization/init.js.map +1 -1
- package/dist/database/initialization/schema-version.js +1 -1
- package/dist/database/initialization/schema-version.js.map +1 -1
- package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +32 -32
- package/dist/database/migrations/v4/20251225000000_v4_seed_missing_help_data.d.ts +14 -0
- package/dist/database/migrations/v4/20251225000000_v4_seed_missing_help_data.d.ts.map +1 -0
- package/dist/database/migrations/v4/20251225000000_v4_seed_missing_help_data.js +201 -0
- package/dist/database/migrations/v4/20251225000000_v4_seed_missing_help_data.js.map +1 -0
- package/dist/database/migrations/v4/20251225000001_v4_fix_help_params.d.ts +12 -0
- package/dist/database/migrations/v4/20251225000001_v4_fix_help_params.d.ts.map +1 -0
- package/dist/database/migrations/v4/20251225000001_v4_fix_help_params.js +61 -0
- package/dist/database/migrations/v4/20251225000001_v4_fix_help_params.js.map +1 -0
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts +15 -0
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.d.ts.map +1 -0
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +74 -0
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js.map +1 -0
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/init-skills.d.ts +6 -1
- package/dist/init-skills.d.ts.map +1 -1
- package/dist/init-skills.js +50 -1
- package/dist/init-skills.js.map +1 -1
- package/dist/knexfile.d.ts.map +1 -1
- package/dist/knexfile.js +16 -12
- package/dist/knexfile.js.map +1 -1
- package/dist/server/setup.d.ts.map +1 -1
- package/dist/server/setup.js +33 -11
- package/dist/server/setup.js.map +1 -1
- package/dist/server/tool-handlers.d.ts.map +1 -1
- package/dist/server/tool-handlers.js +7 -1
- package/dist/server/tool-handlers.js.map +1 -1
- package/dist/server/tool-registry.js +1 -1
- package/dist/server/tool-registry.js.map +1 -1
- package/dist/tests/database/sql-dump/table-ordering.test.js +6 -1
- package/dist/tests/database/sql-dump/table-ordering.test.js.map +1 -1
- package/dist/tests/docker/native/constraint-operations.test.js +74 -137
- package/dist/tests/docker/native/constraint-operations.test.js.map +1 -1
- package/dist/tests/docker/native/decision-operations.test.js +52 -40
- package/dist/tests/docker/native/decision-operations.test.js.map +1 -1
- package/dist/tests/docker/native/help-system.test.d.ts +3 -2
- package/dist/tests/docker/native/help-system.test.d.ts.map +1 -1
- package/dist/tests/docker/native/help-system.test.js +90 -80
- package/dist/tests/docker/native/help-system.test.js.map +1 -1
- package/dist/tests/docker/native/suggest-tool.test.d.ts +2 -2
- package/dist/tests/docker/native/suggest-tool.test.js +130 -63
- package/dist/tests/docker/native/suggest-tool.test.js.map +1 -1
- package/dist/tests/docker/native/task-operations.test.js +9 -19
- package/dist/tests/docker/native/task-operations.test.js.map +1 -1
- package/dist/tests/docker/native/test-harness.d.ts.map +1 -1
- package/dist/tests/docker/native/test-harness.js +6 -5
- package/dist/tests/docker/native/test-harness.js.map +1 -1
- package/dist/tests/feature/decision/batch-validation-comprehensive.test.js +7 -8
- package/dist/tests/feature/decision/batch-validation-comprehensive.test.js.map +1 -1
- package/dist/tests/feature/decision/context-modular.test.js +1 -3
- package/dist/tests/feature/decision/context-modular.test.js.map +1 -1
- package/dist/tests/feature/decision/truncate.test.d.ts +8 -0
- package/dist/tests/feature/decision/truncate.test.d.ts.map +1 -0
- package/dist/tests/feature/decision/truncate.test.js +192 -0
- package/dist/tests/feature/decision/truncate.test.js.map +1 -0
- package/dist/tests/feature/help/help-system.test.d.ts +1 -13
- package/dist/tests/feature/help/help-system.test.d.ts.map +1 -1
- package/dist/tests/feature/help/help-system.test.js +107 -331
- package/dist/tests/feature/help/help-system.test.js.map +1 -1
- package/dist/tests/feature/task/auto-pruning-decision-link.test.js +2 -4
- package/dist/tests/feature/task/auto-pruning-decision-link.test.js.map +1 -1
- package/dist/tests/integration/all-features.standalone.js +1 -3
- package/dist/tests/integration/all-features.standalone.js.map +1 -1
- package/dist/tests/migrations/test-all-versions-real.js +2 -4
- package/dist/tests/migrations/test-all-versions-real.js.map +1 -1
- package/dist/tests/migrations/test-all-versions.js +3 -7
- package/dist/tests/migrations/test-all-versions.js.map +1 -1
- package/dist/tests/unit/config/plan-toml-cache.test.d.ts +9 -0
- package/dist/tests/unit/config/plan-toml-cache.test.d.ts.map +1 -0
- package/dist/tests/unit/config/plan-toml-cache.test.js +230 -0
- package/dist/tests/unit/config/plan-toml-cache.test.js.map +1 -0
- package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts +10 -0
- package/dist/tests/unit/hooks/plan-toml-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/hooks/plan-toml-parser.test.js +316 -0
- package/dist/tests/unit/hooks/plan-toml-parser.test.js.map +1 -0
- package/dist/tests/unit/universal-knex.test.js +3 -0
- package/dist/tests/unit/universal-knex.test.js.map +1 -1
- package/dist/tests/unit/utils/config-loader.test.js +130 -191
- package/dist/tests/unit/utils/config-loader.test.js.map +1 -1
- package/dist/tests/unit/utils/project-detector.test.js +24 -0
- package/dist/tests/unit/utils/project-detector.test.js.map +1 -1
- package/dist/tests/unit/validation/parameter-validation.test.js +2 -2
- package/dist/tests/unit/validation/parameter-validation.test.js.map +1 -1
- package/dist/tests/unit/validation/policy-validation.test.js +1 -3
- package/dist/tests/unit/validation/policy-validation.test.js.map +1 -1
- package/dist/tools/constraints/actions/activate.d.ts +46 -0
- package/dist/tools/constraints/actions/activate.d.ts.map +1 -0
- package/dist/tools/constraints/actions/activate.js +105 -0
- package/dist/tools/constraints/actions/activate.js.map +1 -0
- package/dist/tools/constraints/actions/add.d.ts.map +1 -1
- package/dist/tools/constraints/actions/add.js +30 -13
- package/dist/tools/constraints/actions/add.js.map +1 -1
- package/dist/tools/constraints/actions/deactivate.d.ts.map +1 -1
- package/dist/tools/constraints/actions/deactivate.js +7 -4
- package/dist/tools/constraints/actions/deactivate.js.map +1 -1
- package/dist/tools/constraints/actions/get.d.ts.map +1 -1
- package/dist/tools/constraints/actions/get.js +10 -7
- package/dist/tools/constraints/actions/get.js.map +1 -1
- package/dist/tools/constraints/actions/suggest-pending.d.ts +41 -0
- package/dist/tools/constraints/actions/suggest-pending.d.ts.map +1 -0
- package/dist/tools/constraints/actions/suggest-pending.js +71 -0
- package/dist/tools/constraints/actions/suggest-pending.js.map +1 -0
- package/dist/tools/constraints/help/example.d.ts.map +1 -1
- package/dist/tools/constraints/help/example.js +65 -1
- package/dist/tools/constraints/help/example.js.map +1 -1
- package/dist/tools/constraints/help/help.d.ts.map +1 -1
- package/dist/tools/constraints/help/help.js +10 -5
- package/dist/tools/constraints/help/help.js.map +1 -1
- package/dist/tools/constraints/index.d.ts +2 -0
- package/dist/tools/constraints/index.d.ts.map +1 -1
- package/dist/tools/constraints/index.js +2 -0
- package/dist/tools/constraints/index.js.map +1 -1
- package/dist/tools/context/actions/add-context.d.ts.map +1 -1
- package/dist/tools/context/actions/add-context.js +13 -6
- package/dist/tools/context/actions/add-context.js.map +1 -1
- package/dist/tools/context/actions/list-contexts.d.ts.map +1 -1
- package/dist/tools/context/actions/list-contexts.js +12 -7
- package/dist/tools/context/actions/list-contexts.js.map +1 -1
- package/dist/tools/context/actions/list.d.ts.map +1 -1
- package/dist/tools/context/actions/list.js +8 -0
- package/dist/tools/context/actions/list.js.map +1 -1
- package/dist/tools/context/actions/search-advanced.d.ts.map +1 -1
- package/dist/tools/context/actions/search-advanced.js +41 -27
- package/dist/tools/context/actions/search-advanced.js.map +1 -1
- package/dist/tools/context/actions/search-layer.d.ts.map +1 -1
- package/dist/tools/context/actions/search-layer.js +8 -0
- package/dist/tools/context/actions/search-layer.js.map +1 -1
- package/dist/tools/context/actions/search-tags.d.ts.map +1 -1
- package/dist/tools/context/actions/search-tags.js +8 -0
- package/dist/tools/context/actions/search-tags.js.map +1 -1
- package/dist/tools/files/actions/check-lock.d.ts.map +1 -1
- package/dist/tools/files/actions/check-lock.js +9 -3
- package/dist/tools/files/actions/check-lock.js.map +1 -1
- package/dist/tools/files/actions/get.d.ts.map +1 -1
- package/dist/tools/files/actions/get.js +18 -13
- package/dist/tools/files/actions/get.js.map +1 -1
- package/dist/tools/files/actions/record-batch.d.ts.map +1 -1
- package/dist/tools/files/actions/record-batch.js +11 -6
- package/dist/tools/files/actions/record-batch.js.map +1 -1
- package/dist/tools/files/actions/record.d.ts.map +1 -1
- package/dist/tools/files/actions/record.js +8 -2
- package/dist/tools/files/actions/record.js.map +1 -1
- package/dist/tools/files/help/example.js +8 -8
- package/dist/tools/files/help/example.js.map +1 -1
- package/dist/tools/files/help/help.js +4 -4
- package/dist/tools/files/help/help.js.map +1 -1
- package/dist/tools/files/internal/validation.d.ts.map +1 -1
- package/dist/tools/files/internal/validation.js +1 -2
- package/dist/tools/files/internal/validation.js.map +1 -1
- package/dist/tools/help-queries.d.ts.map +1 -1
- package/dist/tools/help-queries.js +57 -27
- package/dist/tools/help-queries.js.map +1 -1
- package/dist/tools/suggest/actions/by-tags.d.ts.map +1 -1
- package/dist/tools/suggest/actions/by-tags.js +3 -1
- package/dist/tools/suggest/actions/by-tags.js.map +1 -1
- package/dist/tools/suggest/help/constraint-help.js +2 -2
- package/dist/tools/suggest/help/constraint-help.js.map +1 -1
- package/dist/tools/tasks/help/example.d.ts.map +1 -1
- package/dist/tools/tasks/help/example.js +10 -0
- package/dist/tools/tasks/help/example.js.map +1 -1
- package/dist/tools/tasks/help/help.d.ts.map +1 -1
- package/dist/tools/tasks/help/help.js +10 -0
- package/dist/tools/tasks/help/help.js.map +1 -1
- package/dist/tools/use_case/actions/search.js +5 -5
- package/dist/tools/use_case/actions/search.js.map +1 -1
- package/dist/tools/use_case/help/example.d.ts +2 -7
- package/dist/tools/use_case/help/example.d.ts.map +1 -1
- package/dist/tools/use_case/help/example.js +24 -37
- package/dist/tools/use_case/help/example.js.map +1 -1
- package/dist/tools/use_case/help/help.js +1 -1
- package/dist/tools/use_case/help/help.js.map +1 -1
- package/dist/types/actions.d.ts +1 -1
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types.d.ts +11 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/action-specs/constraint-specs.d.ts +1 -1
- package/dist/utils/action-specs/constraint-specs.d.ts.map +1 -1
- package/dist/utils/action-specs/constraint-specs.js +22 -5
- package/dist/utils/action-specs/constraint-specs.js.map +1 -1
- package/dist/utils/action-specs/decision-specs.js +13 -13
- package/dist/utils/action-specs/decision-specs.js.map +1 -1
- package/dist/utils/action-specs/file-specs.d.ts.map +1 -1
- package/dist/utils/action-specs/file-specs.js +8 -10
- package/dist/utils/action-specs/file-specs.js.map +1 -1
- package/dist/utils/db-aggregations.d.ts.map +1 -1
- package/dist/utils/db-aggregations.js +44 -1
- package/dist/utils/db-aggregations.js.map +1 -1
- package/dist/utils/hook-queue.d.ts +43 -3
- package/dist/utils/hook-queue.d.ts.map +1 -1
- package/dist/utils/hook-queue.js +326 -32
- package/dist/utils/hook-queue.js.map +1 -1
- package/dist/utils/param-normalizer.d.ts +52 -0
- package/dist/utils/param-normalizer.d.ts.map +1 -0
- package/dist/utils/param-normalizer.js +70 -0
- package/dist/utils/param-normalizer.js.map +1 -0
- package/dist/utils/parameter-validator.d.ts.map +1 -1
- package/dist/utils/parameter-validator.js +2 -0
- package/dist/utils/parameter-validator.js.map +1 -1
- package/dist/utils/project-detector.js +21 -6
- package/dist/utils/project-detector.js.map +1 -1
- package/dist/utils/suggestion-scorer.d.ts.map +1 -1
- package/dist/utils/suggestion-scorer.js +5 -0
- package/dist/utils/suggestion-scorer.js.map +1 -1
- package/dist/utils/text-truncate.d.ts +13 -0
- package/dist/utils/text-truncate.d.ts.map +1 -0
- package/dist/utils/text-truncate.js +18 -0
- package/dist/utils/text-truncate.js.map +1 -0
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.d.ts.map +1 -1
- package/dist/utils/validators.js +1 -1
- package/dist/utils/validators.js.map +1 -1
- package/dist/watcher/base-watcher.d.ts.map +1 -1
- package/dist/watcher/base-watcher.js +4 -3
- package/dist/watcher/base-watcher.js.map +1 -1
- package/dist/watcher/file-watcher.d.ts.map +1 -1
- package/dist/watcher/file-watcher.js +5 -1
- package/dist/watcher/file-watcher.js.map +1 -1
- package/dist/watcher/queue-watcher.d.ts +12 -1
- package/dist/watcher/queue-watcher.d.ts.map +1 -1
- package/dist/watcher/queue-watcher.js +92 -12
- package/dist/watcher/queue-watcher.js.map +1 -1
- package/docs/ADR_CONCEPTS.md +4 -0
- package/docs/HOOKS_GUIDE.md +1 -1
- package/package.json +87 -123
- package/dist/tests/feature/vcs/git-aware-completion.test.d.ts +0 -6
- package/dist/tests/feature/vcs/git-aware-completion.test.d.ts.map +0 -1
- package/dist/tests/feature/vcs/git-aware-completion.test.js +0 -197
- package/dist/tests/feature/vcs/git-aware-completion.test.js.map +0 -1
- package/dist/tests/feature/vcs/two-step-git-completion.test.d.ts +0 -6
- package/dist/tests/feature/vcs/two-step-git-completion.test.d.ts.map +0 -1
- package/dist/tests/feature/vcs/two-step-git-completion.test.js +0 -305
- package/dist/tests/feature/vcs/two-step-git-completion.test.js.map +0 -1
- package/dist/tests/feature/vcs/vcs-staging.test.d.ts +0 -6
- package/dist/tests/feature/vcs/vcs-staging.test.d.ts.map +0 -1
- package/dist/tests/feature/vcs/vcs-staging.test.js +0 -142
- package/dist/tests/feature/vcs/vcs-staging.test.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activate constraints (by tag or by ID)
|
|
3
|
+
*
|
|
4
|
+
* - activateConstraintsByTag: Bulk activate by tag (for plan-based workflow)
|
|
5
|
+
* - activateConstraint: Single constraint by ID (MCP action)
|
|
6
|
+
*
|
|
7
|
+
* @since v4.2.1
|
|
8
|
+
*/
|
|
9
|
+
import { DatabaseAdapter } from '../../../adapters/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Activate constraints by tag response
|
|
12
|
+
*/
|
|
13
|
+
export interface ActivateConstraintsResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
activated_count: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Activate constraint by ID response
|
|
19
|
+
*/
|
|
20
|
+
export interface ActivateConstraintByIdResponse {
|
|
21
|
+
success: boolean;
|
|
22
|
+
constraint_id: number;
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Activate all constraints matching a specific tag
|
|
27
|
+
*
|
|
28
|
+
* Used by queue-watcher to activate constraints when implementation starts.
|
|
29
|
+
* The tag typically contains the plan_id short form (8 chars).
|
|
30
|
+
*
|
|
31
|
+
* @param tag - Tag to match (e.g., plan_id short form)
|
|
32
|
+
* @param adapter - Optional database adapter (for testing)
|
|
33
|
+
* @returns Number of constraints activated
|
|
34
|
+
*/
|
|
35
|
+
export declare function activateConstraintsByTag(tag: string, adapter?: DatabaseAdapter): Promise<ActivateConstraintsResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Activate a single constraint by ID
|
|
38
|
+
*
|
|
39
|
+
* @param params - Parameters containing constraint_id
|
|
40
|
+
* @param adapter - Optional database adapter (for testing)
|
|
41
|
+
* @returns Success response with constraint ID
|
|
42
|
+
*/
|
|
43
|
+
export declare function activateConstraint(params: {
|
|
44
|
+
constraint_id: number;
|
|
45
|
+
}, adapter?: DatabaseAdapter): Promise<ActivateConstraintByIdResponse>;
|
|
46
|
+
//# sourceMappingURL=activate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activate.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/activate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,2BAA2B,CAAC,CAqCtC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,EACjC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,8BAA8B,CAAC,CA6CzC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activate constraints (by tag or by ID)
|
|
3
|
+
*
|
|
4
|
+
* - activateConstraintsByTag: Bulk activate by tag (for plan-based workflow)
|
|
5
|
+
* - activateConstraint: Single constraint by ID (MCP action)
|
|
6
|
+
*
|
|
7
|
+
* @since v4.2.1
|
|
8
|
+
*/
|
|
9
|
+
import { getAdapter } from '../../../database.js';
|
|
10
|
+
import { getProjectContext } from '../../../utils/project-context.js';
|
|
11
|
+
import { normalizeParams, CONSTRAINT_ALIASES } from '../../../utils/param-normalizer.js';
|
|
12
|
+
import connectionManager from '../../../utils/connection-manager.js';
|
|
13
|
+
import { SQLITE_TRUE } from '../../../constants.js';
|
|
14
|
+
/**
|
|
15
|
+
* Activate all constraints matching a specific tag
|
|
16
|
+
*
|
|
17
|
+
* Used by queue-watcher to activate constraints when implementation starts.
|
|
18
|
+
* The tag typically contains the plan_id short form (8 chars).
|
|
19
|
+
*
|
|
20
|
+
* @param tag - Tag to match (e.g., plan_id short form)
|
|
21
|
+
* @param adapter - Optional database adapter (for testing)
|
|
22
|
+
* @returns Number of constraints activated
|
|
23
|
+
*/
|
|
24
|
+
export async function activateConstraintsByTag(tag, adapter) {
|
|
25
|
+
const actualAdapter = adapter ?? getAdapter();
|
|
26
|
+
const knex = actualAdapter.getKnex();
|
|
27
|
+
try {
|
|
28
|
+
return await connectionManager.executeWithRetry(async () => {
|
|
29
|
+
const projectId = getProjectContext().getProjectId();
|
|
30
|
+
// Find constraints with matching tag that are inactive
|
|
31
|
+
const constraintIds = await knex('v4_constraints as c')
|
|
32
|
+
.join('v4_constraint_tags as ct', 'c.id', 'ct.constraint_id')
|
|
33
|
+
.join('v4_tags as t', 'ct.tag_id', 't.id')
|
|
34
|
+
.where('c.project_id', projectId)
|
|
35
|
+
.where('c.active', 0)
|
|
36
|
+
.where('t.name', tag)
|
|
37
|
+
.select('c.id')
|
|
38
|
+
.then(rows => rows.map(r => r.id));
|
|
39
|
+
if (constraintIds.length === 0) {
|
|
40
|
+
return { success: true, activated_count: 0 };
|
|
41
|
+
}
|
|
42
|
+
// Activate all matching constraints
|
|
43
|
+
await knex('v4_constraints')
|
|
44
|
+
.whereIn('id', constraintIds)
|
|
45
|
+
.where('project_id', projectId)
|
|
46
|
+
.update({ active: SQLITE_TRUE });
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
activated_count: constraintIds.length,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
throw new Error(`Failed to activate constraints: ${message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Activate a single constraint by ID
|
|
60
|
+
*
|
|
61
|
+
* @param params - Parameters containing constraint_id
|
|
62
|
+
* @param adapter - Optional database adapter (for testing)
|
|
63
|
+
* @returns Success response with constraint ID
|
|
64
|
+
*/
|
|
65
|
+
export async function activateConstraint(params, adapter) {
|
|
66
|
+
const actualAdapter = adapter ?? getAdapter();
|
|
67
|
+
const knex = actualAdapter.getKnex();
|
|
68
|
+
// Normalize aliases: id → constraint_id
|
|
69
|
+
const normalizedParams = normalizeParams(params, CONSTRAINT_ALIASES);
|
|
70
|
+
try {
|
|
71
|
+
return await connectionManager.executeWithRetry(async () => {
|
|
72
|
+
const projectId = getProjectContext().getProjectId();
|
|
73
|
+
// Check if constraint exists
|
|
74
|
+
const constraint = await knex('v4_constraints')
|
|
75
|
+
.where('id', normalizedParams.constraint_id)
|
|
76
|
+
.where('project_id', projectId)
|
|
77
|
+
.first();
|
|
78
|
+
if (!constraint) {
|
|
79
|
+
throw new Error(`Constraint not found: ${normalizedParams.constraint_id}`);
|
|
80
|
+
}
|
|
81
|
+
if (constraint.active === 1) {
|
|
82
|
+
return {
|
|
83
|
+
success: true,
|
|
84
|
+
constraint_id: normalizedParams.constraint_id,
|
|
85
|
+
message: 'Constraint already active',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Activate the constraint
|
|
89
|
+
await knex('v4_constraints')
|
|
90
|
+
.where('id', normalizedParams.constraint_id)
|
|
91
|
+
.where('project_id', projectId)
|
|
92
|
+
.update({ active: SQLITE_TRUE });
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
constraint_id: normalizedParams.constraint_id,
|
|
96
|
+
message: 'Constraint activated',
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
102
|
+
throw new Error(`Failed to activate constraint: ${message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=activate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activate.js","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/activate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAmBpD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,GAAW,EACX,OAAyB;IAEzB,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;IAErC,IAAI,CAAC;QACH,OAAO,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE;YACzD,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC,YAAY,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;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/add.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/add.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAmB7D,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,qBAAqB,CAAC,CA+FhC"}
|
|
@@ -6,6 +6,7 @@ import { getAdapter, getLayerId, getOrCreateTag, getOrCreateCategoryId } from '.
|
|
|
6
6
|
import { STRING_TO_PRIORITY, DEFAULT_PRIORITY, SQLITE_TRUE, STANDARD_LAYERS } from '../../../constants.js';
|
|
7
7
|
import { validateCategory, validatePriority } from '../../../utils/validators.js';
|
|
8
8
|
import { validateActionParams } from '../../../utils/parameter-validator.js';
|
|
9
|
+
import { normalizeParams, CONSTRAINT_ALIASES } from '../../../utils/param-normalizer.js';
|
|
9
10
|
import { parseStringArray } from '../../../utils/param-parser.js';
|
|
10
11
|
import { getProjectContext } from '../../../utils/project-context.js';
|
|
11
12
|
import connectionManager from '../../../utils/connection-manager.js';
|
|
@@ -18,50 +19,65 @@ import connectionManager from '../../../utils/connection-manager.js';
|
|
|
18
19
|
*/
|
|
19
20
|
export async function addConstraint(params, adapter) {
|
|
20
21
|
const actualAdapter = adapter ?? getAdapter();
|
|
22
|
+
// Normalize aliases: text → constraint_text
|
|
23
|
+
const normalizedParams = normalizeParams(params, CONSTRAINT_ALIASES);
|
|
21
24
|
try {
|
|
22
25
|
return await connectionManager.executeWithRetry(async () => {
|
|
23
26
|
// Fail-fast project_id validation (Constraint #29)
|
|
24
27
|
const projectId = getProjectContext().getProjectId();
|
|
25
28
|
// Validate parameters
|
|
26
|
-
validateActionParams('constraint', 'add',
|
|
29
|
+
validateActionParams('constraint', 'add', normalizedParams);
|
|
27
30
|
// Validate category
|
|
28
|
-
validateCategory(
|
|
31
|
+
validateCategory(normalizedParams.category);
|
|
29
32
|
// Validate priority if provided
|
|
30
|
-
const priorityStr =
|
|
33
|
+
const priorityStr = normalizedParams.priority || 'medium';
|
|
31
34
|
validatePriority(priorityStr);
|
|
32
35
|
const priority = STRING_TO_PRIORITY[priorityStr] || DEFAULT_PRIORITY;
|
|
33
36
|
// Validate and get layer ID if provided
|
|
34
37
|
let layerId = null;
|
|
35
|
-
if (
|
|
36
|
-
if (!STANDARD_LAYERS.includes(
|
|
38
|
+
if (normalizedParams.layer) {
|
|
39
|
+
if (!STANDARD_LAYERS.includes(normalizedParams.layer)) {
|
|
37
40
|
throw new Error(`Invalid layer. Must be one of: ${STANDARD_LAYERS.join(', ')}`);
|
|
38
41
|
}
|
|
39
|
-
layerId = await getLayerId(actualAdapter,
|
|
42
|
+
layerId = await getLayerId(actualAdapter, normalizedParams.layer);
|
|
40
43
|
if (!layerId) {
|
|
41
|
-
throw new Error(`Layer not found: ${
|
|
44
|
+
throw new Error(`Layer not found: ${normalizedParams.layer}`);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
// Use transaction for multi-table insert
|
|
45
48
|
const result = await actualAdapter.transaction(async (trx) => {
|
|
46
49
|
// Get or create category
|
|
47
|
-
const categoryId = await getOrCreateCategoryId(actualAdapter,
|
|
50
|
+
const categoryId = await getOrCreateCategoryId(actualAdapter, normalizedParams.category, trx);
|
|
51
|
+
// Duplicate check: skip if same text + category already exists
|
|
52
|
+
const existing = await trx('v4_constraints')
|
|
53
|
+
.where({
|
|
54
|
+
constraint_text: normalizedParams.constraint_text,
|
|
55
|
+
category_id: categoryId,
|
|
56
|
+
project_id: projectId
|
|
57
|
+
})
|
|
58
|
+
.first();
|
|
59
|
+
if (existing) {
|
|
60
|
+
return { constraintId: existing.id, alreadyExists: true };
|
|
61
|
+
}
|
|
48
62
|
// Note: Agent tracking removed in v4.0 (created_by param kept for API compatibility but not stored)
|
|
49
63
|
// Calculate timestamp
|
|
50
64
|
const ts = Math.floor(Date.now() / 1000);
|
|
51
65
|
// Insert constraint with project_id (agent_id removed in v4.0)
|
|
66
|
+
// v4.2.1: Support active parameter for plan-based workflow
|
|
67
|
+
const activeValue = normalizedParams.active === false ? 0 : SQLITE_TRUE;
|
|
52
68
|
const [constraintId] = await trx('v4_constraints').insert({
|
|
53
69
|
category_id: categoryId,
|
|
54
70
|
layer_id: layerId,
|
|
55
|
-
constraint_text:
|
|
71
|
+
constraint_text: normalizedParams.constraint_text,
|
|
56
72
|
priority: priority,
|
|
57
|
-
active:
|
|
73
|
+
active: activeValue,
|
|
58
74
|
ts: ts,
|
|
59
75
|
project_id: projectId
|
|
60
76
|
});
|
|
61
77
|
// Insert m_tags if provided
|
|
62
|
-
if (
|
|
78
|
+
if (normalizedParams.tags && normalizedParams.tags.length > 0) {
|
|
63
79
|
// Parse tags (handles both arrays and JSON strings from MCP)
|
|
64
|
-
const tags = parseStringArray(
|
|
80
|
+
const tags = parseStringArray(normalizedParams.tags);
|
|
65
81
|
for (const tagName of tags) {
|
|
66
82
|
const tagId = await getOrCreateTag(actualAdapter, projectId, tagName, trx); // v3.7.3: pass projectId
|
|
67
83
|
await trx('v4_constraint_tags').insert({
|
|
@@ -70,11 +86,12 @@ export async function addConstraint(params, adapter) {
|
|
|
70
86
|
});
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
|
-
return { constraintId: Number(constraintId) };
|
|
89
|
+
return { constraintId: Number(constraintId), alreadyExists: false };
|
|
74
90
|
});
|
|
75
91
|
return {
|
|
76
92
|
success: true,
|
|
77
93
|
constraint_id: result.constraintId,
|
|
94
|
+
already_exists: result.alreadyExists,
|
|
78
95
|
};
|
|
79
96
|
});
|
|
80
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/add.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AAMrE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA2B,EAC3B,OAAyB;IAEzB,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAE9C,IAAI,CAAC;QACH,OAAO,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE;YACzD,mDAAmD;YACnD,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC,YAAY,EAAE,CAAC;YAErD,sBAAsB;YACtB,oBAAoB,CAAC,YAAY,E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BACb,aAAa,EAAE,MAAM,CAAC,YAAY;gBAClC,cAAc,EAAE,MAAM,CAAC,aAAa;aACrC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/deactivate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/deactivate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,0BAA0B,EAClC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,4BAA4B,CAAC,CAsCvC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getAdapter } from '../../../database.js';
|
|
6
6
|
import { validateActionParams } from '../../../utils/parameter-validator.js';
|
|
7
|
+
import { normalizeParams, CONSTRAINT_ALIASES } from '../../../utils/param-normalizer.js';
|
|
7
8
|
import { getProjectContext } from '../../../utils/project-context.js';
|
|
8
9
|
import connectionManager from '../../../utils/connection-manager.js';
|
|
9
10
|
import { SQLITE_FALSE } from '../../../constants.js';
|
|
@@ -18,23 +19,25 @@ import { SQLITE_FALSE } from '../../../constants.js';
|
|
|
18
19
|
export async function deactivateConstraint(params, adapter) {
|
|
19
20
|
const actualAdapter = adapter ?? getAdapter();
|
|
20
21
|
const knex = actualAdapter.getKnex();
|
|
22
|
+
// Normalize aliases: id → constraint_id
|
|
23
|
+
const normalizedParams = normalizeParams(params, CONSTRAINT_ALIASES);
|
|
21
24
|
try {
|
|
22
25
|
return await connectionManager.executeWithRetry(async () => {
|
|
23
26
|
// Fail-fast project_id validation (Constraint #29)
|
|
24
27
|
const projectId = getProjectContext().getProjectId();
|
|
25
28
|
// Validate parameters
|
|
26
|
-
validateActionParams('constraint', 'deactivate',
|
|
29
|
+
validateActionParams('constraint', 'deactivate', normalizedParams);
|
|
27
30
|
// Check if constraint exists in current project
|
|
28
31
|
const constraint = await knex('v4_constraints')
|
|
29
|
-
.where({ id:
|
|
32
|
+
.where({ id: normalizedParams.constraint_id, project_id: projectId })
|
|
30
33
|
.select('id', 'active')
|
|
31
34
|
.first();
|
|
32
35
|
if (!constraint) {
|
|
33
|
-
throw new Error(`Constraint not found: ${
|
|
36
|
+
throw new Error(`Constraint not found: ${normalizedParams.constraint_id}`);
|
|
34
37
|
}
|
|
35
38
|
// Update constraint to inactive (idempotent) with project_id filter
|
|
36
39
|
await knex('v4_constraints')
|
|
37
|
-
.where({ id:
|
|
40
|
+
.where({ id: normalizedParams.constraint_id, project_id: projectId })
|
|
38
41
|
.update({ active: SQLITE_FALSE });
|
|
39
42
|
return {
|
|
40
43
|
success: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/deactivate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CA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;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EAEvB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/get.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAS7D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EAEvB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,sBAAsB,CAAC,CAyGjC"}
|
|
@@ -32,8 +32,11 @@ export async function getConstraints(params, adapter) {
|
|
|
32
32
|
let query = knex('v4_constraints as c')
|
|
33
33
|
.join('v4_constraint_categories as cat', 'c.category_id', 'cat.id')
|
|
34
34
|
.leftJoin('v4_layers as l', 'c.layer_id', 'l.id')
|
|
35
|
-
.where('c.project_id', projectId)
|
|
36
|
-
|
|
35
|
+
.where('c.project_id', projectId);
|
|
36
|
+
// Filter by active status (default: active only, unless include_inactive=true)
|
|
37
|
+
if (!params.include_inactive) {
|
|
38
|
+
query = query.where('c.active', db.boolTrue());
|
|
39
|
+
}
|
|
37
40
|
// Filter by category
|
|
38
41
|
if (params.category) {
|
|
39
42
|
validateCategory(params.category);
|
|
@@ -83,11 +86,11 @@ export async function getConstraints(params, adapter) {
|
|
|
83
86
|
'c.priority',
|
|
84
87
|
knex.raw(`${db.dateFunction('c.ts')} as created_at`),
|
|
85
88
|
// Tags subquery
|
|
86
|
-
knex.raw(`(
|
|
87
|
-
SELECT ${db.stringAgg('t2.name', ',')}
|
|
88
|
-
FROM v4_constraint_tags ct2
|
|
89
|
-
JOIN v4_tags t2 ON ct2.tag_id = t2.id
|
|
90
|
-
WHERE ct2.constraint_id = c.id
|
|
89
|
+
knex.raw(`(
|
|
90
|
+
SELECT ${db.stringAgg('t2.name', ',')}
|
|
91
|
+
FROM v4_constraint_tags ct2
|
|
92
|
+
JOIN v4_tags t2 ON ct2.tag_id = t2.id
|
|
93
|
+
WHERE ct2.constraint_id = c.id
|
|
91
94
|
) as tags`),
|
|
92
95
|
]);
|
|
93
96
|
// Convert priority integer to string and parse tags
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/get.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAOxE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,OAAyB;IAEzB,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;IAErC,IAAI,CAAC;QACH,OAAO,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE;YACzD,mDAAmD;YACnD,MAAM,SAAS,GAAG,iBAAiB,E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E,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;;;;kBAI7B,CAAC;aACZ,CAAC,CAAC;YAEH,oDAAoD;YACpD,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAuB,CAAC;YACjE,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACnC,GAAG,GAAG;gBACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;aAC5C,CAAC,CAAU,CAAC;YAEb,OAAO;gBACL,WAAW;gBACX,KAAK,EAAE,WAAW,CAAC,MAAM;aAC1B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest Pending Constraints Action (v4.2.0+)
|
|
3
|
+
*
|
|
4
|
+
* Returns constraint candidates from plan TOML cache that haven't been registered yet.
|
|
5
|
+
* Allows AI to re-suggest constraints after task completion.
|
|
6
|
+
*
|
|
7
|
+
* This action does NOT require database access - it reads from the session cache.
|
|
8
|
+
*/
|
|
9
|
+
import { type ConstraintCandidate } from '../../../config/global-config.js';
|
|
10
|
+
/**
|
|
11
|
+
* Parameters for suggest_pending action
|
|
12
|
+
*/
|
|
13
|
+
export interface SuggestPendingParams {
|
|
14
|
+
/** Project path (optional, uses CWD if not specified) */
|
|
15
|
+
project_path?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Response from suggest_pending action
|
|
19
|
+
*/
|
|
20
|
+
export interface SuggestPendingResponse {
|
|
21
|
+
/** Whether there are pending constraints */
|
|
22
|
+
has_pending: boolean;
|
|
23
|
+
/** Plan ID associated with the constraints */
|
|
24
|
+
plan_id: string | null;
|
|
25
|
+
/** Plan file name */
|
|
26
|
+
plan_file: string | null;
|
|
27
|
+
/** Pending constraint candidates */
|
|
28
|
+
constraints: ConstraintCandidate[];
|
|
29
|
+
/** MCP command examples for registration */
|
|
30
|
+
commands: string[];
|
|
31
|
+
/** User-friendly message */
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get pending constraint candidates from plan TOML cache
|
|
36
|
+
*
|
|
37
|
+
* @param params - Action parameters
|
|
38
|
+
* @returns Pending constraints with registration commands
|
|
39
|
+
*/
|
|
40
|
+
export declare function suggestPendingConstraints(params?: SuggestPendingParams): Promise<SuggestPendingResponse>;
|
|
41
|
+
//# sourceMappingURL=suggest-pending.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest-pending.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/suggest-pending.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAM1C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,WAAW,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qBAAqB;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oCAAoC;IACpC,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,GAAE,oBAAyB,GAChC,OAAO,CAAC,sBAAsB,CAAC,CAwDjC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Suggest Pending Constraints Action (v4.2.0+)
|
|
3
|
+
*
|
|
4
|
+
* Returns constraint candidates from plan TOML cache that haven't been registered yet.
|
|
5
|
+
* Allows AI to re-suggest constraints after task completion.
|
|
6
|
+
*
|
|
7
|
+
* This action does NOT require database access - it reads from the session cache.
|
|
8
|
+
*/
|
|
9
|
+
import { loadPlanTomlCache, loadCurrentPlan, } from '../../../config/global-config.js';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Action Implementation
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Get pending constraint candidates from plan TOML cache
|
|
15
|
+
*
|
|
16
|
+
* @param params - Action parameters
|
|
17
|
+
* @returns Pending constraints with registration commands
|
|
18
|
+
*/
|
|
19
|
+
export async function suggestPendingConstraints(params = {}) {
|
|
20
|
+
const projectPath = params.project_path || process.cwd();
|
|
21
|
+
// Load current plan info
|
|
22
|
+
const planInfo = loadCurrentPlan(projectPath);
|
|
23
|
+
if (!planInfo) {
|
|
24
|
+
return {
|
|
25
|
+
has_pending: false,
|
|
26
|
+
plan_id: null,
|
|
27
|
+
plan_file: null,
|
|
28
|
+
constraints: [],
|
|
29
|
+
commands: [],
|
|
30
|
+
message: 'No active plan found. Use Plan agent to create a plan first.',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Load plan TOML cache
|
|
34
|
+
const cache = loadPlanTomlCache(projectPath);
|
|
35
|
+
if (!cache || cache.plan_id !== planInfo.plan_id) {
|
|
36
|
+
return {
|
|
37
|
+
has_pending: false,
|
|
38
|
+
plan_id: planInfo.plan_id,
|
|
39
|
+
plan_file: planInfo.plan_file,
|
|
40
|
+
constraints: [],
|
|
41
|
+
commands: [],
|
|
42
|
+
message: `Plan "${planInfo.plan_file}" has no TOML-defined constraints.`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (cache.constraints.length === 0) {
|
|
46
|
+
return {
|
|
47
|
+
has_pending: false,
|
|
48
|
+
plan_id: cache.plan_id,
|
|
49
|
+
plan_file: planInfo.plan_file,
|
|
50
|
+
constraints: [],
|
|
51
|
+
commands: [],
|
|
52
|
+
message: `Plan "${planInfo.plan_file}" has no constraint candidates.`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Generate MCP commands for each constraint
|
|
56
|
+
const commands = cache.constraints.map((c) => {
|
|
57
|
+
const priority = c.priority || 'medium';
|
|
58
|
+
const layer = c.layer ? ` layer="${c.layer}"` : '';
|
|
59
|
+
const tags = c.tags && c.tags.length > 0 ? ` tags="${c.tags.join(',')}"` : '';
|
|
60
|
+
return `mcp__sqlew__constraint action="add" constraint_text="${c.text}" category="${c.category}" priority="${priority}"${layer}${tags}`;
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
has_pending: true,
|
|
64
|
+
plan_id: cache.plan_id,
|
|
65
|
+
plan_file: planInfo.plan_file,
|
|
66
|
+
constraints: cache.constraints,
|
|
67
|
+
commands,
|
|
68
|
+
message: `Found ${cache.constraints.length} constraint candidate(s) from plan "${planInfo.plan_file}".`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=suggest-pending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest-pending.js","sourceRoot":"","sources":["../../../../src/tools/constraints/actions/suggest-pending.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,iBAAiB,EACjB,eAAe,GAIhB,MAAM,kCAAkC,CAAC;AAgC1C,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU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IAAI,QAAQ,CAAC;QACxC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO,wDAAwD,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,QAAQ,eAAe,QAAQ,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;IAC1I,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ;QACR,OAAO,EAAE,SAAS,KAAK,CAAC,WAAW,CAAC,MAAM,uCAAuC,QAAQ,CAAC,SAAS,IAAI;KACxG,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/help/example.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../../../src/tools/constraints/help/example.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,CAuMvC"}
|
|
@@ -69,16 +69,78 @@ export function constraintExample() {
|
|
|
69
69
|
rationale: 'Prevents injection attacks (SQL, XSS, etc.)'
|
|
70
70
|
}
|
|
71
71
|
]
|
|
72
|
+
},
|
|
73
|
+
'code-style': {
|
|
74
|
+
description: 'Code style constraints for naming conventions, formatting, documentation',
|
|
75
|
+
examples: [
|
|
76
|
+
{
|
|
77
|
+
scenario: 'Naming Convention',
|
|
78
|
+
example: '{ action: "add", category: "code-style", constraint_text: "All public functions must use camelCase naming", priority: "medium", layer: "cross-cutting", tags: ["naming", "convention"] }',
|
|
79
|
+
rationale: 'Ensures consistent code readability across the codebase'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
scenario: 'Documentation Required',
|
|
83
|
+
example: '{ action: "add", category: "code-style", constraint_text: "All public APIs must have JSDoc comments", priority: "medium", layer: "documentation", tags: ["jsdoc", "api"] }',
|
|
84
|
+
rationale: 'Improves maintainability and developer experience'
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
management: {
|
|
90
|
+
activate: {
|
|
91
|
+
description: 'Reactivate a previously deactivated constraint',
|
|
92
|
+
examples: [
|
|
93
|
+
{
|
|
94
|
+
scenario: 'Reactivate Constraint',
|
|
95
|
+
example: '{ action: "activate", constraint_id: 5 }',
|
|
96
|
+
rationale: 'Use when a temporarily deactivated constraint should be enforced again'
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
deactivate: {
|
|
101
|
+
description: 'Deactivate a constraint without deleting it',
|
|
102
|
+
examples: [
|
|
103
|
+
{
|
|
104
|
+
scenario: 'Temporarily Disable Constraint',
|
|
105
|
+
example: '{ action: "deactivate", constraint_id: 5 }',
|
|
106
|
+
rationale: 'Useful for temporary exceptions or during refactoring'
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
get_with_inactive: {
|
|
111
|
+
description: 'Retrieve all constraints including inactive ones',
|
|
112
|
+
examples: [
|
|
113
|
+
{
|
|
114
|
+
scenario: 'List All Constraints',
|
|
115
|
+
example: '{ action: "get", include_inactive: true }',
|
|
116
|
+
rationale: 'Review all constraints including deactivated ones for audit or reactivation'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
scenario: 'Filter by Category with Inactive',
|
|
120
|
+
example: '{ action: "get", category: "security", include_inactive: true }',
|
|
121
|
+
rationale: 'See all security constraints to identify ones that might need reactivation'
|
|
122
|
+
}
|
|
123
|
+
]
|
|
72
124
|
}
|
|
73
125
|
},
|
|
74
126
|
workflows: {
|
|
127
|
+
constraint_lifecycle: {
|
|
128
|
+
description: 'Full lifecycle of a constraint from creation to deactivation/reactivation',
|
|
129
|
+
steps: [
|
|
130
|
+
{ step: 1, action: 'Add new constraint', example: '{ action: "add", category: "security", constraint_text: "All passwords must be hashed with bcrypt", priority: "critical" }' },
|
|
131
|
+
{ step: 2, action: 'Retrieve active constraints', example: '{ action: "get", category: "security" }' },
|
|
132
|
+
{ step: 3, action: 'Temporarily deactivate during migration', example: '{ action: "deactivate", constraint_id: 5 }' },
|
|
133
|
+
{ step: 4, action: 'List all including inactive for review', example: '{ action: "get", include_inactive: true }' },
|
|
134
|
+
{ step: 5, action: 'Reactivate after migration complete', example: '{ action: "activate", constraint_id: 5 }' }
|
|
135
|
+
]
|
|
136
|
+
},
|
|
75
137
|
constraint_validation: {
|
|
76
138
|
description: 'Workflow for validating code against constraints',
|
|
77
139
|
steps: [
|
|
78
140
|
{
|
|
79
141
|
step: 1,
|
|
80
142
|
action: 'Retrieve active constraints for layer',
|
|
81
|
-
example: '{ action: "get", layer: "business"
|
|
143
|
+
example: '{ action: "get", layer: "business" }'
|
|
82
144
|
},
|
|
83
145
|
{
|
|
84
146
|
step: 2,
|
|
@@ -133,6 +195,8 @@ export function constraintExample() {
|
|
|
133
195
|
],
|
|
134
196
|
managing_constraints: [
|
|
135
197
|
'Review constraints regularly and deactivate outdated ones',
|
|
198
|
+
'Use activate/deactivate for temporary exceptions instead of deleting',
|
|
199
|
+
'Periodically review inactive constraints with include_inactive: true',
|
|
136
200
|
'Link constraints to related decisions and tasks',
|
|
137
201
|
'Use constraints for both technical and business requirements',
|
|
138
202
|
'Validate code changes against active constraints',
|