Skip to content

Package internal/migrate

Import path: go.devnw.com/canary/internal/migrate

package migrate // import "go.devnw.com/canary/internal/migrate"

API (raw go doc)


package migrate // import "go.devnw.com/canary/internal/migrate"

CANARY: REQ=CBIN-131; FEATURE="MigrateFrom"; ASPECT=CLI; STATUS=IMPL;
OWNER=canary; UPDATED=2025-10-16

CONSTANTS

const (
    ConfidenceLow    = "LOW"
    ConfidenceMedium = "MEDIUM"
    ConfidenceHigh   = "HIGH"
)
    Confidence levels for orphan detection


FUNCTIONS

func CalculateConfidence(orphan *OrphanedRequirement) string
    CalculateConfidence determines confidence level based on orphan
    characteristics

func ExecuteMigration(rootDir string, plan *MigrationPlan, dryRun bool) error
    ExecuteMigration performs the migration

func GeneratePlan(orphan *OrphanedRequirement) (string, error)
    GeneratePlan creates an implementation plan from an orphaned requirement

func GenerateSpec(orphan *OrphanedRequirement) (string, error)
    GenerateSpec creates a specification from an orphaned requirement

func GetMigrationSummary(plan *MigrationPlan) string
    GetMigrationSummary returns a human-readable summary


TYPES

type FileCopy struct {
    Source string
    Dest   string
}
    FileCopy represents a file to be copied

type FileMerge struct {
    Source      string
    Dest        string
    Description string
}
    FileMerge represents a file that needs merging

type MigrationPlan struct {
    SystemType    SystemType
    FilesToCopy   []FileCopy
    FilesToMerge  []FileMerge
    FilesToCreate []string
    Warnings      []string
}
    MigrationPlan describes what will be migrated

func PlanMigration(rootDir string, systemType SystemType, dryRun bool) (*MigrationPlan, error)
    PlanMigration creates a migration plan

type OrphanPlan struct {
    Orphans      []*OrphanedRequirement
    TotalOrphans int
    Excluded     []string
}
    OrphanPlan represents the plan for migrating orphaned requirements

func DryRun(db *storage.DB, rootDir string, excludePaths []string) (*OrphanPlan, error)
    DryRun simulates migration without creating files

type OrphanedRequirement struct {
    ReqID        string
    Features     []*storage.Token
    FeatureCount int
    Confidence   string
}
    OrphanedRequirement represents a requirement with tokens but no
    specification

func DetectOrphans(db *storage.DB, rootDir string, excludePaths []string) ([]*OrphanedRequirement, error)
    DetectOrphans finds all requirements with tokens but no specification

type SystemType string
    SystemType represents the type of system being migrated from

const (
    SystemTypeSpecKit      SystemType = "spec-kit"
    SystemTypeLegacyCanary SystemType = "legacy-canary"
    SystemTypeMigrated     SystemType = "migrated"
    SystemTypeUnknown      SystemType = "unknown"
)
func DetectSystemType(rootDir string) (SystemType, string)
    DetectSystemType identifies what type of system exists in a directory