projectionlab-mcp 1.4.1 → 1.5.0

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.
Files changed (116) hide show
  1. package/HOW-IT-WORKS.md +2 -2
  2. package/README.md +4 -2
  3. package/REFERENCE.md +20 -8
  4. package/dist/appBusy.d.ts +3 -0
  5. package/dist/appBusy.js +7 -0
  6. package/dist/appBusy.js.map +1 -0
  7. package/dist/appMap.d.ts +59 -0
  8. package/dist/appMap.js +595 -0
  9. package/dist/appMap.js.map +1 -0
  10. package/dist/appResultsPage.d.ts +31 -0
  11. package/dist/appResultsPage.js +427 -0
  12. package/dist/appResultsPage.js.map +1 -0
  13. package/dist/bootstrap.d.ts +3 -1
  14. package/dist/bootstrap.js +18 -3
  15. package/dist/bootstrap.js.map +1 -1
  16. package/dist/bridge.d.ts +42 -5
  17. package/dist/bridge.js +15 -1
  18. package/dist/bridge.js.map +1 -1
  19. package/dist/changeSummary.d.ts +129 -0
  20. package/dist/changeSummary.js +346 -0
  21. package/dist/changeSummary.js.map +1 -0
  22. package/dist/editAccess.d.ts +6 -3
  23. package/dist/editAccess.js +10 -3
  24. package/dist/editAccess.js.map +1 -1
  25. package/dist/errors.d.ts +1 -1
  26. package/dist/errors.js.map +1 -1
  27. package/dist/extensionBridge.d.ts +27 -6
  28. package/dist/extensionBridge.js +103 -11
  29. package/dist/extensionBridge.js.map +1 -1
  30. package/dist/index.js +19 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/instructions.d.ts +1 -1
  33. package/dist/instructions.js +2 -2
  34. package/dist/largeOutput.js +2 -23
  35. package/dist/largeOutput.js.map +1 -1
  36. package/dist/planEventTemplates.d.ts +35 -0
  37. package/dist/planEventTemplates.js +177 -0
  38. package/dist/planEventTemplates.js.map +1 -0
  39. package/dist/planReport.d.ts +9 -0
  40. package/dist/planReport.js +902 -0
  41. package/dist/planReport.js.map +1 -0
  42. package/dist/plans.d.ts +2 -0
  43. package/dist/plans.js +6 -0
  44. package/dist/plans.js.map +1 -1
  45. package/dist/printHtml.d.ts +8 -0
  46. package/dist/printHtml.js +144 -0
  47. package/dist/printHtml.js.map +1 -0
  48. package/dist/prompts/index.js +41 -11
  49. package/dist/prompts/index.js.map +1 -1
  50. package/dist/reportCopy.d.ts +16 -0
  51. package/dist/reportCopy.js +55 -0
  52. package/dist/reportCopy.js.map +1 -0
  53. package/dist/resources/appMap.d.ts +2 -0
  54. package/dist/resources/appMap.js +14 -0
  55. package/dist/resources/appMap.js.map +1 -0
  56. package/dist/resources/knowledge.d.ts +1 -1
  57. package/dist/resources/knowledge.js +302 -71
  58. package/dist/resources/knowledge.js.map +1 -1
  59. package/dist/retention.d.ts +8 -0
  60. package/dist/retention.js +35 -0
  61. package/dist/retention.js.map +1 -0
  62. package/dist/settingsReport.d.ts +35 -0
  63. package/dist/settingsReport.js +56 -22
  64. package/dist/settingsReport.js.map +1 -1
  65. package/dist/snapshot.d.ts +12 -0
  66. package/dist/snapshot.js +52 -2
  67. package/dist/snapshot.js.map +1 -1
  68. package/dist/tools/addPlanEvent.d.ts +4 -0
  69. package/dist/tools/addPlanEvent.js +301 -0
  70. package/dist/tools/addPlanEvent.js.map +1 -0
  71. package/dist/tools/clonePlan.d.ts +1 -1
  72. package/dist/tools/clonePlan.js +11 -1
  73. package/dist/tools/clonePlan.js.map +1 -1
  74. package/dist/tools/deletePlan.d.ts +1 -1
  75. package/dist/tools/deletePlan.js +10 -1
  76. package/dist/tools/deletePlan.js.map +1 -1
  77. package/dist/tools/findInApp.d.ts +2 -0
  78. package/dist/tools/findInApp.js +31 -0
  79. package/dist/tools/findInApp.js.map +1 -0
  80. package/dist/tools/listChanges.d.ts +3 -0
  81. package/dist/tools/listChanges.js +147 -0
  82. package/dist/tools/listChanges.js.map +1 -0
  83. package/dist/tools/planReport.d.ts +3 -0
  84. package/dist/tools/planReport.js +62 -0
  85. package/dist/tools/planReport.js.map +1 -0
  86. package/dist/tools/projection.d.ts +3 -0
  87. package/dist/tools/projection.js +381 -0
  88. package/dist/tools/projection.js.map +1 -0
  89. package/dist/tools/removePlanEvent.d.ts +4 -0
  90. package/dist/tools/removePlanEvent.js +196 -0
  91. package/dist/tools/removePlanEvent.js.map +1 -0
  92. package/dist/tools/restore.d.ts +1 -1
  93. package/dist/tools/restore.js +30 -6
  94. package/dist/tools/restore.js.map +1 -1
  95. package/dist/tools/settingsReport.js +23 -4
  96. package/dist/tools/settingsReport.js.map +1 -1
  97. package/dist/tools/snapshots.d.ts +1 -1
  98. package/dist/tools/snapshots.js +65 -31
  99. package/dist/tools/snapshots.js.map +1 -1
  100. package/dist/tools/updateAccount.d.ts +1 -1
  101. package/dist/tools/updateAccount.js +12 -1
  102. package/dist/tools/updateAccount.js.map +1 -1
  103. package/dist/tools/updatePlanEvent.d.ts +1 -1
  104. package/dist/tools/updatePlanEvent.js +19 -2
  105. package/dist/tools/updatePlanEvent.js.map +1 -1
  106. package/dist/tools/updatePlanSection.d.ts +1 -1
  107. package/dist/tools/updatePlanSection.js +19 -3
  108. package/dist/tools/updatePlanSection.js.map +1 -1
  109. package/dist/tools/updatePlanSettings.d.ts +1 -1
  110. package/dist/tools/updatePlanSettings.js +16 -4
  111. package/dist/tools/updatePlanSettings.js.map +1 -1
  112. package/dist/types/wire.d.ts +30 -2
  113. package/dist/types/wire.js +8 -0
  114. package/dist/types/wire.js.map +1 -1
  115. package/package.json +1 -1
  116. package/skills/projectionlab/SKILL.md +142 -18
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Plain-language summaries of write-tool changes, carried as `summary` in each
3
+ * write tool's dry-run and confirmed output. A summary names the plan, item,
4
+ * and setting, and shows old and new values the way ProjectionLab displays
5
+ * them, so an agent can relay it to the user as is.
6
+ *
7
+ * Every builder takes values already passed through `redactSecrets`, so a
8
+ * summary never carries more than the JSON beside it. Each builder depends
9
+ * only on the computed change, not on whether the write is confirmed.
10
+ */
11
+ /** The most lines a summary lists before "and N more changes". */
12
+ export declare const SUMMARY_MAX_LINES = 20;
13
+ export interface SummaryFieldChange {
14
+ before: unknown;
15
+ after: unknown;
16
+ }
17
+ /** A section or collection name in words: "withdrawalStrategy" as
18
+ * "Withdrawal strategy", "currentFinances" as "Current Finances". */
19
+ export declare function sectionTitle(section: string): string;
20
+ /** A field path in words, for a field with no recorded on-screen label:
21
+ * "allocation.stocks" as "Allocation stocks", "points.0.rate" as
22
+ * "Points #1 rate". */
23
+ export declare function pathWords(path: string): string;
24
+ /** "Label: old → new" lines for path-addressed changes in one data-model
25
+ * scope (a settings section, an event section, or "accounts"). */
26
+ export declare function fieldChangeLines(scope: string | undefined, changes: Record<string, SummaryFieldChange>): string[];
27
+ /** Lines past the cap folded into "and N more changes". */
28
+ export declare function capLines(lines: readonly string[], max?: number): string[];
29
+ export declare function accountChangeSummary(input: {
30
+ accountName: unknown;
31
+ kind?: string;
32
+ changes: Record<string, SummaryFieldChange>;
33
+ }): string;
34
+ export declare function planEventChangeSummary(input: {
35
+ planName: unknown;
36
+ section: string;
37
+ eventName: string;
38
+ changes: Record<string, SummaryFieldChange>;
39
+ /** The event's start and end before and after the change, and the plan's
40
+ * milestone names, so a start or end reads as the plan shows it
41
+ * ("Retirement", "age 65"). */
42
+ timing?: {
43
+ before: Record<string, unknown>;
44
+ after: Record<string, unknown>;
45
+ milestones: ReadonlyMap<string, string>;
46
+ };
47
+ }): string;
48
+ /** A new plan event: its type, then the values it is added with. */
49
+ export declare function planEventAddSummary(input: {
50
+ planName: unknown;
51
+ section: string;
52
+ eventName: unknown;
53
+ typeTitle: string;
54
+ /** Path-addressed values shown as "Label: value". */
55
+ fields: Record<string, unknown>;
56
+ timing: {
57
+ start: unknown;
58
+ end: unknown;
59
+ milestones: ReadonlyMap<string, string>;
60
+ };
61
+ }): string;
62
+ export declare function planEventRemoveSummary(input: {
63
+ planName: unknown;
64
+ section: string;
65
+ eventName: string;
66
+ }): string;
67
+ export declare function planSettingsChangeSummary(input: {
68
+ planName: unknown;
69
+ section: string;
70
+ changes: Record<string, SummaryFieldChange>;
71
+ }): string;
72
+ /** A section replacement, item by item: field names only, since the values
73
+ * of a whole-section write are listed in the diff beside it. */
74
+ export declare function planSectionChangeSummary(input: {
75
+ planName: unknown;
76
+ section: string;
77
+ currentCount: number;
78
+ newCount: number;
79
+ added?: readonly string[];
80
+ removed?: readonly string[];
81
+ modified?: readonly {
82
+ name: string;
83
+ changes: Record<string, unknown>;
84
+ }[];
85
+ fieldChanges?: Record<string, unknown>;
86
+ }): string;
87
+ export declare function clonePlanSummary(input: {
88
+ sourceName: unknown;
89
+ newName: unknown;
90
+ counts: Record<string, number>;
91
+ }): string;
92
+ export declare function deletePlanSummary(input: {
93
+ planName: unknown;
94
+ counts: Record<string, number>;
95
+ }): string;
96
+ export declare function restoreCurrentFinancesSummary(input: {
97
+ topLevelKeys: readonly string[];
98
+ keptAccounts?: readonly unknown[];
99
+ }): string;
100
+ export declare function restorePlansSummary(input: {
101
+ currentCount: number;
102
+ incomingCount: number;
103
+ planDiff: readonly {
104
+ name: string;
105
+ status: "unchanged" | "modified" | "added" | "removed";
106
+ changes?: Record<string, string>;
107
+ }[];
108
+ }): string;
109
+ export declare function restoreSettingsSummary(input: {
110
+ topLevelKeys: readonly string[];
111
+ keptSecrets?: readonly string[];
112
+ }): string;
113
+ /**
114
+ * What a confirmed write was, in words, named by the backup it took first:
115
+ * "A plan section change; the backup holds Plans." A backup saves whole
116
+ * sections, so this names the kind of write and the data it saved, and no
117
+ * more: which plan or item changed is not recorded, and projectionlab_diff
118
+ * shows the values.
119
+ */
120
+ export declare function changeSummary(input: {
121
+ operation: string;
122
+ sections: readonly string[];
123
+ }): string;
124
+ export declare function rollbackSummary(input: {
125
+ timestamp: string;
126
+ operation: string;
127
+ sections: readonly string[];
128
+ keptAccounts?: readonly unknown[];
129
+ }): string;
@@ -0,0 +1,346 @@
1
+ import { matchDataModelField } from "./dataModel.js";
2
+ import { MAX_VALUE_CHARS } from "./diff.js";
3
+ import { startLabel } from "./plans.js";
4
+ import { REDACTED } from "./redact.js";
5
+ import { choiceText, formatValue, words } from "./settingsReport.js";
6
+ /**
7
+ * Plain-language summaries of write-tool changes, carried as `summary` in each
8
+ * write tool's dry-run and confirmed output. A summary names the plan, item,
9
+ * and setting, and shows old and new values the way ProjectionLab displays
10
+ * them, so an agent can relay it to the user as is.
11
+ *
12
+ * Every builder takes values already passed through `redactSecrets`, so a
13
+ * summary never carries more than the JSON beside it. Each builder depends
14
+ * only on the computed change, not on whether the write is confirmed.
15
+ */
16
+ /** The most lines a summary lists before "and N more changes". */
17
+ export const SUMMARY_MAX_LINES = 20;
18
+ /** The marker `applyExistingPathChanges` stores for a field that is absent. */
19
+ const ABSENT = "[ABSENT]";
20
+ /** A section or collection name in words: "withdrawalStrategy" as
21
+ * "Withdrawal strategy", "currentFinances" as "Current Finances". */
22
+ export function sectionTitle(section) {
23
+ if (section === "currentFinances")
24
+ return "Current Finances";
25
+ if (section === "montecarlo")
26
+ return "Monte Carlo";
27
+ return words(section);
28
+ }
29
+ /** A field path in words, for a field with no recorded on-screen label:
30
+ * "allocation.stocks" as "Allocation stocks", "points.0.rate" as
31
+ * "Points #1 rate". */
32
+ export function pathWords(path) {
33
+ const text = path
34
+ .split(".")
35
+ .map((segment) => /^\d+$/.test(segment) ? `#${Number(segment) + 1}` : words(segment).toLowerCase())
36
+ .join(" ");
37
+ return text.charAt(0).toUpperCase() + text.slice(1);
38
+ }
39
+ function quoted(name) {
40
+ return `"${typeof name === "string" && name.length > 0 ? name : "unnamed"}"`;
41
+ }
42
+ function isPlainObject(value) {
43
+ return !!value && typeof value === "object" && !Array.isArray(value);
44
+ }
45
+ /** One stored value as ProjectionLab shows it, in the units the data model
46
+ * records for its field; a value with no recorded units is shown plain. */
47
+ function valueText(value, path, units, allowedValues) {
48
+ if (value === ABSENT || value === undefined || value === null)
49
+ return "not set";
50
+ if (value === REDACTED)
51
+ return "(hidden)";
52
+ if (Array.isArray(value) &&
53
+ value.some((item) => isPlainObject(item) && Object.keys(item).length > 2)) {
54
+ return `${value.length} entr${value.length === 1 ? "y" : "ies"}`;
55
+ }
56
+ const leaf = path.split(".").pop() ?? path;
57
+ const text = choiceText(path, value, allowedValues) ??
58
+ choiceText(leaf, value, allowedValues) ??
59
+ formatValue(value, units);
60
+ // The same bound the diff puts on a value, so one long note cannot flood
61
+ // the summary.
62
+ return text.length > MAX_VALUE_CHARS
63
+ ? `${text.slice(0, MAX_VALUE_CHARS)}… (${text.length} characters)`
64
+ : text;
65
+ }
66
+ /** "Label: old → new" lines for path-addressed changes in one data-model
67
+ * scope (a settings section, an event section, or "accounts"). */
68
+ export function fieldChangeLines(scope, changes) {
69
+ return Object.entries(changes).map(([path, { before, after }]) => {
70
+ const field = scope ? matchDataModelField(scope, path) : undefined;
71
+ const label = field?.uiLabel ?? pathWords(path);
72
+ // A group of values is named, not listed: its contents may hold fields
73
+ // the summary has no words for.
74
+ if (isPlainObject(before) || isPlainObject(after))
75
+ return `${label}: changed`;
76
+ const from = valueText(before, path, field?.units, field?.allowedValues);
77
+ const to = valueText(after, path, field?.units, field?.allowedValues);
78
+ return `${label}: ${from} → ${to}`;
79
+ });
80
+ }
81
+ /** Lines past the cap folded into "and N more changes". */
82
+ export function capLines(lines, max = SUMMARY_MAX_LINES) {
83
+ if (lines.length <= max)
84
+ return [...lines];
85
+ const shown = lines.slice(0, max);
86
+ const rest = lines.length - max;
87
+ shown.push(`and ${rest} more change${rest === 1 ? "" : "s"}`);
88
+ return shown;
89
+ }
90
+ function render(head, lines, tail) {
91
+ const body = capLines(lines).map((line) => `- ${line}`);
92
+ return [head, ...body, ...(tail ? [tail] : [])].join("\n");
93
+ }
94
+ const NO_CHANGE = "Nothing changes: every supplied value already matches.";
95
+ const BACKUP = "A backup is taken first, so this can be undone.";
96
+ /** A word list's entry for `key`, ignoring keys inherited from
97
+ * Object.prototype, since the keys come from stored documents. */
98
+ function ownWord(table, key) {
99
+ return Object.hasOwn(table, key) ? table[key] : undefined;
100
+ }
101
+ /** A Current Finances record's kind as ProjectionLab names it. */
102
+ const KIND_WORDS = {
103
+ account: "account",
104
+ debt: "debt",
105
+ "real-asset": "real asset",
106
+ };
107
+ export function accountChangeSummary(input) {
108
+ const what = `Current Finances ${ownWord(KIND_WORDS, input.kind ?? "") ?? "account"} ${quoted(input.accountName)}`;
109
+ if (Object.keys(input.changes).length === 0)
110
+ return `${what}: ${NO_CHANGE}`;
111
+ return render(`${what}:`, fieldChangeLines("accounts", input.changes), BACKUP);
112
+ }
113
+ /** The event fields that hold when an event starts and ends, with their
114
+ * words. */
115
+ const TIMING_FIELDS = [
116
+ ["start", "Starts"],
117
+ ["end", "Ends"],
118
+ ];
119
+ /** A start or end as the plan shows it: "not set" when absent, a keyword in
120
+ * words, undefined for a kind the summary has no words for. */
121
+ function timingText(value, milestones) {
122
+ if (value === undefined || value === null || value === ABSENT)
123
+ return "not set";
124
+ const label = startLabel(value, milestones);
125
+ if (label === undefined)
126
+ return undefined;
127
+ return isPlainObject(value) && value.type === "keyword" ? words(label).toLowerCase() : label;
128
+ }
129
+ export function planEventChangeSummary(input) {
130
+ const what = `Plan ${quoted(input.planName)}, ${sectionTitle(input.section).toLowerCase()} item ${quoted(input.eventName)}`;
131
+ if (Object.keys(input.changes).length === 0)
132
+ return `${what}: ${NO_CHANGE}`;
133
+ const rest = { ...input.changes };
134
+ const lines = [];
135
+ const timing = input.timing;
136
+ if (timing) {
137
+ for (const [field, label] of TIMING_FIELDS) {
138
+ const paths = Object.keys(rest).filter((path) => path === field || path.startsWith(`${field}.`));
139
+ if (paths.length === 0)
140
+ continue;
141
+ const from = timingText(timing.before[field], timing.milestones);
142
+ const to = timingText(timing.after[field], timing.milestones);
143
+ // A start or end of a kind with no words, or a change the words do not
144
+ // show (such as a modifier on an age), stays as its field changes.
145
+ if (from === undefined || to === undefined || from === to)
146
+ continue;
147
+ for (const path of paths)
148
+ delete rest[path];
149
+ lines.push(`${label}: ${from} → ${to}`);
150
+ }
151
+ }
152
+ lines.push(...fieldChangeLines(input.section, rest));
153
+ return render(`${what}:`, lines, BACKUP);
154
+ }
155
+ /** A new plan event: its type, then the values it is added with. */
156
+ export function planEventAddSummary(input) {
157
+ const lines = [`Type: ${input.typeTitle}`];
158
+ for (const [path, value] of Object.entries(input.fields)) {
159
+ const field = matchDataModelField(input.section, path);
160
+ const label = field?.uiLabel ?? pathWords(path);
161
+ lines.push(isPlainObject(value)
162
+ ? `${label}: set`
163
+ : `${label}: ${valueText(value, path, field?.units, field?.allowedValues)}`);
164
+ }
165
+ for (const [field, label] of TIMING_FIELDS) {
166
+ const text = timingText(input.timing[field], input.timing.milestones);
167
+ if (text !== undefined)
168
+ lines.push(`${label}: ${text}`);
169
+ }
170
+ return render(`Plan ${quoted(input.planName)}, add ${sectionTitle(input.section).toLowerCase()} item ${quoted(input.eventName)}:`, lines, BACKUP);
171
+ }
172
+ export function planEventRemoveSummary(input) {
173
+ return [
174
+ `Plan ${quoted(input.planName)}: remove ${sectionTitle(input.section).toLowerCase()} item ${quoted(input.eventName)}.`,
175
+ BACKUP,
176
+ ].join("\n");
177
+ }
178
+ export function planSettingsChangeSummary(input) {
179
+ const what = `Plan ${quoted(input.planName)} settings, ${sectionTitle(input.section)}`;
180
+ if (Object.keys(input.changes).length === 0)
181
+ return `${what}: ${NO_CHANGE}`;
182
+ return render(`${what}:`, fieldChangeLines(input.section, input.changes), BACKUP);
183
+ }
184
+ /** A section replacement, item by item: field names only, since the values
185
+ * of a whole-section write are listed in the diff beside it. */
186
+ export function planSectionChangeSummary(input) {
187
+ const lines = [];
188
+ for (const name of input.added ?? [])
189
+ lines.push(`Add ${quoted(name)}`);
190
+ for (const name of input.removed ?? [])
191
+ lines.push(`Remove ${quoted(name)}`);
192
+ for (const { name, changes } of input.modified ?? []) {
193
+ lines.push(`Change ${quoted(name)}: ${fieldNames(input.section, changes)}`);
194
+ }
195
+ const fields = Object.keys(input.fieldChanges ?? {});
196
+ if (fields.length > 0) {
197
+ lines.push(`Change ${fieldNames(input.section, input.fieldChanges ?? {})}`);
198
+ }
199
+ const what = `Plan ${quoted(input.planName)}, ${sectionTitle(input.section).toLowerCase()} section`;
200
+ if (lines.length === 0)
201
+ return `${what}: ${NO_CHANGE}`;
202
+ // A settings-shaped section (variables, montecarlo, withdrawalStrategy)
203
+ // holds fields, not items, so it has no count to show.
204
+ if (fields.length > 0 && input.currentCount === 0 && input.newCount === 0) {
205
+ return render(`${what}:`, lines, BACKUP);
206
+ }
207
+ const counts = input.currentCount === input.newCount
208
+ ? itemsText(input.newCount)
209
+ : `${input.currentCount} → ${itemsText(input.newCount)}`;
210
+ return render(`${what} (${counts}):`, lines, BACKUP);
211
+ }
212
+ function itemsText(count) {
213
+ return `${count} item${count === 1 ? "" : "s"}`;
214
+ }
215
+ /** How many field names one summary line lists before folding the rest. */
216
+ const FIELD_NAMES_MAX = 8;
217
+ function fieldNames(scope, changes) {
218
+ return namesText(Object.keys(changes).map((path) => matchDataModelField(scope, path)?.uiLabel ?? pathWords(path)), FIELD_NAMES_MAX, "field");
219
+ }
220
+ /** A comma-separated list of names, the ones past `max` folded into
221
+ * "and N more <noun>s". */
222
+ function namesText(names, max, noun) {
223
+ if (names.length <= max)
224
+ return names.join(", ");
225
+ const rest = names.length - max;
226
+ return [...names.slice(0, max), `and ${rest} more ${noun}${rest === 1 ? "" : "s"}`].join(", ");
227
+ }
228
+ /** Item counts by section: "income: 3, expenses: 12, accounts: 4". */
229
+ function countsText(counts) {
230
+ const parts = Object.entries(counts)
231
+ .filter(([, count]) => count > 0)
232
+ .map(([section, count]) => `${sectionTitle(section).toLowerCase()}: ${count}`);
233
+ return parts.length > 0 ? parts.join(", ") : "no items";
234
+ }
235
+ export function clonePlanSummary(input) {
236
+ return [
237
+ `Add plan ${quoted(input.newName)} as a copy of ${quoted(input.sourceName)} (${countsText(input.counts)}).`,
238
+ "A plan copy does not change Current Finances or the other plans.",
239
+ BACKUP,
240
+ ].join("\n");
241
+ }
242
+ export function deletePlanSummary(input) {
243
+ return [
244
+ `Delete plan ${quoted(input.planName)} and everything in it (${countsText(input.counts)}).`,
245
+ BACKUP,
246
+ ].join("\n");
247
+ }
248
+ /** How many kept accounts one summary line names before folding the rest. */
249
+ const KEPT_ACCOUNTS_MAX = 10;
250
+ function keptAccountsLine(kept) {
251
+ if (!kept || kept.length === 0)
252
+ return [];
253
+ const names = kept.map((entry) => isPlainObject(entry) ? quoted(entry.name ?? entry.id) : quoted(entry));
254
+ return [
255
+ `Kept as they are (not in the replacement): ${namesText(names, KEPT_ACCOUNTS_MAX, "account")}`,
256
+ ];
257
+ }
258
+ export function restoreCurrentFinancesSummary(input) {
259
+ return render("Replace Current Finances with the supplied data:", [
260
+ `Replaced: ${input.topLevelKeys.map((key) => sectionTitle(key)).join(", ") || "nothing"}`,
261
+ ...keptAccountsLine(input.keptAccounts),
262
+ ], BACKUP);
263
+ }
264
+ export function restorePlansSummary(input) {
265
+ const lines = input.planDiff
266
+ .filter((entry) => entry.status !== "unchanged")
267
+ .map((entry) => {
268
+ if (entry.status === "added")
269
+ return `Add plan ${quoted(entry.name)}`;
270
+ if (entry.status === "removed")
271
+ return `Remove plan ${quoted(entry.name)}`;
272
+ const parts = Object.entries(entry.changes ?? {}).map(([key, change]) => `${sectionTitle(key).toLowerCase()} ${change}`);
273
+ return parts.length > 0
274
+ ? `Change plan ${quoted(entry.name)}: ${parts.join("; ")}`
275
+ : `Replace plan ${quoted(entry.name)}`;
276
+ });
277
+ const unchanged = input.planDiff.filter((e) => e.status === "unchanged").length;
278
+ if (unchanged > 0) {
279
+ lines.push(`${unchanged} other plan${unchanged === 1 ? "" : "s"} replaced, with the same name and item counts`);
280
+ }
281
+ return render(`Replace all plans (${input.currentCount} → ${input.incomingCount}):`, lines, BACKUP);
282
+ }
283
+ export function restoreSettingsSummary(input) {
284
+ const lines = [
285
+ `Replaced: ${input.topLevelKeys.map((key) => sectionTitle(key)).join(", ") || "nothing"}`,
286
+ ];
287
+ if (input.keptSecrets && input.keptSecrets.length > 0) {
288
+ lines.push(`Kept from the current settings (hidden values): ${input.keptSecrets.map(pathWords).join(", ")}`);
289
+ }
290
+ return render("Replace all Settings with the supplied data:", lines, BACKUP);
291
+ }
292
+ /** What a backup was taken before, by the operation that took it. */
293
+ const OPERATION_WORDS = {
294
+ updateAccount: "a Current Finances account change",
295
+ updatePlanEvent: "a plan item change",
296
+ addPlanEvent: "a plan item addition",
297
+ removePlanEvent: "a plan item removal",
298
+ updatePlanSection: "a plan section change",
299
+ updatePlanSettings: "a plan settings change",
300
+ clonePlan: "a plan copy",
301
+ deletePlan: "a plan deletion",
302
+ restoreCurrentFinances: "a Current Finances replacement",
303
+ restorePlans: "a replacement of all plans",
304
+ restoreSettings: "a Settings replacement",
305
+ };
306
+ function operationText(operation) {
307
+ if (operation.startsWith("rollback_pre_"))
308
+ return "a rollback";
309
+ return ownWord(OPERATION_WORDS, operation) ?? `"${words(operation).toLowerCase()}"`;
310
+ }
311
+ /** A backup's time as a reader names it, in the server's time zone. */
312
+ function timeText(timestamp) {
313
+ const time = new Date(timestamp);
314
+ if (Number.isNaN(time.getTime()))
315
+ return timestamp;
316
+ return time.toLocaleString("en-US", {
317
+ year: "numeric",
318
+ month: "short",
319
+ day: "numeric",
320
+ hour: "numeric",
321
+ minute: "2-digit",
322
+ timeZoneName: "short",
323
+ });
324
+ }
325
+ /**
326
+ * What a confirmed write was, in words, named by the backup it took first:
327
+ * "A plan section change; the backup holds Plans." A backup saves whole
328
+ * sections, so this names the kind of write and the data it saved, and no
329
+ * more: which plan or item changed is not recorded, and projectionlab_diff
330
+ * shows the values.
331
+ */
332
+ export function changeSummary(input) {
333
+ const phrase = operationText(input.operation);
334
+ const opening = phrase.charAt(0).toUpperCase() + phrase.slice(1);
335
+ const sections = input.sections
336
+ .map((section) => sectionTitle(section))
337
+ .join(", ");
338
+ return sections ? `${opening}; the backup holds ${sections}.` : `${opening}.`;
339
+ }
340
+ export function rollbackSummary(input) {
341
+ return render(`Restore the backup taken ${timeText(input.timestamp)}, before ${operationText(input.operation)}:`, [
342
+ `Restored: ${input.sections.map((section) => sectionTitle(section)).join(", ")}`,
343
+ ...keptAccountsLine(input.keptAccounts),
344
+ ], "The current state is backed up first, so this rollback can itself be undone.");
345
+ }
346
+ //# sourceMappingURL=changeSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeSummary.js","sourceRoot":"","sources":["../src/changeSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAErE;;;;;;;;;GASG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,+EAA+E;AAC/E,MAAM,MAAM,GAAG,UAAU,CAAC;AAO1B;qEACqE;AACrE,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,OAAO,KAAK,iBAAiB;QAAE,OAAO,kBAAkB,CAAC;IAC7D,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,aAAa,CAAC;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC;AAED;;uBAEuB;AACvB,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,IAAI,GAAG,IAAI;SACd,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CACjF;SACA,IAAI,CAAC,GAAG,CAAC,CA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AAC;AAED,MAAM,UAAU,eAAe,CAAC,KAK/B;IACC,OAAO,MAAM,CACX,4BAA4B,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAClG;QACE,aAAa,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAChF,GAAG,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC;KACxC,EACD,8EAA8E,CAC/E,CAAC;AACJ,CAAC"}
@@ -8,8 +8,11 @@ import { ProjectionLabError } from "./errors.js";
8
8
  */
