mira-cli-ts 0.26.14 → 0.26.16
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/dist/cli.js +42 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -169,6 +169,7 @@ Usage:
|
|
|
169
169
|
mira workspace add <path> Add workspace (validates path)
|
|
170
170
|
mira workspace remove <id|path> Remove workspace
|
|
171
171
|
mira workspace switch <id|path> Switch workspace (sets cwd for new sessions)
|
|
172
|
+
mira project list List projects (workspaces)
|
|
172
173
|
mira project init [--template ts] [--path <dir>] Init mira.json in project
|
|
173
174
|
mira manager Active jobs + recent sessions
|
|
174
175
|
mira health Liveness (/healthz)
|
|
@@ -734,6 +735,43 @@ async function cmdWorkspaceSwitch(opts) {
|
|
|
734
735
|
console.error(`workspace not found: ${target}`);
|
|
735
736
|
process.exit(1);
|
|
736
737
|
}
|
|
738
|
+
async function cmdProjectList() {
|
|
739
|
+
try {
|
|
740
|
+
const res = await apiFetch("/workspaces");
|
|
741
|
+
if (!res.ok) {
|
|
742
|
+
console.error(`project list failed: ${res.status} ${await res.text()}`);
|
|
743
|
+
process.exit(1);
|
|
744
|
+
}
|
|
745
|
+
const data = await res.json();
|
|
746
|
+
const list = data.workspaces ?? [];
|
|
747
|
+
if (list.length === 0) {
|
|
748
|
+
console.log("No projects \u2014 add one with: mira workspace add /path/to/repo or mira project init --template ts --path /path/to/repo");
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
for (const w of list) {
|
|
752
|
+
console.log(`${w.id.slice(0, 8)} ${w.path} (${w.name})`);
|
|
753
|
+
}
|
|
754
|
+
} catch (e) {
|
|
755
|
+
try {
|
|
756
|
+
const { readFileSync, existsSync } = __require("fs");
|
|
757
|
+
const home = process.env.HOME ?? "";
|
|
758
|
+
const fp = home ? `${home}/.mira/workspaces.json` : `${process.cwd()}/.mira/workspaces.json`;
|
|
759
|
+
if (existsSync(fp)) {
|
|
760
|
+
const raw = readFileSync(fp, "utf-8");
|
|
761
|
+
const parsed = JSON.parse(raw);
|
|
762
|
+
const list = Array.isArray(parsed) ? parsed : parsed.workspaces ?? [];
|
|
763
|
+
if (list.length === 0)
|
|
764
|
+
console.log("No projects");
|
|
765
|
+
else
|
|
766
|
+
for (const w of list)
|
|
767
|
+
console.log(`${(w.id ?? "").slice(0, 8)} ${w.path} (${w.name ?? w.path.split("/").pop()})`);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
} catch {}
|
|
771
|
+
console.error(`project list failed: ${String(e.message ?? e)}`);
|
|
772
|
+
process.exit(1);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
737
775
|
async function cmdProjectInit(opts) {
|
|
738
776
|
const template = String(opts.template ?? opts.t ?? "default").trim() || "default";
|
|
739
777
|
const targetPath = String(opts.path ?? opts.p ?? positionalPath() ?? process.cwd()).trim() || process.cwd();
|
|
@@ -946,10 +984,12 @@ async function main() {
|
|
|
946
984
|
return;
|
|
947
985
|
case "project":
|
|
948
986
|
case "projects":
|
|
949
|
-
if (sub === "
|
|
987
|
+
if (sub === "list" || sub === "ls" || sub === null)
|
|
988
|
+
await cmdProjectList();
|
|
989
|
+
else if (sub === "init")
|
|
950
990
|
await cmdProjectInit(opts);
|
|
951
991
|
else {
|
|
952
|
-
console.error(`unknown project subcommand: ${sub ?? ""} \u2014 try: init`);
|
|
992
|
+
console.error(`unknown project subcommand: ${sub ?? ""} \u2014 try: list, init`);
|
|
953
993
|
process.exit(1);
|
|
954
994
|
}
|
|
955
995
|
return;
|