@superkou/openspec 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +213 -0
- package/bin/openspec.js +5 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +544 -0
- package/dist/commands/change.d.ts +35 -0
- package/dist/commands/change.js +277 -0
- package/dist/commands/completion.d.ts +72 -0
- package/dist/commands/completion.js +264 -0
- package/dist/commands/config.d.ts +36 -0
- package/dist/commands/config.js +611 -0
- package/dist/commands/context-store.d.ts +3 -0
- package/dist/commands/context-store.js +475 -0
- package/dist/commands/feedback.d.ts +9 -0
- package/dist/commands/feedback.js +183 -0
- package/dist/commands/initiative.d.ts +13 -0
- package/dist/commands/initiative.js +318 -0
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/schema.js +869 -0
- package/dist/commands/show.d.ts +14 -0
- package/dist/commands/show.js +132 -0
- package/dist/commands/spec.d.ts +15 -0
- package/dist/commands/spec.js +225 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/commands/validate.js +294 -0
- package/dist/commands/workflow/index.d.ts +19 -0
- package/dist/commands/workflow/index.js +13 -0
- package/dist/commands/workflow/initiative-link.d.ts +24 -0
- package/dist/commands/workflow/initiative-link.js +47 -0
- package/dist/commands/workflow/instructions.d.ts +29 -0
- package/dist/commands/workflow/instructions.js +344 -0
- package/dist/commands/workflow/new-change.d.ts +17 -0
- package/dist/commands/workflow/new-change.js +141 -0
- package/dist/commands/workflow/schemas.d.ts +10 -0
- package/dist/commands/workflow/schemas.js +34 -0
- package/dist/commands/workflow/set-change.d.ts +13 -0
- package/dist/commands/workflow/set-change.js +87 -0
- package/dist/commands/workflow/shared.d.ts +59 -0
- package/dist/commands/workflow/shared.js +116 -0
- package/dist/commands/workflow/status.d.ts +14 -0
- package/dist/commands/workflow/status.js +90 -0
- package/dist/commands/workflow/templates.d.ts +16 -0
- package/dist/commands/workflow/templates.js +69 -0
- package/dist/commands/workspace/context-status.d.ts +4 -0
- package/dist/commands/workspace/context-status.js +59 -0
- package/dist/commands/workspace/open-target-selection.d.ts +13 -0
- package/dist/commands/workspace/open-target-selection.js +146 -0
- package/dist/commands/workspace/open-view.d.ts +62 -0
- package/dist/commands/workspace/open-view.js +249 -0
- package/dist/commands/workspace/open.d.ts +37 -0
- package/dist/commands/workspace/open.js +110 -0
- package/dist/commands/workspace/opener-selection.d.ts +11 -0
- package/dist/commands/workspace/opener-selection.js +98 -0
- package/dist/commands/workspace/operations.d.ts +29 -0
- package/dist/commands/workspace/operations.js +543 -0
- package/dist/commands/workspace/prompt-theme.d.ts +29 -0
- package/dist/commands/workspace/prompt-theme.js +24 -0
- package/dist/commands/workspace/registration.d.ts +13 -0
- package/dist/commands/workspace/registration.js +84 -0
- package/dist/commands/workspace/selection.d.ts +8 -0
- package/dist/commands/workspace/selection.js +104 -0
- package/dist/commands/workspace/setup-prompts.d.ts +13 -0
- package/dist/commands/workspace/setup-prompts.js +121 -0
- package/dist/commands/workspace/types.d.ts +103 -0
- package/dist/commands/workspace/types.js +36 -0
- package/dist/commands/workspace.d.ts +5 -0
- package/dist/commands/workspace.js +577 -0
- package/dist/core/archive.d.ts +11 -0
- package/dist/core/archive.js +318 -0
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/index.d.ts +9 -0
- package/dist/core/artifact-graph/index.js +14 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +183 -0
- package/dist/core/artifact-graph/instruction-loader.js +256 -0
- package/dist/core/artifact-graph/outputs.d.ts +14 -0
- package/dist/core/artifact-graph/outputs.js +39 -0
- package/dist/core/artifact-graph/resolver.d.ts +81 -0
- package/dist/core/artifact-graph/resolver.js +257 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +31 -0
- package/dist/core/artifact-graph/types.d.ts +40 -0
- package/dist/core/artifact-graph/types.js +29 -0
- package/dist/core/available-tools.d.ts +17 -0
- package/dist/core/available-tools.js +43 -0
- package/dist/core/change-metadata/index.d.ts +2 -0
- package/dist/core/change-metadata/index.js +2 -0
- package/dist/core/change-metadata/schema.d.ts +18 -0
- package/dist/core/change-metadata/schema.js +28 -0
- package/dist/core/change-status-policy.d.ts +50 -0
- package/dist/core/change-status-policy.js +70 -0
- package/dist/core/collections/index.d.ts +3 -0
- package/dist/core/collections/index.js +3 -0
- package/dist/core/collections/initiatives/collection.d.ts +4 -0
- package/dist/core/collections/initiatives/collection.js +17 -0
- package/dist/core/collections/initiatives/index.d.ts +6 -0
- package/dist/core/collections/initiatives/index.js +6 -0
- package/dist/core/collections/initiatives/operations.d.ts +49 -0
- package/dist/core/collections/initiatives/operations.js +175 -0
- package/dist/core/collections/initiatives/resolution.d.ts +87 -0
- package/dist/core/collections/initiatives/resolution.js +374 -0
- package/dist/core/collections/initiatives/schema.d.ts +41 -0
- package/dist/core/collections/initiatives/schema.js +134 -0
- package/dist/core/collections/initiatives/templates.d.ts +12 -0
- package/dist/core/collections/initiatives/templates.js +90 -0
- package/dist/core/collections/runtime.d.ts +46 -0
- package/dist/core/collections/runtime.js +194 -0
- package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
- package/dist/core/command-generation/adapters/amazon-q.js +26 -0
- package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
- package/dist/core/command-generation/adapters/antigravity.js +26 -0
- package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
- package/dist/core/command-generation/adapters/auggie.js +27 -0
- package/dist/core/command-generation/adapters/bob.d.ts +14 -0
- package/dist/core/command-generation/adapters/bob.js +45 -0
- package/dist/core/command-generation/adapters/claude.d.ts +13 -0
- package/dist/core/command-generation/adapters/claude.js +50 -0
- package/dist/core/command-generation/adapters/cline.d.ts +14 -0
- package/dist/core/command-generation/adapters/cline.js +27 -0
- package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
- package/dist/core/command-generation/adapters/codebuddy.js +28 -0
- package/dist/core/command-generation/adapters/codex.d.ts +16 -0
- package/dist/core/command-generation/adapters/codex.js +39 -0
- package/dist/core/command-generation/adapters/continue.d.ts +13 -0
- package/dist/core/command-generation/adapters/continue.js +28 -0
- package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
- package/dist/core/command-generation/adapters/costrict.js +27 -0
- package/dist/core/command-generation/adapters/crush.d.ts +13 -0
- package/dist/core/command-generation/adapters/crush.js +30 -0
- package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
- package/dist/core/command-generation/adapters/cursor.js +44 -0
- package/dist/core/command-generation/adapters/factory.d.ts +13 -0
- package/dist/core/command-generation/adapters/factory.js +27 -0
- package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
- package/dist/core/command-generation/adapters/gemini.js +26 -0
- package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
- package/dist/core/command-generation/adapters/github-copilot.js +26 -0
- package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
- package/dist/core/command-generation/adapters/iflow.js +29 -0
- package/dist/core/command-generation/adapters/index.d.ts +32 -0
- package/dist/core/command-generation/adapters/index.js +32 -0
- package/dist/core/command-generation/adapters/junie.d.ts +13 -0
- package/dist/core/command-generation/adapters/junie.js +26 -0
- package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/kilocode.js +23 -0
- package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
- package/dist/core/command-generation/adapters/kiro.js +26 -0
- package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
- package/dist/core/command-generation/adapters/lingma.js +30 -0
- package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
- package/dist/core/command-generation/adapters/opencode.js +29 -0
- package/dist/core/command-generation/adapters/pi.d.ts +18 -0
- package/dist/core/command-generation/adapters/pi.js +55 -0
- package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
- package/dist/core/command-generation/adapters/qoder.js +30 -0
- package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
- package/dist/core/command-generation/adapters/qwen.js +26 -0
- package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
- package/dist/core/command-generation/adapters/roocode.js +27 -0
- package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
- package/dist/core/command-generation/adapters/windsurf.js +51 -0
- package/dist/core/command-generation/generator.d.ts +21 -0
- package/dist/core/command-generation/generator.js +27 -0
- package/dist/core/command-generation/index.d.ts +22 -0
- package/dist/core/command-generation/index.js +24 -0
- package/dist/core/command-generation/registry.d.ts +36 -0
- package/dist/core/command-generation/registry.js +98 -0
- package/dist/core/command-generation/types.d.ts +56 -0
- package/dist/core/command-generation/types.js +8 -0
- package/dist/core/completions/command-registry.d.ts +3 -0
- package/dist/core/completions/command-registry.js +961 -0
- package/dist/core/completions/completion-provider.d.ts +71 -0
- package/dist/core/completions/completion-provider.js +129 -0
- package/dist/core/completions/factory.d.ts +64 -0
- package/dist/core/completions/factory.js +75 -0
- package/dist/core/completions/generators/bash-generator.d.ts +35 -0
- package/dist/core/completions/generators/bash-generator.js +230 -0
- package/dist/core/completions/generators/fish-generator.d.ts +32 -0
- package/dist/core/completions/generators/fish-generator.js +160 -0
- package/dist/core/completions/generators/powershell-generator.d.ts +36 -0
- package/dist/core/completions/generators/powershell-generator.js +266 -0
- package/dist/core/completions/generators/zsh-generator.d.ts +47 -0
- package/dist/core/completions/generators/zsh-generator.js +274 -0
- package/dist/core/completions/installers/bash-installer.d.ts +87 -0
- package/dist/core/completions/installers/bash-installer.js +318 -0
- package/dist/core/completions/installers/fish-installer.d.ts +43 -0
- package/dist/core/completions/installers/fish-installer.js +143 -0
- package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
- package/dist/core/completions/installers/powershell-installer.js +387 -0
- package/dist/core/completions/installers/zsh-installer.d.ts +117 -0
- package/dist/core/completions/installers/zsh-installer.js +421 -0
- package/dist/core/completions/shared-flags.d.ts +12 -0
- package/dist/core/completions/shared-flags.js +28 -0
- package/dist/core/completions/templates/bash-templates.d.ts +6 -0
- package/dist/core/completions/templates/bash-templates.js +30 -0
- package/dist/core/completions/templates/fish-templates.d.ts +7 -0
- package/dist/core/completions/templates/fish-templates.js +45 -0
- package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
- package/dist/core/completions/templates/powershell-templates.js +34 -0
- package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
- package/dist/core/completions/templates/zsh-templates.js +45 -0
- package/dist/core/completions/types.d.ts +101 -0
- package/dist/core/completions/types.js +2 -0
- package/dist/core/config-prompts.d.ts +9 -0
- package/dist/core/config-prompts.js +34 -0
- package/dist/core/config-schema.d.ts +86 -0
- package/dist/core/config-schema.js +213 -0
- package/dist/core/config.d.ts +18 -0
- package/dist/core/config.js +39 -0
- package/dist/core/context-store/binding.d.ts +53 -0
- package/dist/core/context-store/binding.js +197 -0
- package/dist/core/context-store/errors.d.ts +20 -0
- package/dist/core/context-store/errors.js +22 -0
- package/dist/core/context-store/foundation.d.ts +55 -0
- package/dist/core/context-store/foundation.js +321 -0
- package/dist/core/context-store/index.d.ts +6 -0
- package/dist/core/context-store/index.js +6 -0
- package/dist/core/context-store/operations.d.ts +85 -0
- package/dist/core/context-store/operations.js +528 -0
- package/dist/core/context-store/registry.d.ts +45 -0
- package/dist/core/context-store/registry.js +229 -0
- package/dist/core/converters/json-converter.d.ts +6 -0
- package/dist/core/converters/json-converter.js +51 -0
- package/dist/core/global-config.d.ts +49 -0
- package/dist/core/global-config.js +124 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +7 -0
- package/dist/core/init.d.ts +37 -0
- package/dist/core/init.js +593 -0
- package/dist/core/legacy-cleanup.d.ts +162 -0
- package/dist/core/legacy-cleanup.js +514 -0
- package/dist/core/list.d.ts +9 -0
- package/dist/core/list.js +171 -0
- package/dist/core/migration.d.ts +23 -0
- package/dist/core/migration.js +108 -0
- package/dist/core/parsers/change-parser.d.ts +13 -0
- package/dist/core/parsers/change-parser.js +197 -0
- package/dist/core/parsers/markdown-parser.d.ts +26 -0
- package/dist/core/parsers/markdown-parser.js +227 -0
- package/dist/core/parsers/requirement-blocks.d.ts +37 -0
- package/dist/core/parsers/requirement-blocks.js +201 -0
- package/dist/core/parsers/spec-structure.d.ts +9 -0
- package/dist/core/parsers/spec-structure.js +88 -0
- package/dist/core/planning-home.d.ts +21 -0
- package/dist/core/planning-home.js +108 -0
- package/dist/core/profile-sync-drift.d.ts +38 -0
- package/dist/core/profile-sync-drift.js +200 -0
- package/dist/core/profiles.d.ts +26 -0
- package/dist/core/profiles.js +40 -0
- package/dist/core/project-config.d.ts +64 -0
- package/dist/core/project-config.js +223 -0
- package/dist/core/schemas/base.schema.d.ts +13 -0
- package/dist/core/schemas/base.schema.js +13 -0
- package/dist/core/schemas/change.schema.d.ts +73 -0
- package/dist/core/schemas/change.schema.js +31 -0
- package/dist/core/schemas/index.d.ts +4 -0
- package/dist/core/schemas/index.js +4 -0
- package/dist/core/schemas/spec.schema.d.ts +18 -0
- package/dist/core/schemas/spec.schema.js +15 -0
- package/dist/core/shared/index.d.ts +8 -0
- package/dist/core/shared/index.js +8 -0
- package/dist/core/shared/skill-generation.d.ts +49 -0
- package/dist/core/shared/skill-generation.js +96 -0
- package/dist/core/shared/tool-detection.d.ts +71 -0
- package/dist/core/shared/tool-detection.js +158 -0
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +392 -0
- package/dist/core/styles/palette.d.ts +7 -0
- package/dist/core/styles/palette.js +8 -0
- package/dist/core/templates/index.d.ts +8 -0
- package/dist/core/templates/index.js +9 -0
- package/dist/core/templates/skill-templates.d.ts +19 -0
- package/dist/core/templates/skill-templates.js +18 -0
- package/dist/core/templates/types.d.ts +19 -0
- package/dist/core/templates/types.js +5 -0
- package/dist/core/templates/workflows/apply-change.d.ts +10 -0
- package/dist/core/templates/workflows/apply-change.js +314 -0
- package/dist/core/templates/workflows/archive-change.d.ts +10 -0
- package/dist/core/templates/workflows/archive-change.js +277 -0
- package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
- package/dist/core/templates/workflows/bulk-archive-change.js +492 -0
- package/dist/core/templates/workflows/continue-change.d.ts +10 -0
- package/dist/core/templates/workflows/continue-change.js +234 -0
- package/dist/core/templates/workflows/explore.d.ts +10 -0
- package/dist/core/templates/workflows/explore.js +459 -0
- package/dist/core/templates/workflows/feedback.d.ts +9 -0
- package/dist/core/templates/workflows/feedback.js +108 -0
- package/dist/core/templates/workflows/ff-change.d.ts +10 -0
- package/dist/core/templates/workflows/ff-change.js +200 -0
- package/dist/core/templates/workflows/new-change.d.ts +10 -0
- package/dist/core/templates/workflows/new-change.js +143 -0
- package/dist/core/templates/workflows/onboard.d.ts +10 -0
- package/dist/core/templates/workflows/onboard.js +563 -0
- package/dist/core/templates/workflows/propose.d.ts +10 -0
- package/dist/core/templates/workflows/propose.js +218 -0
- package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
- package/dist/core/templates/workflows/sync-specs.js +290 -0
- package/dist/core/templates/workflows/verify-change.d.ts +10 -0
- package/dist/core/templates/workflows/verify-change.js +338 -0
- package/dist/core/update.d.ts +82 -0
- package/dist/core/update.js +557 -0
- package/dist/core/validation/constants.d.ts +34 -0
- package/dist/core/validation/constants.js +40 -0
- package/dist/core/validation/types.d.ts +18 -0
- package/dist/core/validation/types.js +2 -0
- package/dist/core/validation/validator.d.ts +43 -0
- package/dist/core/validation/validator.js +435 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.js +168 -0
- package/dist/core/workspace/foundation.d.ts +67 -0
- package/dist/core/workspace/foundation.js +295 -0
- package/dist/core/workspace/index.d.ts +8 -0
- package/dist/core/workspace/index.js +8 -0
- package/dist/core/workspace/legacy-state.d.ts +28 -0
- package/dist/core/workspace/legacy-state.js +200 -0
- package/dist/core/workspace/link-input.d.ts +9 -0
- package/dist/core/workspace/link-input.js +32 -0
- package/dist/core/workspace/open-surface.d.ts +45 -0
- package/dist/core/workspace/open-surface.js +215 -0
- package/dist/core/workspace/openers.d.ts +21 -0
- package/dist/core/workspace/openers.js +124 -0
- package/dist/core/workspace/registry.d.ts +24 -0
- package/dist/core/workspace/registry.js +146 -0
- package/dist/core/workspace/skills.d.ts +57 -0
- package/dist/core/workspace/skills.js +334 -0
- package/dist/core/workspace/state-io.d.ts +10 -0
- package/dist/core/workspace/state-io.js +121 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/prompts/searchable-multi-select.d.ts +28 -0
- package/dist/prompts/searchable-multi-select.js +159 -0
- package/dist/telemetry/config.d.ts +38 -0
- package/dist/telemetry/config.js +136 -0
- package/dist/telemetry/index.d.ts +31 -0
- package/dist/telemetry/index.js +164 -0
- package/dist/ui/ascii-patterns.d.ts +16 -0
- package/dist/ui/ascii-patterns.js +133 -0
- package/dist/ui/welcome-screen.d.ts +10 -0
- package/dist/ui/welcome-screen.js +146 -0
- package/dist/utils/change-metadata.d.ts +54 -0
- package/dist/utils/change-metadata.js +141 -0
- package/dist/utils/change-utils.d.ts +71 -0
- package/dist/utils/change-utils.js +123 -0
- package/dist/utils/command-references.d.ts +18 -0
- package/dist/utils/command-references.js +20 -0
- package/dist/utils/file-system.d.ts +41 -0
- package/dist/utils/file-system.js +301 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/interactive.d.ts +18 -0
- package/dist/utils/interactive.js +21 -0
- package/dist/utils/item-discovery.d.ts +4 -0
- package/dist/utils/item-discovery.js +72 -0
- package/dist/utils/match.d.ts +3 -0
- package/dist/utils/match.js +22 -0
- package/dist/utils/shell-detection.d.ts +20 -0
- package/dist/utils/shell-detection.js +41 -0
- package/dist/utils/task-progress.d.ts +8 -0
- package/dist/utils/task-progress.js +36 -0
- package/package.json +85 -0
- package/schemas/spec-driven/schema.yaml +151 -0
- package/schemas/spec-driven/templates/design.md +19 -0
- package/schemas/spec-driven/templates/proposal.md +23 -0
- package/schemas/spec-driven/templates/spec.md +8 -0
- package/schemas/spec-driven/templates/tasks.md +9 -0
- package/schemas/workspace-planning/schema.yaml +72 -0
- package/schemas/workspace-planning/templates/design.md +33 -0
- package/schemas/workspace-planning/templates/proposal.md +28 -0
- package/schemas/workspace-planning/templates/spec.md +9 -0
- package/schemas/workspace-planning/templates/tasks.md +15 -0
- package/scripts/postinstall.js +83 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class ShowCommand {
|
|
2
|
+
execute(itemName?: string, options?: {
|
|
3
|
+
json?: boolean;
|
|
4
|
+
type?: string;
|
|
5
|
+
noInteractive?: boolean;
|
|
6
|
+
[k: string]: any;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
private normalizeType;
|
|
9
|
+
private runInteractiveByType;
|
|
10
|
+
private showDirect;
|
|
11
|
+
private printNonInteractiveHint;
|
|
12
|
+
private warnIrrelevantFlags;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=show.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { isInteractive } from '../utils/interactive.js';
|
|
2
|
+
import { getActiveChangeIds, getSpecIds } from '../utils/item-discovery.js';
|
|
3
|
+
import { ChangeCommand } from './change.js';
|
|
4
|
+
import { SpecCommand } from './spec.js';
|
|
5
|
+
import { nearestMatches } from '../utils/match.js';
|
|
6
|
+
const CHANGE_FLAG_KEYS = new Set(['deltasOnly', 'requirementsOnly']);
|
|
7
|
+
const SPEC_FLAG_KEYS = new Set(['requirements', 'scenarios', 'requirement']);
|
|
8
|
+
export class ShowCommand {
|
|
9
|
+
async execute(itemName, options = {}) {
|
|
10
|
+
const interactive = isInteractive(options);
|
|
11
|
+
const typeOverride = this.normalizeType(options.type);
|
|
12
|
+
if (!itemName) {
|
|
13
|
+
if (interactive) {
|
|
14
|
+
const { select } = await import('@inquirer/prompts');
|
|
15
|
+
const type = await select({
|
|
16
|
+
message: '你想显示什么?',
|
|
17
|
+
choices: [
|
|
18
|
+
{ name: '变更', value: 'change' },
|
|
19
|
+
{ name: '规格', value: 'spec' },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
await this.runInteractiveByType(type, options);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.printNonInteractiveHint();
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await this.showDirect(itemName, { typeOverride, options });
|
|
30
|
+
}
|
|
31
|
+
normalizeType(value) {
|
|
32
|
+
if (!value)
|
|
33
|
+
return undefined;
|
|
34
|
+
const v = value.toLowerCase();
|
|
35
|
+
if (v === 'change' || v === 'spec')
|
|
36
|
+
return v;
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
async runInteractiveByType(type, options) {
|
|
40
|
+
const { select } = await import('@inquirer/prompts');
|
|
41
|
+
if (type === 'change') {
|
|
42
|
+
const changes = await getActiveChangeIds();
|
|
43
|
+
if (changes.length === 0) {
|
|
44
|
+
console.error('未找到变更。');
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const picked = await select({ message: '选择一个变更', choices: changes.map(id => ({ name: id, value: id })) });
|
|
49
|
+
const cmd = new ChangeCommand();
|
|
50
|
+
await cmd.show(picked, options);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const specs = await getSpecIds();
|
|
54
|
+
if (specs.length === 0) {
|
|
55
|
+
console.error('未找到规格。');
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const picked = await select({ message: '选择一个规格', choices: specs.map(id => ({ name: id, value: id })) });
|
|
60
|
+
const cmd = new SpecCommand();
|
|
61
|
+
await cmd.show(picked, options);
|
|
62
|
+
}
|
|
63
|
+
async showDirect(itemName, params) {
|
|
64
|
+
// Optimize lookups when type is pre-specified
|
|
65
|
+
let isChange = false;
|
|
66
|
+
let isSpec = false;
|
|
67
|
+
let changes = [];
|
|
68
|
+
let specs = [];
|
|
69
|
+
if (params.typeOverride === 'change') {
|
|
70
|
+
changes = await getActiveChangeIds();
|
|
71
|
+
isChange = changes.includes(itemName);
|
|
72
|
+
}
|
|
73
|
+
else if (params.typeOverride === 'spec') {
|
|
74
|
+
specs = await getSpecIds();
|
|
75
|
+
isSpec = specs.includes(itemName);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
[changes, specs] = await Promise.all([getActiveChangeIds(), getSpecIds()]);
|
|
79
|
+
isChange = changes.includes(itemName);
|
|
80
|
+
isSpec = specs.includes(itemName);
|
|
81
|
+
}
|
|
82
|
+
const resolvedType = params.typeOverride ?? (isChange ? 'change' : isSpec ? 'spec' : undefined);
|
|
83
|
+
if (!resolvedType) {
|
|
84
|
+
console.error(`未知项目 '${itemName}'`);
|
|
85
|
+
const suggestions = nearestMatches(itemName, [...changes, ...specs]);
|
|
86
|
+
if (suggestions.length)
|
|
87
|
+
console.error(`你是否想找: ${suggestions.join(', ')}?`);
|
|
88
|
+
process.exitCode = 1;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!params.typeOverride && isChange && isSpec) {
|
|
92
|
+
console.error(`项目 '${itemName}' 同时匹配了变更和规格,存在歧义。`);
|
|
93
|
+
console.error('请传递 --type change|spec,或使用: openspec change show / openspec spec show');
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.warnIrrelevantFlags(resolvedType, params.options);
|
|
98
|
+
if (resolvedType === 'change') {
|
|
99
|
+
const cmd = new ChangeCommand();
|
|
100
|
+
await cmd.show(itemName, params.options);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const cmd = new SpecCommand();
|
|
104
|
+
await cmd.show(itemName, params.options);
|
|
105
|
+
}
|
|
106
|
+
printNonInteractiveHint() {
|
|
107
|
+
console.error('没有可显示的内容。试试以下命令之一:');
|
|
108
|
+
console.error(' openspec show <项目>');
|
|
109
|
+
console.error(' openspec change show');
|
|
110
|
+
console.error(' openspec spec show');
|
|
111
|
+
console.error('或者在交互式终端中运行。');
|
|
112
|
+
}
|
|
113
|
+
warnIrrelevantFlags(type, options) {
|
|
114
|
+
const irrelevant = [];
|
|
115
|
+
if (type === 'change') {
|
|
116
|
+
for (const k of SPEC_FLAG_KEYS)
|
|
117
|
+
if (k in options)
|
|
118
|
+
irrelevant.push(k);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
for (const k of CHANGE_FLAG_KEYS)
|
|
122
|
+
if (k in options)
|
|
123
|
+
irrelevant.push(k);
|
|
124
|
+
}
|
|
125
|
+
if (irrelevant.length > 0) {
|
|
126
|
+
console.error(`警告: 忽略不适用于 ${type} 的标志: ${irrelevant.join(', ')}`);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=show.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
interface ShowOptions {
|
|
3
|
+
json?: boolean;
|
|
4
|
+
requirements?: boolean;
|
|
5
|
+
scenarios?: boolean;
|
|
6
|
+
requirement?: string;
|
|
7
|
+
noInteractive?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class SpecCommand {
|
|
10
|
+
private SPECS_DIR;
|
|
11
|
+
show(specId?: string, options?: ShowOptions): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare function registerSpecCommand(rootProgram: typeof program): import("commander").Command;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { MarkdownParser } from '../core/parsers/markdown-parser.js';
|
|
4
|
+
import { Validator } from '../core/validation/validator.js';
|
|
5
|
+
import { isInteractive } from '../utils/interactive.js';
|
|
6
|
+
import { getSpecIds } from '../utils/item-discovery.js';
|
|
7
|
+
const SPECS_DIR = 'openspec/specs';
|
|
8
|
+
function parseSpecFromFile(specPath, specId) {
|
|
9
|
+
const content = readFileSync(specPath, 'utf-8');
|
|
10
|
+
const parser = new MarkdownParser(content);
|
|
11
|
+
return parser.parseSpec(specId);
|
|
12
|
+
}
|
|
13
|
+
function validateRequirementIndex(spec, requirementOpt) {
|
|
14
|
+
if (!requirementOpt)
|
|
15
|
+
return undefined;
|
|
16
|
+
const index = Number.parseInt(requirementOpt, 10);
|
|
17
|
+
if (!Number.isInteger(index) || index < 1 || index > spec.requirements.length) {
|
|
18
|
+
throw new Error(`需求 ${requirementOpt} 未找到`);
|
|
19
|
+
}
|
|
20
|
+
return index - 1; // convert to 0-based
|
|
21
|
+
}
|
|
22
|
+
function filterSpec(spec, options) {
|
|
23
|
+
const requirementIndex = validateRequirementIndex(spec, options.requirement);
|
|
24
|
+
const includeScenarios = options.scenarios !== false && !options.requirements;
|
|
25
|
+
const filteredRequirements = (requirementIndex !== undefined
|
|
26
|
+
? [spec.requirements[requirementIndex]]
|
|
27
|
+
: spec.requirements).map(req => ({
|
|
28
|
+
text: req.text,
|
|
29
|
+
scenarios: includeScenarios ? req.scenarios : [],
|
|
30
|
+
}));
|
|
31
|
+
const metadata = spec.metadata ?? { version: '1.0.0', format: 'openspec' };
|
|
32
|
+
return {
|
|
33
|
+
name: spec.name,
|
|
34
|
+
overview: spec.overview,
|
|
35
|
+
requirements: filteredRequirements,
|
|
36
|
+
metadata,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Print the raw markdown content for a spec file without any formatting.
|
|
41
|
+
* Raw-first behavior ensures text mode is a passthrough for deterministic output.
|
|
42
|
+
*/
|
|
43
|
+
function printSpecTextRaw(specPath) {
|
|
44
|
+
const content = readFileSync(specPath, 'utf-8');
|
|
45
|
+
console.log(content);
|
|
46
|
+
}
|
|
47
|
+
export class SpecCommand {
|
|
48
|
+
SPECS_DIR = 'openspec/specs';
|
|
49
|
+
async show(specId, options = {}) {
|
|
50
|
+
if (!specId) {
|
|
51
|
+
const canPrompt = isInteractive(options);
|
|
52
|
+
const specIds = await getSpecIds();
|
|
53
|
+
if (canPrompt && specIds.length > 0) {
|
|
54
|
+
const { select } = await import('@inquirer/prompts');
|
|
55
|
+
specId = await select({
|
|
56
|
+
message: '选择一个规格进行查看',
|
|
57
|
+
choices: specIds.map(id => ({ name: id, value: id })),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error('缺少必需参数 <spec-id>');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const specPath = join(this.SPECS_DIR, specId, 'spec.md');
|
|
65
|
+
if (!existsSync(specPath)) {
|
|
66
|
+
throw new Error(`规格 '${specId}' 未找到于 openspec/specs/${specId}/spec.md`);
|
|
67
|
+
}
|
|
68
|
+
if (options.json) {
|
|
69
|
+
if (options.requirements && options.requirement) {
|
|
70
|
+
throw new Error('选项 --requirements 和 --requirement 不能同时使用');
|
|
71
|
+
}
|
|
72
|
+
const parsed = parseSpecFromFile(specPath, specId);
|
|
73
|
+
const filtered = filterSpec(parsed, options);
|
|
74
|
+
const output = {
|
|
75
|
+
id: specId,
|
|
76
|
+
title: parsed.name,
|
|
77
|
+
overview: parsed.overview,
|
|
78
|
+
requirementCount: filtered.requirements.length,
|
|
79
|
+
requirements: filtered.requirements,
|
|
80
|
+
metadata: parsed.metadata ?? { version: '1.0.0', format: 'openspec' },
|
|
81
|
+
};
|
|
82
|
+
console.log(JSON.stringify(output, null, 2));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
printSpecTextRaw(specPath);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function registerSpecCommand(rootProgram) {
|
|
89
|
+
const specCommand = rootProgram
|
|
90
|
+
.command('spec')
|
|
91
|
+
.description('管理和查看 OpenSpec 规格');
|
|
92
|
+
// Deprecation notice for noun-based commands
|
|
93
|
+
specCommand.hook('preAction', () => {
|
|
94
|
+
console.error('警告:"openspec spec ..." 命令已弃用。建议使用动词优先命令(如 "openspec show"、"openspec validate --specs")。');
|
|
95
|
+
});
|
|
96
|
+
specCommand
|
|
97
|
+
.command('show [spec-id]')
|
|
98
|
+
.description('显示指定的规格')
|
|
99
|
+
.option('--json', '以 JSON 格式输出')
|
|
100
|
+
.option('--requirements', '仅 JSON:只显示需求(排除场景)')
|
|
101
|
+
.option('--no-scenarios', '仅 JSON:排除场景内容')
|
|
102
|
+
.option('-r, --requirement <id>', '仅 JSON:按 ID 显示特定需求(从 1 开始)')
|
|
103
|
+
.option('--no-interactive', '禁用交互式提示')
|
|
104
|
+
.action(async (specId, options) => {
|
|
105
|
+
try {
|
|
106
|
+
const cmd = new SpecCommand();
|
|
107
|
+
await cmd.show(specId, options);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error(`错误:${error instanceof Error ? error.message : '未知错误'}`);
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
specCommand
|
|
115
|
+
.command('list')
|
|
116
|
+
.description('列出所有可用的规格')
|
|
117
|
+
.option('--json', '以 JSON 格式输出')
|
|
118
|
+
.option('--long', '显示 ID、标题和数量')
|
|
119
|
+
.action((options) => {
|
|
120
|
+
try {
|
|
121
|
+
if (!existsSync(SPECS_DIR)) {
|
|
122
|
+
console.log('未找到项目');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const specs = readdirSync(SPECS_DIR, { withFileTypes: true })
|
|
126
|
+
.filter(dirent => dirent.isDirectory())
|
|
127
|
+
.map(dirent => {
|
|
128
|
+
const specPath = join(SPECS_DIR, dirent.name, 'spec.md');
|
|
129
|
+
if (existsSync(specPath)) {
|
|
130
|
+
try {
|
|
131
|
+
const spec = parseSpecFromFile(specPath, dirent.name);
|
|
132
|
+
return {
|
|
133
|
+
id: dirent.name,
|
|
134
|
+
title: spec.name,
|
|
135
|
+
requirementCount: spec.requirements.length
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return {
|
|
140
|
+
id: dirent.name,
|
|
141
|
+
title: dirent.name,
|
|
142
|
+
requirementCount: 0
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
})
|
|
148
|
+
.filter((spec) => spec !== null)
|
|
149
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
150
|
+
if (options.json) {
|
|
151
|
+
console.log(JSON.stringify(specs, null, 2));
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (specs.length === 0) {
|
|
155
|
+
console.log('未找到项目');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!options.long) {
|
|
159
|
+
specs.forEach(spec => console.log(spec.id));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
specs.forEach(spec => {
|
|
163
|
+
console.log(`${spec.id}: ${spec.title} [需求 ${spec.requirementCount}]`);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.error(`错误:${error instanceof Error ? error.message : '未知错误'}`);
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
specCommand
|
|
173
|
+
.command('validate [spec-id]')
|
|
174
|
+
.description('验证规格结构')
|
|
175
|
+
.option('--strict', '启用严格验证模式')
|
|
176
|
+
.option('--json', '以 JSON 格式输出验证报告')
|
|
177
|
+
.option('--no-interactive', '禁用交互式提示')
|
|
178
|
+
.action(async (specId, options) => {
|
|
179
|
+
try {
|
|
180
|
+
if (!specId) {
|
|
181
|
+
const canPrompt = isInteractive(options);
|
|
182
|
+
const specIds = await getSpecIds();
|
|
183
|
+
if (canPrompt && specIds.length > 0) {
|
|
184
|
+
const { select } = await import('@inquirer/prompts');
|
|
185
|
+
specId = await select({
|
|
186
|
+
message: '选择一个规格进行验证',
|
|
187
|
+
choices: specIds.map(id => ({ name: id, value: id })),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
throw new Error('缺少必需参数 <spec-id>');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const specPath = join(SPECS_DIR, specId, 'spec.md');
|
|
195
|
+
if (!existsSync(specPath)) {
|
|
196
|
+
throw new Error(`规格 '${specId}' 未找到于 openspec/specs/${specId}/spec.md`);
|
|
197
|
+
}
|
|
198
|
+
const validator = new Validator(options.strict);
|
|
199
|
+
const report = await validator.validateSpec(specPath);
|
|
200
|
+
if (options.json) {
|
|
201
|
+
console.log(JSON.stringify(report, null, 2));
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
if (report.valid) {
|
|
205
|
+
console.log(`规格 '${specId}' 有效`);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
console.error(`规格 '${specId}' 存在问题`);
|
|
209
|
+
report.issues.forEach(issue => {
|
|
210
|
+
const label = issue.level === 'ERROR' ? '错误' : issue.level === 'WARNING' ? '警告' : issue.level;
|
|
211
|
+
const prefix = issue.level === 'ERROR' ? '✗' : issue.level === 'WARNING' ? '⚠' : 'ℹ';
|
|
212
|
+
console.error(`${prefix} [${label}] ${issue.path}: ${issue.message}`);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
process.exitCode = report.valid ? 0 : 1;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
console.error(`错误:${error instanceof Error ? error.message : '未知错误'}`);
|
|
220
|
+
process.exitCode = 1;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
return specCommand;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface ExecuteOptions {
|
|
2
|
+
all?: boolean;
|
|
3
|
+
changes?: boolean;
|
|
4
|
+
specs?: boolean;
|
|
5
|
+
type?: string;
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
noInteractive?: boolean;
|
|
9
|
+
interactive?: boolean;
|
|
10
|
+
concurrency?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class ValidateCommand {
|
|
13
|
+
execute(itemName: string | undefined, options?: ExecuteOptions): Promise<void>;
|
|
14
|
+
private normalizeType;
|
|
15
|
+
private runInteractiveSelector;
|
|
16
|
+
private printNonInteractiveHint;
|
|
17
|
+
private validateDirectItem;
|
|
18
|
+
private validateByType;
|
|
19
|
+
private printReport;
|
|
20
|
+
private printNextSteps;
|
|
21
|
+
private runBulkValidation;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=validate.d.ts.map
|