@castlekit/castle 0.1.3 → 0.1.4
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/bin/castle.js +69 -4
- package/install.sh +18 -7
- package/package.json +1 -1
package/bin/castle.js
CHANGED
|
@@ -41,6 +41,70 @@ program
|
|
|
41
41
|
await open(url);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
program
|
|
45
|
+
.command("update")
|
|
46
|
+
.description("Check for updates and install the latest version")
|
|
47
|
+
.action(async () => {
|
|
48
|
+
const { execSync } = await import("child_process");
|
|
49
|
+
|
|
50
|
+
console.log(pc.bold("\n 🏰 Castle\n"));
|
|
51
|
+
console.log(pc.dim(" Checking for updates...\n"));
|
|
52
|
+
|
|
53
|
+
let latest;
|
|
54
|
+
try {
|
|
55
|
+
latest = execSync("npm view @castlekit/castle version", {
|
|
56
|
+
encoding: "utf-8",
|
|
57
|
+
timeout: 15000,
|
|
58
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
59
|
+
}).trim();
|
|
60
|
+
} catch {
|
|
61
|
+
console.log(pc.yellow(" Could not check for updates. Try again later.\n"));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (version === latest) {
|
|
66
|
+
console.log(` You're on the latest version (${pc.green(version)}).\n`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check for major version bump
|
|
71
|
+
const currentMajor = parseInt(version.split(".")[0], 10);
|
|
72
|
+
const latestMajor = parseInt(latest.split(".")[0], 10);
|
|
73
|
+
|
|
74
|
+
if (latestMajor > currentMajor) {
|
|
75
|
+
const readline = await import("readline");
|
|
76
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
77
|
+
const answer = await new Promise((resolve) => {
|
|
78
|
+
rl.question(
|
|
79
|
+
` ${pc.yellow("⚠")} Castle ${pc.cyan(latest)} is available (you have ${pc.dim(version)}).\n` +
|
|
80
|
+
` This is a major version update and may include breaking changes.\n\n` +
|
|
81
|
+
` Continue? (y/N) `,
|
|
82
|
+
resolve
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
rl.close();
|
|
86
|
+
|
|
87
|
+
if (answer.toLowerCase() !== "y") {
|
|
88
|
+
console.log(pc.dim("\n Update cancelled.\n"));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
console.log();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log(` Updating Castle from ${pc.dim(version)} to ${pc.cyan(latest)}...\n`);
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
execSync(`npm install -g @castlekit/castle@${latest}`, {
|
|
98
|
+
stdio: "inherit",
|
|
99
|
+
timeout: 120000,
|
|
100
|
+
});
|
|
101
|
+
console.log(pc.green(`\n ✔ Updated successfully!\n`));
|
|
102
|
+
} catch {
|
|
103
|
+
console.log(pc.red(`\n Update failed.`));
|
|
104
|
+
console.log(` Try manually: ${pc.cyan(`npm install -g @castlekit/castle@${latest}`)}\n`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
44
108
|
program
|
|
45
109
|
.command("status")
|
|
46
110
|
.description("Show Castle and agent status")
|
|
@@ -83,10 +147,11 @@ if (process.argv.length <= 2) {
|
|
|
83
147
|
} else {
|
|
84
148
|
console.log(pc.bold("\n 🏰 Castle\n"));
|
|
85
149
|
console.log(pc.dim(" The multi-agent workspace.\n"));
|
|
86
|
-
console.log(` ${pc.cyan("castle open")}
|
|
87
|
-
console.log(` ${pc.cyan("castle setup")}
|
|
88
|
-
console.log(` ${pc.cyan("castle status")}
|
|
89
|
-
console.log(` ${pc.cyan("castle
|
|
150
|
+
console.log(` ${pc.cyan("castle open")} Open the web UI`);
|
|
151
|
+
console.log(` ${pc.cyan("castle setup")} Re-run setup wizard`);
|
|
152
|
+
console.log(` ${pc.cyan("castle status")} Show status`);
|
|
153
|
+
console.log(` ${pc.cyan("castle update")} Check for updates`);
|
|
154
|
+
console.log(` ${pc.cyan("castle --help")} All commands\n`);
|
|
90
155
|
}
|
|
91
156
|
})();
|
|
92
157
|
} else {
|
package/install.sh
CHANGED
|
@@ -556,11 +556,7 @@ install_castle() {
|
|
|
556
556
|
|
|
557
557
|
# Check if this version is already installed
|
|
558
558
|
local installed_version=""
|
|
559
|
-
installed_version="$(npm list -g @castlekit/castle --depth=0
|
|
560
|
-
let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{
|
|
561
|
-
try{const j=JSON.parse(d);console.log(j.dependencies?.['@castlekit/castle']?.version||'')}catch{}
|
|
562
|
-
})
|
|
563
|
-
" 2>/dev/null || true)"
|
|
559
|
+
installed_version="$(npm list -g @castlekit/castle --depth=0 2>/dev/null | grep '@castlekit/castle@' | sed 's/.*@castlekit\/castle@//' | tr -d '[:space:]' || true)"
|
|
564
560
|
|
|
565
561
|
if [[ -n "$resolved_version" && "$installed_version" == "$resolved_version" ]]; then
|
|
566
562
|
echo -e "${SUCCESS}✓${NC} Castle ${INFO}${resolved_version}${NC} already installed"
|
|
@@ -599,9 +595,24 @@ main() {
|
|
|
599
595
|
|
|
600
596
|
# Check for existing installation
|
|
601
597
|
local is_upgrade=false
|
|
602
|
-
|
|
603
|
-
|
|
598
|
+
local existing_bin=""
|
|
599
|
+
existing_bin="$(type -P castle 2>/dev/null || true)"
|
|
600
|
+
if [[ -n "$existing_bin" ]]; then
|
|
604
601
|
is_upgrade=true
|
|
602
|
+
|
|
603
|
+
# Check if already fully set up with the latest version
|
|
604
|
+
local current_ver=""
|
|
605
|
+
current_ver="$(npm list -g @castlekit/castle --depth=0 2>/dev/null | grep '@castlekit/castle@' | sed 's/.*@castlekit\/castle@//' | tr -d '[:space:]' || true)"
|
|
606
|
+
local target_ver=""
|
|
607
|
+
target_ver="$(npm view "@castlekit/castle@${CASTLE_VERSION}" version 2>/dev/null || true)"
|
|
608
|
+
|
|
609
|
+
if [[ -n "$current_ver" && -n "$target_ver" && "$current_ver" == "$target_ver" && -f "$HOME/.castle/castle.json" ]]; then
|
|
610
|
+
echo -e "${SUCCESS}✓${NC} Castle ${INFO}${current_ver}${NC} already installed and configured"
|
|
611
|
+
echo -e "${MUTED}Nothing to do. Run ${INFO}castle setup${NC} to reconfigure.${NC}"
|
|
612
|
+
return 0
|
|
613
|
+
fi
|
|
614
|
+
|
|
615
|
+
echo -e "${WARN}→${NC} Existing Castle installation detected"
|
|
605
616
|
fi
|
|
606
617
|
|
|
607
618
|
# Step 1: Homebrew (macOS only)
|