@devtrack-solution/codesdd 1.2.2 → 1.2.3
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/.sdd/skills/curated/api-clean-flask-langgraph/SKILL.md +17 -17
- package/.sdd/skills/curated/devtrack-api/SKILL.md +160 -28
- package/.sdd/skills/curated/devtrack-api/agents/openai.yaml +1 -1
- package/.sdd/skills/curated/devtrack-api/references/architecture-governance.md +8 -7
- package/.sdd/skills/curated/devtrack-api/references/consumer-sync-policy.md +93 -0
- package/.sdd/skills/curated/devtrack-api/references/contract-pack.yaml +317 -0
- package/.sdd/skills/curated/devtrack-api/references/field-validation-protocol.md +95 -0
- package/.sdd/skills/curated/devtrack-api/references/foundation-layout.md +295 -0
- package/.sdd/skills/curated/devtrack-api/references/implementation-checklist.md +4 -4
- package/.sdd/skills/curated/devtrack-api/references/imports-lint.md +4 -0
- package/.sdd/skills/curated/devtrack-api/references/testing-validation.md +2 -2
- package/LICENSE +1 -1
- package/README.md +243 -51
- package/bin/codesdd.js +3 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +11 -558
- package/dist/cli/program.d.ts +14 -0
- package/dist/cli/program.js +645 -0
- package/dist/commands/change.js +5 -5
- package/dist/commands/completion.d.ts +1 -1
- package/dist/commands/completion.js +9 -2
- package/dist/commands/config.js +159 -20
- package/dist/commands/feedback.js +1 -1
- package/dist/commands/schema.d.ts +63 -0
- package/dist/commands/schema.js +12 -12
- package/dist/commands/sdd/backlog.d.ts +3 -0
- package/dist/commands/sdd/backlog.js +54 -0
- package/dist/commands/sdd/execution.js +147 -16
- package/dist/commands/sdd/plugin.d.ts +3 -0
- package/dist/commands/sdd/plugin.js +153 -0
- package/dist/commands/sdd/shared.js +2 -23
- package/dist/commands/sdd/skills.js +7 -0
- package/dist/commands/sdd.js +69 -12
- package/dist/commands/spec.js +9 -9
- package/dist/commands/validate.js +6 -6
- package/dist/commands/workflow/instructions.js +6 -6
- package/dist/commands/workflow/new-change.js +3 -3
- package/dist/commands/workflow/shared.d.ts +1 -1
- package/dist/commands/workflow/shared.js +4 -4
- package/dist/core/archive.js +15 -5
- package/dist/core/artifact-graph/instruction-loader.d.ts +1 -1
- package/dist/core/artifact-graph/instruction-loader.js +3 -3
- package/dist/core/artifact-graph/resolver.d.ts +4 -4
- package/dist/core/artifact-graph/resolver.js +6 -6
- package/dist/core/branding.js +3 -3
- package/dist/core/cli/command-matrix.js +10 -1
- package/dist/core/cli-command-quality.d.ts +27 -0
- package/dist/core/cli-command-quality.js +171 -0
- package/dist/core/command-generation/adapters/costrict.d.ts +1 -1
- package/dist/core/command-generation/adapters/costrict.js +2 -2
- package/dist/core/command-generation/types.d.ts +1 -1
- package/dist/core/completions/command-registry.d.ts +1 -1
- package/dist/core/completions/command-registry.js +155 -12
- package/dist/core/completions/completion-provider.d.ts +14 -1
- package/dist/core/completions/completion-provider.js +29 -1
- package/dist/core/completions/generators/bash-generator.d.ts +1 -1
- package/dist/core/completions/generators/bash-generator.js +20 -12
- package/dist/core/completions/generators/fish-generator.d.ts +9 -1
- package/dist/core/completions/generators/fish-generator.js +39 -25
- package/dist/core/completions/generators/powershell-generator.d.ts +1 -1
- package/dist/core/completions/generators/powershell-generator.js +21 -11
- package/dist/core/completions/generators/zsh-generator.d.ts +3 -6
- package/dist/core/completions/generators/zsh-generator.js +21 -42
- package/dist/core/completions/installers/bash-installer.js +6 -6
- package/dist/core/completions/installers/fish-installer.js +1 -1
- package/dist/core/completions/installers/powershell-installer.js +14 -14
- package/dist/core/completions/installers/zsh-installer.d.ts +7 -1
- package/dist/core/completions/installers/zsh-installer.js +36 -8
- package/dist/core/completions/templates/bash-templates.d.ts +1 -1
- package/dist/core/completions/templates/bash-templates.js +12 -6
- package/dist/core/completions/templates/fish-templates.d.ts +2 -2
- package/dist/core/completions/templates/fish-templates.js +20 -9
- package/dist/core/completions/templates/powershell-templates.d.ts +1 -1
- package/dist/core/completions/templates/powershell-templates.js +13 -4
- package/dist/core/completions/templates/zsh-templates.d.ts +1 -1
- package/dist/core/completions/templates/zsh-templates.js +18 -9
- package/dist/core/config-schema.d.ts +3 -1
- package/dist/core/config-schema.js +26 -1
- package/dist/core/config.d.ts +3 -3
- package/dist/core/config.js +4 -4
- package/dist/core/global-config.d.ts +41 -12
- package/dist/core/global-config.js +344 -27
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/init.d.ts +6 -1
- package/dist/core/init.js +99 -77
- package/dist/core/legacy-cleanup.d.ts +17 -17
- package/dist/core/legacy-cleanup.js +96 -79
- package/dist/core/list.js +18 -4
- package/dist/core/migration.d.ts +3 -1
- package/dist/core/migration.js +7 -8
- package/dist/core/parsers/change-parser.js +1 -1
- package/dist/core/parsers/markdown-parser.js +2 -2
- package/dist/core/profile-sync-drift.d.ts +1 -1
- package/dist/core/profile-sync-drift.js +13 -13
- package/dist/core/project-config.d.ts +4 -4
- package/dist/core/project-config.js +11 -11
- package/dist/core/schemas/change.schema.d.ts +1 -1
- package/dist/core/schemas/change.schema.js +1 -1
- package/dist/core/schemas/spec.schema.d.ts +1 -1
- package/dist/core/schemas/spec.schema.js +1 -1
- package/dist/core/sdd/adr.js +23 -1
- package/dist/core/sdd/agent-binding.d.ts +346 -0
- package/dist/core/sdd/agent-binding.js +343 -0
- package/dist/core/sdd/backlog-cli.d.ts +16 -0
- package/dist/core/sdd/backlog-cli.js +146 -0
- package/dist/core/sdd/backlog-conflict-policy.d.ts +58 -0
- package/dist/core/sdd/backlog-conflict-policy.js +230 -0
- package/dist/core/sdd/backlog-projection.d.ts +8 -0
- package/dist/core/sdd/backlog-projection.js +89 -0
- package/dist/core/sdd/backlog-provider-contract.d.ts +252 -0
- package/dist/core/sdd/backlog-provider-contract.js +158 -0
- package/dist/core/sdd/bootstrap.js +2 -2
- package/dist/core/sdd/check.d.ts +42 -0
- package/dist/core/sdd/check.js +22 -22
- package/dist/core/sdd/contract.d.ts +13 -0
- package/dist/core/sdd/contract.js +36 -0
- package/dist/core/sdd/coordination/coordination-adapters.d.ts +38 -0
- package/dist/core/sdd/coordination/coordination-adapters.js +139 -1
- package/dist/core/sdd/deepagent-contracts.d.ts +276 -0
- package/dist/core/sdd/deepagent-contracts.js +173 -0
- package/dist/core/sdd/deepagents/adr-governor.d.ts +2 -0
- package/dist/core/sdd/deepagents/adr-governor.js +30 -0
- package/dist/core/sdd/deepagents/backend.d.ts +63 -0
- package/dist/core/sdd/deepagents/backend.js +174 -0
- package/dist/core/sdd/deepagents/codesdd-tools.d.ts +39 -0
- package/dist/core/sdd/deepagents/codesdd-tools.js +83 -0
- package/dist/core/sdd/deepagents/evidence-mapper.d.ts +86 -0
- package/dist/core/sdd/deepagents/evidence-mapper.js +178 -0
- package/dist/core/sdd/deepagents/model-provider.d.ts +53 -0
- package/dist/core/sdd/deepagents/model-provider.js +379 -0
- package/dist/core/sdd/deepagents/policy-enforcement.d.ts +30 -0
- package/dist/core/sdd/deepagents/policy-enforcement.js +90 -0
- package/dist/core/sdd/deepagents/policy.d.ts +75 -0
- package/dist/core/sdd/deepagents/policy.js +358 -0
- package/dist/core/sdd/deepagents/quality-witness.d.ts +3 -0
- package/dist/core/sdd/deepagents/quality-witness.js +77 -0
- package/dist/core/sdd/deepagents/reversa-subagents.d.ts +75 -0
- package/dist/core/sdd/deepagents/reversa-subagents.js +182 -0
- package/dist/core/sdd/deepagents/runtime-factory.d.ts +90 -0
- package/dist/core/sdd/deepagents/runtime-factory.js +231 -0
- package/dist/core/sdd/deepagents/runtime-loader.d.ts +16 -0
- package/dist/core/sdd/deepagents/runtime-loader.js +65 -0
- package/dist/core/sdd/default-bootstrap-files.d.ts +2 -2
- package/dist/core/sdd/default-bootstrap-files.js +36 -2
- package/dist/core/sdd/default-skills.d.ts +30 -0
- package/dist/core/sdd/default-skills.js +181 -5
- package/dist/core/sdd/devtrack-api-appliance.d.ts +84 -0
- package/dist/core/sdd/devtrack-api-appliance.js +257 -0
- package/dist/core/sdd/devtrack-api-architecture.d.ts +31 -0
- package/dist/core/sdd/devtrack-api-architecture.js +608 -0
- package/dist/core/sdd/devtrack-api-import-boundary.d.ts +19 -0
- package/dist/core/sdd/devtrack-api-import-boundary.js +32 -0
- package/dist/core/sdd/diagnose.d.ts +59 -0
- package/dist/core/sdd/diagnose.js +37 -37
- package/dist/core/sdd/docs-sync.js +33 -5
- package/dist/core/sdd/domain/post-active-validation.d.ts +7 -0
- package/dist/core/sdd/domain/post-active-validation.js +61 -0
- package/dist/core/sdd/domain/transition-engine.js +1 -0
- package/dist/core/sdd/entity-reference.d.ts +5 -0
- package/dist/core/sdd/entity-reference.js +22 -0
- package/dist/core/sdd/governance-backfill.d.ts +31 -0
- package/dist/core/sdd/governance-backfill.js +359 -0
- package/dist/core/sdd/governance-parser.d.ts +21 -0
- package/dist/core/sdd/governance-parser.js +91 -0
- package/dist/core/sdd/governance-schemas.d.ts +245 -0
- package/dist/core/sdd/governance-schemas.js +143 -0
- package/dist/core/sdd/{import-openspec.d.ts → import-legacy-spec.d.ts} +7 -7
- package/dist/core/sdd/{import-openspec.js → import-legacy-spec.js} +21 -29
- package/dist/core/sdd/init.d.ts +3 -0
- package/dist/core/sdd/init.js +6 -3
- package/dist/core/sdd/json-schema.js +100 -6
- package/dist/core/sdd/knowledge-graph.d.ts +45 -0
- package/dist/core/sdd/knowledge-graph.js +288 -0
- package/dist/core/sdd/legacy-operations.js +431 -43
- package/dist/core/sdd/lenses.d.ts +1 -0
- package/dist/core/sdd/lenses.js +29 -1
- package/dist/core/sdd/migrate-workspace.js +56 -2
- package/dist/core/sdd/migrate.d.ts +1 -1
- package/dist/core/sdd/migrate.js +36 -2
- package/dist/core/sdd/package-structure-gate.d.ts +83 -0
- package/dist/core/sdd/package-structure-gate.js +362 -0
- package/dist/core/sdd/parallel-feat-automation.d.ts +152 -0
- package/dist/core/sdd/parallel-feat-automation.js +212 -0
- package/dist/core/sdd/plugin-broker.d.ts +558 -0
- package/dist/core/sdd/plugin-broker.js +482 -0
- package/dist/core/sdd/plugin-certification.d.ts +79 -0
- package/dist/core/sdd/plugin-certification.js +453 -0
- package/dist/core/sdd/plugin-cli.d.ts +109 -0
- package/dist/core/sdd/plugin-cli.js +198 -0
- package/dist/core/sdd/plugin-evidence.d.ts +275 -0
- package/dist/core/sdd/plugin-evidence.js +307 -0
- package/dist/core/sdd/plugin-manifest.d.ts +164 -0
- package/dist/core/sdd/plugin-manifest.js +215 -0
- package/dist/core/sdd/plugin-policy-pack.d.ts +88 -0
- package/dist/core/sdd/plugin-policy-pack.js +236 -0
- package/dist/core/sdd/plugin-policy.d.ts +68 -0
- package/dist/core/sdd/plugin-policy.js +212 -0
- package/dist/core/sdd/plugin-registry.d.ts +311 -0
- package/dist/core/sdd/plugin-registry.js +138 -0
- package/dist/core/sdd/plugin-skill-binding.d.ts +151 -0
- package/dist/core/sdd/plugin-skill-binding.js +339 -0
- package/dist/core/sdd/quality-artifact-manifest-validator.d.ts +28 -0
- package/dist/core/sdd/quality-artifact-manifest-validator.js +167 -0
- package/dist/core/sdd/quality-evidence-renderer.d.ts +65 -0
- package/dist/core/sdd/quality-evidence-renderer.js +218 -0
- package/dist/core/sdd/quality-scenario-runner.d.ts +42 -0
- package/dist/core/sdd/quality-scenario-runner.js +613 -0
- package/dist/core/sdd/quality-validation.d.ts +547 -0
- package/dist/core/sdd/quality-validation.js +239 -0
- package/dist/core/sdd/resolve-project-root.d.ts +2 -2
- package/dist/core/sdd/resolve-project-root.js +11 -5
- package/dist/core/sdd/sanitize.d.ts +30 -1
- package/dist/core/sdd/sanitize.js +23 -23
- package/dist/core/sdd/services/agent-run.service.d.ts +65 -0
- package/dist/core/sdd/services/agent-run.service.js +189 -0
- package/dist/core/sdd/services/breakdown.service.js +2 -1
- package/dist/core/sdd/services/context.service.js +18 -16
- package/dist/core/sdd/services/debate.service.js +15 -2
- package/dist/core/sdd/services/feature-lint.service.d.ts +22 -0
- package/dist/core/sdd/services/feature-lint.service.js +105 -5
- package/dist/core/sdd/services/finalize.service.d.ts +80 -0
- package/dist/core/sdd/services/finalize.service.js +323 -24
- package/dist/core/sdd/services/frontend-gap.service.js +22 -7
- package/dist/core/sdd/services/governance-control-plane-runtime-adapters.d.ts +17 -0
- package/dist/core/sdd/services/governance-control-plane-runtime-adapters.js +38 -0
- package/dist/core/sdd/services/governance-control-plane.service.d.ts +66 -0
- package/dist/core/sdd/services/governance-control-plane.service.js +134 -0
- package/dist/core/sdd/services/ingest-deposito.service.js +1 -1
- package/dist/core/sdd/services/legacy-capability.service.d.ts +10 -7
- package/dist/core/sdd/services/legacy-capability.service.js +38 -21
- package/dist/core/sdd/services/mcp-runtime.service.d.ts +123 -8
- package/dist/core/sdd/services/mcp-runtime.service.js +1085 -33
- package/dist/core/sdd/services/onboard.service.js +2 -1
- package/dist/core/sdd/services/rebuild.service.js +6 -1
- package/dist/core/sdd/services/skills-sync.service.d.ts +17 -5
- package/dist/core/sdd/services/skills-sync.service.js +55 -2
- package/dist/core/sdd/services/start.service.js +6 -4
- package/dist/core/sdd/skill-bundles-curation-schema.d.ts +66 -0
- package/dist/core/sdd/skill-bundles-curation-schema.js +52 -0
- package/dist/core/sdd/skill-evidence.d.ts +19 -0
- package/dist/core/sdd/skill-evidence.js +38 -0
- package/dist/core/sdd/skill-policy-pool.d.ts +46 -0
- package/dist/core/sdd/skill-policy-pool.js +185 -0
- package/dist/core/sdd/state.d.ts +22 -0
- package/dist/core/sdd/state.js +66 -41
- package/dist/core/sdd/structural-health.d.ts +42 -42
- package/dist/core/sdd/types.d.ts +33 -7
- package/dist/core/sdd/types.js +17 -0
- package/dist/core/sdd/upgrade-to-codesdd.d.ts +45 -0
- package/dist/core/sdd/upgrade-to-codesdd.js +179 -0
- package/dist/core/sdd/workspace-schemas.d.ts +285 -14
- package/dist/core/sdd/workspace-schemas.js +148 -0
- package/dist/core/sdd/write-manifest.js +22 -4
- package/dist/core/shared/skill-generation.d.ts +1 -1
- package/dist/core/shared/skill-generation.js +15 -15
- package/dist/core/shared/tool-detection.d.ts +3 -3
- package/dist/core/shared/tool-detection.js +14 -14
- package/dist/core/specs-apply.js +6 -6
- package/dist/core/templates/index.d.ts +1 -1
- package/dist/core/templates/index.js +1 -1
- package/dist/core/templates/workflows/apply-change.js +14 -14
- package/dist/core/templates/workflows/archive-change.js +32 -32
- package/dist/core/templates/workflows/bulk-archive-change.js +25 -25
- package/dist/core/templates/workflows/continue-change.js +12 -12
- package/dist/core/templates/workflows/explore.js +29 -29
- package/dist/core/templates/workflows/feedback.js +6 -6
- package/dist/core/templates/workflows/ff-change.js +24 -24
- package/dist/core/templates/workflows/new-change.js +20 -20
- package/dist/core/templates/workflows/onboard.js +33 -33
- package/dist/core/templates/workflows/propose.js +23 -23
- package/dist/core/templates/workflows/sdd.js +8 -8
- package/dist/core/templates/workflows/sync-specs.js +19 -19
- package/dist/core/templates/workflows/verify-change.js +17 -17
- package/dist/core/update.d.ts +2 -2
- package/dist/core/update.js +16 -15
- package/dist/core/validation/constants.d.ts +1 -1
- package/dist/core/validation/constants.js +1 -1
- package/dist/core/view.js +11 -11
- package/dist/telemetry/config.d.ts +2 -1
- package/dist/telemetry/config.js +17 -8
- package/dist/telemetry/index.d.ts +10 -2
- package/dist/telemetry/index.js +40 -7
- package/dist/ui/ascii-patterns.d.ts +2 -2
- package/dist/ui/ascii-patterns.js +2 -2
- package/dist/ui/welcome-screen.js +2 -2
- package/dist/utils/change-metadata.d.ts +4 -4
- package/dist/utils/change-metadata.js +6 -6
- package/dist/utils/change-utils.d.ts +3 -3
- package/dist/utils/change-utils.js +5 -5
- package/dist/utils/file-system.js +1 -1
- package/dist/utils/interactive.js +1 -1
- package/dist/utils/item-discovery.js +4 -4
- package/dist/utils/legacy-spec-compat.d.ts +2 -0
- package/dist/utils/legacy-spec-compat.js +2 -0
- package/dist/utils/shell-detection.d.ts +1 -0
- package/dist/utils/shell-detection.js +16 -0
- package/package.json +27 -17
- package/schemas/sdd/1-spec.schema.json +1 -1
- package/schemas/sdd/2-plan.schema.json +73 -1
- package/schemas/sdd/3-tasks.schema.json +73 -1
- package/schemas/sdd/4-changelog.schema.json +1 -1
- package/schemas/sdd/5-quality.schema.json +442 -2
- package/schemas/sdd/adr.schema.json +148 -0
- package/schemas/sdd/agent-binding-adapter.schema.json +210 -0
- package/schemas/sdd/agent-binding-resolution.schema.json +338 -0
- package/schemas/sdd/backlog-projection-plan.schema.json +180 -0
- package/schemas/sdd/backlog-provider-contract.schema.json +260 -0
- package/schemas/sdd/codesdd-plugin.schema.json +474 -0
- package/schemas/sdd/debate.schema.json +244 -0
- package/schemas/sdd/deepagent-decision-evidence.schema.json +58 -0
- package/schemas/sdd/deepagent-env-contract.schema.json +143 -0
- package/schemas/sdd/deepagent-quality-evidence.schema.json +108 -0
- package/schemas/sdd/deepagent-run-evidence.schema.json +192 -0
- package/schemas/sdd/deepagent-run-plan.schema.json +197 -0
- package/schemas/sdd/deepagent-run-request.schema.json +321 -0
- package/schemas/sdd/deepagent-subagent-evidence.schema.json +110 -0
- package/schemas/sdd/deepagent-tool-call-evidence.schema.json +78 -0
- package/schemas/sdd/discarded.schema.json +127 -0
- package/schemas/sdd/epic.schema.json +147 -0
- package/schemas/sdd/insight.schema.json +136 -0
- package/schemas/sdd/parallel-feat-automation-plan.schema.json +215 -0
- package/schemas/sdd/parallel-feat-automation-request.schema.json +109 -0
- package/schemas/sdd/plugin-artifact-manifest.schema.json +150 -0
- package/schemas/sdd/plugin-compliance-index.schema.json +136 -0
- package/schemas/sdd/plugin-dry-run-plan.schema.json +260 -0
- package/schemas/sdd/plugin-evidence-manifest.schema.json +569 -0
- package/schemas/sdd/plugin-policy-evaluation.schema.json +92 -0
- package/schemas/sdd/plugin-policy-pack-evaluation.schema.json +94 -0
- package/schemas/sdd/plugin-policy-pack.schema.json +196 -0
- package/schemas/sdd/plugin-registry.schema.json +558 -0
- package/schemas/sdd/plugin-rollback-manifest.schema.json +87 -0
- package/schemas/sdd/plugin-runtime-invocation-plan.schema.json +845 -0
- package/schemas/sdd/plugin-skill-binding-resolution.schema.json +305 -0
- package/schemas/sdd/plugin-skill-binding.schema.json +88 -0
- package/schemas/sdd/plugin-validation-manifest.schema.json +123 -0
- package/schemas/sdd/quality-architecture-schema.schema.json +216 -0
- package/schemas/sdd/quality-evidence-bundle.schema.json +1228 -0
- package/schemas/sdd/quality-run.schema.json +197 -0
- package/schemas/sdd/quality-scenario.schema.json +252 -0
- package/schemas/sdd/workspace-catalog.schema.json +9841 -22
- package/schemas/spec-driven/schema.yaml +4 -4
- package/schemas/spec-driven/templates/proposal.md +1 -1
- package/dist/utils/openspec-compat.d.ts +0 -2
- package/dist/utils/openspec-compat.js +0 -2
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { pluginArtifactManifestSchema, } from './plugin-broker.js';
|
|
3
|
+
import { pluginComplianceIndexSchema, pluginValidationManifestSchema, } from './plugin-evidence.js';
|
|
4
|
+
const FEATURE_REF_PATTERN = /^FEAT-\d{4}$/;
|
|
5
|
+
const SCENARIO_ID_PATTERN = /^QVAL-\d{4}$/;
|
|
6
|
+
const ARCHITECTURE_SCHEMA_ID_PATTERN = /^ARCH-GATE-[a-z0-9][a-z0-9-]*$/;
|
|
7
|
+
const RUN_ID_PATTERN = /^qrun-[0-9]{8}t[0-9]{6}z-[a-z0-9-]+$/;
|
|
8
|
+
const ISSUE_CODE_PATTERN = /^[A-Z][A-Z0-9_]*$/;
|
|
9
|
+
const WINDOWS_ABSOLUTE_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
|
|
10
|
+
const jsonObjectSchema = z.record(z.string(), z.unknown());
|
|
11
|
+
const safeRelativePathSchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.refine((value) => isSafeRelativePath(value), {
|
|
15
|
+
message: 'Path must be relative to the project root and must not contain traversal segments.',
|
|
16
|
+
});
|
|
17
|
+
export const qualityAuthorityRefSchema = z.object({
|
|
18
|
+
type: z.enum(['adr', 'skill', 'foundation', 'debate', 'epic', 'feature', 'schema']),
|
|
19
|
+
ref: z.string().min(1),
|
|
20
|
+
path: safeRelativePathSchema.optional(),
|
|
21
|
+
version: z.string().min(1).optional(),
|
|
22
|
+
update_policy: z.string().min(1),
|
|
23
|
+
});
|
|
24
|
+
export const qualityGateRefSchema = z.object({
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
type: z.enum(['schema', 'filesystem', 'import', 'runtime', 'evidence', 'certification', 'drift']),
|
|
27
|
+
severity: z.enum(['warn', 'fail']).default('warn'),
|
|
28
|
+
issue_codes: z.array(z.string().regex(ISSUE_CODE_PATTERN)).default([]),
|
|
29
|
+
remediation: z.string().min(1),
|
|
30
|
+
});
|
|
31
|
+
export const qualityScenarioExpectedArtifactSchema = z.object({
|
|
32
|
+
path_pattern: z.string().min(1),
|
|
33
|
+
required: z.boolean().default(true),
|
|
34
|
+
artifact_class: z.string().min(1),
|
|
35
|
+
checksum_required: z.boolean().default(false),
|
|
36
|
+
});
|
|
37
|
+
export const qualityScenarioSchema = z.object({
|
|
38
|
+
schema_version: z.literal(1),
|
|
39
|
+
id: z.string().regex(SCENARIO_ID_PATTERN),
|
|
40
|
+
title: z.string().min(10),
|
|
41
|
+
feature_ref: z.string().regex(FEATURE_REF_PATTERN).optional(),
|
|
42
|
+
mode: z.enum(['dry_run', 'apply_sandbox', 'runtime', 'traceability']),
|
|
43
|
+
intent: z.string().min(30),
|
|
44
|
+
authority: z.array(qualityAuthorityRefSchema).min(1),
|
|
45
|
+
input: z.object({
|
|
46
|
+
prompt: z.string().min(1).optional(),
|
|
47
|
+
fixture_path: safeRelativePathSchema.optional(),
|
|
48
|
+
payload: jsonObjectSchema.default({}),
|
|
49
|
+
}),
|
|
50
|
+
expected_artifacts: z.array(qualityScenarioExpectedArtifactSchema).default([]),
|
|
51
|
+
gates: z.array(qualityGateRefSchema).min(1),
|
|
52
|
+
negative_variants: z
|
|
53
|
+
.array(z.object({
|
|
54
|
+
id: z.string().min(1),
|
|
55
|
+
description: z.string().min(10),
|
|
56
|
+
expected_issue_codes: z.array(z.string().regex(ISSUE_CODE_PATTERN)).min(1),
|
|
57
|
+
}))
|
|
58
|
+
.default([]),
|
|
59
|
+
allowed_nondeterminism: z.array(z.string().min(1)).default([]),
|
|
60
|
+
required_evidence: z.array(z.string().min(1)).min(1),
|
|
61
|
+
});
|
|
62
|
+
export const architectureLayerRuleSchema = z.object({
|
|
63
|
+
path_patterns: z.array(z.string().min(1)).min(1),
|
|
64
|
+
allowed_file_patterns: z.array(z.string().min(1)).default([]),
|
|
65
|
+
forbidden_file_patterns: z.array(z.string().min(1)).default([]),
|
|
66
|
+
allowed_imports: z.array(z.string().min(1)).default([]),
|
|
67
|
+
forbidden_imports: z.array(z.string().min(1)).default([]),
|
|
68
|
+
required_evidence: z.array(z.string().min(1)).default([]),
|
|
69
|
+
});
|
|
70
|
+
export const qualityArchitectureSchema = z.object({
|
|
71
|
+
schema_version: z.literal(1),
|
|
72
|
+
id: z.string().regex(ARCHITECTURE_SCHEMA_ID_PATTERN),
|
|
73
|
+
title: z.string().min(10),
|
|
74
|
+
stack: z.string().min(1),
|
|
75
|
+
authority: z.array(qualityAuthorityRefSchema).min(1),
|
|
76
|
+
applies_to: z.object({
|
|
77
|
+
plugin: z.string().min(1).optional(),
|
|
78
|
+
capability: z.string().min(1).optional(),
|
|
79
|
+
project_kind: z.string().min(1).optional(),
|
|
80
|
+
}),
|
|
81
|
+
layers: z.record(z.string().min(1), architectureLayerRuleSchema).refine((layers) => Object.keys(layers).length > 0, { message: 'At least one architecture layer rule is required.' }),
|
|
82
|
+
exceptions: z.object({
|
|
83
|
+
require_adr: z.boolean().default(true),
|
|
84
|
+
require_expiration: z.boolean().default(true),
|
|
85
|
+
allowed_refs: z.array(z.string().min(1)).default([]),
|
|
86
|
+
}),
|
|
87
|
+
update_policy: z.object({
|
|
88
|
+
owner: z.string().min(1),
|
|
89
|
+
review_trigger: z.string().min(1),
|
|
90
|
+
stale_after_days: z.number().int().positive().optional(),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
export const qualityRunFindingSchema = z.object({
|
|
94
|
+
code: z.string().regex(ISSUE_CODE_PATTERN),
|
|
95
|
+
severity: z.enum(['info', 'warn', 'error', 'blocker']),
|
|
96
|
+
message: z.string().min(1),
|
|
97
|
+
remediation: z.string().min(1),
|
|
98
|
+
path: safeRelativePathSchema.optional(),
|
|
99
|
+
gate_id: z.string().min(1).optional(),
|
|
100
|
+
});
|
|
101
|
+
export const qualityRunSchema = z.object({
|
|
102
|
+
schema_version: z.literal(1),
|
|
103
|
+
run_id: z.string().regex(RUN_ID_PATTERN),
|
|
104
|
+
scenario_ref: z.string().regex(SCENARIO_ID_PATTERN),
|
|
105
|
+
feature_ref: z.string().regex(FEATURE_REF_PATTERN),
|
|
106
|
+
started_at: z.string().datetime(),
|
|
107
|
+
finished_at: z.string().datetime().optional(),
|
|
108
|
+
mode: z.enum(['dry_run', 'apply_sandbox', 'runtime', 'traceability']),
|
|
109
|
+
status: z.enum(['passed', 'warning', 'failed', 'blocked']),
|
|
110
|
+
plugin_ref: z
|
|
111
|
+
.object({
|
|
112
|
+
id: z.string().min(1),
|
|
113
|
+
version: z.string().min(1),
|
|
114
|
+
capability: z.string().min(1),
|
|
115
|
+
})
|
|
116
|
+
.optional(),
|
|
117
|
+
command: z.object({
|
|
118
|
+
argv: z.array(z.string().min(1)).min(1),
|
|
119
|
+
cwd: safeRelativePathSchema.default('.'),
|
|
120
|
+
env_keys: z.array(z.string().min(1)).default([]),
|
|
121
|
+
}),
|
|
122
|
+
schema_versions: z.record(z.string(), z.string()).default({}),
|
|
123
|
+
artifacts: z.array(safeRelativePathSchema).default([]),
|
|
124
|
+
findings: z.array(qualityRunFindingSchema).default([]),
|
|
125
|
+
evidence_bundle_path: safeRelativePathSchema.optional(),
|
|
126
|
+
metadata: jsonObjectSchema.default({}),
|
|
127
|
+
});
|
|
128
|
+
export const qualityFilesystemSnapshotSchema = z.object({
|
|
129
|
+
root: safeRelativePathSchema.default('.'),
|
|
130
|
+
files: z.array(z.object({
|
|
131
|
+
path: safeRelativePathSchema,
|
|
132
|
+
size_bytes: z.number().int().nonnegative(),
|
|
133
|
+
sha256: z.string().min(1).optional(),
|
|
134
|
+
})).default([]),
|
|
135
|
+
});
|
|
136
|
+
export const qualityImportGraphSchema = z.object({
|
|
137
|
+
nodes: z.array(safeRelativePathSchema).default([]),
|
|
138
|
+
edges: z.array(z.object({
|
|
139
|
+
from: safeRelativePathSchema,
|
|
140
|
+
to: z.string().min(1),
|
|
141
|
+
kind: z.enum(['relative', 'package', 'alias']).default('relative'),
|
|
142
|
+
})).default([]),
|
|
143
|
+
});
|
|
144
|
+
export const qualityEvidenceBundleSchema = z
|
|
145
|
+
.object({
|
|
146
|
+
schema_version: z.literal(1),
|
|
147
|
+
run: qualityRunSchema,
|
|
148
|
+
scenario: qualityScenarioSchema,
|
|
149
|
+
architecture_schema: qualityArchitectureSchema.optional(),
|
|
150
|
+
artifact_manifest: pluginArtifactManifestSchema.optional(),
|
|
151
|
+
validation_manifest: pluginValidationManifestSchema.optional(),
|
|
152
|
+
compliance_index: pluginComplianceIndexSchema.optional(),
|
|
153
|
+
filesystem_snapshot: qualityFilesystemSnapshotSchema,
|
|
154
|
+
import_graph: qualityImportGraphSchema,
|
|
155
|
+
command_log_ref: safeRelativePathSchema.optional(),
|
|
156
|
+
exceptions: z.array(z.object({
|
|
157
|
+
ref: z.string().min(1),
|
|
158
|
+
reason: z.string().min(1),
|
|
159
|
+
expires_at: z.string().datetime().optional(),
|
|
160
|
+
compensating_control: z.string().min(1),
|
|
161
|
+
})).default([]),
|
|
162
|
+
checksums: z.array(z.object({
|
|
163
|
+
path: safeRelativePathSchema,
|
|
164
|
+
sha256: z.string().min(1),
|
|
165
|
+
})).default([]),
|
|
166
|
+
})
|
|
167
|
+
.superRefine((bundle, context) => {
|
|
168
|
+
if (bundle.run.scenario_ref !== bundle.scenario.id) {
|
|
169
|
+
context.addIssue({
|
|
170
|
+
code: 'custom',
|
|
171
|
+
path: ['run', 'scenario_ref'],
|
|
172
|
+
message: `Run scenario_ref ${bundle.run.scenario_ref} must match scenario id ${bundle.scenario.id}.`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (bundle.scenario.feature_ref && bundle.run.feature_ref !== bundle.scenario.feature_ref) {
|
|
176
|
+
context.addIssue({
|
|
177
|
+
code: 'custom',
|
|
178
|
+
path: ['run', 'feature_ref'],
|
|
179
|
+
message: `Run feature_ref ${bundle.run.feature_ref} must match scenario feature_ref ${bundle.scenario.feature_ref}.`,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (bundle.run.evidence_bundle_path) {
|
|
183
|
+
const expectedPrefix = `.sdd/reports/quality-runs/${bundle.run.run_id}/`;
|
|
184
|
+
if (!bundle.run.evidence_bundle_path.startsWith(expectedPrefix)) {
|
|
185
|
+
context.addIssue({
|
|
186
|
+
code: 'custom',
|
|
187
|
+
path: ['run', 'evidence_bundle_path'],
|
|
188
|
+
message: `Evidence bundle path must live under ${expectedPrefix}.`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const requiredEvidence of bundle.scenario.required_evidence) {
|
|
193
|
+
if (!bundleHasRequiredEvidence(bundle, requiredEvidence)) {
|
|
194
|
+
context.addIssue({
|
|
195
|
+
code: 'custom',
|
|
196
|
+
path: ['scenario', 'required_evidence'],
|
|
197
|
+
message: `Required evidence "${requiredEvidence}" is missing from the evidence bundle.`,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
export function parseQualityScenario(value) {
|
|
203
|
+
return qualityScenarioSchema.parse(value);
|
|
204
|
+
}
|
|
205
|
+
export function parseQualityArchitectureSchema(value) {
|
|
206
|
+
return qualityArchitectureSchema.parse(value);
|
|
207
|
+
}
|
|
208
|
+
export function parseQualityRun(value) {
|
|
209
|
+
return qualityRunSchema.parse(value);
|
|
210
|
+
}
|
|
211
|
+
export function parseQualityEvidenceBundle(value) {
|
|
212
|
+
return qualityEvidenceBundleSchema.parse(value);
|
|
213
|
+
}
|
|
214
|
+
function isSafeRelativePath(value) {
|
|
215
|
+
if (value.startsWith('/') || WINDOWS_ABSOLUTE_PATH_PATTERN.test(value)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return !value.split(/[\\/]+/u).some((segment) => segment === '..');
|
|
219
|
+
}
|
|
220
|
+
function bundleHasRequiredEvidence(bundle, evidence) {
|
|
221
|
+
if (evidence === 'artifact_manifest')
|
|
222
|
+
return Boolean(bundle.artifact_manifest);
|
|
223
|
+
if (evidence === 'validation_manifest')
|
|
224
|
+
return Boolean(bundle.validation_manifest);
|
|
225
|
+
if (evidence === 'compliance_index')
|
|
226
|
+
return Boolean(bundle.compliance_index);
|
|
227
|
+
if (evidence === 'architecture_schema')
|
|
228
|
+
return Boolean(bundle.architecture_schema);
|
|
229
|
+
if (evidence === 'filesystem_snapshot')
|
|
230
|
+
return bundle.filesystem_snapshot.files.length > 0;
|
|
231
|
+
if (evidence === 'import_graph')
|
|
232
|
+
return bundle.import_graph.nodes.length > 0 || bundle.import_graph.edges.length > 0;
|
|
233
|
+
if (evidence === 'command_log')
|
|
234
|
+
return Boolean(bundle.command_log_ref);
|
|
235
|
+
if (evidence === 'checksums')
|
|
236
|
+
return bundle.checksums.length > 0;
|
|
237
|
+
return bundle.run.artifacts.some((artifact) => artifact.includes(evidence));
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=quality-validation.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolves the project root by walking up from `startDir` until we find a
|
|
3
|
-
* directory that looks like a project root (contains
|
|
4
|
-
* or `.git`).
|
|
3
|
+
* directory that looks like a project root (contains `.sdd/`, `legacy-spec/`,
|
|
4
|
+
* `package.json`, or `.git`).
|
|
5
5
|
*
|
|
6
6
|
* This handles the common case where the CLI is invoked from inside `.sdd/` or
|
|
7
7
|
* another subdirectory, preventing the double-nesting bug (e.g. `.sdd/.sdd`).
|
|
@@ -2,8 +2,8 @@ import path from 'node:path';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the project root by walking up from `startDir` until we find a
|
|
5
|
-
* directory that looks like a project root (contains
|
|
6
|
-
* or `.git`).
|
|
5
|
+
* directory that looks like a project root (contains `.sdd/`, `legacy-spec/`,
|
|
6
|
+
* `package.json`, or `.git`).
|
|
7
7
|
*
|
|
8
8
|
* This handles the common case where the CLI is invoked from inside `.sdd/` or
|
|
9
9
|
* another subdirectory, preventing the double-nesting bug (e.g. `.sdd/.sdd`).
|
|
@@ -24,7 +24,7 @@ export function resolveProjectRoot(startDir = process.cwd()) {
|
|
|
24
24
|
if (parent === current) {
|
|
25
25
|
// Reached filesystem root without finding a project root.
|
|
26
26
|
// Fall back to original startDir so the existing error messages
|
|
27
|
-
// (e.g. "Run
|
|
27
|
+
// (e.g. "Run codesdd sdd init") still make sense.
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
current = parent;
|
|
@@ -32,8 +32,14 @@ export function resolveProjectRoot(startDir = process.cwd()) {
|
|
|
32
32
|
return absoluteStart;
|
|
33
33
|
}
|
|
34
34
|
function isProjectRoot(dir) {
|
|
35
|
-
//
|
|
36
|
-
if (existsSync(path.join(dir, '
|
|
35
|
+
// .sdd/ is the canonical CodeSDD governance directory.
|
|
36
|
+
if (existsSync(path.join(dir, '.sdd')))
|
|
37
|
+
return true;
|
|
38
|
+
// legacy-spec/ is a legacy compatibility root.
|
|
39
|
+
if (existsSync(path.join(dir, 'legacy-spec')))
|
|
40
|
+
return true;
|
|
41
|
+
// codesdd/ may exist in projects created during the transition window.
|
|
42
|
+
if (existsSync(path.join(dir, 'codesdd')))
|
|
37
43
|
return true;
|
|
38
44
|
// package.json is a strong signal for Node.js project roots
|
|
39
45
|
if (existsSync(path.join(dir, 'package.json')))
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type StructuralDiagnosticReport, type StructuralSanitizerReport, type StructuralSanitizerTransactionManifest } from './structural-health.js';
|
|
1
|
+
import { type StructuralDiagnosticReport, type StructuralSanitizerReport, type StructuralSanitizerTransactionManifest, type StructuralSanitizerTransactionOperation } from './structural-health.js';
|
|
2
|
+
export type Finding = StructuralDiagnosticReport['findings'][number];
|
|
3
|
+
export type SanitizerAction = StructuralSanitizerReport['actions'][number];
|
|
2
4
|
export interface SddSanitizeCommandOptions {
|
|
3
5
|
dryRun?: boolean;
|
|
4
6
|
apply?: boolean;
|
|
@@ -27,6 +29,33 @@ export declare class SddSanitizeOptionsError extends Error {
|
|
|
27
29
|
export declare class SddSanitizeApplyError extends Error {
|
|
28
30
|
constructor(message: string);
|
|
29
31
|
}
|
|
32
|
+
export declare function actionToken(input: string): string;
|
|
33
|
+
export declare function createSourceReportId(report: StructuralDiagnosticReport): string;
|
|
34
|
+
export declare function isInsidePath(rootPath: string, candidatePath: string): boolean;
|
|
35
|
+
export declare function toAuditTimestampToken(value?: Date): string;
|
|
36
|
+
export declare function createTransactionId(sourceReportId: string, value?: Date): string;
|
|
37
|
+
export declare function pathExists(targetPath: string): Promise<boolean>;
|
|
38
|
+
export declare function hashPath(targetPath: string): Promise<string | undefined>;
|
|
39
|
+
export declare function resolveInSddRoot(projectRoot: string, memoryRoot: string, candidatePath: string, label: string): Promise<string>;
|
|
40
|
+
export declare function transactionDirs(projectRoot: string, transactionId: string): {
|
|
41
|
+
sanitizeRoot: string;
|
|
42
|
+
backupRoot: string;
|
|
43
|
+
manifestPath: string;
|
|
44
|
+
auditLogPath: string;
|
|
45
|
+
};
|
|
46
|
+
export declare function backupPath(targetPath: string, backupRoot: string): Promise<string | undefined>;
|
|
47
|
+
export declare function removePathSafely(targetPath: string): Promise<void>;
|
|
48
|
+
export declare function toLifecycleTargetPath(finding: Finding): string | undefined;
|
|
49
|
+
export declare function toQuarantinePath(location?: string): string | undefined;
|
|
50
|
+
export declare function toWorkspaceBackupPath(location?: string): string | undefined;
|
|
51
|
+
export declare function inferOperation(finding: Finding): SanitizerAction['operation'];
|
|
52
|
+
export declare function makeActionFromFinding(finding: Finding, index: number): SanitizerAction;
|
|
53
|
+
export declare function buildSanitizerDryRunReport(report: StructuralDiagnosticReport): StructuralSanitizerReport;
|
|
54
|
+
export declare function manifestSummary(operations: StructuralSanitizerTransactionOperation[]): StructuralSanitizerTransactionManifest['summary'];
|
|
55
|
+
export declare function writeAuditLog(auditLogPath: string, lines: Array<Record<string, unknown>>): Promise<void>;
|
|
56
|
+
export declare function rollbackOperation(projectRoot: string, memoryRoot: string, rollback: StructuralSanitizerTransactionOperation['rollback']): Promise<void>;
|
|
57
|
+
export declare function applySanitizerPlan(projectRoot: string, source: 'diagnose' | 'report', diagnosticReport: StructuralDiagnosticReport, dryRunReport: StructuralSanitizerReport): Promise<SddSanitizeResult>;
|
|
58
|
+
export declare function loadDiagnosticReportFromFile(projectRoot: string, reportPath: string): Promise<StructuralDiagnosticReport>;
|
|
30
59
|
export declare function formatSanitizerText(report: StructuralSanitizerReport): string;
|
|
31
60
|
export declare class SddSanitizeCommand {
|
|
32
61
|
execute(projectRoot: string, options?: SddSanitizeCommandOptions): Promise<SddSanitizeResult>;
|
|
@@ -19,11 +19,11 @@ export class SddSanitizeApplyError extends Error {
|
|
|
19
19
|
this.name = 'SddSanitizeApplyError';
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function actionToken(input) {
|
|
22
|
+
export function actionToken(input) {
|
|
23
23
|
const normalized = input.toUpperCase().replace(/[^A-Z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
24
24
|
return normalized.length > 0 ? normalized : 'GENERIC';
|
|
25
25
|
}
|
|
26
|
-
function createSourceReportId(report) {
|
|
26
|
+
export function createSourceReportId(report) {
|
|
27
27
|
const digest = createHash('sha1')
|
|
28
28
|
.update(JSON.stringify({
|
|
29
29
|
root_path: report.root_path,
|
|
@@ -43,19 +43,19 @@ function createSourceReportId(report) {
|
|
|
43
43
|
.toUpperCase();
|
|
44
44
|
return `SH-REPORT-${digest}`;
|
|
45
45
|
}
|
|
46
|
-
function isInsidePath(rootPath, candidatePath) {
|
|
46
|
+
export function isInsidePath(rootPath, candidatePath) {
|
|
47
47
|
const relative = path.relative(rootPath, candidatePath);
|
|
48
48
|
return relative === '' || (!!relative && !relative.startsWith('..') && !path.isAbsolute(relative));
|
|
49
49
|
}
|
|
50
|
-
function toAuditTimestampToken(value = new Date()) {
|
|
50
|
+
export function toAuditTimestampToken(value = new Date()) {
|
|
51
51
|
return value.toISOString().replace(/[-:]/g, '').replace(/\.\d{3}Z$/, 'Z');
|
|
52
52
|
}
|
|
53
|
-
function createTransactionId(sourceReportId, value = new Date()) {
|
|
53
|
+
export function createTransactionId(sourceReportId, value = new Date()) {
|
|
54
54
|
const timestamp = toAuditTimestampToken(value);
|
|
55
55
|
const suffix = createHash('sha1').update(`${sourceReportId}:${value.toISOString()}`).digest('hex').slice(0, 8).toUpperCase();
|
|
56
56
|
return `SAN-${timestamp}-${suffix}`;
|
|
57
57
|
}
|
|
58
|
-
async function pathExists(targetPath) {
|
|
58
|
+
export async function pathExists(targetPath) {
|
|
59
59
|
try {
|
|
60
60
|
await lstat(targetPath);
|
|
61
61
|
return true;
|
|
@@ -64,7 +64,7 @@ async function pathExists(targetPath) {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
async function hashPath(targetPath) {
|
|
67
|
+
export async function hashPath(targetPath) {
|
|
68
68
|
let stat;
|
|
69
69
|
try {
|
|
70
70
|
stat = await lstat(targetPath);
|
|
@@ -88,7 +88,7 @@ async function hashPath(targetPath) {
|
|
|
88
88
|
}
|
|
89
89
|
return `other:${stat.mode}`;
|
|
90
90
|
}
|
|
91
|
-
async function resolveInSddRoot(projectRoot, memoryRoot, candidatePath, label) {
|
|
91
|
+
export async function resolveInSddRoot(projectRoot, memoryRoot, candidatePath, label) {
|
|
92
92
|
try {
|
|
93
93
|
return await RootResolver.verifyRealpathContainment(projectRoot, memoryRoot, candidatePath, label);
|
|
94
94
|
}
|
|
@@ -99,7 +99,7 @@ async function resolveInSddRoot(projectRoot, memoryRoot, candidatePath, label) {
|
|
|
99
99
|
throw error;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
function transactionDirs(projectRoot, transactionId) {
|
|
102
|
+
export function transactionDirs(projectRoot, transactionId) {
|
|
103
103
|
const sanitizeRoot = path.resolve(projectRoot, '.sdd', 'reports', 'sanitize');
|
|
104
104
|
const backupRoot = path.join(sanitizeRoot, transactionId, 'backups');
|
|
105
105
|
return {
|
|
@@ -109,7 +109,7 @@ function transactionDirs(projectRoot, transactionId) {
|
|
|
109
109
|
auditLogPath: path.join(sanitizeRoot, `${transactionId}-audit.jsonl`),
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
async function backupPath(targetPath, backupRoot) {
|
|
112
|
+
export async function backupPath(targetPath, backupRoot) {
|
|
113
113
|
if (!(await pathExists(targetPath)))
|
|
114
114
|
return undefined;
|
|
115
115
|
const suffix = createHash('sha1').update(targetPath).digest('hex').slice(0, 10);
|
|
@@ -118,7 +118,7 @@ async function backupPath(targetPath, backupRoot) {
|
|
|
118
118
|
await cp(targetPath, backupPathResolved, { recursive: true });
|
|
119
119
|
return backupPathResolved;
|
|
120
120
|
}
|
|
121
|
-
async function removePathSafely(targetPath) {
|
|
121
|
+
export async function removePathSafely(targetPath) {
|
|
122
122
|
const stat = await lstat(targetPath).catch(() => null);
|
|
123
123
|
if (!stat)
|
|
124
124
|
return;
|
|
@@ -128,7 +128,7 @@ async function removePathSafely(targetPath) {
|
|
|
128
128
|
}
|
|
129
129
|
await unlink(targetPath);
|
|
130
130
|
}
|
|
131
|
-
function toLifecycleTargetPath(finding) {
|
|
131
|
+
export function toLifecycleTargetPath(finding) {
|
|
132
132
|
const evidence = finding.evidence;
|
|
133
133
|
const expectedRoot = typeof evidence.expected_root === 'string' ? evidence.expected_root : undefined;
|
|
134
134
|
const itemId = typeof evidence.id === 'string' ? evidence.id : undefined;
|
|
@@ -143,19 +143,19 @@ function toLifecycleTargetPath(finding) {
|
|
|
143
143
|
}
|
|
144
144
|
return undefined;
|
|
145
145
|
}
|
|
146
|
-
function toQuarantinePath(location) {
|
|
146
|
+
export function toQuarantinePath(location) {
|
|
147
147
|
if (!location)
|
|
148
148
|
return undefined;
|
|
149
149
|
const baseName = path.posix.basename(location);
|
|
150
150
|
return path.posix.join('.sdd', 'quarantine', baseName);
|
|
151
151
|
}
|
|
152
|
-
function toWorkspaceBackupPath(location) {
|
|
152
|
+
export function toWorkspaceBackupPath(location) {
|
|
153
153
|
if (!location)
|
|
154
154
|
return undefined;
|
|
155
155
|
const normalized = location.replace(/\\/g, '/').replace(/^\.sdd\//, '');
|
|
156
156
|
return path.posix.join('.sdd', 'backup', normalized);
|
|
157
157
|
}
|
|
158
|
-
function inferOperation(finding) {
|
|
158
|
+
export function inferOperation(finding) {
|
|
159
159
|
switch (finding.rule_id) {
|
|
160
160
|
case 'SH-RULE-MISSING-DIRECTORY':
|
|
161
161
|
return 'mkdir';
|
|
@@ -179,7 +179,7 @@ function inferOperation(finding) {
|
|
|
179
179
|
return 'manual_review';
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
function makeActionFromFinding(finding, index) {
|
|
182
|
+
export function makeActionFromFinding(finding, index) {
|
|
183
183
|
const operation = inferOperation(finding);
|
|
184
184
|
const actionId = `SH-ACTION-${actionToken(finding.finding_id)}-${actionToken(operation)}-${index + 1}`;
|
|
185
185
|
const candidate = {
|
|
@@ -216,7 +216,7 @@ function makeActionFromFinding(finding, index) {
|
|
|
216
216
|
const id = typeof evidence.id === 'string' ? evidence.id : undefined;
|
|
217
217
|
const hasLegacyMarkdown = evidence.has_legacy_markdown === true;
|
|
218
218
|
candidate.notes = hasLegacyMarkdown && id
|
|
219
|
-
? `${candidate.notes} Suggested migration:
|
|
219
|
+
? `${candidate.notes} Suggested migration: codesdd sdd migrate-workspace --feat ${id}.`
|
|
220
220
|
: `${candidate.notes} Suggested repair: manually edit the YAML to satisfy the workspace schema.`;
|
|
221
221
|
}
|
|
222
222
|
if (finding.rule_id === 'SH-RULE-LIFECYCLE-VIOLATION') {
|
|
@@ -233,7 +233,7 @@ function makeActionFromFinding(finding, index) {
|
|
|
233
233
|
}
|
|
234
234
|
return StructuralSanitizerActionSchema.parse(candidate);
|
|
235
235
|
}
|
|
236
|
-
function buildSanitizerDryRunReport(report) {
|
|
236
|
+
export function buildSanitizerDryRunReport(report) {
|
|
237
237
|
const actions = [];
|
|
238
238
|
const blockedActions = [];
|
|
239
239
|
report.findings.forEach((finding, index) => {
|
|
@@ -253,7 +253,7 @@ function buildSanitizerDryRunReport(report) {
|
|
|
253
253
|
blocked_actions: blockedActions,
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
|
-
function manifestSummary(operations) {
|
|
256
|
+
export function manifestSummary(operations) {
|
|
257
257
|
return {
|
|
258
258
|
applied: operations.filter((item) => item.status === 'applied').length,
|
|
259
259
|
skipped: operations.filter((item) => item.status === 'skipped').length,
|
|
@@ -261,7 +261,7 @@ function manifestSummary(operations) {
|
|
|
261
261
|
rolled_back: operations.filter((item) => item.status === 'rolled_back').length,
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
async function writeAuditLog(auditLogPath, lines) {
|
|
264
|
+
export async function writeAuditLog(auditLogPath, lines) {
|
|
265
265
|
await mkdir(path.dirname(auditLogPath), { recursive: true });
|
|
266
266
|
if (lines.length === 0) {
|
|
267
267
|
await writeFile(auditLogPath, '', 'utf-8');
|
|
@@ -270,7 +270,7 @@ async function writeAuditLog(auditLogPath, lines) {
|
|
|
270
270
|
const payload = `${lines.map((line) => JSON.stringify(line)).join('\n')}\n`;
|
|
271
271
|
await writeFile(auditLogPath, payload, 'utf-8');
|
|
272
272
|
}
|
|
273
|
-
async function rollbackOperation(projectRoot, memoryRoot, rollback) {
|
|
273
|
+
export async function rollbackOperation(projectRoot, memoryRoot, rollback) {
|
|
274
274
|
const operation = StructuralSanitizerRollbackOperationSchema.parse(rollback);
|
|
275
275
|
if (operation.operation === 'noop')
|
|
276
276
|
return;
|
|
@@ -302,7 +302,7 @@ async function rollbackOperation(projectRoot, memoryRoot, rollback) {
|
|
|
302
302
|
await cp(backup, target, { recursive: true });
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
async function applySanitizerPlan(projectRoot, source, diagnosticReport, dryRunReport) {
|
|
305
|
+
export async function applySanitizerPlan(projectRoot, source, diagnosticReport, dryRunReport) {
|
|
306
306
|
const config = await loadProjectSddConfig(projectRoot);
|
|
307
307
|
const paths = resolveSddPaths(path.resolve(projectRoot), config);
|
|
308
308
|
const transactionId = createTransactionId(dryRunReport.source_report_id);
|
|
@@ -581,7 +581,7 @@ async function applySanitizerPlan(projectRoot, source, diagnosticReport, dryRunR
|
|
|
581
581
|
transaction: manifest,
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
|
-
async function loadDiagnosticReportFromFile(projectRoot, reportPath) {
|
|
584
|
+
export async function loadDiagnosticReportFromFile(projectRoot, reportPath) {
|
|
585
585
|
const absolutePath = path.resolve(projectRoot, reportPath);
|
|
586
586
|
let raw;
|
|
587
587
|
try {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type DeepAgentsRuntimeAdapterEnvelope } from '../deepagents/runtime-factory.js';
|
|
2
|
+
import { type DeepAgentRunEvidence, type DeepAgentRunPlan } from '../deepagents/evidence-mapper.js';
|
|
3
|
+
import { type DeepAgentsOperationalPreflight } from '../deepagents/policy.js';
|
|
4
|
+
import type { DeepAgentsRuntimeImporter } from '../deepagents/runtime-loader.js';
|
|
5
|
+
import type { SddStores } from '../store/sdd-stores.js';
|
|
6
|
+
declare const DEEPAGENTS_RUN_MODES: readonly ["read-only", "plan", "validate", "apply-sandbox", "apply-approved"];
|
|
7
|
+
export type DeepAgentsRunMode = (typeof DEEPAGENTS_RUN_MODES)[number];
|
|
8
|
+
export type DeepAgentsRunStatus = 'allowed' | 'blocked';
|
|
9
|
+
export interface DeepAgentsRunRequest {
|
|
10
|
+
provider: string;
|
|
11
|
+
mode?: string;
|
|
12
|
+
plugin_execution_path?: string;
|
|
13
|
+
plugin_flow?: string[];
|
|
14
|
+
operations?: string[];
|
|
15
|
+
write_scope?: string[];
|
|
16
|
+
planned_writes?: string[];
|
|
17
|
+
requested_env?: string[];
|
|
18
|
+
network_domains?: string[];
|
|
19
|
+
approval_grants?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface DeepAgentsRunResult {
|
|
22
|
+
schema_version: 1;
|
|
23
|
+
feature_id: string;
|
|
24
|
+
provider: 'deepagents';
|
|
25
|
+
requested_provider: string;
|
|
26
|
+
mode_requested: string;
|
|
27
|
+
mode: DeepAgentsRunMode;
|
|
28
|
+
status: DeepAgentsRunStatus;
|
|
29
|
+
fail_closed: true;
|
|
30
|
+
reasons: string[];
|
|
31
|
+
evidence: {
|
|
32
|
+
run_id: string;
|
|
33
|
+
generated_at: string;
|
|
34
|
+
policy: 'deepagents-run-governance/v1';
|
|
35
|
+
direct_state_write_allowed: false;
|
|
36
|
+
plugin_execution: {
|
|
37
|
+
broker_only: true;
|
|
38
|
+
requested_path: string;
|
|
39
|
+
required_flow: string[];
|
|
40
|
+
completed_flow: string[];
|
|
41
|
+
missing_flow: string[];
|
|
42
|
+
};
|
|
43
|
+
runtime?: {
|
|
44
|
+
preflight: DeepAgentsOperationalPreflight;
|
|
45
|
+
adapter: DeepAgentsRuntimeAdapterEnvelope;
|
|
46
|
+
plan: DeepAgentRunPlan;
|
|
47
|
+
run: DeepAgentRunEvidence;
|
|
48
|
+
agent_result?: unknown;
|
|
49
|
+
fake_result?: unknown;
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare class DeepAgentsRunService {
|
|
55
|
+
execute(featureId: string, request: DeepAgentsRunRequest, options?: {
|
|
56
|
+
projectRoot?: string;
|
|
57
|
+
env?: NodeJS.ProcessEnv;
|
|
58
|
+
stores?: SddStores;
|
|
59
|
+
importer?: DeepAgentsRuntimeImporter;
|
|
60
|
+
}): Promise<DeepAgentsRunResult>;
|
|
61
|
+
private executeRuntimePath;
|
|
62
|
+
private invokeReadyRuntime;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=agent-run.service.d.ts.map
|