9
9
  export declare function editsDisabledError(access: Exclude<EditAccess, "enabled">): ProjectionLabError;
10
10
  /**
11
- * Refuses the tool call unless the connected executor allows edits. Write
12
- * tools call this first, so a dry run reports the refusal before any preview,
13
- * read, or snapshot.
11
+ * Refuses the tool call unless the connected executor allows edits, and
12
+ * while ProjectionLab is in Compare or What If mode. Write tools call this
13
+ * first, so a dry run reports the refusal before any preview, read, or
14
+ * snapshot. When Compare cannot be read (an executor without the app
15
+ * results reads, or a ProjectionLab release with other store names) the
16
+ * call goes ahead; the bridge checks again just before each write.
14
17
  */
15
18
  export declare function requireEditsEnabled(bridge: Bridge): Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import { ProjectionLabError } from "./errors.js";
2
+ import { appBusyWriteError } from "./appBusy.js";
2
3
  const SWITCH = "\"Enable agent plan edits\"";
3
4
  /**
4
5
  * The READ_ONLY_MODE error for an executor whose edits are not enabled.
@@ -17,13 +18,19 @@ export function editsDisabledError(access) {
17
18
  "It takes effect at once, with no restart; then retry.");
18
19
  }
19
20
  /**
20
- * Refuses the tool call unless the connected executor allows edits. Write
21
- * tools call this first, so a dry run reports the refusal before any preview,
22
- * read, or snapshot.
21
+ * Refuses the tool call unless the connected executor allows edits, and
22
+ * while ProjectionLab is in Compare or What If mode. Write tools call this
23
+ * first, so a dry run reports the refusal before any preview, read, or
24
+ * snapshot. When Compare cannot be read (an executor without the app
25
+ * results reads, or a ProjectionLab release with other store names) the
26
+ * call goes ahead; the bridge checks again just before each write.
23
27
  */
