Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions fix_ps_errors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
files=(
"lib/windows/AutoOS.ClaudeAutostart.psm1"
"lib/windows/AutoOS.Detect.psm1"
"lib/windows/AutoOS.Serve.psm1"
)
for file in "${files[@]}"; do
sed -i 's/catch { $_ | Out-Null }/catch { $null = $_ }/g' "$file"
done
78 changes: 56 additions & 22 deletions lib/linux/catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
CATALOG_PATH=""
declare -a CAT_ID CAT_NAME CAT_DESC CAT_PROVIDER CAT_PACKAGE CAT_REQUIRES
declare -a CAT_PROFILES CAT_POST CAT_PROMPT CAT_NOTES CAT_GROUP CAT_VERIFY CAT_CASK
declare -A CAT_PROMPT_Q CAT_PROMPT_D CAT_PROMPT_H CAT_PROFILE_DESC
declare -a CAT_PROFILE_KEYS

catalog_require_python() {
if ! has_cmd python3; then
Expand Down Expand Up @@ -98,16 +100,38 @@ catalog_load() {
CAT_ID=(); CAT_NAME=(); CAT_DESC=(); CAT_PROVIDER=(); CAT_PACKAGE=()
CAT_REQUIRES=(); CAT_PROFILES=(); CAT_POST=(); CAT_PROMPT=(); CAT_NOTES=(); CAT_GROUP=()
CAT_VERIFY=(); CAT_CASK=(); CAT_HOMEPAGE=(); CAT_INSTALLED=()
CAT_PROMPT_Q=(); CAT_PROMPT_D=(); CAT_PROMPT_H=()
CAT_PROFILE_DESC=(); CAT_PROFILE_KEYS=()

# Delimiter is US (0x1f), NOT tab: tab is an IFS *whitespace* character, so
# bash collapses runs of them and every empty field shifts the columns left.
while IFS=$'\x1f' read -r id name desc provider package requires profiles post prompt notes group verify cask homepage; do
[[ -z "$id" ]] && continue
CAT_ID+=("$id"); CAT_NAME+=("$name"); CAT_DESC+=("$desc")
CAT_PROVIDER+=("$provider");CAT_PACKAGE+=("$package");CAT_REQUIRES+=("$requires")
CAT_PROFILES+=("$profiles");CAT_POST+=("$post"); CAT_PROMPT+=("$prompt")
CAT_NOTES+=("$notes"); CAT_GROUP+=("$group"); CAT_VERIFY+=("$verify")
CAT_CASK+=("$cask"); CAT_HOMEPAGE+=("$homepage"); CAT_INSTALLED+=(0)
local state="components"
while IFS=$'\x1f' read -r col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14; do
if [[ "$col1" == "---PROMPTS---" ]]; then
state="prompts"
continue
elif [[ "$col1" == "---PROFILES---" ]]; then
state="profiles"
continue
fi

if [[ "$state" == "components" ]]; then
[[ -z "$col1" ]] && continue
CAT_ID+=("$col1"); CAT_NAME+=("$col2"); CAT_DESC+=("$col3")
CAT_PROVIDER+=("$col4"); CAT_PACKAGE+=("$col5"); CAT_REQUIRES+=("$col6")
CAT_PROFILES+=("$col7"); CAT_POST+=("$col8"); CAT_PROMPT+=("$col9")
CAT_NOTES+=("$col10"); CAT_GROUP+=("$col11"); CAT_VERIFY+=("$col12")
CAT_CASK+=("$col13"); CAT_HOMEPAGE+=("$col14"); CAT_INSTALLED+=(0)
elif [[ "$state" == "prompts" ]]; then
[[ -z "$col1" ]] && continue
CAT_PROMPT_Q["$col1"]="$col2"
CAT_PROMPT_D["$col1"]="$col3"
CAT_PROMPT_H["$col1"]="$col4"
elif [[ "$state" == "profiles" ]]; then
[[ -z "$col1" ]] && continue
CAT_PROFILE_KEYS+=("$col1")
CAT_PROFILE_DESC["$col1"]="$col2"
fi
done < <(python3 - "$path" "$arch" "$headless" <<'PY'
import json, sys
path, arch, headless = sys.argv[1], sys.argv[2], sys.argv[3] == "1"
Expand All @@ -128,6 +152,19 @@ for grp in cat.get("categories", []):
c.get("verify","") or "",
"1" if c.get("cask") else "0", c.get("homepage", ""),
]))

