@lssm/module.contractspec-workspace 1.43.0 → 1.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formatter.d.ts +42 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +163 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +5 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FormatterConfig, FormatterType } from "@lssm/lib.contracts";
|
|
2
|
+
|
|
3
|
+
//#region src/formatter.d.ts
|
|
4
|
+
|
|
5
|
+
interface FormatterOptions {
|
|
6
|
+
/** Override formatter type from config */
|
|
7
|
+
type?: FormatterType;
|
|
8
|
+
/** Skip formatting entirely */
|
|
9
|
+
skip?: boolean;
|
|
10
|
+
/** Working directory for formatter */
|
|
11
|
+
cwd?: string;
|
|
12
|
+
/** Silent mode - don't log output */
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface FormatResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
formatted: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
duration?: number;
|
|
20
|
+
formatterUsed?: FormatterType;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Auto-detect available formatters in the workspace.
|
|
24
|
+
* Returns the first detected formatter in priority order.
|
|
25
|
+
*/
|
|
26
|
+
declare function detectFormatter(cwd?: string): Promise<FormatterType | null>;
|
|
27
|
+
interface FormatLogger {
|
|
28
|
+
log: (message: string) => void;
|
|
29
|
+
warn: (message: string) => void;
|
|
30
|
+
success: (message: string) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Format a single file or array of files.
|
|
34
|
+
*/
|
|
35
|
+
declare function formatFiles(files: string | string[], config?: FormatterConfig, options?: FormatterOptions, logger?: FormatLogger): Promise<FormatResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Format files in batch, grouping by directory for efficiency.
|
|
38
|
+
*/
|
|
39
|
+
declare function formatFilesBatch(files: string[], config?: FormatterConfig, options?: FormatterOptions, logger?: FormatLogger): Promise<FormatResult>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FormatLogger, FormatResult, FormatterOptions, detectFormatter, formatFiles, formatFilesBatch };
|
|
42
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../src/formatter.ts"],"sourcesContent":[],"mappings":";;;;AAiLiB,UAlKA,gBAAA,CAkKY;EASP;EAEX,IAAA,CAAA,EA3KF,aA2KE;EACC;EACD,IAAA,CAAA,EAAA,OAAA;EACA;EAAR,GAAA,CAAA,EAAA,MAAA;EAAO;EA8EY,MAAA,CAAA,EAAA,OAAA;;AAGV,UAtPK,YAAA,CAsPL;EACD,OAAA,EAAA,OAAA;EACA,SAAA,EAAA,OAAA;EAAR,KAAA,CAAA,EAAA,MAAA;EAAO,QAAA,CAAA,EAAA,MAAA;kBAnPQ;;;;;;iBAkDI,eAAA,gBAEnB,QAAQ;UA8FM,YAAA;;;;;;;;iBASK,WAAA,oCAEX,2BACC,2BACD,eACR,QAAQ;;;;iBA8EW,gBAAA,2BAEX,2BACC,2BACD,eACR,QAAQ"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
|
|
7
|
+
//#region src/formatter.ts
|
|
8
|
+
/**
|
|
9
|
+
* Formatter utility for ContractSpec CLI.
|
|
10
|
+
*
|
|
11
|
+
* Detects and runs code formatters on generated files.
|
|
12
|
+
*/
|
|
13
|
+
const execAsync = promisify(exec);
|
|
14
|
+
/**
|
|
15
|
+
* Config files that indicate a formatter is available.
|
|
16
|
+
*/
|
|
17
|
+
const FORMATTER_CONFIG_FILES = {
|
|
18
|
+
prettier: [
|
|
19
|
+
".prettierrc",
|
|
20
|
+
".prettierrc.json",
|
|
21
|
+
".prettierrc.yaml",
|
|
22
|
+
".prettierrc.yml",
|
|
23
|
+
".prettierrc.js",
|
|
24
|
+
".prettierrc.cjs",
|
|
25
|
+
".prettierrc.mjs",
|
|
26
|
+
"prettier.config.js",
|
|
27
|
+
"prettier.config.cjs",
|
|
28
|
+
"prettier.config.mjs"
|
|
29
|
+
],
|
|
30
|
+
eslint: [
|
|
31
|
+
".eslintrc",
|
|
32
|
+
".eslintrc.json",
|
|
33
|
+
".eslintrc.yaml",
|
|
34
|
+
".eslintrc.yml",
|
|
35
|
+
".eslintrc.js",
|
|
36
|
+
".eslintrc.cjs",
|
|
37
|
+
"eslint.config.js",
|
|
38
|
+
"eslint.config.mjs",
|
|
39
|
+
"eslint.config.cjs"
|
|
40
|
+
],
|
|
41
|
+
biome: ["biome.json", "biome.jsonc"],
|
|
42
|
+
dprint: ["dprint.json", ".dprint.json"],
|
|
43
|
+
custom: []
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Package.json dependencies that indicate a formatter is available.
|
|
47
|
+
*/
|
|
48
|
+
const FORMATTER_PACKAGES = {
|
|
49
|
+
prettier: ["prettier"],
|
|
50
|
+
eslint: ["eslint"],
|
|
51
|
+
biome: ["@biomejs/biome"],
|
|
52
|
+
dprint: ["dprint"],
|
|
53
|
+
custom: []
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Auto-detect available formatters in the workspace.
|
|
57
|
+
* Returns the first detected formatter in priority order.
|
|
58
|
+
*/
|
|
59
|
+
async function detectFormatter(cwd = process.cwd()) {
|
|
60
|
+
for (const formatter of [
|
|
61
|
+
"prettier",
|
|
62
|
+
"biome",
|
|
63
|
+
"eslint",
|
|
64
|
+
"dprint"
|
|
65
|
+
]) if (await isFormatterAvailable(formatter, cwd)) return formatter;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check if a specific formatter is available in the workspace.
|
|
70
|
+
*/
|
|
71
|
+
async function isFormatterAvailable(formatter, cwd) {
|
|
72
|
+
const configFiles = FORMATTER_CONFIG_FILES[formatter] || [];
|
|
73
|
+
for (const configFile of configFiles) if (existsSync(resolve(cwd, configFile))) return true;
|
|
74
|
+
const packageJsonPath = resolve(cwd, "package.json");
|
|
75
|
+
if (existsSync(packageJsonPath)) try {
|
|
76
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
77
|
+
const allDeps = {
|
|
78
|
+
...packageJson.dependencies,
|
|
79
|
+
...packageJson.devDependencies
|
|
80
|
+
};
|
|
81
|
+
const packages = FORMATTER_PACKAGES[formatter] || [];
|
|
82
|
+
for (const pkg of packages) if (pkg in allDeps) return true;
|
|
83
|
+
} catch {}
|
|
84
|
+
const parentDir = dirname(cwd);
|
|
85
|
+
if (parentDir !== cwd && parentDir !== "/") return isFormatterAvailable(formatter, parentDir);
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the command for a specific formatter type.
|
|
90
|
+
*/
|
|
91
|
+
function getFormatterCommand(type, files, config) {
|
|
92
|
+
const fileArgs = files.map((f) => `"${f}"`).join(" ");
|
|
93
|
+
const extraArgs = config?.args?.join(" ") || "";
|
|
94
|
+
switch (type) {
|
|
95
|
+
case "prettier": return `npx prettier --write ${extraArgs} ${fileArgs}`;
|
|
96
|
+
case "eslint": return `npx eslint --fix ${extraArgs} ${fileArgs}`;
|
|
97
|
+
case "biome": return `npx @biomejs/biome format --write ${extraArgs} ${fileArgs}`;
|
|
98
|
+
case "dprint": return `npx dprint fmt ${extraArgs} ${fileArgs}`;
|
|
99
|
+
case "custom":
|
|
100
|
+
if (!config?.command) throw new Error("Custom formatter requires a command to be specified in config");
|
|
101
|
+
return `${config.command} ${extraArgs} ${fileArgs}`;
|
|
102
|
+
default: throw new Error(`Unknown formatter type: ${type}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Format a single file or array of files.
|
|
107
|
+
*/
|
|
108
|
+
async function formatFiles(files, config, options, logger) {
|
|
109
|
+
const startTime = Date.now();
|
|
110
|
+
const fileList = Array.isArray(files) ? files : [files];
|
|
111
|
+
const cwd = options?.cwd || process.cwd();
|
|
112
|
+
if (options?.skip || config?.enabled === false) return {
|
|
113
|
+
success: true,
|
|
114
|
+
formatted: false,
|
|
115
|
+
duration: Date.now() - startTime
|
|
116
|
+
};
|
|
117
|
+
let formatterType = options?.type || config?.type;
|
|
118
|
+
if (!formatterType) {
|
|
119
|
+
const detected = await detectFormatter(cwd);
|
|
120
|
+
if (!detected) return {
|
|
121
|
+
success: true,
|
|
122
|
+
formatted: false,
|
|
123
|
+
duration: Date.now() - startTime
|
|
124
|
+
};
|
|
125
|
+
formatterType = detected;
|
|
126
|
+
}
|
|
127
|
+
const command = getFormatterCommand(formatterType, fileList, config);
|
|
128
|
+
const timeout = config?.timeout || 3e4;
|
|
129
|
+
if (!options?.silent && logger) logger.log(`🎨 Formatting ${fileList.length} file(s) with ${formatterType}...`);
|
|
130
|
+
try {
|
|
131
|
+
await execAsync(command, {
|
|
132
|
+
cwd,
|
|
133
|
+
timeout
|
|
134
|
+
});
|
|
135
|
+
if (!options?.silent && logger) logger.success(`✅ Formatted ${fileList.length} file(s)`);
|
|
136
|
+
return {
|
|
137
|
+
success: true,
|
|
138
|
+
formatted: true,
|
|
139
|
+
duration: Date.now() - startTime,
|
|
140
|
+
formatterUsed: formatterType
|
|
141
|
+
};
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
+
if (!options?.silent && logger) logger.warn(`⚠️ Formatting failed (continuing anyway): ${errorMessage}`);
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
formatted: false,
|
|
148
|
+
error: errorMessage,
|
|
149
|
+
duration: Date.now() - startTime,
|
|
150
|
+
formatterUsed: formatterType
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Format files in batch, grouping by directory for efficiency.
|
|
156
|
+
*/
|
|
157
|
+
async function formatFilesBatch(files, config, options, logger) {
|
|
158
|
+
return formatFiles(files, config, options, logger);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
export { detectFormatter, formatFiles, formatFilesBatch };
|
|
163
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","names":["FORMATTER_CONFIG_FILES: Record<FormatterType, string[]>","FORMATTER_PACKAGES: Record<FormatterType, string[]>"],"sources":["../src/formatter.ts"],"sourcesContent":["/**\n * Formatter utility for ContractSpec CLI.\n *\n * Detects and runs code formatters on generated files.\n */\n\nimport { exec } from 'node:child_process';\nimport { promisify } from 'node:util';\nimport { existsSync } from 'node:fs';\nimport { resolve, dirname } from 'node:path';\nimport { readFile } from 'node:fs/promises';\nimport type { FormatterConfig, FormatterType } from '@lssm/lib.contracts';\n\nconst execAsync = promisify(exec);\n\nexport interface FormatterOptions {\n /** Override formatter type from config */\n type?: FormatterType;\n /** Skip formatting entirely */\n skip?: boolean;\n /** Working directory for formatter */\n cwd?: string;\n /** Silent mode - don't log output */\n silent?: boolean;\n}\n\nexport interface FormatResult {\n success: boolean;\n formatted: boolean;\n error?: string;\n duration?: number;\n formatterUsed?: FormatterType;\n}\n\n/**\n * Config files that indicate a formatter is available.\n */\nconst FORMATTER_CONFIG_FILES: Record<FormatterType, string[]> = {\n prettier: [\n '.prettierrc',\n '.prettierrc.json',\n '.prettierrc.yaml',\n '.prettierrc.yml',\n '.prettierrc.js',\n '.prettierrc.cjs',\n '.prettierrc.mjs',\n 'prettier.config.js',\n 'prettier.config.cjs',\n 'prettier.config.mjs',\n ],\n eslint: [\n '.eslintrc',\n '.eslintrc.json',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.js',\n '.eslintrc.cjs',\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n ],\n biome: ['biome.json', 'biome.jsonc'],\n dprint: ['dprint.json', '.dprint.json'],\n custom: [],\n};\n\n/**\n * Package.json dependencies that indicate a formatter is available.\n */\nconst FORMATTER_PACKAGES: Record<FormatterType, string[]> = {\n prettier: ['prettier'],\n eslint: ['eslint'],\n biome: ['@biomejs/biome'],\n dprint: ['dprint'],\n custom: [],\n};\n\n/**\n * Auto-detect available formatters in the workspace.\n * Returns the first detected formatter in priority order.\n */\nexport async function detectFormatter(\n cwd: string = process.cwd()\n): Promise<FormatterType | null> {\n // Priority order for formatters\n const priority: FormatterType[] = ['prettier', 'biome', 'eslint', 'dprint'];\n\n for (const formatter of priority) {\n if (await isFormatterAvailable(formatter, cwd)) {\n return formatter;\n }\n }\n\n return null;\n}\n\n/**\n * Check if a specific formatter is available in the workspace.\n */\nasync function isFormatterAvailable(\n formatter: FormatterType,\n cwd: string\n): Promise<boolean> {\n // Check for config files\n const configFiles = FORMATTER_CONFIG_FILES[formatter] || [];\n for (const configFile of configFiles) {\n if (existsSync(resolve(cwd, configFile))) {\n return true;\n }\n }\n\n // Check package.json dependencies\n const packageJsonPath = resolve(cwd, 'package.json');\n if (existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(\n await readFile(packageJsonPath, 'utf-8')\n ) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n const packages = FORMATTER_PACKAGES[formatter] || [];\n for (const pkg of packages) {\n if (pkg in allDeps) {\n return true;\n }\n }\n } catch {\n // Ignore parse errors\n }\n }\n\n // Walk up to find monorepo root\n const parentDir = dirname(cwd);\n if (parentDir !== cwd && parentDir !== '/') {\n return isFormatterAvailable(formatter, parentDir);\n }\n\n return false;\n}\n\n/**\n * Get the command for a specific formatter type.\n */\nfunction getFormatterCommand(\n type: FormatterType,\n files: string[],\n config?: FormatterConfig\n): string {\n const fileArgs = files.map((f) => `\"${f}\"`).join(' ');\n const extraArgs = config?.args?.join(' ') || '';\n\n switch (type) {\n case 'prettier':\n return `npx prettier --write ${extraArgs} ${fileArgs}`;\n case 'eslint':\n return `npx eslint --fix ${extraArgs} ${fileArgs}`;\n case 'biome':\n return `npx @biomejs/biome format --write ${extraArgs} ${fileArgs}`;\n case 'dprint':\n return `npx dprint fmt ${extraArgs} ${fileArgs}`;\n case 'custom':\n if (!config?.command) {\n throw new Error(\n 'Custom formatter requires a command to be specified in config'\n );\n }\n return `${config.command} ${extraArgs} ${fileArgs}`;\n default:\n throw new Error(`Unknown formatter type: ${type}`);\n }\n}\n\nexport interface FormatLogger {\n log: (message: string) => void;\n warn: (message: string) => void;\n success: (message: string) => void;\n}\n\n/**\n * Format a single file or array of files.\n */\nexport async function formatFiles(\n files: string | string[],\n config?: FormatterConfig,\n options?: FormatterOptions,\n logger?: FormatLogger\n): Promise<FormatResult> {\n const startTime = Date.now();\n const fileList = Array.isArray(files) ? files : [files];\n const cwd = options?.cwd || process.cwd();\n\n // Skip if explicitly disabled\n if (options?.skip || config?.enabled === false) {\n return {\n success: true,\n formatted: false,\n duration: Date.now() - startTime,\n };\n }\n\n // Determine formatter to use\n let formatterType = options?.type || config?.type;\n\n // Auto-detect if not specified\n if (!formatterType) {\n const detected = await detectFormatter(cwd);\n if (!detected) {\n // No formatter available - silently skip\n return {\n success: true,\n formatted: false,\n duration: Date.now() - startTime,\n };\n }\n formatterType = detected;\n }\n\n // Build command\n const command = getFormatterCommand(formatterType, fileList, config);\n const timeout = config?.timeout || 30000;\n\n if (!options?.silent && logger) {\n logger.log(\n `🎨 Formatting ${fileList.length} file(s) with ${formatterType}...`\n );\n }\n\n try {\n await execAsync(command, {\n cwd,\n timeout,\n });\n\n if (!options?.silent && logger) {\n logger.success(`✅ Formatted ${fileList.length} file(s)`);\n }\n\n return {\n success: true,\n formatted: true,\n duration: Date.now() - startTime,\n formatterUsed: formatterType,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n // Log warning but don't fail the operation\n if (!options?.silent && logger) {\n logger.warn(`⚠️ Formatting failed (continuing anyway): ${errorMessage}`);\n }\n\n return {\n success: false,\n formatted: false,\n error: errorMessage,\n duration: Date.now() - startTime,\n formatterUsed: formatterType,\n };\n }\n}\n\n/**\n * Format files in batch, grouping by directory for efficiency.\n */\nexport async function formatFilesBatch(\n files: string[],\n config?: FormatterConfig,\n options?: FormatterOptions,\n logger?: FormatLogger\n): Promise<FormatResult> {\n // For now, just format all files together\n // Future optimization: group by directory and run formatter per directory\n return formatFiles(files, config, options, logger);\n}\n"],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ import { generateComponentTemplate, generateHandlerTemplate, generateTestTemplat
|
|
|
31
31
|
import { capitalize, escapeString, toCamelCase, toKebabCase, toPascalCase } from "./templates/utils.js";
|
|
32
32
|
import { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt } from "./ai/spec-creation.js";
|
|
33
33
|
import { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt } from "./ai/code-generation.js";
|
|
34
|
-
|
|
34
|
+
import { FormatLogger, FormatResult, FormatterOptions, detectFormatter, formatFiles, formatFilesBatch } from "./formatter.js";
|
|
35
|
+
export { AIGenerationOptions, AnalyzedOperationKind, AnalyzedSpecType, AppBlueprintSpecData, AppConfigFeatureFlagData, AppConfigMappingData, AppRouteConfigData, BREAKING_RULES, BaseSpecData, ClassifyOptions, CodeGenerationContext, ContractGraph, ContractNode, ContractSnapshot, DEFAULT_RULES, DEFAULT_WORKSPACE_CONFIG, DataViewFieldData, DataViewKind, DataViewSpecData, DeepDiffOptions, EventSnapshot, EventSpecData, ExperimentAllocationData, ExperimentMetricData, ExperimentSpecData, ExperimentVariantData, ExperimentVariantOverrideData, ExtractedRef, FeatureScanResult, FeatureSpecData, FieldSnapshot, FieldType, FormSpecData, FormatLogger, FormatResult, FormatterOptions, GenerationResult, GenerationTarget, GroupKeyFn, GroupedItems, HttpBindingSnapshot, INFO_RULES, ImpactDelta, ImpactResult, ImpactRule, ImpactSeverity, ImpactStatus, ImpactSummary, IntegrationCapabilityRefData, IntegrationCapabilityRequirementData, IntegrationCategoryData, IntegrationConfigFieldData, IntegrationConfigFieldType, IntegrationHealthCheckMethod, IntegrationOwnershipModeData, IntegrationSecretFieldData, IntegrationSpecData, IoSnapshot, KnowledgeCategoryData, KnowledgeRetentionData, KnowledgeSpaceSpecData, KnowledgeTrustLevel, MigrationSpecData, MigrationStepData, MigrationStepKind, NON_BREAKING_RULES, OpKind, OperationSnapshot, OperationSpecData, PresentationKind, PresentationSpecData, RandomAllocationData, RefInfo, RefType, RuleSeverity, RulesConfig, SemanticDiffItem, SemanticDiffOptions, SemanticDiffType, SnapshotOptions, SpecBuildType, SpecFilter, SpecGenerationContext, SpecGroupingStrategies, SpecKind, SpecScanResult, SpecSnapshot, SpecType, Stability, StepType, StickyAllocationData, TargetedAllocationData, TargetingRuleData, TelemetryAnomalyRuleData, TelemetryEventData, TelemetryPrivacy, TelemetryPropertyData, TelemetryProviderData, TelemetrySpecData, TestTarget, ValidationResult, WorkflowSpecData, WorkflowStepData, WorkflowTransitionData, WorkspaceConfig, addContractNode, addExampleContext, buildComponentPrompt, buildEventSpecPrompt, buildFormPrompt, buildHandlerPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, buildReverseEdges, buildTestPrompt, capitalize, classifyImpact, computeFieldDiff, computeFieldsDiff, computeHash, computeIoDiff, computeSemanticDiff, createContractGraph, detectCycles, detectFormatter, escapeString, extractEmittedEvents, extractPolicyRefs, extractTestRefs, filterFeatures, filterSpecs, findMatchingRule, findMissingDependencies, formatFiles, formatFilesBatch, generateAppBlueprintSpec, generateComponentTemplate, generateDataViewSpec, generateEventSpec, generateExperimentSpec, generateHandlerTemplate, generateIntegrationSpec, generateKnowledgeSpaceSpec, generateMigrationSpec, generateOperationSpec, generatePresentationSpec, generateSnapshot, generateTelemetrySpec, generateTestTemplate, generateWorkflowRunnerTemplate, generateWorkflowSpec, getCodeGenSystemPrompt, getRulesBySeverity, getSystemPrompt, getUniqueSpecDomains, getUniqueSpecOwners, getUniqueSpecTags, groupSpecs, groupSpecsToArray, inferSpecTypeFromFilePath, isBreakingChange, isFeatureFile, normalizeValue, parseImportedSpecNames, scanAllSpecsFromSource, scanFeatureSource, scanSpecSource, sortFields, sortSpecs, toCamelCase, toCanonicalJson, toDot, toKebabCase, toPascalCase, validateSpecStructure };
|
package/dist/index.js
CHANGED
|
@@ -28,5 +28,6 @@ import { generateKnowledgeSpaceSpec } from "./templates/knowledge.js";
|
|
|
28
28
|
import { generateComponentTemplate, generateHandlerTemplate, generateTestTemplate } from "./templates/handler.js";
|
|
29
29
|
import { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt } from "./ai/spec-creation.js";
|
|
30
30
|
import { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt } from "./ai/code-generation.js";
|
|
31
|
+
import { detectFormatter, formatFiles, formatFilesBatch } from "./formatter.js";
|
|
31
32
|
|
|
32
|
-
export { BREAKING_RULES, DEFAULT_RULES, DEFAULT_WORKSPACE_CONFIG, INFO_RULES, NON_BREAKING_RULES, SpecGroupingStrategies, addContractNode, addExampleContext, buildComponentPrompt, buildEventSpecPrompt, buildFormPrompt, buildHandlerPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, buildReverseEdges, buildTestPrompt, capitalize, classifyImpact, computeFieldDiff, computeFieldsDiff, computeHash, computeIoDiff, computeSemanticDiff, createContractGraph, detectCycles, escapeString, extractEmittedEvents, extractPolicyRefs, extractTestRefs, filterFeatures, filterSpecs, findMatchingRule, findMissingDependencies, generateAppBlueprintSpec, generateComponentTemplate, generateDataViewSpec, generateEventSpec, generateExperimentSpec, generateHandlerTemplate, generateIntegrationSpec, generateKnowledgeSpaceSpec, generateMigrationSpec, generateOperationSpec, generatePresentationSpec, generateSnapshot, generateTelemetrySpec, generateTestTemplate, generateWorkflowRunnerTemplate, generateWorkflowSpec, getCodeGenSystemPrompt, getRulesBySeverity, getSystemPrompt, getUniqueSpecDomains, getUniqueSpecOwners, getUniqueSpecTags, groupSpecs, groupSpecsToArray, inferSpecTypeFromFilePath, isBreakingChange, isFeatureFile, normalizeValue, parseImportedSpecNames, scanAllSpecsFromSource, scanFeatureSource, scanSpecSource, sortFields, sortSpecs, toCamelCase, toCanonicalJson, toDot, toKebabCase, toPascalCase, validateSpecStructure };
|
|
33
|
+
export { BREAKING_RULES, DEFAULT_RULES, DEFAULT_WORKSPACE_CONFIG, INFO_RULES, NON_BREAKING_RULES, SpecGroupingStrategies, addContractNode, addExampleContext, buildComponentPrompt, buildEventSpecPrompt, buildFormPrompt, buildHandlerPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, buildReverseEdges, buildTestPrompt, capitalize, classifyImpact, computeFieldDiff, computeFieldsDiff, computeHash, computeIoDiff, computeSemanticDiff, createContractGraph, detectCycles, detectFormatter, escapeString, extractEmittedEvents, extractPolicyRefs, extractTestRefs, filterFeatures, filterSpecs, findMatchingRule, findMissingDependencies, formatFiles, formatFilesBatch, generateAppBlueprintSpec, generateComponentTemplate, generateDataViewSpec, generateEventSpec, generateExperimentSpec, generateHandlerTemplate, generateIntegrationSpec, generateKnowledgeSpaceSpec, generateMigrationSpec, generateOperationSpec, generatePresentationSpec, generateSnapshot, generateTelemetrySpec, generateTestTemplate, generateWorkflowRunnerTemplate, generateWorkflowSpec, getCodeGenSystemPrompt, getRulesBySeverity, getSystemPrompt, getUniqueSpecDomains, getUniqueSpecOwners, getUniqueSpecTags, groupSpecs, groupSpecsToArray, inferSpecTypeFromFilePath, isBreakingChange, isFeatureFile, normalizeValue, parseImportedSpecNames, scanAllSpecsFromSource, scanFeatureSource, scanSpecSource, sortFields, sortSpecs, toCamelCase, toCanonicalJson, toDot, toKebabCase, toPascalCase, validateSpecStructure };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/module.contractspec-workspace",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"test": "bun run"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lssm/lib.contracts": "1.43.
|
|
27
|
-
"@lssm/lib.schema": "1.43.
|
|
26
|
+
"@lssm/lib.contracts": "1.43.2",
|
|
27
|
+
"@lssm/lib.schema": "1.43.1",
|
|
28
28
|
"zod": "^4.1.13"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@lssm/tool.tsdown": "1.43.
|
|
32
|
-
"@lssm/tool.typescript": "1.43.
|
|
31
|
+
"@lssm/tool.tsdown": "1.43.1",
|
|
32
|
+
"@lssm/tool.typescript": "1.43.1",
|
|
33
33
|
"tsdown": "^0.18.3",
|
|
34
34
|
"typescript": "^5.9.3"
|
|
35
35
|
},
|