mustflow 2.75.1 → 2.84.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 (41) hide show
  1. package/README.md +31 -3
  2. package/dist/cli/commands/docs.js +86 -2
  3. package/dist/cli/commands/script-pack.js +5 -0
  4. package/dist/cli/i18n/en.js +101 -2
  5. package/dist/cli/i18n/es.js +101 -2
  6. package/dist/cli/i18n/fr.js +101 -2
  7. package/dist/cli/i18n/hi.js +101 -2
  8. package/dist/cli/i18n/ko.js +101 -2
  9. package/dist/cli/i18n/zh.js +101 -2
  10. package/dist/cli/lib/script-pack-registry.js +162 -7
  11. package/dist/cli/script-packs/code-export-diff.js +160 -0
  12. package/dist/cli/script-packs/code-outline.js +33 -5
  13. package/dist/cli/script-packs/code-route-outline.js +155 -0
  14. package/dist/cli/script-packs/docs-reference-drift.js +150 -0
  15. package/dist/cli/script-packs/repo-config-chain.js +163 -0
  16. package/dist/cli/script-packs/repo-related-files.js +161 -0
  17. package/dist/core/code-outline.js +527 -80
  18. package/dist/core/config-chain.js +595 -0
  19. package/dist/core/export-diff.js +359 -0
  20. package/dist/core/public-json-contracts.js +75 -0
  21. package/dist/core/reference-drift.js +388 -0
  22. package/dist/core/related-files.js +493 -0
  23. package/dist/core/route-outline.js +912 -0
  24. package/dist/core/script-pack-suggestions.js +111 -5
  25. package/dist/core/source-anchors.js +13 -1
  26. package/package.json +1 -1
  27. package/schemas/README.md +28 -5
  28. package/schemas/code-outline-report.schema.json +47 -1
  29. package/schemas/code-symbol-read-report.schema.json +64 -4
  30. package/schemas/config-chain-report.schema.json +187 -0
  31. package/schemas/export-diff-report.schema.json +220 -0
  32. package/schemas/reference-drift-report.schema.json +166 -0
  33. package/schemas/related-files-report.schema.json +145 -0
  34. package/schemas/route-outline-report.schema.json +200 -0
  35. package/templates/default/common/.mustflow/config/commands.toml +21 -0
  36. package/templates/default/i18n.toml +7 -1
  37. package/templates/default/locales/en/.mustflow/docs/agent-workflow.md +1 -1
  38. package/templates/default/locales/en/.mustflow/skills/INDEX.md +2 -1
  39. package/templates/default/locales/en/.mustflow/skills/cross-agent-session-reference/SKILL.md +131 -0
  40. package/templates/default/locales/en/.mustflow/skills/routes.toml +6 -0
  41. package/templates/default/manifest.toml +8 -1