print("---PROMPTS---")
prompts = cat.get("prompts", {})
for k, v in prompts.items():
if not isinstance(v, dict): continue
q = (v.get("question", "") or "").replace("\x1f", " ")
d = (v.get("default", "") or "").replace("\x1f", " ")
h = (v.get("help", "") or "").replace("\x1f", " ")
print(f"{k}\x1f{q}\x1f{d}\x1f{h}")

print("---PROFILES---")
for name, desc in (cat.get("profiles") or {}).items():
print(f"{name}\x1f{desc}")
PY
)
}
Expand Down Expand Up @@ -211,21 +248,21 @@ catalog_resolve() {

# catalog_prompt_field <path> <prompt-key> <field>
catalog_prompt_field() {
python3 - "$1" "$2" "$3" <<'PY'
import json, sys
cat = json.load(open(sys.argv[1], encoding="utf-8"))
print((cat.get("prompts", {}).get(sys.argv[2], {}) or {}).get(sys.argv[3], "") or "")
PY
local key="$2" field="$3"
case "$field" in
question) echo "${CAT_PROMPT_Q[$key]:-}" ;;
default) echo "${CAT_PROMPT_D[$key]:-}" ;;
help) echo "${CAT_PROMPT_H[$key]:-}" ;;
*) echo "" ;;
esac
}

# catalog_profile_list <path> — echoes "name<TAB>description" per profile.
catalog_profile_list() {
python3 - "$1" <<'PY'
import json, sys
cat = json.load(open(sys.argv[1], encoding="utf-8"))
for name, desc in (cat.get("profiles") or {}).items():
print(f"{name}\t{desc}")
PY
local k
for k in "${CAT_PROFILE_KEYS[@]}"; do
printf '%s\t%s\n' "$k" "${CAT_PROFILE_DESC[$k]}"
done
}

catalog_detect_installed() {
Expand All @@ -237,8 +274,5 @@ catalog_detect_installed() {
}

catalog_has_profile() {
python3 - "$CATALOG_PATH" "$1" <<'PY'
import json,sys
sys.exit(0 if sys.argv[2] in json.load(open(sys.argv[1],encoding='utf8'))['profiles'] else 1)
PY
[[ -n "${CAT_PROFILE_DESC[$1]+_}" ]]
}
4 changes: 2 additions & 2 deletions lib/windows/AutoOS.ClaudeAutostart.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Get-AutoOSClaudeDefaults {
foreach ($p in $block.PSObject.Properties) { $table[$p.Name] = $p.Value }
if ($table.Count -gt 0) { return $table }
}
} catch { }
} catch { $null = $_ }
}
@{
enabled = $true; snapshot_interval_mins = 5; liveness_window_mins = 240
Expand Down Expand Up @@ -272,7 +272,7 @@ function Get-AutoOSClaudeState {
sessions = @($doc.sessions)
}
}
} catch { }
} catch { $null = $_ }
}
[pscustomobject]@{ version = $script:StateVersion; captured_at = 0; captured_at_iso = $null; sessions = @() }
}
Expand Down
4 changes: 2 additions & 2 deletions lib/windows/AutoOS.Detect.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Get-AutoOSWingetPackageProcess {
$process = [Diagnostics.Process]::Start($psi)
# Close stdin so a prompt that slipped past --disable-interactivity reads
# EOF and gives up, instead of sitting there until the timeout.
try { $process.StandardInput.Close() } catch { }
try { $process.StandardInput.Close() } catch { $null = $_ }
$process
} catch { $null }
}
Expand All @@ -144,7 +144,7 @@ function Get-AutoOSWingetPackageResult {
$Process.Kill()
}
} catch { $packages = @() }
finally { try { $Process.Dispose() } catch { } }
finally { try { $Process.Dispose() } catch { $null = $_ } }
$packages
}

Expand Down
4 changes: 2 additions & 2 deletions lib/windows/AutoOS.Serve.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function Get-AutoOSExampleBlock {
try {
$block = (Get-Content -LiteralPath $path -Raw -Encoding UTF8 | ConvertFrom-Json).$Name
if ($block) { return $block }
} catch { }
} catch { $null = $_ }
@{}
}

Expand All @@ -286,7 +286,7 @@ function Get-AutoOSDetectedAnswers {
try {
$value = (& git config --global $pair.Setting 2>$null | Select-Object -First 1)
if ($value) { $answers[$pair.Key] = [string]$value }
} catch { }
} catch { $null = $_ }
}
$answers
}
Expand Down
Loading