# Workspace Manager Utility

## Purpose

Manages the JIRA expansion pack workspace directory structure under `.bmad-workspace/ck-jira-integration/`, providing consistent file paths and migration support.

## Base Path Configuration

[[LLM: The JIRA expansion pack workspace is:
`.bmad-workspace/ck-jira-integration/`

All expansion pack files MUST be created under this directory.
]]

## Directory Structure

```
.bmad-workspace/ck-jira-integration/
├── config/              # Configuration files
│   └── jira-expansion-config.yaml
├── reports/             # Generated reports
│   ├── sprint/
│   ├── quality/
│   ├── roadmap/
│   └── correlation/
├── sync/                # Synchronization artifacts
│   ├── daily/          # Daily standups
│   ├── weekly/         # Weekly syncs
│   └── reports/        # Sync reports
├── feedback/           # Learning system data
│   └── jira-expansion-learnings.md
├── recovery/           # Operation recovery files
├── locks/              # Operation locks
├── cache/              # Temporary cache
└── archive/            # Archived reports
```

## Path Helper Functions

### Get Base Path

[[LLM: Always return `.bmad-workspace/ck-jira-integration/`]]

### Get Config Path

[[LLM: Return `.bmad-workspace/ck-jira-integration/config/{{filename}}`]]

### Get Report Path

[[LLM: Return `.bmad-workspace/ck-jira-integration/reports/{{type}}/{{filename}}`]]

### Get Sync Path

[[LLM: Return `.bmad-workspace/ck-jira-integration/sync/{{type}}/{{filename}}`]]

## Migration Support

### Check Legacy Paths

[[LLM: For backward compatibility, check these legacy locations:

1. `.bmad-workspace/ck-jira-integration/config/jira-expansion-config.yaml` → `.bmad-workspace/ck-jira-integration/config/jira-expansion-config.yaml`
2. `.bmad-workspace/config/jira-expansion-config.yaml` → `.bmad-workspace/ck-jira-integration/config/jira-expansion-config.yaml`
3. `.bmad-workspace/reports/sprint/` → `.bmad-workspace/ck-jira-integration/reports/sprint/`
4. `.bmad-workspace/sync/daily/` → `.bmad-workspace/ck-jira-integration/sync/daily/`
5. `.bmad-workspace/feedback/jira-expansion-learnings.md` → `.bmad-workspace/ck-jira-integration/feedback/jira-expansion-learnings.md`
   ]]

### Migration Process

[[LLM: When accessing a file:

1. Check new location first
2. If not found, check legacy location
3. If found in legacy location:
   - Copy to new location
   - Log migration event
   - Optionally delete old file (with user permission)
4. Return new location path
   ]]

## Usage Examples

### Creating a Report

```
# Instead of: .bmad-workspace/reports/sprint/sprint-health-2024-01-15.md
# Use: .bmad-workspace/ck-jira-integration/reports/sprint/sprint-health-2024-01-15.md
```

### Checking Configuration

```
# Instead of: .bmad-workspace/config/jira-expansion-config.yaml
# Use: .bmad-workspace/ck-jira-integration/config/jira-expansion-config.yaml
```

### Daily Standup

```
# Instead of: .bmad-workspace/sync/daily/standup-2024-01-15.md
# Use: .bmad-workspace/ck-jira-integration/sync/daily/standup-2024-01-15.md
```

## Directory Creation

[[LLM: Ensure directories exist before writing:

1. Check if parent directory exists
2. If not, create full path recursively
3. Set appropriate permissions
4. Log directory creation
   ]]

## Cleanup Support

### Archive Old Files

[[LLM: Move files older than 30 days to archive:
`.bmad-workspace/ck-jira-integration/archive/{{year}}/{{month}}/`]]

### Remove Pack Data

[[LLM: To clean all pack data:
Remove entire `.bmad-workspace/ck-jira-integration/` directory]]

## Benefits

1. **Isolation**: No conflicts with other expansion packs
2. **Organization**: Clear structure for all pack files
3. **Cleanup**: Easy to remove all pack artifacts
4. **Migration**: Smooth transition from legacy paths
5. **Multi-Instance**: Could support multiple JIRA projects

## Implementation Notes

- Always use this utility for file paths
- Never hardcode `.bmad-workspace/` paths directly
- Support both new and legacy paths during transition
- Log all migrations for tracking
