@thiagodiogo/pastelsdd 1.0.0-beta.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 +3 -0
- package/bin/pastelsdd.js +5 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +526 -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 +282 -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-view.d.ts +62 -0
- package/dist/commands/workspace/open-view.js +228 -0
- package/dist/commands/workspace/open.d.ts +37 -0
- package/dist/commands/workspace/open.js +102 -0
- package/dist/commands/workspace/opener-selection.d.ts +11 -0
- package/dist/commands/workspace/opener-selection.js +93 -0
- package/dist/commands/workspace/operations.d.ts +28 -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 +6 -0
- package/dist/commands/workspace/selection.js +122 -0
- package/dist/commands/workspace/types.d.ts +103 -0
- package/dist/commands/workspace/types.js +36 -0
- package/dist/commands/workspace.d.ts +6 -0
- package/dist/commands/workspace.js +678 -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 +939 -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 +38 -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 +54 -0
- package/dist/core/context-store/foundation.js +318 -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 +62 -0
- package/dist/core/context-store/operations.js +352 -0
- package/dist/core/context-store/registry.d.ts +35 -0
- package/dist/core/context-store/registry.js +158 -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 +33 -0
- package/dist/core/validation/validator.js +418 -0
- package/dist/core/view.d.ts +8 -0
- package/dist/core/view.js +168 -0
- package/dist/core/workspace/foundation.d.ts +62 -0
- package/dist/core/workspace/foundation.js +274 -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 +43 -0
- package/dist/core/workspace/open-surface.js +214 -0
- package/dist/core/workspace/openers.d.ts +21 -0
- package/dist/core/workspace/openers.js +119 -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 +119 -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 +84 -0
- package/schemas/spec-driven/schema.yaml +153 -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,214 @@
|
|
|
1
|
+
import * as nodeFs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { FileSystemUtils } from '../../utils/file-system.js';
|
|
4
|
+
import { getWorkspaceContextInitiativeId, getWorkspaceCodeWorkspacePath, getWorkspacePortableIgnorePatterns, } from './foundation.js';
|
|
5
|
+
const fs = nodeFs.promises;
|
|
6
|
+
export const WORKSPACE_GUIDANCE_START_MARKER = '<!-- PASTELSDD:WORKSPACE-GUIDANCE:START -->';
|
|
7
|
+
export const WORKSPACE_GUIDANCE_END_MARKER = '<!-- PASTELSDD:WORKSPACE-GUIDANCE:END -->';
|
|
8
|
+
export const WORKSPACE_GUIDANCE_BODY = `# Pastelsdd Workspace Guidance
|
|
9
|
+
|
|
10
|
+
This directory is an Pastelsdd workspace: a local working view over context stores, initiatives, repos, and folders.
|
|
11
|
+
|
|
12
|
+
- Use this workspace to open the local view of coordinated work.
|
|
13
|
+
- Use initiatives for durable cross-team or cross-repo intent, decisions, requirements, and coordination context.
|
|
14
|
+
- Use repo-local Pastelsdd changes for implementation plans owned by a repo or team.
|
|
15
|
+
- Use linked repos and folders to inspect context, understand ownership, and make edits in the place that owns the work.
|
|
16
|
+
- Keep workspace-local files focused on local paths, opener state, agent setup, and other machine-specific view state.
|
|
17
|
+
- Use Pastelsdd workspace commands instead of hand-editing \`workspace.yaml\`.
|
|
18
|
+
- If this workspace contains legacy or beta workspace-level planning files, treat them as compatibility context unless the user explicitly asks to use that beta flow.`;
|
|
19
|
+
async function fileExists(filePath) {
|
|
20
|
+
try {
|
|
21
|
+
return (await fs.stat(filePath)).isFile();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function directoryExists(dirPath) {
|
|
28
|
+
try {
|
|
29
|
+
return (await fs.stat(dirPath)).isDirectory();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function formatGuidancePathList(items) {
|
|
36
|
+
if (items.length === 0) {
|
|
37
|
+
return '- None selected yet.';
|
|
38
|
+
}
|
|
39
|
+
return items.map((item) => `- ${item.label}: ${item.path}`).join('\n');
|
|
40
|
+
}
|
|
41
|
+
function buildWorkspaceContextGuidance(viewState, resolvedContext) {
|
|
42
|
+
const linkedRoots = Object.entries(viewState.links)
|
|
43
|
+
.filter((entry) => typeof entry[1] === 'string')
|
|
44
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
45
|
+
.map(([name, linkPath]) => ({ label: name, path: linkPath }));
|
|
46
|
+
if (!viewState.context) {
|
|
47
|
+
return `## Local View
|
|
48
|
+
|
|
49
|
+
This workspace is not bound to an initiative. It is still a first-class local view over selected repos or folders.
|
|
50
|
+
|
|
51
|
+
## Linked Implementation Context
|
|
52
|
+
|
|
53
|
+
${formatGuidancePathList(linkedRoots)}`;
|
|
54
|
+
}
|
|
55
|
+
const storedContextSelector = viewState.context.store.selector;
|
|
56
|
+
const storedContextStore = viewState.context
|
|
57
|
+
? storedContextSelector?.kind === 'path'
|
|
58
|
+
? `${viewState.context.store.id} via ${storedContextSelector.path}`
|
|
59
|
+
: viewState.context.store.id
|
|
60
|
+
: null;
|
|
61
|
+
const storedInitiativeId = viewState.context
|
|
62
|
+
? getWorkspaceContextInitiativeId(viewState.context)
|
|
63
|
+
: null;
|
|
64
|
+
const contextLines = resolvedContext
|
|
65
|
+
? [
|
|
66
|
+
`- Context store: ${resolvedContext.contextStore.id} (${resolvedContext.contextStore.root})`,
|
|
67
|
+
`- Initiative: ${resolvedContext.initiative.id} (${resolvedContext.initiative.root})`,
|
|
68
|
+
`- Initiative title: ${resolvedContext.initiative.title}`,
|
|
69
|
+
`- Initiative metadata: ${resolvedContext.initiative.metadataPath}`,
|
|
70
|
+
'- Broader context may exist in the context store, but this workspace opens the selected initiative by default.',
|
|
71
|
+
].join('\n')
|
|
72
|
+
: [
|
|
73
|
+
`- Context store: ${storedContextStore}`,
|
|
74
|
+
`- Initiative: ${storedInitiativeId}`,
|
|
75
|
+
'- Run `pastelsdd workspace open --json` to refresh resolved local paths for this view.',
|
|
76
|
+
].join('\n');
|
|
77
|
+
return `## Selected Initiative Context
|
|
78
|
+
|
|
79
|
+
${contextLines}
|
|
80
|
+
|
|
81
|
+
## Advisory Edit Boundaries
|
|
82
|
+
|
|
83
|
+
- Treat initiative and context-store files as shared coordination context.
|
|
84
|
+
- Treat linked repos and folders as local implementation context when the user has selected them.
|
|
85
|
+
- These boundaries are advisory in this Pastelsdd version; use judgment and repo ownership when editing.
|
|
86
|
+
|
|
87
|
+
## Linked Implementation Context
|
|
88
|
+
|
|
89
|
+
${formatGuidancePathList(linkedRoots)}`;
|
|
90
|
+
}
|
|
91
|
+
export function buildWorkspaceGuidanceBlock(viewState, resolvedContext) {
|
|
92
|
+
const contextGuidance = viewState
|
|
93
|
+
? `\n\n${buildWorkspaceContextGuidance(viewState, resolvedContext)}`
|
|
94
|
+
: '';
|
|
95
|
+
return `${WORKSPACE_GUIDANCE_START_MARKER}
|
|
96
|
+
${WORKSPACE_GUIDANCE_BODY}${contextGuidance}
|
|
97
|
+
${WORKSPACE_GUIDANCE_END_MARKER}`;
|
|
98
|
+
}
|
|
99
|
+
export function applyWorkspaceGuidanceBlock(existingContent, viewState, resolvedContext) {
|
|
100
|
+
const block = buildWorkspaceGuidanceBlock(viewState, resolvedContext);
|
|
101
|
+
const startIndex = existingContent.indexOf(WORKSPACE_GUIDANCE_START_MARKER);
|
|
102
|
+
const endIndex = existingContent.indexOf(WORKSPACE_GUIDANCE_END_MARKER);
|
|
103
|
+
if (startIndex !== -1 || endIndex !== -1) {
|
|
104
|
+
if (startIndex === -1 || endIndex === -1 || endIndex < startIndex) {
|
|
105
|
+
throw new Error('Invalid Pastelsdd workspace guidance marker state in AGENTS.md.');
|
|
106
|
+
}
|
|
107
|
+
const before = existingContent.slice(0, startIndex).trimEnd();
|
|
108
|
+
const after = existingContent
|
|
109
|
+
.slice(endIndex + WORKSPACE_GUIDANCE_END_MARKER.length)
|
|
110
|
+
.trimStart();
|
|
111
|
+
const prefix = before.length > 0 ? `${before}\n\n` : '';
|
|
112
|
+
const suffix = after.length > 0 ? `\n\n${after.trimEnd()}\n` : '\n';
|
|
113
|
+
return `${prefix}${block}${suffix}`;
|
|
114
|
+
}
|
|
115
|
+
if (existingContent.trim().length === 0) {
|
|
116
|
+
return `${block}\n`;
|
|
117
|
+
}
|
|
118
|
+
return `${existingContent.trimEnd()}\n\n${block}\n`;
|
|
119
|
+
}
|
|
120
|
+
export function buildWorkspaceCodeWorkspaceContent(links, resolvedContext) {
|
|
121
|
+
const folders = [
|
|
122
|
+
{
|
|
123
|
+
path: '.',
|
|
124
|
+
},
|
|
125
|
+
...(resolvedContext
|
|
126
|
+
? [
|
|
127
|
+
{
|
|
128
|
+
name: `initiative:${resolvedContext.initiative.id}`,
|
|
129
|
+
path: resolvedContext.initiative.root,
|
|
130
|
+
},
|
|
131
|
+
]
|
|
132
|
+
: []),
|
|
133
|
+
...links.map((link) => ({
|
|
134
|
+
name: link.name,
|
|
135
|
+
path: link.path,
|
|
136
|
+
})),
|
|
137
|
+
];
|
|
138
|
+
return `${JSON.stringify({ folders }, null, 2)}\n`;
|
|
139
|
+
}
|
|
140
|
+
export async function writeWorkspaceCodeWorkspaceFile(codeWorkspacePath, links, resolvedContext) {
|
|
141
|
+
await FileSystemUtils.writeFile(codeWorkspacePath, buildWorkspaceCodeWorkspaceContent(links, resolvedContext));
|
|
142
|
+
}
|
|
143
|
+
export async function resolveWorkspaceOpenLinks(viewState) {
|
|
144
|
+
const links = [];
|
|
145
|
+
const skipped = [];
|
|
146
|
+
for (const linkName of Object.keys(viewState.links).sort((a, b) => a.localeCompare(b))) {
|
|
147
|
+
const localPath = viewState.links[linkName] ?? null;
|
|
148
|
+
if (!localPath) {
|
|
149
|
+
skipped.push({
|
|
150
|
+
name: linkName,
|
|
151
|
+
path: null,
|
|
152
|
+
reason: 'missing-local-path',
|
|
153
|
+
});
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!(await directoryExists(localPath))) {
|
|
157
|
+
skipped.push({
|
|
158
|
+
name: linkName,
|
|
159
|
+
path: localPath,
|
|
160
|
+
reason: 'path-missing',
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
links.push({
|
|
165
|
+
name: linkName,
|
|
166
|
+
path: localPath,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return { links, skipped };
|
|
170
|
+
}
|
|
171
|
+
async function syncWorkspaceGuidance(workspaceRoot, viewState, resolvedContext) {
|
|
172
|
+
const agentsPath = path.join(workspaceRoot, 'AGENTS.md');
|
|
173
|
+
const existingContent = (await fileExists(agentsPath))
|
|
174
|
+
? await fs.readFile(agentsPath, 'utf-8')
|
|
175
|
+
: '';
|
|
176
|
+
await FileSystemUtils.writeFile(agentsPath, applyWorkspaceGuidanceBlock(existingContent, viewState, resolvedContext));
|
|
177
|
+
return agentsPath;
|
|
178
|
+
}
|
|
179
|
+
async function syncWorkspaceCodeWorkspace(workspaceRoot, viewState, links, resolvedContext) {
|
|
180
|
+
const codeWorkspacePath = getWorkspaceCodeWorkspacePath(workspaceRoot, viewState.name);
|
|
181
|
+
await writeWorkspaceCodeWorkspaceFile(codeWorkspacePath, links, resolvedContext);
|
|
182
|
+
return codeWorkspacePath;
|
|
183
|
+
}
|
|
184
|
+
async function syncWorkspaceIgnoreRules(workspaceRoot, workspaceName) {
|
|
185
|
+
const gitignorePath = path.join(workspaceRoot, '.gitignore');
|
|
186
|
+
const patterns = getWorkspacePortableIgnorePatterns(workspaceName);
|
|
187
|
+
const existingContent = (await fileExists(gitignorePath))
|
|
188
|
+
? await fs.readFile(gitignorePath, 'utf-8')
|
|
189
|
+
: '';
|
|
190
|
+
const existingLines = new Set(existingContent
|
|
191
|
+
.split(/\r?\n/u)
|
|
192
|
+
.map((line) => line.trim())
|
|
193
|
+
.filter((line) => line.length > 0));
|
|
194
|
+
const missingPatterns = patterns.filter((pattern) => !existingLines.has(pattern));
|
|
195
|
+
if (missingPatterns.length === 0) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const prefix = existingContent.length > 0 && !existingContent.endsWith('\n') ? '\n' : '';
|
|
199
|
+
await FileSystemUtils.writeFile(gitignorePath, `${existingContent}${prefix}${missingPatterns.join('\n')}\n`);
|
|
200
|
+
}
|
|
201
|
+
export async function syncWorkspaceOpenSurface(workspaceRoot, viewState, resolvedContext) {
|
|
202
|
+
const openLinks = await resolveWorkspaceOpenLinks(viewState);
|
|
203
|
+
const agentsPath = await syncWorkspaceGuidance(workspaceRoot, viewState, resolvedContext);
|
|
204
|
+
const codeWorkspacePath = await syncWorkspaceCodeWorkspace(workspaceRoot, viewState, openLinks.links, resolvedContext);
|
|
205
|
+
await syncWorkspaceIgnoreRules(workspaceRoot, viewState.name);
|
|
206
|
+
return {
|
|
207
|
+
...openLinks,
|
|
208
|
+
generated: {
|
|
209
|
+
agentsPath,
|
|
210
|
+
codeWorkspacePath,
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=open-surface.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WorkspacePreferredOpener, WorkspaceSupportedOpenerValue } from './foundation.js';
|
|
2
|
+
export interface WorkspaceOpenerChoice {
|
|
3
|
+
value: WorkspaceSupportedOpenerValue;
|
|
4
|
+
label: string;
|
|
5
|
+
opener: WorkspacePreferredOpener;
|
|
6
|
+
executable: string;
|
|
7
|
+
available: boolean;
|
|
8
|
+
unavailableNote: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function isWorkspaceExecutableAvailable(executable: string, options?: {
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
platform?: NodeJS.Platform;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export declare function getWorkspaceOpenerExecutable(opener: WorkspacePreferredOpener): string;
|
|
15
|
+
export declare function getWorkspaceOpenerLabel(opener: WorkspacePreferredOpener): string;
|
|
16
|
+
export declare function listWorkspaceOpenerChoices(options?: {
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
platform?: NodeJS.Platform;
|
|
19
|
+
}): WorkspaceOpenerChoice[];
|
|
20
|
+
export declare function getDefaultWorkspaceOpenerChoiceValue(choices: WorkspaceOpenerChoice[]): WorkspaceSupportedOpenerValue;
|
|
21
|
+
//# sourceMappingURL=openers.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as nodeFs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { parseWorkspacePreferredOpenerValue, } from './foundation.js';
|
|
4
|
+
const fs = nodeFs;
|
|
5
|
+
const WORKSPACE_OPENER_CHOICE_DEFINITIONS = [
|
|
6
|
+
{
|
|
7
|
+
value: 'editor',
|
|
8
|
+
label: 'VS Code editor',
|
|
9
|
+
executable: 'code',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
value: 'codex',
|
|
13
|
+
label: 'Codex',
|
|
14
|
+
executable: 'codex',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: 'claude',
|
|
18
|
+
label: 'Claude',
|
|
19
|
+
executable: 'claude',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: 'github-copilot',
|
|
23
|
+
label: 'GitHub Copilot in VS Code',
|
|
24
|
+
executable: 'code',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
function getPathValue(env) {
|
|
28
|
+
return env.PATH ?? env.Path ?? env.path ?? '';
|
|
29
|
+
}
|
|
30
|
+
function getPathExts(env, platform) {
|
|
31
|
+
if (platform !== 'win32') {
|
|
32
|
+
return [''];
|
|
33
|
+
}
|
|
34
|
+
const pathExt = env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD';
|
|
35
|
+
return pathExt
|
|
36
|
+
.split(';')
|
|
37
|
+
.map((extension) => extension.trim())
|
|
38
|
+
.filter((extension) => extension.length > 0);
|
|
39
|
+
}
|
|
40
|
+
function isExecutableFile(candidatePath, platform) {
|
|
41
|
+
try {
|
|
42
|
+
const stats = fs.statSync(candidatePath);
|
|
43
|
+
if (!stats.isFile()) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (platform === 'win32') {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
fs.accessSync(candidatePath, fs.constants.X_OK);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function isWorkspaceExecutableAvailable(executable, options = {}) {
|
|
57
|
+
const env = options.env ?? process.env;
|
|
58
|
+
const platform = options.platform ?? process.platform;
|
|
59
|
+
if (executable.includes('/') || executable.includes('\\')) {
|
|
60
|
+
return isExecutableFile(executable, platform);
|
|
61
|
+
}
|
|
62
|
+
const pathEntries = getPathValue(env)
|
|
63
|
+
.split(path.delimiter)
|
|
64
|
+
.filter((entry) => entry.length > 0);
|
|
65
|
+
const pathExts = getPathExts(env, platform);
|
|
66
|
+
for (const entry of pathEntries) {
|
|
67
|
+
for (const extension of pathExts) {
|
|
68
|
+
const candidate = path.join(entry, executable + extension);
|
|
69
|
+
if (isExecutableFile(candidate, platform)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
export function getWorkspaceOpenerExecutable(opener) {
|
|
77
|
+
if (opener.kind === 'editor') {
|
|
78
|
+
return 'code';
|
|
79
|
+
}
|
|
80
|
+
if (opener.id === 'github-copilot') {
|
|
81
|
+
return 'code';
|
|
82
|
+
}
|
|
83
|
+
return opener.id;
|
|
84
|
+
}
|
|
85
|
+
export function getWorkspaceOpenerLabel(opener) {
|
|
86
|
+
if (opener.kind === 'editor') {
|
|
87
|
+
return 'VS Code editor';
|
|
88
|
+
}
|
|
89
|
+
if (opener.id === 'github-copilot') {
|
|
90
|
+
return 'GitHub Copilot in VS Code';
|
|
91
|
+
}
|
|
92
|
+
if (opener.id === 'codex') {
|
|
93
|
+
return 'Codex';
|
|
94
|
+
}
|
|
95
|
+
return 'Claude';
|
|
96
|
+
}
|
|
97
|
+
export function listWorkspaceOpenerChoices(options = {}) {
|
|
98
|
+
const choices = WORKSPACE_OPENER_CHOICE_DEFINITIONS.map((definition) => {
|
|
99
|
+
const available = isWorkspaceExecutableAvailable(definition.executable, options);
|
|
100
|
+
return {
|
|
101
|
+
value: definition.value,
|
|
102
|
+
label: definition.label,
|
|
103
|
+
opener: parseWorkspacePreferredOpenerValue(definition.value),
|
|
104
|
+
executable: definition.executable,
|
|
105
|
+
available,
|
|
106
|
+
unavailableNote: available ? null : `${definition.executable} not found on PATH`,
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return choices.sort((a, b) => {
|
|
110
|
+
if (a.available !== b.available) {
|
|
111
|
+
return a.available ? -1 : 1;
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function getDefaultWorkspaceOpenerChoiceValue(choices) {
|
|
117
|
+
return choices.find((choice) => choice.available)?.value ?? 'editor';
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=openers.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const MANAGED_WORKSPACES_DIR_NAME = "workspaces";
|
|
2
|
+
export declare const WORKSPACE_REGISTRY_FILE_NAME = "registry.yaml";
|
|
3
|
+
export interface WorkspaceRegistryState {
|
|
4
|
+
version: 1;
|
|
5
|
+
workspaces: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface WorkspaceRegistryEntry {
|
|
8
|
+
name: string;
|
|
9
|
+
workspaceRoot: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WorkspacePathOptions {
|
|
12
|
+
globalDataDir?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getManagedWorkspacesDir(options?: WorkspacePathOptions): string;
|
|
15
|
+
export declare function getManagedWorkspaceRoot(workspaceName: string, options?: WorkspacePathOptions): string;
|
|
16
|
+
export declare function getWorkspaceRegistryPath(options?: WorkspacePathOptions): string;
|
|
17
|
+
export declare function parseWorkspaceRegistryState(content: string): WorkspaceRegistryState;
|
|
18
|
+
export declare function serializeWorkspaceRegistryState(state: WorkspaceRegistryState): string;
|
|
19
|
+
export declare function listWorkspaceRegistryEntries(registry: WorkspaceRegistryState): WorkspaceRegistryEntry[];
|
|
20
|
+
export declare function listKnownWorkspaceEntries(options?: WorkspacePathOptions): Promise<WorkspaceRegistryEntry[]>;
|
|
21
|
+
export declare function listManagedWorkspaceEntries(options?: WorkspacePathOptions): Promise<WorkspaceRegistryEntry[]>;
|
|
22
|
+
export declare function readWorkspaceRegistryState(options?: WorkspacePathOptions): Promise<WorkspaceRegistryState | null>;
|
|
23
|
+
export declare function writeWorkspaceRegistryState(state: WorkspaceRegistryState, options?: WorkspacePathOptions): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as nodeFs from 'node:fs';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
4
|
+
import { getGlobalDataDir } from '../global-config.js';
|
|
5
|
+
import { FileSystemUtils } from '../../utils/file-system.js';
|
|
6
|
+
import { validateWorkspaceName } from './foundation.js';
|
|
7
|
+
import { isWorkspaceRoot, readWorkspaceViewState } from './state-io.js';
|
|
8
|
+
const fs = nodeFs.promises;
|
|
9
|
+
export const MANAGED_WORKSPACES_DIR_NAME = 'workspaces';
|
|
10
|
+
export const WORKSPACE_REGISTRY_FILE_NAME = 'registry.yaml';
|
|
11
|
+
function joinWorkspacePath(basePath, ...segments) {
|
|
12
|
+
return FileSystemUtils.joinPath(basePath, ...segments);
|
|
13
|
+
}
|
|
14
|
+
async function pathIsFile(filePath) {
|
|
15
|
+
try {
|
|
16
|
+
return (await fs.stat(filePath)).isFile();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function pathIsDirectory(dirPath) {
|
|
23
|
+
try {
|
|
24
|
+
return (await fs.stat(dirPath)).isDirectory();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function formatZodIssues(error) {
|
|
31
|
+
return error.issues
|
|
32
|
+
.map((issue) => {
|
|
33
|
+
const location = issue.path.length > 0 ? issue.path.join('.') : 'root';
|
|
34
|
+
return `${location}: ${issue.message}`;
|
|
35
|
+
})
|
|
36
|
+
.join('; ');
|
|
37
|
+
}
|
|
38
|
+
function parseYamlObject(content, label) {
|
|
39
|
+
try {
|
|
40
|
+
return parseYaml(content);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
44
|
+
throw new Error(`Invalid ${label}: ${message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function assertValidMapKeys(keys, validator, label) {
|
|
48
|
+
for (const key of keys) {
|
|
49
|
+
try {
|
|
50
|
+
validator(key);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
throw new Error(`Invalid ${label} '${key}': ${message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const RegistryStateSchema = z.object({
|
|
59
|
+
version: z.literal(1),
|
|
60
|
+
workspaces: z.record(z.string(), z.string()),
|
|
61
|
+
}).strict();
|
|
62
|
+
export function getManagedWorkspacesDir(options = {}) {
|
|
63
|
+
return joinWorkspacePath(options.globalDataDir ?? getGlobalDataDir(), MANAGED_WORKSPACES_DIR_NAME);
|
|
64
|
+
}
|
|
65
|
+
export function getManagedWorkspaceRoot(workspaceName, options = {}) {
|
|
66
|
+
validateWorkspaceName(workspaceName);
|
|
67
|
+
return joinWorkspacePath(getManagedWorkspacesDir(options), workspaceName);
|
|
68
|
+
}
|
|
69
|
+
export function getWorkspaceRegistryPath(options = {}) {
|
|
70
|
+
return joinWorkspacePath(getManagedWorkspacesDir(options), WORKSPACE_REGISTRY_FILE_NAME);
|
|
71
|
+
}
|
|
72
|
+
export function parseWorkspaceRegistryState(content) {
|
|
73
|
+
const raw = parseYamlObject(content, 'workspace registry state');
|
|
74
|
+
const result = RegistryStateSchema.safeParse(raw);
|
|
75
|
+
if (!result.success) {
|
|
76
|
+
throw new Error(`Invalid workspace registry state: ${formatZodIssues(result.error)}`);
|
|
77
|
+
}
|
|
78
|
+
assertValidMapKeys(Object.keys(result.data.workspaces), validateWorkspaceName, 'workspace registry name');
|
|
79
|
+
return {
|
|
80
|
+
version: 1,
|
|
81
|
+
workspaces: result.data.workspaces,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function serializeWorkspaceRegistryState(state) {
|
|
85
|
+
assertValidMapKeys(Object.keys(state.workspaces), validateWorkspaceName, 'workspace registry name');
|
|
86
|
+
for (const [workspaceName, workspaceRoot] of Object.entries(state.workspaces)) {
|
|
87
|
+
if (typeof workspaceRoot !== 'string') {
|
|
88
|
+
throw new Error(`Invalid workspace registry entry '${workspaceName}': path must be a string`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return stringifyYaml({
|
|
92
|
+
version: 1,
|
|
93
|
+
workspaces: state.workspaces,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export function listWorkspaceRegistryEntries(registry) {
|
|
97
|
+
return Object.entries(registry.workspaces)
|
|
98
|
+
.map(([name, workspaceRoot]) => ({ name, workspaceRoot }))
|
|
99
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
100
|
+
}
|
|
101
|
+
export async function listKnownWorkspaceEntries(options = {}) {
|
|
102
|
+
const legacyRegistry = await readWorkspaceRegistryState(options);
|
|
103
|
+
const workspaces = new Map(Object.entries(legacyRegistry?.workspaces ?? {}));
|
|
104
|
+
for (const entry of await listManagedWorkspaceEntries(options)) {
|
|
105
|
+
workspaces.set(entry.name, entry.workspaceRoot);
|
|
106
|
+
}
|
|
107
|
+
return [...workspaces.entries()]
|
|
108
|
+
.map(([name, workspaceRoot]) => ({ name, workspaceRoot }))
|
|
109
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
110
|
+
}
|
|
111
|
+
export async function listManagedWorkspaceEntries(options = {}) {
|
|
112
|
+
const workspacesDir = getManagedWorkspacesDir(options);
|
|
113
|
+
if (!(await pathIsDirectory(workspacesDir))) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const entries = await fs.readdir(workspacesDir, { withFileTypes: true });
|
|
117
|
+
const workspaces = [];
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
if (!entry.isDirectory()) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const workspaceRoot = FileSystemUtils.canonicalizeExistingPath(joinWorkspacePath(workspacesDir, entry.name));
|
|
123
|
+
if (!(await isWorkspaceRoot(workspaceRoot))) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const state = await readWorkspaceViewState(workspaceRoot);
|
|
128
|
+
workspaces.push({ name: state.name, workspaceRoot });
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
workspaces.push({ name: entry.name, workspaceRoot });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return workspaces.sort((a, b) => a.name.localeCompare(b.name));
|
|
135
|
+
}
|
|
136
|
+
export async function readWorkspaceRegistryState(options = {}) {
|
|
137
|
+
const registryPath = getWorkspaceRegistryPath(options);
|
|
138
|
+
if (!(await pathIsFile(registryPath))) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
return parseWorkspaceRegistryState(await fs.readFile(registryPath, 'utf-8'));
|
|
142
|
+
}
|
|
143
|
+
export async function writeWorkspaceRegistryState(state, options = {}) {
|
|
144
|
+
await FileSystemUtils.writeFile(getWorkspaceRegistryPath(options), serializeWorkspaceRegistryState(state));
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type AIToolOption } from '../config.js';
|
|
2
|
+
import { type Delivery, type Profile } from '../global-config.js';
|
|
3
|
+
import type { WorkspaceSkillState } from './foundation.js';
|
|
4
|
+
export interface WorkspaceSkillAgentResult {
|
|
5
|
+
tool_id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
skills_path: string;
|
|
8
|
+
workflow_ids: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface WorkspaceSkillRemovedResult extends WorkspaceSkillAgentResult {
|
|
11
|
+
reason: 'agent_unselected' | 'workflow_unselected';
|
|
12
|
+
}
|
|
13
|
+
export interface WorkspaceSkillSkippedResult {
|
|
14
|
+
tool_id?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface WorkspaceSkillFailedResult {
|
|
20
|
+
tool_id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
error: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WorkspaceSkillInstallationReport {
|
|
25
|
+
profile: Profile;
|
|
26
|
+
delivery: Delivery;
|
|
27
|
+
workflow_ids: string[];
|
|
28
|
+
selected_agents: string[];
|
|
29
|
+
skills_only: true;
|
|
30
|
+
delivery_notice: string | null;
|
|
31
|
+
generated: WorkspaceSkillAgentResult[];
|
|
32
|
+
added: WorkspaceSkillAgentResult[];
|
|
33
|
+
refreshed: WorkspaceSkillAgentResult[];
|
|
34
|
+
removed: WorkspaceSkillRemovedResult[];
|
|
35
|
+
skipped: WorkspaceSkillSkippedResult[];
|
|
36
|
+
failed: WorkspaceSkillFailedResult[];
|
|
37
|
+
}
|
|
38
|
+
type WorkspaceSkillCapableTool = AIToolOption & {
|
|
39
|
+
skillsDir: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function getCurrentWorkspaceSkillProfileSelection(): {
|
|
42
|
+
profile: Profile;
|
|
43
|
+
delivery: Delivery;
|
|
44
|
+
workflow_ids: string[];
|
|
45
|
+
};
|
|
46
|
+
export declare function hasWorkspaceSkillProfileDrift(state: {
|
|
47
|
+
workspace_skills?: WorkspaceSkillState;
|
|
48
|
+
} | null | undefined): boolean;
|
|
49
|
+
export declare function getWorkspaceSkillCapableTools(): WorkspaceSkillCapableTool[];
|
|
50
|
+
export declare function getWorkspaceSkillToolIds(): string[];
|
|
51
|
+
export declare function parseWorkspaceSkillToolsValue(rawTools: string): string[];
|
|
52
|
+
export declare function createWorkspaceSkillSkippedReport(reason: string, message: string): WorkspaceSkillInstallationReport;
|
|
53
|
+
export declare function getWorkspaceSkillDirectory(workspaceRoot: string, toolId: string): string;
|
|
54
|
+
export declare function generateWorkspaceAgentSkills(workspaceRoot: string, selectedAgentIds: string[]): Promise<WorkspaceSkillInstallationReport>;
|
|
55
|
+
export declare function updateWorkspaceAgentSkills(workspaceRoot: string, selectedAgentIds: string[], previousSkillState?: WorkspaceSkillState): Promise<WorkspaceSkillInstallationReport>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=skills.d.ts.map
|