@mediaproc/core 1.9.0 → 1.10.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.
- package/dist/explain/constants/commonPhrases.d.ts +2 -1
- package/dist/explain/constants/commonPhrases.d.ts.map +1 -1
- package/dist/explain/constants/commonPhrases.js +56 -53
- package/dist/explain/constants/commonPhrases.js.map +1 -1
- package/dist/explain/explainFlag.js +1 -1
- package/dist/explain/explainFlag.js.map +1 -1
- package/dist/explain/formatters/explainFormatter.d.ts.map +1 -1
- package/dist/explain/formatters/explainFormatter.js +10 -2
- package/dist/explain/formatters/explainFormatter.js.map +1 -1
- package/dist/explain/phrases/explainSentences.d.ts +15 -28
- package/dist/explain/phrases/explainSentences.d.ts.map +1 -1
- package/dist/explain/phrases/explainSentences.js +27 -47
- package/dist/explain/phrases/explainSentences.js.map +1 -1
- package/dist/explain/templates/explainDetailsTemplate.d.ts.map +1 -1
- package/dist/explain/templates/explainDetailsTemplate.js +49 -145
- package/dist/explain/templates/explainDetailsTemplate.js.map +1 -1
- package/dist/explain/templates/explainHumanTemplate.d.ts.map +1 -1
- package/dist/explain/templates/explainHumanTemplate.js +48 -146
- package/dist/explain/templates/explainHumanTemplate.js.map +1 -1
- package/dist/types/explainTypes.d.ts +43 -59
- package/dist/types/explainTypes.d.ts.map +1 -1
- package/dist/types/explainTypes.js.map +1 -1
- package/dist/utils/file/fileDetection.d.ts.map +1 -1
- package/dist/utils/file/fileDetection.js +0 -1
- package/dist/utils/file/fileDetection.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,155 +1,59 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import boxen from 'boxen';
|
|
3
|
-
|
|
3
|
+
import { explainSentences } from '../phrases/explainSentences.js';
|
|
4
|
+
const SECTION_STYLES = {
|
|
5
|
+
'SUMMARY': txt => chalk.bold.bgCyan.black(` ${txt} `),
|
|
6
|
+
'WHAT WILL HAPPEN': txt => chalk.bold.bgGreen.black(` ${txt} `),
|
|
7
|
+
'OUTPUTS': txt => chalk.bold.bgMagenta.black(` ${txt} `),
|
|
8
|
+
'FLAGS': txt => chalk.bold.bgYellow.black(` ${txt} `),
|
|
9
|
+
'WHAT WILL NOT HAPPEN': txt => chalk.bold.bgRed.white(` ${txt} `),
|
|
10
|
+
'PROCESSING FLOW': txt => chalk.bold.bgWhite.black(` ${txt} `),
|
|
11
|
+
'OUTCOME': txt => chalk.bold.bgRedBright.white(` ${txt} `),
|
|
12
|
+
'TECHNICAL DETAILS': txt => chalk.bold.bgGray.white(` ${txt} `),
|
|
13
|
+
};
|
|
4
14
|
export function explainDetailsTemplate(context) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.join('\n'));
|
|
42
|
-
const techEffects = context.effects
|
|
43
|
-
.filter(eff => typeof eff === 'string' && !eff.match(/effectNamespace|schemaVersion|processingScope/))
|
|
44
|
-
.map(val => displayValue(val));
|
|
45
|
-
if (techEffects.length > 0) {
|
|
46
|
-
lines.push(chalk.gray('Technical Effects: ' + techEffects.join(', ')));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// === INPUTS ===
|
|
50
|
-
if (context.inputs && (context.inputs.inputPath || (context.inputs.files && context.inputs.files.length > 0))) {
|
|
51
|
-
lines.push('');
|
|
52
|
-
lines.push(chalk.bold.bgBlue.black(' INPUTS '));
|
|
53
|
-
if (context.inputs.inputPath) {
|
|
54
|
-
lines.push(chalk.cyan('• Input path: ') + chalk.white(displayValue(context.inputs.inputPath, 'None')));
|
|
55
|
-
}
|
|
56
|
-
if (context.inputs.files && context.inputs.files.length > 0) {
|
|
57
|
-
lines.push(chalk.cyan('• Files detected: ') + chalk.white(displayValue(context.inputs.files, 'None')));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// === OUTPUTS ===
|
|
61
|
-
if (context.outputs && Object.keys(context.outputs).length > 0) {
|
|
62
|
-
lines.push('');
|
|
63
|
-
lines.push(chalk.bold.bgMagenta.black(' OUTPUTS '));
|
|
64
|
-
for (const [k, v] of Object.entries(context.outputs)) {
|
|
65
|
-
lines.push(chalk.magenta('• ' + k + ': ') + chalk.white(displayValue(v, 'None')));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// === FLAGS ===
|
|
69
|
-
if (context.usedFlags && Object.keys(context.usedFlags).length > 0) {
|
|
70
|
-
lines.push('');
|
|
71
|
-
lines.push(chalk.bold.bgYellow.black(' FLAGS '));
|
|
72
|
-
const userFlags = Object.entries(context.usedFlags)
|
|
73
|
-
.filter(([_, v]) => v.source === 'user')
|
|
74
|
-
.map(([name, v]) => chalk.yellow('• ' + name + ': ') + chalk.white(displayValue(v.value)));
|
|
75
|
-
const defaultFlags = Object.entries(context.usedFlags)
|
|
76
|
-
.filter(([_, v]) => v.source !== 'user')
|
|
77
|
-
.map(([name, v]) => chalk.gray('• ' + name + ': ') + chalk.white(displayValue(v.value)));
|
|
78
|
-
if (userFlags.length > 0) {
|
|
79
|
-
lines.push(chalk.yellow('User Flags:'));
|
|
80
|
-
lines.push(userFlags.join('\n'));
|
|
81
|
-
}
|
|
82
|
-
if (defaultFlags.length > 0) {
|
|
83
|
-
lines.push(chalk.gray('Default Flags:'));
|
|
84
|
-
lines.push(defaultFlags.join('\n'));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// === SAFETY ===
|
|
88
|
-
lines.push('');
|
|
89
|
-
lines.push(chalk.bold.bgRed.white(' SAFETY '));
|
|
90
|
-
lines.push(chalk.green('No network access. All processing is local. No telemetry is collected.'));
|
|
91
|
-
// === PROCESSING FLOW ===
|
|
92
|
-
if (context.executionSteps && context.executionSteps.length > 0) {
|
|
93
|
-
lines.push('');
|
|
94
|
-
lines.push(chalk.bold.bgWhite.black(' PROCESSING FLOW '));
|
|
95
|
-
for (const step of context.executionSteps) {
|
|
96
|
-
const s = typeof step === 'string' ? step.trim() : '';
|
|
97
|
-
const actionStep = /^[A-Z]/.test(s) ? s : s.charAt(0).toUpperCase() + s.slice(1);
|
|
98
|
-
lines.push(chalk.white('→ ') + chalk.cyan(actionStep));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// === OUTCOME ===
|
|
102
|
-
if (context.outcome &&
|
|
103
|
-
((Array.isArray(context.outcome.errors) && context.outcome.errors.length > 0) ||
|
|
104
|
-
(Array.isArray(context.outcome.warnings) && context.outcome.warnings.length > 0))) {
|
|
105
|
-
lines.push('');
|
|
106
|
-
lines.push(chalk.bold.bgRedBright.white(' OUTCOME '));
|
|
107
|
-
if (Array.isArray(context.outcome.errors) && context.outcome.errors.length > 0) {
|
|
108
|
-
lines.push(chalk.red('Errors:'));
|
|
109
|
-
for (const err of context.outcome.errors) {
|
|
110
|
-
lines.push(chalk.red('• ' + displayValue(err, 'None')));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(context.outcome.warnings) && context.outcome.warnings.length > 0) {
|
|
114
|
-
lines.push(chalk.yellow('Warnings:'));
|
|
115
|
-
for (const warn of context.outcome.warnings) {
|
|
116
|
-
lines.push(chalk.yellow('• ' + displayValue(warn, 'None')));
|
|
15
|
+
const lines = [];
|
|
16
|
+
const sentences = [];
|
|
17
|
+
// Details mode: plugin-agnostic, detailed, relevant sentences only
|
|
18
|
+
if (explainSentences.summaryHeader)
|
|
19
|
+
sentences.push(explainSentences.summaryHeader());
|
|
20
|
+
if (explainSentences.inputRead)
|
|
21
|
+
sentences.push(explainSentences.inputRead(context));
|
|
22
|
+
if (explainSentences.whatWillHappenHeader)
|
|
23
|
+
sentences.push(explainSentences.whatWillHappenHeader());
|
|
24
|
+
if (explainSentences.outputWrite)
|
|
25
|
+
sentences.push(explainSentences.outputWrite(context));
|
|
26
|
+
if (explainSentences.flagsUsedHeader)
|
|
27
|
+
sentences.push(explainSentences.flagsUsedHeader());
|
|
28
|
+
if (explainSentences.whatWillNotHappenHeader)
|
|
29
|
+
sentences.push(explainSentences.whatWillNotHappenHeader());
|
|
30
|
+
// Group the original plugin-agnostic phrases for this section
|
|
31
|
+
const notHappen = [
|
|
32
|
+
explainSentences.noNetwork(),
|
|
33
|
+
explainSentences.noBackgroundTasks(),
|
|
34
|
+
explainSentences.noOriginalModification(),
|
|
35
|
+
explainSentences.dataLocalOnly()
|
|
36
|
+
].join(' ');
|
|
37
|
+
sentences.push(notHappen);
|
|
38
|
+
if (explainSentences.technicalDetailsHeader)
|
|
39
|
+
sentences.push(explainSentences.technicalDetailsHeader());
|
|
40
|
+
if (explainSentences.summarySuccess)
|
|
41
|
+
sentences.push(explainSentences.summarySuccess());
|
|
42
|
+
for (const sentence of sentences) {
|
|
43
|
+
if (typeof sentence === 'string') {
|
|
44
|
+
// Detect section headers (e.g., 'SUMMARY:', 'WHAT WILL HAPPEN:', 'WHAT WILL NOT HAPPEN:')
|
|
45
|
+
const match = sentence.match(/^(SUMMARY|WHAT WILL HAPPEN|WHAT WILL NOT HAPPEN|OUTPUTS|FLAGS|SAFETY|PROCESSING FLOW|OUTCOME|TECHNICAL DETAILS):\s*(.*)$/);
|
|
46
|
+
if (match) {
|
|
47
|
+
const [, section, rest] = match;
|
|
48
|
+
lines.push(SECTION_STYLES[section] ? SECTION_STYLES[section](section) : section);
|
|
49
|
+
if (rest && rest.trim())
|
|
50
|
+
lines.push(rest.trim());
|
|
117
51
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
// === TECHNICAL DETAILS ===
|
|
122
|
-
if (context.technical && typeof context.technical === 'object' && Object.keys(context.technical).length > 0) {
|
|
123
|
-
lines.push('');
|
|
124
|
-
lines.push(chalk.bold.bgGray.white(' TECHNICAL DETAILS '));
|
|
125
|
-
const detailsArr = Object.entries(context.technical)
|
|
126
|
-
.filter(([, v]) => v !== undefined && v !== null && v !== '' && v !== 'unknown')
|
|
127
|
-
.map(([k, v]) => chalk.gray('• ' + k + ': ') + chalk.white(displayValue(v)));
|
|
128
|
-
if (detailsArr.length > 0) {
|
|
129
|
-
lines.push(detailsArr.join('\n'));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// Custom plugin sections
|
|
133
|
-
if (context.customSections && Array.isArray(context.customSections)) {
|
|
134
|
-
for (const section of context.customSections) {
|
|
135
|
-
if (section.items && section.items.length > 0) {
|
|
136
|
-
lines.push('');
|
|
137
|
-
lines.push(chalk.bold.bgMagenta.white(` ${section.title.toUpperCase()} `));
|
|
138
|
-
for (const item of section.items) {
|
|
139
|
-
let safeItem = (typeof item === 'function') ? '[function]' : displayValue(item);
|
|
140
|
-
lines.push(chalk.magentaBright('• ' + safeItem));
|
|
141
|
-
}
|
|
52
|
+
else {
|
|
53
|
+
lines.push(sentence);
|
|
142
54
|
}
|
|
143
55
|
}
|
|
144
56
|
}
|
|
145
|
-
// Tips
|
|
146
|
-
lines.push('');
|
|
147
|
-
lines.push(chalk.bgWhiteBright.black('Tip: ') + chalk.gray('Use --json for machine-readable output.'));
|
|
148
|
-
lines.push(chalk.bgWhiteBright.black('Tip: ') + chalk.gray('See the documentation for more details.'));
|
|
149
|
-
// Always print the summary/result phrase at the end
|
|
150
|
-
lines.push('');
|
|
151
|
-
lines.push(chalk.bold.bgGreen.black('✔ Operation explained successfully.'));
|
|
152
|
-
// Wrap all in a single box with a subtle border and modern look
|
|
153
57
|
return boxen(lines.join('\n'), {
|
|
154
58
|
padding: 1,
|
|
155
59
|
borderColor: 'gray',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explainDetailsTemplate.js","sourceRoot":"","sources":["../../../src/explain/templates/explainDetailsTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"explainDetailsTemplate.js","sourceRoot":"","sources":["../../../src/explain/templates/explainDetailsTemplate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,cAAc,GAA4C;IAC9D,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IACrD,kBAAkB,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IAC/D,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IACxD,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IACrD,sBAAsB,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IACjE,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IAC9D,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IAC1D,mBAAmB,EAAE,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,EAAE,CAAC,CAAC;IACvG,IAAI,gBAAgB,CAAC,cAAc;QAAE,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC;IAEvF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,0FAA0F;YAC1F,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,0HAA0H,CAAC,CAAC;YACzJ,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;gBAChC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACjF,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;oBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,OAAO;QACpB,eAAe,EAAE,OAAO;KACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explainHumanTemplate.d.ts","sourceRoot":"","sources":["../../../src/explain/templates/explainHumanTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"explainHumanTemplate.d.ts","sourceRoot":"","sources":["../../../src/explain/templates/explainHumanTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAiB7D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CA2CpE"}
|
|
@@ -1,155 +1,58 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import boxen from 'boxen';
|
|
3
|
-
|
|
3
|
+
import { explainSentences } from '../phrases/explainSentences.js';
|
|
4
|
+
// Section header mapping for human mode
|
|
5
|
+
const SECTION_STYLES = {
|
|
6
|
+
'SUMMARY': txt => chalk.bold.bgCyan.black(` ${txt} `),
|
|
7
|
+
'WHAT WILL HAPPEN': txt => chalk.bold.bgGreen.black(` ${txt} `),
|
|
8
|
+
'OUTPUTS': txt => chalk.bold.bgMagenta.black(` ${txt} `),
|
|
9
|
+
'FLAGS': txt => chalk.bold.bgYellow.black(` ${txt} `),
|
|
10
|
+
'WHAT WILL NOT HAPPEN': txt => chalk.bold.bgRed.white(` ${txt} `),
|
|
11
|
+
'PROCESSING FLOW': txt => chalk.bold.bgWhite.black(` ${txt} `),
|
|
12
|
+
'OUTCOME': txt => chalk.bold.bgRedBright.white(` ${txt} `),
|
|
13
|
+
'TECHNICAL DETAILS': txt => chalk.bold.bgGray.white(` ${txt} `),
|
|
14
|
+
};
|
|
4
15
|
export function explainHumanTemplate(context) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.map(eff => typeof eff === 'string' && eff.match(/effectNamespace|schemaVersion|processingScope/) ? '' : chalk.greenBright('• ' + displayValue(eff)))
|
|
40
|
-
.filter(Boolean)
|
|
41
|
-
.join('\n'));
|
|
42
|
-
const techEffects = context.effects
|
|
43
|
-
.filter(eff => typeof eff === 'string' && !eff.match(/effectNamespace|schemaVersion|processingScope/))
|
|
44
|
-
.map(val => displayValue(val));
|
|
45
|
-
if (techEffects.length > 0) {
|
|
46
|
-
lines.push(chalk.gray('Technical Effects: ' + techEffects.join(', ')));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// === INPUTS ===
|
|
50
|
-
if (context.inputs && (context.inputs.inputPath || (context.inputs.files && context.inputs.files.length > 0))) {
|
|
51
|
-
lines.push('');
|
|
52
|
-
lines.push(chalk.bold.bgBlue.black(' INPUTS '));
|
|
53
|
-
if (context.inputs.inputPath) {
|
|
54
|
-
lines.push(chalk.cyan('• Input path: ') + chalk.white(displayValue(context.inputs.inputPath, 'None')));
|
|
55
|
-
}
|
|
56
|
-
if (context.inputs.files && context.inputs.files.length > 0) {
|
|
57
|
-
lines.push(chalk.cyan('• Files detected: ') + chalk.white(displayValue(context.inputs.files, 'None')));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// === OUTPUTS ===
|
|
61
|
-
if (context.outputs && Object.keys(context.outputs).length > 0) {
|
|
62
|
-
lines.push('');
|
|
63
|
-
lines.push(chalk.bold.bgMagenta.black(' OUTPUTS '));
|
|
64
|
-
for (const [k, v] of Object.entries(context.outputs)) {
|
|
65
|
-
lines.push(chalk.magenta('• ' + k + ': ') + chalk.white(displayValue(v, 'None')));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// === FLAGS ===
|
|
69
|
-
if (context.usedFlags && Object.keys(context.usedFlags).length > 0) {
|
|
70
|
-
lines.push('');
|
|
71
|
-
lines.push(chalk.bold.bgYellow.black(' FLAGS '));
|
|
72
|
-
const userFlags = Object.entries(context.usedFlags)
|
|
73
|
-
.filter(([_, v]) => v.source === 'user')
|
|
74
|
-
.map(([name, v]) => chalk.yellow('• ' + name + ': ') + chalk.white(displayValue(v.value)));
|
|
75
|
-
const defaultFlags = Object.entries(context.usedFlags)
|
|
76
|
-
.filter(([_, v]) => v.source !== 'user')
|
|
77
|
-
.map(([name, v]) => chalk.gray('• ' + name + ': ') + chalk.white(displayValue(v.value)));
|
|
78
|
-
if (userFlags.length > 0) {
|
|
79
|
-
lines.push(chalk.yellow('User Flags:'));
|
|
80
|
-
lines.push(userFlags.join('\n'));
|
|
81
|
-
}
|
|
82
|
-
if (defaultFlags.length > 0) {
|
|
83
|
-
lines.push(chalk.gray('Default Flags:'));
|
|
84
|
-
lines.push(defaultFlags.join('\n'));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// === SAFETY ===
|
|
88
|
-
lines.push('');
|
|
89
|
-
lines.push(chalk.bold.bgRed.white(' SAFETY '));
|
|
90
|
-
lines.push(chalk.green('No network access. All processing is local. No telemetry is collected.'));
|
|
91
|
-
// === PROCESSING FLOW ===
|
|
92
|
-
if (context.executionSteps && context.executionSteps.length > 0) {
|
|
93
|
-
lines.push('');
|
|
94
|
-
lines.push(chalk.bold.bgWhite.black(' PROCESSING FLOW '));
|
|
95
|
-
for (const step of context.executionSteps) {
|
|
96
|
-
const s = typeof step === 'string' ? step.trim() : '';
|
|
97
|
-
const actionStep = /^[A-Z]/.test(s) ? s : s.charAt(0).toUpperCase() + s.slice(1);
|
|
98
|
-
lines.push(chalk.white('→ ') + chalk.cyan(actionStep));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// === OUTCOME ===
|
|
102
|
-
if (context.outcome &&
|
|
103
|
-
((Array.isArray(context.outcome.errors) && context.outcome.errors.length > 0) ||
|
|
104
|
-
(Array.isArray(context.outcome.warnings) && context.outcome.warnings.length > 0))) {
|
|
105
|
-
lines.push('');
|
|
106
|
-
lines.push(chalk.bold.bgRedBright.white(' OUTCOME '));
|
|
107
|
-
if (Array.isArray(context.outcome.errors) && context.outcome.errors.length > 0) {
|
|
108
|
-
lines.push(chalk.red('Errors:'));
|
|
109
|
-
for (const err of context.outcome.errors) {
|
|
110
|
-
lines.push(chalk.red('• ' + displayValue(err, 'None')));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(context.outcome.warnings) && context.outcome.warnings.length > 0) {
|
|
114
|
-
lines.push(chalk.yellow('Warnings:'));
|
|
115
|
-
for (const warn of context.outcome.warnings) {
|
|
116
|
-
lines.push(chalk.yellow('• ' + displayValue(warn, 'None')));
|
|
16
|
+
const lines = [];
|
|
17
|
+
// Use explainSentences to get all needed sentences for this mode
|
|
18
|
+
const sentences = [];
|
|
19
|
+
// Human mode: overview only, plugin-agnostic, no details
|
|
20
|
+
if (explainSentences.summaryHeader)
|
|
21
|
+
sentences.push(explainSentences.summaryHeader());
|
|
22
|
+
if (explainSentences.inputRead)
|
|
23
|
+
sentences.push(explainSentences.inputRead(context));
|
|
24
|
+
if (explainSentences.whatWillHappenHeader)
|
|
25
|
+
sentences.push(explainSentences.whatWillHappenHeader());
|
|
26
|
+
if (explainSentences.outputWrite)
|
|
27
|
+
sentences.push(explainSentences.outputWrite(context));
|
|
28
|
+
if (explainSentences.whatWillNotHappenHeader)
|
|
29
|
+
sentences.push(explainSentences.whatWillNotHappenHeader());
|
|
30
|
+
// Group the original plugin-agnostic phrases for this section
|
|
31
|
+
const notHappen = [
|
|
32
|
+
explainSentences.noNetwork(),
|
|
33
|
+
explainSentences.noBackgroundTasks(),
|
|
34
|
+
explainSentences.noOriginalModification(),
|
|
35
|
+
explainSentences.dataLocalOnly()
|
|
36
|
+
].join(' ');
|
|
37
|
+
sentences.push(notHappen);
|
|
38
|
+
if (explainSentences.summarySuccess)
|
|
39
|
+
sentences.push(explainSentences.summarySuccess());
|
|
40
|
+
// Render with section styling
|
|
41
|
+
for (const sentence of sentences) {
|
|
42
|
+
if (typeof sentence === 'string') {
|
|
43
|
+
// Detect section headers (e.g., 'SUMMARY:', 'WHAT WILL HAPPEN:', 'WHAT WILL NOT HAPPEN:')
|
|
44
|
+
const match = sentence.match(/^(SUMMARY|WHAT WILL HAPPEN|WHAT WILL NOT HAPPEN|OUTPUTS|FLAGS|SAFETY|PROCESSING FLOW|OUTCOME|TECHNICAL DETAILS):\s*(.*)$/);
|
|
45
|
+
if (match) {
|
|
46
|
+
const [, section, rest] = match;
|
|
47
|
+
lines.push(SECTION_STYLES[section] ? SECTION_STYLES[section](section) : section);
|
|
48
|
+
if (rest && rest.trim())
|
|
49
|
+
lines.push(rest.trim());
|
|
117
50
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
// === TECHNICAL DETAILS ===
|
|
122
|
-
if (context.technical && typeof context.technical === 'object' && Object.keys(context.technical).length > 0) {
|
|
123
|
-
lines.push('');
|
|
124
|
-
lines.push(chalk.bold.bgGray.white(' TECHNICAL DETAILS '));
|
|
125
|
-
const detailsArr = Object.entries(context.technical)
|
|
126
|
-
.filter(([, v]) => v !== undefined && v !== null && v !== '' && v !== 'unknown')
|
|
127
|
-
.map(([k, v]) => chalk.gray('• ' + k + ': ') + chalk.white(displayValue(v)));
|
|
128
|
-
if (detailsArr.length > 0) {
|
|
129
|
-
lines.push(detailsArr.join('\n'));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// Custom plugin sections
|
|
133
|
-
if (context.customSections && Array.isArray(context.customSections)) {
|
|
134
|
-
for (const section of context.customSections) {
|
|
135
|
-
if (section.items && section.items.length > 0) {
|
|
136
|
-
lines.push('');
|
|
137
|
-
lines.push(chalk.bold.bgMagenta.white(` ${section.title.toUpperCase()} `));
|
|
138
|
-
for (const item of section.items) {
|
|
139
|
-
let safeItem = (typeof item === 'function') ? '[function]' : displayValue(item);
|
|
140
|
-
lines.push(chalk.magentaBright('• ' + safeItem));
|
|
141
|
-
}
|
|
51
|
+
else {
|
|
52
|
+
lines.push(sentence);
|
|
142
53
|
}
|
|
143
54
|
}
|
|
144
55
|
}
|
|
145
|
-
// Tips
|
|
146
|
-
lines.push('');
|
|
147
|
-
lines.push(chalk.bgWhiteBright.black('Tip: ') + chalk.gray('Use --json for machine-readable output.'));
|
|
148
|
-
lines.push(chalk.bgWhiteBright.black('Tip: ') + chalk.gray('See the documentation for more details.'));
|
|
149
|
-
// Always print the summary/result phrase at the end
|
|
150
|
-
lines.push('');
|
|
151
|
-
lines.push(chalk.bold.bgGreen.black('✔ Operation explained successfully.'));
|
|
152
|
-
// Wrap all in a single box with a subtle border and modern look
|
|
153
56
|
return boxen(lines.join('\n'), {
|
|
154
57
|
padding: 1,
|
|
155
58
|
borderColor: 'gray',
|
|
@@ -157,5 +60,4 @@ export function explainHumanTemplate(context) {
|
|
|
157
60
|
backgroundColor: 'black',
|
|
158
61
|
});
|
|
159
62
|
}
|
|
160
|
-
// Used/user/default flags
|
|
161
63
|
//# sourceMappingURL=explainHumanTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explainHumanTemplate.js","sourceRoot":"","sources":["../../../src/explain/templates/explainHumanTemplate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,
|
|
1
|
+
{"version":3,"file":"explainHumanTemplate.js","sourceRoot":"","sources":["../../../src/explain/templates/explainHumanTemplate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,wCAAwC;AACxC,MAAM,cAAc,GAA4C;IAC9D,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;IACrD,kBAAkB,EAAE,GAAG,CAAC,EAAE,C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AQ,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,OAAO;QACpB,eAAe,EAAE,OAAO;KACzB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -3,30 +3,53 @@ export interface ExplainEffectContext {
|
|
|
3
3
|
effect: string;
|
|
4
4
|
context: ExplainContext;
|
|
5
5
|
}
|
|
6
|
+
export interface CommandRelatedOptions {
|
|
7
|
+
type?: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
purpose: string;
|
|
10
|
+
inputs: string;
|
|
11
|
+
outputs: string;
|
|
12
|
+
flags?: string;
|
|
13
|
+
options: string;
|
|
14
|
+
performance?: string;
|
|
15
|
+
security?: string;
|
|
16
|
+
dependencies?: string;
|
|
17
|
+
sideEffects?: string;
|
|
18
|
+
warnings?: string;
|
|
19
|
+
limitations?: string;
|
|
20
|
+
examples?: string;
|
|
21
|
+
docs?: string;
|
|
22
|
+
author?: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
lastModified?: string;
|
|
25
|
+
relatedCommands?: string;
|
|
26
|
+
}
|
|
27
|
+
export type ExplainFlagSource = 'user' | 'system' | 'default' | 'deprecated' | 'ignored';
|
|
28
|
+
export declare enum ExplainMode {
|
|
29
|
+
Human = "human",
|
|
30
|
+
Details = "details",
|
|
31
|
+
Json = "json",
|
|
32
|
+
Audit = "audit",// coming soon
|
|
33
|
+
Debug = "debug",// coming soon
|
|
34
|
+
Only = "only"
|
|
35
|
+
}
|
|
36
|
+
export interface ExplainDecision {
|
|
37
|
+
key: string;
|
|
38
|
+
value: any;
|
|
39
|
+
reason: string;
|
|
40
|
+
provenance?: ExplainFlagSource;
|
|
41
|
+
omitted?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type ExplainFlowStep = {
|
|
44
|
+
step: string;
|
|
45
|
+
type: 'static' | 'conditional';
|
|
46
|
+
};
|
|
6
47
|
export interface CommonPhrases {
|
|
7
48
|
header: string;
|
|
8
49
|
detailsHeader: string;
|
|
9
50
|
summaryHeader: string;
|
|
10
|
-
commandType: string;
|
|
11
|
-
commandCategory: string;
|
|
12
|
-
commandPurpose: string;
|
|
13
|
-
commandInputs: string;
|
|
14
|
-
commandOutputs: string;
|
|
15
|
-
commandFlags: string;
|
|
16
|
-
commandOptions: string;
|
|
17
|
-
commandPerformance: string;
|
|
18
|
-
commandSecurity: string;
|
|
19
|
-
commandDependencies: string;
|
|
20
|
-
commandSideEffects: string;
|
|
21
|
-
commandWarnings: string;
|
|
22
|
-
commandLimitations: string;
|
|
23
|
-
commandExamples: string;
|
|
24
|
-
commandDocs: string;
|
|
25
|
-
commandAuthor: string;
|
|
26
|
-
commandVersion: string;
|
|
27
|
-
commandLastModified: string;
|
|
28
|
-
commandRelated: string;
|
|
29
51
|
contextEnrichmentPrefix: string;
|
|
52
|
+
commandRelatedOptions: CommandRelatedOptions;
|
|
30
53
|
user: string;
|
|
31
54
|
platform: string;
|
|
32
55
|
mode: string;
|
|
@@ -160,26 +183,6 @@ export interface CommonPhrases {
|
|
|
160
183
|
tipHuman?: string;
|
|
161
184
|
tipOnly?: string;
|
|
162
185
|
}
|
|
163
|
-
export type ExplainFlagSource = 'user' | 'system' | 'default' | 'deprecated' | 'ignored';
|
|
164
|
-
export declare enum ExplainMode {
|
|
165
|
-
Human = "human",
|
|
166
|
-
Details = "details",
|
|
167
|
-
Json = "json",
|
|
168
|
-
Audit = "audit",// coming soon
|
|
169
|
-
Debug = "debug",// coming soon
|
|
170
|
-
Only = "only"
|
|
171
|
-
}
|
|
172
|
-
export interface ExplainDecision {
|
|
173
|
-
key: string;
|
|
174
|
-
value: any;
|
|
175
|
-
reason: string;
|
|
176
|
-
provenance?: ExplainFlagSource;
|
|
177
|
-
omitted?: boolean;
|
|
178
|
-
}
|
|
179
|
-
export type ExplainFlowStep = {
|
|
180
|
-
step: string;
|
|
181
|
-
type: 'static' | 'conditional';
|
|
182
|
-
};
|
|
183
186
|
export interface ExplainContext {
|
|
184
187
|
batch?: {
|
|
185
188
|
size?: number;
|
|
@@ -275,25 +278,6 @@ export interface ExplainContext {
|
|
|
275
278
|
title: string;
|
|
276
279
|
items: string[];
|
|
277
280
|
}>;
|
|
278
|
-
|
|
279
|
-
commandType?: string;
|
|
280
|
-
commandCategory?: string;
|
|
281
|
-
commandPurpose?: string;
|
|
282
|
-
commandInputs?: string;
|
|
283
|
-
commandOutputs?: string;
|
|
284
|
-
commandFlags?: string;
|
|
285
|
-
commandOptions?: string;
|
|
286
|
-
commandPerformance?: string;
|
|
287
|
-
commandSecurity?: string;
|
|
288
|
-
commandDependencies?: string;
|
|
289
|
-
commandSideEffects?: string;
|
|
290
|
-
commandWarnings?: string;
|
|
291
|
-
commandLimitations?: string;
|
|
292
|
-
commandExamples?: string;
|
|
293
|
-
commandDocs?: string;
|
|
294
|
-
commandAuthor?: string;
|
|
295
|
-
commandVersion?: string;
|
|
296
|
-
commandLastModified?: string;
|
|
297
|
-
commandRelated?: string;
|
|
281
|
+
commandRelatedOptions?: CommandRelatedOptions;
|
|
298
282
|
}
|
|
299
283
|
//# sourceMappingURL=explainTypes.d.ts.map
|