24
28
  export async function requireEditsEnabled(bridge) {
25
29
  const access = await bridge.editAccess();
26
30
  if (access !== "enabled")
27
31
  throw editsDisabledError(access);
32
+ const busy = await bridge.appBusy?.();
33
+ if (busy && (busy.comparing || busy.whatIf))
34
+ throw appBusyWriteError(busy.whatIf);
28
35
  }
29
36
  //# sourceMappingURL=editAccess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editAccess.js","sourceRoot":"","sources":["../src/editAccess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,GAAG,6BAA6B,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsC;IACvE,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;QAC7B,OAAO,IAAI,kBAAkB,CAC3B,gBAAgB,EAChB,6GAA6G,EAC7G,8EAA8E;YAC5E,GAAG,MAAM,+EAA+E;YACxF,kFAAkF,CACrF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,kBAAkB,CAC3B,gBAAgB,EAChB,yFAAyF,EACzF,oEAAoE,MAAM,UAAU;QAClF,yFAAyF;QACzF,uDAAuD,CAC1D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC"}
1
+ {"version":3,"file":"editAccess.js","sourceRoot":"","sources":["../src/editAccess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,GAAG,6BAA6B,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsC;IACvE,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;QAC7B,OAAO,IAAI,kBAAkB,CAC3B,gBAAgB,EAChB,6GAA6G,EAC7G,8EAA8E;YAC5E,GAAG,MAAM,+EAA+E;YACxF,kFAAkF,CACrF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,kBAAkB,CAC3B,gBAAgB,EAChB,yFAAyF,EACzF,oEAAoE,MAAM,UAAU;QAClF,yFAAyF;QACzF,uDAAuD,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc;IACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;IACtC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpF,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type ErrorCode = "BROWSER_NOT_READY" | "EXTENSION_NOT_CONNECTED" | "PAGE_NOT_LOADED" | "API_NOT_AVAILABLE" | "API_KEY_INVALID" | "API_KEY_MISSING" | "TIMEOUT" | "INVALID_INPUT" | "READ_ONLY_MODE" | "SNAPSHOT_NOT_FOUND" | "PLAN_CONFLICT" | "UNSUPPORTED_API_VERSION" | "WRITE_NOT_SUPPORTED" | "EXECUTOR_OUTDATED" | "CONTRACT_CHANGED" | "LAYOUT_MISMATCH" | "UNKNOWN";
1
+ export type ErrorCode = "BROWSER_NOT_READY" | "EXTENSION_NOT_CONNECTED" | "PAGE_NOT_LOADED" | "API_NOT_AVAILABLE" | "API_KEY_INVALID" | "API_KEY_MISSING" | "TIMEOUT" | "INVALID_INPUT" | "READ_ONLY_MODE" | "SNAPSHOT_NOT_FOUND" | "PLAN_CONFLICT" | "UNSUPPORTED_API_VERSION" | "WRITE_NOT_SUPPORTED" | "EXECUTOR_OUTDATED" | "CONTRACT_CHANGED" | "LAYOUT_MISMATCH" | "APP_BUSY" | "APP_RESULTS_UNAVAILABLE" | "PROJECTION_TIMEOUT" | "PLAN_NOT_ACTIVE" | "RUN_IN_PROGRESS" | "RUN_UNAVAILABLE" | "UNKNOWN";
2
2
  export interface PlError {
3
3
  error: ErrorCode;
4
4
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA2B5C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEzB;IAEA;IAHlB,YACkB,IAAe,EAC/B,OAAe,EACC,UAAkB;QAElC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAW;QAEf,eAAU,GAAV,UAAU,CAAQ;QAGlC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,YAAY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AC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,OAAO;QACP,UAAU,EAAE,+BAA+B;KAC5C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAmB,EACnB,KAAe;IAEf,OAAO,IAAI,kBAAkB,CAC3B,eAAe,EACf,GAAG,WAAW,wCAAwC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACxE,iGAAiG;QAC/F,0FAA0F;QAC1F,6FAA6F,CAChG,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,2EAA2E;IAC3E,iEAAiE;IACjE,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -1,6 +1,7 @@
1
- import type { Bridge, ConnectionStatus, EditAccess } from "./bridge.js";
1
+ import type { AppBusy, Bridge, ConnectionStatus, EditAccess, WriteContext } from "./bridge.js";
2
2
  import { type ApiContract } from "./layout.js";
3
3
  import type { ExportedData } from "./types/projectionlab.js";
4
+ import { type AppMethod } from "./types/wire.js";
4
5
  export declare class ExtensionBridge implements Bridge {
5
6
  private wss;
6
7
  private conn;
@@ -8,6 +9,8 @@ export declare class ExtensionBridge implements Bridge {
8
9
  private connInstanceId;
9
10
  /** Whether the connected executor honors RequestFrame.expectApiVersion. */
10
11
  private connGuardsApiVersion;
12
+ /** Whether the connected executor serves the AppMethod reads. */
13
+ private connAppResults;
11
14
  private connEditAccess;
12
15
  private readonly pending;
13
16
  /** Random per instance, so request ids never repeat across server
@@ -140,19 +143,37 @@ export declare class ExtensionBridge implements Bridge {
140
143
  * same entry as the write it guards.
141
144
  */
142
145
  private assertWriteSupported;
146
+ /** Refuses an executor that does not serve the AppMethod reads. Call only
147
+ * from the operation chain, after executorSocket. */
148
+ private requireAppResults;
149
+ appRequest(method: AppMethod, options?: Record<string, unknown>): Promise<unknown>;
150
+ appBusy(): Promise<AppBusy | null>;
151
+ /**
152
+ * Compare and What If, and the revisions a write's result carries, read
153
+ * from the page. Call only from the operation chain. Answers null when
154
+ * the executor cannot read the app's stores or the stores are not
155
+ * readable: writes then go ahead as they do without these tools.
156
+ */
157
+ private readAppBusy;
158
+ /**
159
+ * Refuses a write while Compare or What If is on, and returns the
160
+ * revisions to report with it. Call only from the operation chain, in
161
+ * the same entry as the write, just before it.
162
+ */
163
+ private writeContext;
143
164
  editAccess(): Promise<EditAccess>;
144
165
  describePluginApi(): Promise<Record<string, string>>;
145
166
  exportData(opts?: {
146
167
  fresh?: boolean;
147
168
  }): Promise<ExportedData>;
148
- updateAccount(accountId: string, data: Record<string, unknown>, force: boolean | undefined): Promise<void>;
169
+ updateAccount(accountId: string, data: Record<string, unknown>, force: boolean | undefined): Promise<WriteContext>;
149
170
  private restoreCall;
150
- restoreCurrentFinances(state: unknown): Promise<void>;
151
- restorePlans(plans: unknown[]): Promise<void>;
171
+ restoreCurrentFinances(state: unknown): Promise<WriteContext>;
172
+ restorePlans(plans: unknown[]): Promise<WriteContext>;
152
173
  /** Re-reads the plans and writes `plans` as one entry on the operation
153
174
  * chain, so neither a hand-over to another instance nor another operation
154
175
  * of this one can run between the conflict check and the write. */
155
- restorePlansIfUnchanged(read: unknown[], plans: unknown[]): Promise<void>;
156
- restoreSettings(settings: unknown): Promise<void>;
176
+ restorePlansIfUnchanged(read: unknown[], plans: unknown[]): Promise<WriteContext>;
177
+ restoreSettings(settings: unknown): Promise<WriteContext>;
157
178
  close(): Promise<void>;
158
179
  }