yaaw-se 0.1.1 → 0.1.2
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/tui/confirm-plan.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as p from "@clack/prompts";
|
|
2
|
-
import { relative } from "node:path";
|
|
3
2
|
import { integrations } from "../integrations/registry.js";
|
|
4
3
|
const actionLabels = {
|
|
5
4
|
fresh: "Fresh install",
|
|
@@ -8,111 +7,45 @@ const actionLabels = {
|
|
|
8
7
|
repair: "Repair installation",
|
|
9
8
|
uninstall: "Uninstall"
|
|
10
9
|
};
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
function plural(count, noun) {
|
|
18
|
-
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
19
|
-
}
|
|
20
|
-
function formatList(values, limit = 5) {
|
|
21
|
-
if (values.length <= limit)
|
|
22
|
-
return values.join(", ");
|
|
23
|
-
return `${values.slice(0, limit).join(", ")} (+${values.length - limit} more)`;
|
|
10
|
+
function toolSummary(plan) {
|
|
11
|
+
const tools = plan.selectedIntegrations.map(id => integrations[id].displayName);
|
|
12
|
+
if (!tools.length)
|
|
13
|
+
return "";
|
|
14
|
+
return `${tools.join(", ")} · ${plan.selectedSkills.length} skill${plan.selectedSkills.length === 1 ? "" : "s"}`;
|
|
24
15
|
}
|
|
25
16
|
export function formatPlan(plan) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const removals = new Set();
|
|
30
|
-
const preserves = new Set();
|
|
31
|
-
const directories = new Set();
|
|
32
|
-
for (const op of plan.operations) {
|
|
33
|
-
if (op.type === "copy-managed-file" || op.type === "write-managed-file") {
|
|
34
|
-
managedWrites.add(rel(plan, op.path));
|
|
35
|
-
}
|
|
36
|
-
else if (op.type === "write-project-file-if-missing") {
|
|
37
|
-
projectCreates.add(rel(plan, op.path));
|
|
38
|
-
}
|
|
39
|
-
else if (op.type === "update-managed-section") {
|
|
40
|
-
sectionUpdates.push(`${rel(plan, op.path)} [${op.sectionId}]`);
|
|
41
|
-
}
|
|
42
|
-
else if (op.type === "remove-managed-file" || op.type === "remove-managed-section") {
|
|
43
|
-
removals.add(rel(plan, op.path));
|
|
44
|
-
}
|
|
45
|
-
else if (op.type === "preserve") {
|
|
46
|
-
preserves.add(rel(plan, op.path));
|
|
47
|
-
}
|
|
48
|
-
else if (op.type === "mkdir" || op.type === "remove-empty-dir") {
|
|
49
|
-
directories.add(rel(plan, op.path) || ".");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const managedPaths = [...managedWrites];
|
|
53
|
-
const systemWrites = managedPaths.filter(path => path.startsWith(".yaaw-core/system/"));
|
|
54
|
-
const backupWrites = managedPaths.filter(path => path.startsWith(".yaaw-core/install/backups/"));
|
|
55
|
-
const providerSkillPaths = new Set();
|
|
56
|
-
const providerLines = [];
|
|
57
|
-
for (const id of plan.selectedIntegrations) {
|
|
58
|
-
const adapter = integrations[id];
|
|
59
|
-
const root = normalizePath(relative(plan.projectRoot, adapter.skillsRoot(plan.projectRoot)));
|
|
60
|
-
const paths = managedPaths.filter(path => path === root || path.startsWith(`${root}/`));
|
|
61
|
-
for (const path of paths)
|
|
62
|
-
providerSkillPaths.add(path);
|
|
63
|
-
if (paths.length) {
|
|
64
|
-
providerLines.push(` ${adapter.displayName} skill entrypoints: ${plural(paths.length, "file")} -> ${root}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const otherManaged = managedPaths.filter(path => !systemWrites.includes(path) &&
|
|
68
|
-
!backupWrites.includes(path) &&
|
|
69
|
-
!providerSkillPaths.has(path));
|
|
17
|
+
const hasRemovals = plan.operations.some(op => op.type === "remove-managed-file" || op.type === "remove-managed-section");
|
|
18
|
+
const hasProjectDefaults = plan.operations.some(op => op.type === "write-project-file-if-missing");
|
|
19
|
+
const tools = plan.selectedIntegrations.map(id => integrations[id].displayName).join(", ");
|
|
70
20
|
const lines = [
|
|
71
21
|
`Project: ${plan.projectRoot}`,
|
|
72
|
-
|
|
73
|
-
`Tools: ${plan.selectedIntegrations.map(id => integrations[id].displayName).join(", ") || "none"}`,
|
|
74
|
-
`Skills exposed: ${plan.selectedSkills.length}`,
|
|
75
|
-
"",
|
|
76
|
-
"Planned file impact:",
|
|
77
|
-
` Managed files to reconcile: ${managedWrites.size}`,
|
|
78
|
-
` Project files created only if missing: ${projectCreates.size}`,
|
|
79
|
-
` Managed file sections to update: ${sectionUpdates.length}`,
|
|
80
|
-
` Managed files/sections to remove: ${removals.size}`,
|
|
81
|
-
` Local overrides explicitly preserved: ${preserves.size}`,
|
|
82
|
-
` Directories prepared/cleaned: ${directories.size}`,
|
|
22
|
+
...(toolSummary(plan) ? [toolSummary(plan)] : []),
|
|
83
23
|
"",
|
|
84
|
-
"
|
|
24
|
+
"Will:"
|
|
85
25
|
];
|
|
86
|
-
if (
|
|
87
|
-
lines.push(
|
|
88
|
-
}
|
|
89
|
-
lines.push(...providerLines);
|
|
90
|
-
if (backupWrites.length) {
|
|
91
|
-
lines.push(` Safety backups: ${plural(backupWrites.length, "file")} -> .yaaw-core/install/backups`);
|
|
92
|
-
}
|
|
93
|
-
if (otherManaged.length) {
|
|
94
|
-
lines.push(` Other YAAW-managed files: ${plural(otherManaged.length, "file")}`);
|
|
26
|
+
if (plan.action === "uninstall") {
|
|
27
|
+
lines.push(" Remove YAAW-SE managed framework and integration files");
|
|
95
28
|
}
|
|
96
|
-
if (
|
|
97
|
-
lines.push(`
|
|
29
|
+
else if (plan.action === "fresh") {
|
|
30
|
+
lines.push(` Install the YAAW-SE engine${tools ? ` and ${tools} skills` : ""}`);
|
|
98
31
|
}
|
|
99
|
-
|
|
100
|
-
lines.push(`
|
|
32
|
+
else {
|
|
33
|
+
lines.push(` Refresh the YAAW-SE engine${tools ? ` and ${tools} skills` : ""}`);
|
|
101
34
|
}
|
|
102
|
-
if (
|
|
103
|
-
lines.push(
|
|
35
|
+
if (hasRemovals) {
|
|
36
|
+
lines.push(" Remove obsolete YAAW-managed files");
|
|
104
37
|
}
|
|
105
|
-
if (
|
|
106
|
-
lines.push(
|
|
38
|
+
if (hasProjectDefaults && plan.action !== "uninstall") {
|
|
39
|
+
lines.push(" Ensure durable project memory defaults exist");
|
|
107
40
|
}
|
|
108
|
-
lines.push("
|
|
41
|
+
lines.push(" Preserve project memory and user-owned content");
|
|
109
42
|
if (plan.warnings.length) {
|
|
110
43
|
lines.push("", "Warnings:", ...plan.warnings.map(warning => ` ${warning}`));
|
|
111
44
|
}
|
|
112
45
|
return lines.join("\n");
|
|
113
46
|
}
|
|
114
47
|
export async function confirmPlan(plan) {
|
|
115
|
-
p.note(formatPlan(plan),
|
|
48
|
+
p.note(formatPlan(plan), `YAAW-SE ${actionLabels[plan.action].toLowerCase()}`);
|
|
116
49
|
const ok = await p.confirm({ message: "Continue?", initialValue: true });
|
|
117
50
|
if (p.isCancel(ok))
|
|
118
51
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-plan.js","sourceRoot":"","sources":["../../src/tui/confirm-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"confirm-plan.js","sourceRoot":"","sources":["../../src/tui/confirm-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,eAAe;IACtB,cAAc,EAAE,cAAc;IAC9B,MAAM,EAAE,qBAAqB;IAC7B,MAAM,EAAE,qBAAqB;IAC7B,SAAS,EAAE,WAAW;CACd,CAAC;AAEX,SAAS,WAAW,CAAC,IAAiB;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,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