@picassohq/cli 0.0.0-stage → 1.0.1
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/agents/browser_agent.yaml +53 -0
- package/agents/code_reviewer.yaml +49 -0
- package/agents/codebase_investigator.yaml +70 -0
- package/agents/design_auditor.yaml +50 -0
- package/agents/devex_auditor.yaml +50 -0
- package/agents/doc_writer.yaml +54 -0
- package/agents/engineering_architect.yaml +51 -0
- package/agents/generalist.yaml +55 -0
- package/agents/migration_planner.yaml +51 -0
- package/agents/product_reviewer.yaml +48 -0
- package/agents/qa_operator.yaml +52 -0
- package/agents/release_engineer.yaml +50 -0
- package/agents/security_auditor.yaml +62 -0
- package/agents/test_writer.yaml +52 -0
- package/assets/first-light-lockup.png +0 -0
- package/assets/first-light-tagline.png +0 -0
- package/assets/house/README.md +26 -0
- package/assets/house/auraone-banner.png +0 -0
- package/assets/house/auraone-logo.png +0 -0
- package/assets/house/kiro-prism-banner.png +0 -0
- package/assets/house/kiro-prism-logo.png +0 -0
- package/assets/house/picasso-banner.png +0 -0
- package/assets/house/picasso-logo.png +0 -0
- package/assets/wordmark-app.png +0 -0
- package/assets/wordmark-tight.png +0 -0
- package/assets/wordmark.png +0 -0
- package/design/styles.css +1042 -0
- package/dist/build-info.json +37 -0
- package/dist/index.js +3028 -0
- package/goals/cli-hardening.yaml +40 -0
- package/goals/repo-maintenance.yaml +40 -0
- package/package.json +49 -4
- package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
- package/runtime/dsh/picasso-ecosystem.community.json +185 -0
- package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
- package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
- package/runtime/dsh/picasso-isolation.patch.yml +25 -0
- package/runtime/dsh/picasso-providers.patch.yml +373 -0
- package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
- package/runtime/dsh/picasso-sdk.patch.yml +204 -0
- package/runtime/engine-manifest.json +214 -0
- package/runtime/package.json +6 -0
- package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
- package/runtime/packages/picasso-cache-probe/index.js +477 -0
- package/runtime/packages/picasso-cache-probe/package.json +38 -0
- package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-commands/fresh-review.js +573 -0
- package/runtime/packages/picasso-commands/index.js +497 -0
- package/runtime/packages/picasso-commands/package.json +28 -0
- package/runtime/packages/picasso-instructions/conflicts.js +115 -0
- package/runtime/packages/picasso-instructions/formats.js +145 -0
- package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
- package/runtime/packages/picasso-instructions/glob.js +114 -0
- package/runtime/packages/picasso-instructions/globals.js +90 -0
- package/runtime/packages/picasso-instructions/imports.js +123 -0
- package/runtime/packages/picasso-instructions/index.js +326 -0
- package/runtime/packages/picasso-instructions/modes.js +64 -0
- package/runtime/packages/picasso-instructions/package.json +30 -0
- package/runtime/packages/picasso-instructions/parse.js +134 -0
- package/runtime/packages/picasso-instructions/report.js +161 -0
- package/runtime/packages/picasso-instructions/resolve.js +939 -0
- package/runtime/packages/picasso-instructions/scan.js +181 -0
- package/runtime/packages/picasso-instructions/settings.js +150 -0
- package/runtime/packages/picasso-instructions/skills.js +345 -0
- package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
- package/runtime/packages/picasso-lean-context/index.js +6049 -0
- package/runtime/packages/picasso-lean-context/package.json +26 -0
- package/runtime/packages/picasso-lean-context/timeline.js +417 -0
- package/runtime/packages/picasso-librarian/classify.js +146 -0
- package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-librarian/index.js +878 -0
- package/runtime/packages/picasso-librarian/notes.js +159 -0
- package/runtime/packages/picasso-librarian/package.json +34 -0
- package/runtime/packages/picasso-librarian/state.js +478 -0
- package/runtime/packages/picasso-memory/index.js +1184 -0
- package/runtime/packages/picasso-memory/package.json +21 -0
- package/runtime/packages/picasso-model-router/connections.js +895 -0
- package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
- package/runtime/packages/picasso-model-router/index.js +1081 -0
- package/runtime/packages/picasso-model-router/package.json +30 -0
- package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-options/index.js +263 -0
- package/runtime/packages/picasso-options/package.json +28 -0
- package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-progress-reports/index.js +267 -0
- package/runtime/packages/picasso-progress-reports/package.json +30 -0
- package/runtime/packages/picasso-progress-reports/report.js +235 -0
- package/runtime/packages/picasso-sdk-server/aside.js +128 -0
- package/runtime/packages/picasso-sdk-server/connections.js +38 -0
- package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
- package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
- package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
- package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
- package/runtime/packages/picasso-sdk-server/goal.js +131 -0
- package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
- package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
- package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
- package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
- package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
- package/runtime/packages/picasso-sdk-server/index.js +886 -0
- package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
- package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
- package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
- package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
- package/runtime/packages/picasso-sdk-server/package.json +50 -0
- package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
- package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
- package/runtime/packages/picasso-sdk-server/queue.js +322 -0
- package/runtime/packages/picasso-sdk-server/requester.js +43 -0
- package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
- package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
- package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
- package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
- package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
- package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
- package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
- package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
- package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
- package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
- package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
- package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
- package/runtime/packages/picasso-web-search/backends.js +350 -0
- package/runtime/packages/picasso-web-search/config.js +121 -0
- package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
- package/runtime/packages/picasso-web-search/failure.js +111 -0
- package/runtime/packages/picasso-web-search/format.js +35 -0
- package/runtime/packages/picasso-web-search/index.js +66 -0
- package/runtime/packages/picasso-web-search/package.json +38 -0
- package/runtime/packages/picasso-web-search/router.js +155 -0
- package/runtime/packages/picasso-x-reader/circle.js +324 -0
- package/runtime/packages/picasso-x-reader/command.js +169 -0
- package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
- package/runtime/packages/picasso-x-reader/index.js +170 -0
- package/runtime/packages/picasso-x-reader/package.json +39 -0
- package/runtime/packages/picasso-x-reader/read.js +370 -0
- package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
- package/runtime/packages/picasso-x-reader/settings.js +131 -0
- package/runtime/packages/picasso-x-reader/urls.js +154 -0
- package/runtime/packages/picasso-x-reader/xmd.js +512 -0
- package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
- package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
- package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
- package/runtime/plugins/picasso-auto-approve/package.json +28 -0
- package/runtime/plugins/picasso-browser/index.js +424 -0
- package/runtime/plugins/picasso-browser/package.json +28 -0
- package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
- package/runtime/plugins/picasso-checkpoints/index.js +885 -0
- package/runtime/plugins/picasso-checkpoints/package.json +29 -0
- package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
- package/runtime/plugins/picasso-commands/index.js +497 -0
- package/runtime/plugins/picasso-commands/package.json +28 -0
- package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
- package/runtime/plugins/picasso-instructions/formats.js +145 -0
- package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
- package/runtime/plugins/picasso-instructions/glob.js +114 -0
- package/runtime/plugins/picasso-instructions/globals.js +90 -0
- package/runtime/plugins/picasso-instructions/imports.js +123 -0
- package/runtime/plugins/picasso-instructions/index.js +326 -0
- package/runtime/plugins/picasso-instructions/modes.js +64 -0
- package/runtime/plugins/picasso-instructions/package.json +30 -0
- package/runtime/plugins/picasso-instructions/parse.js +134 -0
- package/runtime/plugins/picasso-instructions/report.js +161 -0
- package/runtime/plugins/picasso-instructions/resolve.js +939 -0
- package/runtime/plugins/picasso-instructions/scan.js +181 -0
- package/runtime/plugins/picasso-instructions/settings.js +150 -0
- package/runtime/plugins/picasso-instructions/skills.js +345 -0
- package/runtime/plugins/picasso-lean-context/index.js +6049 -0
- package/runtime/plugins/picasso-lean-context/package.json +26 -0
- package/runtime/plugins/picasso-lean-context/timeline.js +417 -0
- package/runtime/plugins/picasso-librarian/classify.js +146 -0
- package/runtime/plugins/picasso-librarian/index.js +878 -0
- package/runtime/plugins/picasso-librarian/notes.js +159 -0
- package/runtime/plugins/picasso-librarian/package.json +34 -0
- package/runtime/plugins/picasso-librarian/state.js +478 -0
- package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
- package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
- package/runtime/plugins/picasso-mail/inbox.js +207 -0
- package/runtime/plugins/picasso-mail/index.js +293 -0
- package/runtime/plugins/picasso-mail/package.json +22 -0
- package/runtime/plugins/picasso-memory/index.js +1184 -0
- package/runtime/plugins/picasso-memory/package.json +21 -0
- package/runtime/plugins/picasso-model-router/connections.js +895 -0
- package/runtime/plugins/picasso-model-router/index.js +1081 -0
- package/runtime/plugins/picasso-model-router/package.json +30 -0
- package/runtime/plugins/picasso-options/index.js +263 -0
- package/runtime/plugins/picasso-options/package.json +28 -0
- package/runtime/plugins/picasso-progress-reports/index.js +267 -0
- package/runtime/plugins/picasso-progress-reports/package.json +30 -0
- package/runtime/plugins/picasso-progress-reports/report.js +235 -0
- package/runtime/plugins/picasso-provider-models/index.js +436 -0
- package/runtime/plugins/picasso-provider-models/package.json +28 -0
- package/runtime/plugins/picasso-repo-index/index.js +1850 -0
- package/runtime/plugins/picasso-repo-index/package.json +28 -0
- package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
- package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
- package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
- package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
- package/runtime/plugins/picasso-trackers/index.js +895 -0
- package/runtime/plugins/picasso-trackers/package.json +28 -0
- package/runtime/plugins/picasso-web-search/backends.js +350 -0
- package/runtime/plugins/picasso-web-search/config.js +121 -0
- package/runtime/plugins/picasso-web-search/failure.js +111 -0
- package/runtime/plugins/picasso-web-search/format.js +35 -0
- package/runtime/plugins/picasso-web-search/index.js +66 -0
- package/runtime/plugins/picasso-web-search/package.json +38 -0
- package/runtime/plugins/picasso-web-search/router.js +155 -0
- package/runtime/plugins/picasso-x-reader/circle.js +324 -0
- package/runtime/plugins/picasso-x-reader/command.js +169 -0
- package/runtime/plugins/picasso-x-reader/index.js +170 -0
- package/runtime/plugins/picasso-x-reader/package.json +39 -0
- package/runtime/plugins/picasso-x-reader/read.js +370 -0
- package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
- package/runtime/plugins/picasso-x-reader/settings.js +131 -0
- package/runtime/plugins/picasso-x-reader/urls.js +154 -0
- package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
- package/runtime/relay/attachment-text.mjs +737 -0
- package/runtime/relay/companion/companion.css +126 -0
- package/runtime/relay/companion/companion.js +648 -0
- package/runtime/relay/companion/icon.svg +5 -0
- package/runtime/relay/companion/index.html +25 -0
- package/runtime/relay/companion/manifest.json +13 -0
- package/runtime/relay/companion/sw.js +41 -0
- package/runtime/relay/main.mjs +37252 -0
- package/runtime/relay/model-listing.mjs +614 -0
- package/runtime/relay/versions-routes.mjs +1198 -0
- package/runtime/verify-plugins.mjs +205 -0
- package/runtime-lock/package-lock.json +10779 -0
- package/runtime-lock/package.json +7 -0
- package/scripts/install-runtime.mjs +400 -0
- package/README.md +0 -3
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// The inspectable view of a resolution (owner spec §5.7): "what instructions is this agent following, where did they
|
|
2
|
+
// come from, and why were they loaded?" One JSON shape for `picasso instructions --json`, the TUI's /instructions and
|
|
3
|
+
// /context section, and the Mac panel. Zero dependencies.
|
|
4
|
+
|
|
5
|
+
import { describeMode } from './modes.js';
|
|
6
|
+
|
|
7
|
+
export const REPORT_VERSION = 1;
|
|
8
|
+
|
|
9
|
+
/** Activation labels shown in the inspector (the spec's vocabulary). */
|
|
10
|
+
export const ACTIVATION_LABELS = Object.freeze({
|
|
11
|
+
always: 'always',
|
|
12
|
+
glob: 'glob',
|
|
13
|
+
model: 'model-selected',
|
|
14
|
+
manual: 'manual',
|
|
15
|
+
recognized: 'recognised',
|
|
16
|
+
index: 'index',
|
|
17
|
+
'disabled-global': 'disabled-global',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** Status labels shown in the inspector. */
|
|
21
|
+
export const STATUS_LABELS = Object.freeze({
|
|
22
|
+
loaded: 'loaded',
|
|
23
|
+
truncated: 'truncated',
|
|
24
|
+
omitted: 'omitted (budget)',
|
|
25
|
+
'pending-scope': 'pending scope',
|
|
26
|
+
available: 'available',
|
|
27
|
+
manual: 'manual',
|
|
28
|
+
duplicate: 'duplicate',
|
|
29
|
+
overridden: 'overridden',
|
|
30
|
+
excluded: 'not read in this mode',
|
|
31
|
+
recognized: 'recognised, not applied',
|
|
32
|
+
disabled: 'off',
|
|
33
|
+
error: 'error',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @typedef {object} InstructionReportSource
|
|
38
|
+
* @property {string} id
|
|
39
|
+
* @property {string} path
|
|
40
|
+
* @property {string} absolutePath
|
|
41
|
+
* @property {string} format
|
|
42
|
+
* @property {string} formatLabel
|
|
43
|
+
* @property {string} ecosystem
|
|
44
|
+
* @property {string} scope
|
|
45
|
+
* @property {string} activation always | glob | model-selected | manual | recognised | disabled-global
|
|
46
|
+
* @property {string[]} [globs]
|
|
47
|
+
* @property {string} [description]
|
|
48
|
+
* @property {string} status loaded | truncated | omitted | pending-scope | available | manual | duplicate | …
|
|
49
|
+
* @property {string} statusLabel
|
|
50
|
+
* @property {string} why
|
|
51
|
+
* @property {number} tokens
|
|
52
|
+
* @property {number} bytes
|
|
53
|
+
* @property {1 | 2} [tier]
|
|
54
|
+
* @property {string} [duplicateOf]
|
|
55
|
+
* @property {string} [overriddenBy]
|
|
56
|
+
* @property {string[]} [conflicts]
|
|
57
|
+
* @property {string} [error]
|
|
58
|
+
* @property {string[]} [notes]
|
|
59
|
+
* @property {string[]} [ignoredKeys] frontmatter keys Picasso reports and never applies
|
|
60
|
+
* @property {string} [globalId]
|
|
61
|
+
* @property {{ request: string, status: string }[]} [imports]
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {import('./resolve.js').Resolution} resolution
|
|
66
|
+
* @param {{ globals?: readonly { id: string, label: string, ecosystem: string, paths: readonly string[], enabled: boolean, present: boolean }[], sessionId?: string, activeIds?: Iterable<string> }} [extra]
|
|
67
|
+
*/
|
|
68
|
+
export function buildReport(resolution, extra = {}) {
|
|
69
|
+
const sources = resolution.sources.map((source) => {
|
|
70
|
+
/** @type {InstructionReportSource} */
|
|
71
|
+
const row = {
|
|
72
|
+
id: source.id,
|
|
73
|
+
path: source.path,
|
|
74
|
+
absolutePath: source.absolutePath,
|
|
75
|
+
format: source.format,
|
|
76
|
+
formatLabel: source.formatLabel,
|
|
77
|
+
ecosystem: source.ecosystem,
|
|
78
|
+
scope: source.scope,
|
|
79
|
+
activation: ACTIVATION_LABELS[source.activation.kind] ?? source.activation.kind,
|
|
80
|
+
status: source.status,
|
|
81
|
+
statusLabel: STATUS_LABELS[source.status] ?? source.status,
|
|
82
|
+
why: source.why,
|
|
83
|
+
tokens: source.tokens,
|
|
84
|
+
bytes: source.bytes,
|
|
85
|
+
};
|
|
86
|
+
const activation = /** @type {any} */ (source.activation);
|
|
87
|
+
if (Array.isArray(activation.globs) && activation.globs.length > 0) row.globs = [...activation.globs];
|
|
88
|
+
const description = activation.description ?? source.description;
|
|
89
|
+
if (description !== undefined) row.description = description;
|
|
90
|
+
if (source.tier !== undefined) row.tier = source.tier;
|
|
91
|
+
if (source.duplicateOf !== undefined) row.duplicateOf = source.duplicateOf;
|
|
92
|
+
if (source.overriddenBy !== undefined) row.overriddenBy = source.overriddenBy;
|
|
93
|
+
if (source.conflicts !== undefined) row.conflicts = [...source.conflicts];
|
|
94
|
+
if (source.error !== undefined) row.error = source.error;
|
|
95
|
+
if (source.notes !== undefined) row.notes = [...source.notes];
|
|
96
|
+
if (source.ignoredKeys !== undefined) row.ignoredKeys = [...source.ignoredKeys];
|
|
97
|
+
if (source.imports !== undefined) row.imports = source.imports.map((item) => ({ ...item }));
|
|
98
|
+
if (/** @type {any} */ (source).globalId !== undefined) row.globalId = /** @type {any} */ (source).globalId;
|
|
99
|
+
return row;
|
|
100
|
+
});
|
|
101
|
+
const count = (predicate) => sources.filter(predicate).length;
|
|
102
|
+
return {
|
|
103
|
+
version: REPORT_VERSION,
|
|
104
|
+
cwd: resolution.cwd,
|
|
105
|
+
root: { ...resolution.root },
|
|
106
|
+
mode: { id: resolution.mode.id, label: describeMode(resolution.settings) },
|
|
107
|
+
settings: { ...resolution.settings, globals: { ...resolution.settings.globals } },
|
|
108
|
+
...(resolution.settingsError === undefined ? {} : { settingsError: resolution.settingsError }),
|
|
109
|
+
...(extra.sessionId === undefined ? {} : { sessionId: extra.sessionId }),
|
|
110
|
+
tier1: { bytes: resolution.tier1.bytes, tokens: resolution.tier1.tokens, budgetBytes: resolution.tier1.budgetBytes, digest: resolution.tier1.digest },
|
|
111
|
+
totals: {
|
|
112
|
+
sources: sources.length,
|
|
113
|
+
loaded: count((s) => s.status === 'loaded' || s.status === 'truncated'),
|
|
114
|
+
duplicates: count((s) => s.status === 'duplicate'),
|
|
115
|
+
pendingScope: count((s) => s.status === 'pending-scope'),
|
|
116
|
+
available: count((s) => s.status === 'available' || s.status === 'manual'),
|
|
117
|
+
errors: count((s) => s.status === 'error' || s.error !== undefined),
|
|
118
|
+
conflicts: resolution.conflicts.length,
|
|
119
|
+
tokens: sources.reduce((sum, s) => sum + (s.status === 'loaded' || s.status === 'truncated' ? s.tokens : 0), 0),
|
|
120
|
+
},
|
|
121
|
+
sources,
|
|
122
|
+
conflicts: resolution.conflicts.map((conflict) => ({ topic: conflict.topic, note: conflict.note, values: conflict.values.map((v) => ({ ...v })) })),
|
|
123
|
+
docs: resolution.docs.map((doc) => ({ ...doc })),
|
|
124
|
+
globals: (extra.globals ?? []).map((global) => ({ ...global, paths: [...global.paths] })),
|
|
125
|
+
summary: summarize(resolution),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* What a first open of a project found, for the one-line import summary
|
|
131
|
+
* ("Found AGENTS.md, .cursor/rules (4), .github/copilot-instructions.md · 2 duplicates merged · /instructions").
|
|
132
|
+
* Items are the project's instruction formats in registry order (a rule folder counts its files); each surface
|
|
133
|
+
* words the line in its own language.
|
|
134
|
+
* @param {import('./resolve.js').Resolution} resolution
|
|
135
|
+
* @returns {{ items: { label: string, count: number }[], duplicates: number, conflicts: number, errors: number }}
|
|
136
|
+
*/
|
|
137
|
+
export function summarize(resolution) {
|
|
138
|
+
/** @type {Map<string, number>} */
|
|
139
|
+
const counts = new Map();
|
|
140
|
+
for (const source of resolution.sources) {
|
|
141
|
+
if (source.scope === 'global' || source.status === 'disabled') continue;
|
|
142
|
+
counts.set(source.formatLabel, (counts.get(source.formatLabel) ?? 0) + 1);
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
items: [...counts].map(([label, count]) => ({ label, count })),
|
|
146
|
+
duplicates: resolution.sources.filter((s) => s.status === 'duplicate').length,
|
|
147
|
+
conflicts: resolution.conflicts.length,
|
|
148
|
+
errors: resolution.sources.filter((s) => s.status === 'error').length,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The English one-liner (CLI --json consumers and logs); the TUI and the Mac word it with their own strings. */
|
|
153
|
+
export function summaryLine(summary, hint = '/instructions') {
|
|
154
|
+
if (summary.items.length === 0) return '';
|
|
155
|
+
const found = summary.items.map((item) => (item.count > 1 ? `${item.label} (${item.count})` : item.label)).join(', ');
|
|
156
|
+
const parts = [`Found ${found}`];
|
|
157
|
+
if (summary.duplicates > 0) parts.push(`${summary.duplicates} duplicate${summary.duplicates === 1 ? '' : 's'} merged`);
|
|
158
|
+
if (summary.conflicts > 0) parts.push(`${summary.conflicts} possible conflict${summary.conflicts === 1 ? '' : 's'}`);
|
|
159
|
+
if (hint) parts.push(hint);
|
|
160
|
+
return parts.join(' · ');
|
|
161
|
+
}
|