@@ -0,0 +1,161 @@
1
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
2
+ import { t } from '../lib/i18n.js';
3
+ import { formatCliOptionParseError, getParsedCliStringOption, hasCliOptionToken, hasParsedCliOption, parseCliOptions, } from '../lib/option-parser.js';
4
+ import { resolveMustflowRoot } from '../lib/project-root.js';
5
+ import { inspectRelatedFiles, RELATED_FILES_SCRIPT_REF, } from '../../core/related-files.js';
6
+ const RELATED_FILES_OPTIONS = [
7
+ { name: '--json', kind: 'boolean' },
8
+ { name: '--max-files', kind: 'string' },
9
+ { name: '--max-file-bytes', kind: 'string' },
10
+ { name: '--max-candidates', kind: 'string' },
11
+ ];
12
+ function parsePositiveInteger(value, option, lang) {
13
+ if (value === null) {
14
+ return { value: null };
15
+ }
16
+ if (!/^[1-9]\d*$/u.test(value)) {
17
+ return { value: null, error: t(lang, 'relatedFiles.error.invalidPositiveInteger', { option, value }) };
18
+ }
19
+ const parsed = Number(value);
20
+ if (!Number.isSafeInteger(parsed)) {
21
+ return { value: null, error: t(lang, 'relatedFiles.error.invalidPositiveInteger', { option, value }) };
22
+ }
23
+ return { value: parsed };
24
+ }
25
+ export function getRepoRelatedFilesHelp(lang = 'en') {
26
+ return renderHelp({
27
+ usage: 'mf script-pack run repo/related-files map <path...> [options]',
28
+ summary: t(lang, 'relatedFiles.help.summary'),
29
+ options: [
30
+ { label: '--max-files <count>', description: t(lang, 'relatedFiles.help.option.maxFiles') },
31
+ { label: '--max-file-bytes <bytes>', description: t(lang, 'relatedFiles.help.option.maxFileBytes') },
32
+ { label: '--max-candidates <count>', description: t(lang, 'relatedFiles.help.option.maxCandidates') },
33
+ { label: '--json', description: t(lang, 'cli.option.json') },
34
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
35
+ ],
36
+ examples: [
37
+ 'mf script-pack run repo/related-files map src/cli/index.ts --json',
38
+ 'mf script-pack run repo/related-files map src/core/code-outline.ts --max-candidates 50 --json',
39
+ 'mf script-pack run repo/related-files map src tests/cli/package.test.js --max-files 500 --json',
40
+ ],
41
+ exitCodes: [
42
+ { label: '0', description: t(lang, 'relatedFiles.help.exit.ok') },
43
+ { label: '1', description: t(lang, 'relatedFiles.help.exit.fail') },
44
+ ],
45
+ }, lang);
46
+ }
47
+ function parseRelatedFilesOptions(args, lang) {
48
+ const [action, ...rest] = args;
49
+ const parsed = parseCliOptions(rest, RELATED_FILES_OPTIONS, { allowPositionals: true });
50
+ const json = hasParsedCliOption(parsed, '--json');
51
+ const maxFiles = parsePositiveInteger(getParsedCliStringOption(parsed, '--max-files'), '--max-files', lang);
52
+ const maxFileBytes = parsePositiveInteger(getParsedCliStringOption(parsed, '--max-file-bytes'), '--max-file-bytes', lang);
53
+ const maxCandidates = parsePositiveInteger(getParsedCliStringOption(parsed, '--max-candidates'), '--max-candidates', lang);
54
+ if (action !== 'map') {
55
+ return {
56
+ action: 'map',
57
+ json,
58
+ paths: parsed.positionals,
59
+ maxFiles: maxFiles.value,
60
+ maxFileBytes: maxFileBytes.value,
61
+ maxCandidates: maxCandidates.value,
62
+ error: action ? t(lang, 'relatedFiles.error.unknownAction', { action }) : t(lang, 'relatedFiles.error.missingAction'),
63
+ };
64
+ }
65
+ if (parsed.error) {
66
+ return {
67
+ action,
68
+ json,
69
+ paths: parsed.positionals,
70
+ maxFiles: maxFiles.value,
71
+ maxFileBytes: maxFileBytes.value,
72
+ maxCandidates: maxCandidates.value,
73
+ error: formatCliOptionParseError(parsed.error, lang),
74
+ };
75
+ }
76
+ for (const candidate of [maxFiles, maxFileBytes, maxCandidates]) {
77
+ if (candidate.error) {
78
+ return {
79
+ action,
80
+ json,
81
+ paths: parsed.positionals,
82
+ maxFiles: maxFiles.value,
83
+ maxFileBytes: maxFileBytes.value,
84
+ maxCandidates: maxCandidates.value,
85
+ error: candidate.error,
86
+ };
87
+ }
88
+ }
89
+ if (parsed.positionals.length === 0) {
90
+ return {
91
+ action,
92
+ json,
93
+ paths: parsed.positionals,
94
+ maxFiles: maxFiles.value,
95
+ maxFileBytes: maxFileBytes.value,
96
+ maxCandidates: maxCandidates.value,
97
+ error: t(lang, 'relatedFiles.error.missingPath'),
98
+ };
99
+ }
100
+ return {
101
+ action,
102
+ json,
103
+ paths: parsed.positionals,
104
+ maxFiles: maxFiles.value,
105
+ maxFileBytes: maxFileBytes.value,
106
+ maxCandidates: maxCandidates.value,
107
+ };
108
+ }
109
+ function renderRelatedFilesSummary(report, lang) {
110
+ const lines = [
111
+ t(lang, 'relatedFiles.title'),
112
+ `${t(lang, 'scriptPack.label.script')}: ${RELATED_FILES_SCRIPT_REF}`,
113
+ `${t(lang, 'label.status')}: ${report.status}`,
114
+ `${t(lang, 'relatedFiles.label.targets')}: ${report.targets.length}`,
115
+ `${t(lang, 'relatedFiles.label.candidates')}: ${report.candidates.length}`,
116
+ `${t(lang, 'relatedFiles.label.truncated')}: ${report.truncated ? t(lang, 'value.yes') : t(lang, 'value.no')}`,
117
+ ];
118
+ if (report.candidates.length > 0) {
119
+ lines.push(t(lang, 'relatedFiles.label.related'));
120
+ for (const candidate of report.candidates) {
121
+ const line = candidate.line === null ? '' : `:${candidate.line}`;
122
+ lines.push(`- ${candidate.path}: ${candidate.relationship}, ${t(lang, 'relatedFiles.label.confidence')} ${candidate.confidence} (${candidate.source_path}${line})`);
123
+ }
124
+ }
125
+ if (report.findings.length > 0) {
126
+ lines.push(t(lang, 'relatedFiles.label.findings'));
127
+ for (const finding of report.findings) {
128
+ lines.push(`- ${finding.path}: ${finding.code} (${finding.message})`);
129
+ }
130
+ }
131
+ if (report.issues.length > 0) {
132
+ lines.push(t(lang, 'relatedFiles.label.issues'), ...report.issues.map((issue) => `- ${issue}`));
133
+ }
134
+ if (report.candidates.length === 0 && report.findings.length === 0 && report.issues.length === 0) {
135
+ lines.push(t(lang, 'relatedFiles.clean'));
136
+ }
137
+ return lines.join('\n');
138
+ }
139
+ export function runRepoRelatedFilesScript(args, reporter, lang = 'en') {
140
+ if (hasCliOptionToken(args, '--help', ['-h'])) {
141
+ reporter.stdout(getRepoRelatedFilesHelp(lang));
142
+ return 0;
143
+ }
144
+ const options = parseRelatedFilesOptions(args, lang);
145
+ if (options.error) {
146
+ printUsageError(reporter, options.error, 'mf script-pack run repo/related-files --help', getRepoRelatedFilesHelp(lang), lang);
147
+ return 1;
148
+ }
149
+ const report = inspectRelatedFiles(resolveMustflowRoot(), {
150
+ paths: options.paths,
151
+ maxFiles: options.maxFiles ?? undefined,
152
+ maxFileBytes: options.maxFileBytes ?? undefined,
153
+ maxCandidates: options.maxCandidates ?? undefined,
154
+ });
155
+ if (options.json) {
156
+ reporter.stdout(JSON.stringify(report, null, 2));
157
+ return report.ok ? 0 : 1;
158
+ }
159
+ reporter.stdout(renderRelatedFilesSummary(report, lang));
160
+ return report.ok ? 0 : 1;
161
+ }