Update core components including CLI, Nushell libraries, plugins system, and utility scripts for the provisioning system. CLI Updates: - Command implementations - CLI utilities and dispatching - Help system improvements - Command validation Library Updates: - Configuration management system - Infrastructure validation - Extension system improvements - Secrets management - Workspace operations - Cache management system Plugin System: - Interactive form plugin (inquire) - KCL integration plugin - Performance optimization plugins - Plugin registration system Utilities: - Build and distribution scripts - Installation procedures - Testing utilities - Development tools Documentation: - Library module documentation - Extension API guides - Plugin usage guides - Service management documentation All changes are backward compatible. No breaking changes.
185 lines
4.3 KiB
Plaintext
185 lines
4.3 KiB
Plaintext
# Provisioning Project Detection Module
|
|
# Provides functions for technology detection and requirement inference
|
|
|
|
use ../../../lib_provisioning *
|
|
|
|
# Detect technologies in a project
|
|
export def detect-project [
|
|
project_path: string
|
|
--format: string = "text"
|
|
--high-confidence-only: bool = false
|
|
--pretty: bool = false
|
|
--debug: bool = false
|
|
] {
|
|
let detector_bin = (find-detector-binary)
|
|
|
|
if ($detector_bin | is-empty) or not ($detector_bin | path exists) {
|
|
return {
|
|
error: "Detector binary not found"
|
|
message: "Install: cargo build --release --bin provisioning-detector"
|
|
}
|
|
}
|
|
|
|
let mut args = [
|
|
"detect"
|
|
$project_path
|
|
"--format" $format
|
|
]
|
|
|
|
if $high_confidence_only {
|
|
$args = ($args | append "--high-confidence-only")
|
|
}
|
|
|
|
if $pretty {
|
|
$args = ($args | append "--pretty")
|
|
}
|
|
|
|
try {
|
|
let output = (^$detector_bin ...$args 2>&1)
|
|
if $format == "json" {
|
|
$output | from json
|
|
} else {
|
|
{ output: $output }
|
|
}
|
|
} catch {|err|
|
|
{
|
|
error: "Detection failed"
|
|
message: $err.msg
|
|
}
|
|
}
|
|
}
|
|
|
|
# Analyze gaps in infrastructure declaration
|
|
export def complete-project [
|
|
project_path: string
|
|
--format: string = "text"
|
|
--check: bool = false
|
|
--pretty: bool = false
|
|
--debug: bool = false
|
|
] {
|
|
let detector_bin = (find-detector-binary)
|
|
|
|
if ($detector_bin | is-empty) or not ($detector_bin | path exists) {
|
|
return {
|
|
error: "Detector binary not found"
|
|
message: "Install: cargo build --release --bin provisioning-detector"
|
|
}
|
|
}
|
|
|
|
let mut args = [
|
|
"complete"
|
|
$project_path
|
|
"--format" $format
|
|
]
|
|
|
|
if $check {
|
|
$args = ($args | append "--check")
|
|
}
|
|
|
|
if $pretty {
|
|
$args = ($args | append "--pretty")
|
|
}
|
|
|
|
try {
|
|
let output = (^$detector_bin ...$args 2>&1)
|
|
if $format == "json" {
|
|
$output | from json
|
|
} else {
|
|
{ output: $output }
|
|
}
|
|
} catch {|err|
|
|
{
|
|
error: "Completion failed"
|
|
message: $err.msg
|
|
}
|
|
}
|
|
}
|
|
|
|
# Find provisioning-detector binary in standard locations
|
|
def find-detector-binary [] {
|
|
let possible_paths = [
|
|
($env.PROVISIONING? | default "" | path join "platform" "detector" "target" "release" "provisioning-detector")
|
|
($env.PROVISIONING? | default "" | path join "platform" "detector" "target" "debug" "provisioning-detector")
|
|
"/usr/local/bin/provisioning-detector"
|
|
"/usr/bin/provisioning-detector"
|
|
]
|
|
|
|
let existing = ($possible_paths
|
|
| where {|p| ($p | is-not-empty) and ($p | path exists) }
|
|
)
|
|
|
|
if ($existing | length) > 0 {
|
|
$existing | first
|
|
} else {
|
|
""
|
|
}
|
|
}
|
|
|
|
# Format detection results for display
|
|
export def format-detection [
|
|
detection: record
|
|
--format: string = "text"
|
|
] {
|
|
if $format == "json" {
|
|
$detection | to json
|
|
} else {
|
|
# Text formatting
|
|
let output = @"
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
Project Technology Detection Results
|
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
Overall Confidence: ($detection.overall_confidence | into float | math round -p 1 | into string)%
|
|
|
|
Detected Technologies:
|
|
"@
|
|
|
|
let detections = if ($detection.detections | type) == "list" {
|
|
$detection.detections
|
|
} else {
|
|
[]
|
|
}
|
|
|
|
let result = if ($detections | length) > 0 {
|
|
($output + "\n" + ($detections | each {|d|
|
|
$" • ($d.technology) - ($d.confidence | into float | math round -p 1)%\n"
|
|
} | str join ""))
|
|
} else {
|
|
$output + "\n (No technologies detected)\n"
|
|
}
|
|
|
|
$result
|
|
}
|
|
}
|
|
|
|
# Check if project has specific technology
|
|
export def has-technology [
|
|
detection: record
|
|
technology: string
|
|
] {
|
|
$detection.detections
|
|
| any {|d| ($d.technology | str downcase) == ($technology | str downcase) }
|
|
}
|
|
|
|
# Get all detected technologies
|
|
export def get-technologies [
|
|
detection: record
|
|
] {
|
|
$detection.detections | each {|d| $d.technology }
|
|
}
|
|
|
|
# Get all inferred requirements
|
|
export def get-requirements [
|
|
detection: record
|
|
] {
|
|
$detection.requirements | default []
|
|
}
|
|
|
|
# Get required taskservs only
|
|
export def get-required-taskservs [
|
|
detection: record
|
|
] {
|
|
($detection.requirements | default [])
|
|
| where {|r| $r.required == true }
|
|
| each {|r| $r.taskserv }
|
|
} |