@secondlayer/cli 1.1.0 → 1.2.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/dist/cli.js +25734 -17375
- package/dist/cli.js.map +76 -22
- package/dist/index.d.ts +5 -4
- package/dist/index.js +943 -1171
- package/dist/index.js.map +19 -14
- package/dist/plugin-manager.d.ts +5 -4
- package/dist/plugin-manager.js +74 -31
- package/dist/plugin-manager.js.map +6 -5
- package/package.json +12 -8
package/dist/plugin-manager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { AbiContract } from "@secondlayer/stacks/clarity";
|
|
2
|
+
/** Supported Stacks network identifiers for contract resolution. */
|
|
4
3
|
type NetworkName = "mainnet" | "testnet" | "devnet";
|
|
4
|
+
/** Specifies a contract to generate typed interfaces for, either from a deployed address or local Clarity source file. */
|
|
5
5
|
interface ContractSource {
|
|
6
6
|
/**
|
|
7
7
|
* Contract identifier (address.name) for deployed contracts
|
|
@@ -16,6 +16,7 @@ interface ContractSource {
|
|
|
16
16
|
*/
|
|
17
17
|
name?: string;
|
|
18
18
|
}
|
|
19
|
+
/** Configuration for the `@secondlayer/cli` code generator. Defines which contracts to process, output paths, network settings, and plugins. */
|
|
19
20
|
interface SecondLayerConfig {
|
|
20
21
|
/**
|
|
21
22
|
* Contracts to generate interfaces for (optional - plugins can provide these)
|
|
@@ -51,7 +52,7 @@ interface ResolvedContract {
|
|
|
51
52
|
name: string;
|
|
52
53
|
address: string;
|
|
53
54
|
contractName: string;
|
|
54
|
-
abi:
|
|
55
|
+
abi: AbiContract;
|
|
55
56
|
source: "api" | "local";
|
|
56
57
|
}
|
|
57
58
|
/**
|
package/dist/plugin-manager.js
CHANGED
|
@@ -14,28 +14,70 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
14
14
|
// src/utils/format.ts
|
|
15
15
|
var exports_format = {};
|
|
16
16
|
__export(exports_format, {
|
|
17
|
-
formatCode: () => formatCode
|
|
18
|
-
PRETTIER_OPTIONS: () => PRETTIER_OPTIONS
|
|
17
|
+
formatCode: () => formatCode
|
|
19
18
|
});
|
|
20
|
-
import {
|
|
19
|
+
import { Biome, Distribution } from "@biomejs/js-api";
|
|
20
|
+
async function getBiome() {
|
|
21
|
+
if (!biome) {
|
|
22
|
+
biome = await Biome.create({
|
|
23
|
+
distribution: Distribution.NODE
|
|
24
|
+
});
|
|
25
|
+
biome.applyConfiguration({
|
|
26
|
+
formatter: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
indentStyle: "tab",
|
|
29
|
+
lineWidth: 80
|
|
30
|
+
},
|
|
31
|
+
javascript: {
|
|
32
|
+
formatter: {
|
|
33
|
+
semicolons: "always",
|
|
34
|
+
quoteStyle: "single"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
organizeImports: {
|
|
38
|
+
enabled: true
|
|
39
|
+
},
|
|
40
|
+
linter: {
|
|
41
|
+
enabled: true
|
|
42
|
+
},
|
|
43
|
+
assists: {
|
|
44
|
+
enabled: true
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
biome.registerProjectFolder();
|
|
48
|
+
}
|
|
49
|
+
return biome;
|
|
50
|
+
}
|
|
21
51
|
async function formatCode(code) {
|
|
22
|
-
|
|
52
|
+
const b = await getBiome();
|
|
53
|
+
const linted = b.lintContent(code, {
|
|
54
|
+
filePath: "generated.ts",
|
|
55
|
+
fixFileMode: "SafeFixes"
|
|
56
|
+
});
|
|
57
|
+
const formatted = b.formatContent(linted.content, {
|
|
58
|
+
filePath: "generated.ts"
|
|
59
|
+
});
|
|
60
|
+
return formatted.content;
|
|
23
61
|
}
|
|
24
|
-
var
|
|
25
|
-
var init_format =
|
|
26
|
-
PRETTIER_OPTIONS = {
|
|
27
|
-
parser: "typescript",
|
|
28
|
-
singleQuote: true,
|
|
29
|
-
semi: true,
|
|
30
|
-
printWidth: 100,
|
|
31
|
-
trailingComma: "es5"
|
|
32
|
-
};
|
|
33
|
-
});
|
|
62
|
+
var biome = null;
|
|
63
|
+
var init_format = () => {};
|
|
34
64
|
|
|
35
65
|
// src/core/plugin-manager.ts
|
|
36
66
|
import { promises as fs } from "fs";
|
|
37
67
|
import path from "path";
|
|
38
|
-
import {
|
|
68
|
+
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
69
|
+
|
|
70
|
+
// src/utils/contract-id.ts
|
|
71
|
+
function parseContractId(contractId) {
|
|
72
|
+
const dotIndex = contractId.indexOf(".");
|
|
73
|
+
if (dotIndex === -1) {
|
|
74
|
+
throw new Error(`Invalid contract ID: "${contractId}" (expected "address.contractName")`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
address: contractId.slice(0, dotIndex),
|
|
78
|
+
contractName: contractId.slice(dotIndex + 1)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
39
81
|
|
|
40
82
|
// src/types/plugin.ts
|
|
41
83
|
function isClarinetContract(c) {
|
|
@@ -46,6 +88,8 @@ function isDirectFileContract(c) {
|
|
|
46
88
|
}
|
|
47
89
|
|
|
48
90
|
// src/core/plugin-manager.ts
|
|
91
|
+
var validateStacksAddress = _validateStacksAddress;
|
|
92
|
+
|
|
49
93
|
class PluginManager {
|
|
50
94
|
plugins = [];
|
|
51
95
|
logger;
|
|
@@ -107,11 +151,11 @@ class PluginManager {
|
|
|
107
151
|
for (let contract of contracts) {
|
|
108
152
|
if (isClarinetContract(contract) && contract.abi) {
|
|
109
153
|
const address = typeof contract.address === "string" ? contract.address : "";
|
|
110
|
-
const
|
|
154
|
+
const parsed = parseContractId(address);
|
|
111
155
|
const processed = {
|
|
112
|
-
name: contract.name || contractName,
|
|
113
|
-
address:
|
|
114
|
-
contractName,
|
|
156
|
+
name: contract.name || parsed.contractName,
|
|
157
|
+
address: parsed.address,
|
|
158
|
+
contractName: parsed.contractName,
|
|
115
159
|
abi: contract.abi,
|
|
116
160
|
source: "local",
|
|
117
161
|
metadata: { source: "clarinet" }
|
|
@@ -121,11 +165,11 @@ class PluginManager {
|
|
|
121
165
|
}
|
|
122
166
|
if (isDirectFileContract(contract) && contract.abi) {
|
|
123
167
|
const address = typeof contract.address === "string" ? contract.address : "";
|
|
124
|
-
const
|
|
168
|
+
const parsed = parseContractId(address);
|
|
125
169
|
const processed = {
|
|
126
|
-
name: contract.name || contractName,
|
|
127
|
-
address:
|
|
128
|
-
contractName,
|
|
170
|
+
name: contract.name || parsed.contractName,
|
|
171
|
+
address: parsed.address,
|
|
172
|
+
contractName: parsed.contractName,
|
|
129
173
|
abi: contract.abi,
|
|
130
174
|
source: "local",
|
|
131
175
|
metadata: { source: "direct" }
|
|
@@ -153,11 +197,11 @@ class PluginManager {
|
|
|
153
197
|
}
|
|
154
198
|
if (contract.abi) {
|
|
155
199
|
const addressStr = typeof contract.address === "string" ? contract.address : "";
|
|
156
|
-
const
|
|
200
|
+
const parsed = parseContractId(addressStr);
|
|
157
201
|
const processed = {
|
|
158
|
-
name: contract.name ||
|
|
159
|
-
address:
|
|
160
|
-
contractName:
|
|
202
|
+
name: contract.name || parsed.contractName || "unknown",
|
|
203
|
+
address: parsed.address || "unknown",
|
|
204
|
+
contractName: parsed.contractName || contract.name || "unknown",
|
|
161
205
|
abi: contract.abi,
|
|
162
206
|
source: "api",
|
|
163
207
|
metadata: contract.metadata
|
|
@@ -298,11 +342,10 @@ ${JSON.stringify(content, null, 2)}`;
|
|
|
298
342
|
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
299
343
|
},
|
|
300
344
|
validateAddress: (address) => {
|
|
301
|
-
return validateStacksAddress(address.
|
|
345
|
+
return validateStacksAddress(parseContractId(address).address);
|
|
302
346
|
},
|
|
303
347
|
parseContractId: (contractId) => {
|
|
304
|
-
|
|
305
|
-
return { address, contractName };
|
|
348
|
+
return parseContractId(contractId);
|
|
306
349
|
},
|
|
307
350
|
formatCode: async (code) => {
|
|
308
351
|
const { formatCode: formatCode2 } = await Promise.resolve().then(() => (init_format(), exports_format));
|
|
@@ -335,5 +378,5 @@ export {
|
|
|
335
378
|
PluginManager
|
|
336
379
|
};
|
|
337
380
|
|
|
338
|
-
//# debugId=
|
|
381
|
+
//# debugId=F79C39134E35BDE464756E2164756E21
|
|
339
382
|
//# sourceMappingURL=plugin-manager.js.map
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/utils/format.ts", "../src/core/plugin-manager.ts", "../src/types/plugin.ts"],
|
|
3
|
+
"sources": ["../src/utils/format.ts", "../src/core/plugin-manager.ts", "../src/utils/contract-id.ts", "../src/types/plugin.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Shared code formatting utilities\n */\n\nimport {
|
|
6
|
-
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"fs\";\nimport path from \"path\";\nimport { validateStacksAddress } from \"@stacks/transactions\";\nimport type {\n SecondLayerPlugin,\n UserConfig,\n ResolvedConfig,\n GenerateContext,\n Logger,\n PluginUtils,\n GeneratedOutput,\n ProcessedContract,\n ContractConfig,\n HookResult,\n PluginExecutionContext,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n private plugins: SecondLayerPlugin[] = [];\n private logger: Logger;\n private utils: PluginUtils;\n private executionContext: PluginExecutionContext;\n\n constructor() {\n this.logger = this.createLogger();\n this.utils = this.createUtils();\n this.executionContext = {\n phase: \"config\",\n startTime: Date.now(),\n results: new Map(),\n };\n }\n\n /**\n * Register a plugin\n */\n register(plugin: SecondLayerPlugin): void {\n // Validate plugin\n if (!plugin.name || !plugin.version) {\n throw new Error(\"Plugin must have a name and version\");\n }\n\n // Check for duplicate plugin names\n const existing = this.plugins.find((p) => p.name === plugin.name);\n if (existing) {\n throw new Error(\n `Plugin \"${plugin.name}\" is already registered (version ${existing.version})`\n );\n }\n\n this.plugins.push(plugin);\n this.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n }\n\n /**\n * Get all registered plugins\n */\n getPlugins(): SecondLayerPlugin[] {\n return [...this.plugins];\n }\n\n /**\n * Transform user config through all plugins\n */\n async transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n this.executionContext.phase = \"config\";\n let transformedConfig = { ...config };\n\n for (const plugin of this.plugins) {\n if (plugin.transformConfig) {\n this.executionContext.currentPlugin = plugin;\n try {\n const result = await plugin.transformConfig(transformedConfig);\n transformedConfig = result;\n this.recordHookResult(plugin.name, \"transformConfig\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformConfig\", {\n success: false,\n error: err,\n });\n throw new Error(\n `Plugin \"${plugin.name}\" failed during config transformation: ${err.message}`\n );\n }\n }\n }\n\n // Add plugins array to resolved config\n const resolvedConfig: ResolvedConfig = {\n ...transformedConfig,\n plugins: this.plugins,\n };\n\n return resolvedConfig;\n }\n\n /**\n * Transform contracts through all plugins\n */\n async transformContracts(\n contracts: ContractConfig[],\n _config: ResolvedConfig\n ): Promise<ProcessedContract[]> {\n const processedContracts: ProcessedContract[] = [];\n\n for (let contract of contracts) {\n // Handle special case for Clarinet plugin contracts\n if (isClarinetContract(contract) && contract.abi) {\n // Convert Clarinet contracts directly to ProcessedContract format\n const address =\n typeof contract.address === \"string\" ? contract.address : \"\";\n const [contractAddress, contractName] = address.split(\".\");\n const processed: ProcessedContract = {\n name: contract.name || contractName,\n address: contractAddress,\n contractName: contractName,\n abi: contract.abi,\n source: \"local\" as const,\n metadata: { source: \"clarinet\" },\n };\n processedContracts.push(processed);\n continue;\n }\n\n // Handle direct file mode contracts (already have ABIs parsed)\n if (isDirectFileContract(contract) && contract.abi) {\n const address =\n typeof contract.address === \"string\" ? contract.address : \"\";\n const [contractAddress, contractName] = address.split(\".\");\n const processed: ProcessedContract = {\n name: contract.name || contractName,\n address: contractAddress,\n contractName: contractName,\n abi: contract.abi,\n source: \"local\" as const,\n metadata: { source: \"direct\" },\n };\n processedContracts.push(processed);\n continue;\n }\n\n // Transform through each plugin\n for (const plugin of this.plugins) {\n if (plugin.transformContract) {\n this.executionContext.currentPlugin = plugin;\n try {\n contract = await plugin.transformContract(contract);\n this.recordHookResult(plugin.name, \"transformContract\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformContract\", {\n success: false,\n error: err,\n });\n this.logger.warn(\n `Plugin \"${plugin.name}\" failed to transform contract: ${err.message}`\n );\n }\n }\n }\n\n // Convert to ProcessedContract\n if (contract.abi) {\n const addressStr = typeof contract.address === \"string\" ? contract.address : \"\";\n const [contractAddress, originalContractName] = addressStr.split(\".\");\n const processed: ProcessedContract = {\n name: contract.name || originalContractName || \"unknown\",\n address: contractAddress || \"unknown\",\n contractName: originalContractName || contract.name || \"unknown\",\n abi: contract.abi,\n source: \"api\" as const, // Use \"api\" as default for plugin-processed contracts\n metadata: contract.metadata,\n };\n processedContracts.push(processed);\n }\n }\n\n return processedContracts;\n }\n\n /**\n * Execute lifecycle hooks\n */\n async executeHook(\n hookName: keyof SecondLayerPlugin,\n context: any\n ): Promise<void> {\n for (const plugin of this.plugins) {\n const hook = plugin[hookName];\n if (typeof hook === \"function\") {\n this.executionContext.currentPlugin = plugin;\n try {\n await (hook as any).call(plugin, context);\n this.recordHookResult(plugin.name, hookName as string, {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, hookName as string, {\n success: false,\n error: err,\n });\n this.logger.error(\n `Plugin \"${plugin.name}\" failed during ${hookName as string}: ${err.message}`\n );\n // Don't throw - allow other plugins to continue\n }\n }\n }\n }\n\n /**\n * Execute generation phase with full context\n */\n async executeGeneration(\n contracts: ProcessedContract[],\n config: ResolvedConfig\n ): Promise<Map<string, GeneratedOutput>> {\n this.executionContext.phase = \"generate\";\n const outputs = new Map<string, GeneratedOutput>();\n\n // Create generation context\n const context: GenerateContext = {\n config,\n logger: this.logger,\n utils: this.utils,\n contracts,\n outputs,\n augment: (outputKey: string, contractName: string, content: any) => {\n this.augmentOutput(outputs, outputKey, contractName, content);\n },\n addOutput: (key: string, output: GeneratedOutput) => {\n outputs.set(key, output);\n },\n };\n\n // Execute beforeGenerate hooks\n await this.executeHook(\"beforeGenerate\", context);\n\n // Execute generate hooks\n await this.executeHook(\"generate\", context);\n\n // Execute afterGenerate hooks\n await this.executeHook(\"afterGenerate\", context);\n\n return outputs;\n }\n\n /**\n * Transform outputs through plugins\n */\n async transformOutputs(\n outputs: Map<string, GeneratedOutput>\n ): Promise<Map<string, GeneratedOutput>> {\n this.executionContext.phase = \"output\";\n const transformedOutputs = new Map<string, GeneratedOutput>();\n\n for (const [key, output] of outputs) {\n let transformedContent = output.content;\n\n for (const plugin of this.plugins) {\n if (plugin.transformOutput) {\n this.executionContext.currentPlugin = plugin;\n try {\n transformedContent = await plugin.transformOutput(\n transformedContent,\n output.type || \"other\"\n );\n this.recordHookResult(plugin.name, \"transformOutput\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformOutput\", {\n success: false,\n error: err,\n });\n this.logger.warn(\n `Plugin \"${plugin.name}\" failed to transform output: ${err.message}`\n );\n }\n }\n }\n\n transformedOutputs.set(key, {\n ...output,\n content: transformedContent,\n });\n }\n\n return transformedOutputs;\n }\n\n /**\n * Write outputs to disk\n */\n async writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n for (const [, output] of outputs) {\n try {\n const resolvedPath = path.resolve(process.cwd(), output.path);\n await this.utils.ensureDir(path.dirname(resolvedPath));\n await this.utils.writeFile(resolvedPath, output.content);\n // Don't log here - let the main command handle success messaging\n } catch (error) {\n const err = error as Error;\n this.logger.error(`Failed to write ${output.path}: ${err.message}`);\n throw err;\n }\n }\n }\n\n /**\n * Get execution results for debugging\n */\n getExecutionResults(): Map<string, HookResult[]> {\n return new Map(this.executionContext.results);\n }\n\n /**\n * Augment existing output with additional content\n */\n private augmentOutput(\n outputs: Map<string, GeneratedOutput>,\n outputKey: string,\n contractName: string,\n content: any\n ): void {\n const existing = outputs.get(outputKey);\n if (!existing) {\n this.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n return;\n }\n\n // Simple augmentation - append content\n // In a real implementation, this would be more sophisticated\n const augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n outputs.set(outputKey, {\n ...existing,\n content: augmentedContent,\n });\n }\n\n /**\n * Record hook execution result\n */\n private recordHookResult(\n pluginName: string,\n hookName: string,\n result: Omit<HookResult, \"plugin\">\n ): void {\n const key = `${pluginName}:${hookName}`;\n const existing = this.executionContext.results.get(key) || [];\n existing.push({ ...result, plugin: pluginName });\n this.executionContext.results.set(key, existing);\n }\n\n /**\n * Create logger instance\n */\n private createLogger(): Logger {\n return {\n info: (message: string) => console.log(`ℹ️ ${message}`),\n warn: (message: string) => console.warn(`⚠️ ${message}`),\n error: (message: string) => console.error(`❌ ${message}`),\n debug: (message: string) => {\n if (process.env.DEBUG) {\n console.log(`🐛 ${message}`);\n }\n },\n success: (message: string) => console.log(`✅ ${message}`),\n };\n }\n\n /**\n * Create utils instance\n */\n private createUtils(): PluginUtils {\n return {\n toCamelCase: (str: string) => {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n },\n\n toKebabCase: (str: string) => {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n },\n\n validateAddress: (address: string) => {\n return validateStacksAddress(address.split(\".\")[0]);\n },\n\n parseContractId: (contractId: string) => {\n const [address, contractName] = contractId.split(\".\");\n return { address, contractName };\n },\n\n formatCode: async (code: string) => {\n const { formatCode } = await import(\"../utils/format\");\n return formatCode(code);\n },\n\n resolvePath: (relativePath: string) => {\n return path.resolve(process.cwd(), relativePath);\n },\n\n fileExists: async (filePath: string) => {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n },\n\n readFile: async (filePath: string) => {\n return fs.readFile(filePath, \"utf-8\");\n },\n\n writeFile: async (filePath: string, content: string) => {\n await fs.writeFile(filePath, content, \"utf-8\");\n },\n\n ensureDir: async (dirPath: string) => {\n await fs.mkdir(dirPath, { recursive: true });\n },\n };\n }\n}\n",
|
|
5
|
+
"/**\n * Shared code formatting utilities using Biome\n */\n\nimport { Biome, Distribution } from \"@biomejs/js-api\";\n\nlet biome: Biome | null = null;\n\n/**\n * Lazily initialize Biome singleton\n */\nasync function getBiome(): Promise<Biome> {\n\tif (!biome) {\n\t\tbiome = await Biome.create({\n\t\t\tdistribution: Distribution.NODE,\n\t\t});\n\n\t\tbiome.applyConfiguration({\n\t\t\tformatter: {\n\t\t\t\tenabled: true,\n\t\t\t\tindentStyle: \"tab\",\n\t\t\t\tlineWidth: 80,\n\t\t\t},\n\t\t\tjavascript: {\n\t\t\t\tformatter: {\n\t\t\t\t\tsemicolons: \"always\",\n\t\t\t\t\tquoteStyle: \"single\",\n\t\t\t\t},\n\t\t\t},\n\t\t\torganizeImports: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tlinter: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tassists: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t});\n\n\t\tbiome.registerProjectFolder();\n\t}\n\n\treturn biome;\n}\n\n/**\n * Format TypeScript code using Biome\n */\nexport async function formatCode(code: string): Promise<string> {\n\tconst b = await getBiome();\n\n\t// Use lintContent with SafeFixes to organize imports\n\tconst linted = b.lintContent(code, {\n\t\tfilePath: \"generated.ts\",\n\t\tfixFileMode: \"SafeFixes\",\n\t});\n\n\t// Then format\n\tconst formatted = b.formatContent(linted.content, {\n\t\tfilePath: \"generated.ts\",\n\t});\n\n\treturn formatted.content;\n}\n",
|
|
6
|
+
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"fs\";\nimport path from \"path\";\nimport { isValidAddress as _validateStacksAddress } from \"@secondlayer/stacks\";\nconst validateStacksAddress = _validateStacksAddress as (address: string) => boolean;\nimport { parseContractId } from \"../utils/contract-id\";\nimport type {\n SecondLayerPlugin,\n UserConfig,\n ResolvedConfig,\n GenerateContext,\n Logger,\n PluginUtils,\n GeneratedOutput,\n ProcessedContract,\n ContractConfig,\n HookResult,\n PluginExecutionContext,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n private plugins: SecondLayerPlugin[] = [];\n private logger: Logger;\n private utils: PluginUtils;\n private executionContext: PluginExecutionContext;\n\n constructor() {\n this.logger = this.createLogger();\n this.utils = this.createUtils();\n this.executionContext = {\n phase: \"config\",\n startTime: Date.now(),\n results: new Map(),\n };\n }\n\n /**\n * Register a plugin\n */\n register(plugin: SecondLayerPlugin): void {\n // Validate plugin\n if (!plugin.name || !plugin.version) {\n throw new Error(\"Plugin must have a name and version\");\n }\n\n // Check for duplicate plugin names\n const existing = this.plugins.find((p) => p.name === plugin.name);\n if (existing) {\n throw new Error(\n `Plugin \"${plugin.name}\" is already registered (version ${existing.version})`\n );\n }\n\n this.plugins.push(plugin);\n this.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n }\n\n /**\n * Get all registered plugins\n */\n getPlugins(): SecondLayerPlugin[] {\n return [...this.plugins];\n }\n\n /**\n * Transform user config through all plugins\n */\n async transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n this.executionContext.phase = \"config\";\n let transformedConfig = { ...config };\n\n for (const plugin of this.plugins) {\n if (plugin.transformConfig) {\n this.executionContext.currentPlugin = plugin;\n try {\n const result = await plugin.transformConfig(transformedConfig);\n transformedConfig = result;\n this.recordHookResult(plugin.name, \"transformConfig\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformConfig\", {\n success: false,\n error: err,\n });\n throw new Error(\n `Plugin \"${plugin.name}\" failed during config transformation: ${err.message}`\n );\n }\n }\n }\n\n // Add plugins array to resolved config\n const resolvedConfig: ResolvedConfig = {\n ...transformedConfig,\n plugins: this.plugins,\n };\n\n return resolvedConfig;\n }\n\n /**\n * Transform contracts through all plugins\n */\n async transformContracts(\n contracts: ContractConfig[],\n _config: ResolvedConfig\n ): Promise<ProcessedContract[]> {\n const processedContracts: ProcessedContract[] = [];\n\n for (let contract of contracts) {\n // Handle special case for Clarinet plugin contracts\n if (isClarinetContract(contract) && contract.abi) {\n // Convert Clarinet contracts directly to ProcessedContract format\n const address =\n typeof contract.address === \"string\" ? contract.address : \"\";\n const parsed = parseContractId(address);\n const processed: ProcessedContract = {\n name: contract.name || parsed.contractName,\n address: parsed.address,\n contractName: parsed.contractName,\n abi: contract.abi,\n source: \"local\" as const,\n metadata: { source: \"clarinet\" },\n };\n processedContracts.push(processed);\n continue;\n }\n\n // Handle direct file mode contracts (already have ABIs parsed)\n if (isDirectFileContract(contract) && contract.abi) {\n const address =\n typeof contract.address === \"string\" ? contract.address : \"\";\n const parsed = parseContractId(address);\n const processed: ProcessedContract = {\n name: contract.name || parsed.contractName,\n address: parsed.address,\n contractName: parsed.contractName,\n abi: contract.abi,\n source: \"local\" as const,\n metadata: { source: \"direct\" },\n };\n processedContracts.push(processed);\n continue;\n }\n\n // Transform through each plugin\n for (const plugin of this.plugins) {\n if (plugin.transformContract) {\n this.executionContext.currentPlugin = plugin;\n try {\n contract = await plugin.transformContract(contract);\n this.recordHookResult(plugin.name, \"transformContract\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformContract\", {\n success: false,\n error: err,\n });\n this.logger.warn(\n `Plugin \"${plugin.name}\" failed to transform contract: ${err.message}`\n );\n }\n }\n }\n\n // Convert to ProcessedContract\n if (contract.abi) {\n const addressStr = typeof contract.address === \"string\" ? contract.address : \"\";\n const parsed = parseContractId(addressStr);\n const processed: ProcessedContract = {\n name: contract.name || parsed.contractName || \"unknown\",\n address: parsed.address || \"unknown\",\n contractName: parsed.contractName || contract.name || \"unknown\",\n abi: contract.abi,\n source: \"api\" as const, // Use \"api\" as default for plugin-processed contracts\n metadata: contract.metadata,\n };\n processedContracts.push(processed);\n }\n }\n\n return processedContracts;\n }\n\n /**\n * Execute lifecycle hooks\n */\n async executeHook(\n hookName: keyof SecondLayerPlugin,\n context: any\n ): Promise<void> {\n for (const plugin of this.plugins) {\n const hook = plugin[hookName];\n if (typeof hook === \"function\") {\n this.executionContext.currentPlugin = plugin;\n try {\n await (hook as any).call(plugin, context);\n this.recordHookResult(plugin.name, hookName as string, {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, hookName as string, {\n success: false,\n error: err,\n });\n this.logger.error(\n `Plugin \"${plugin.name}\" failed during ${hookName as string}: ${err.message}`\n );\n // Don't throw - allow other plugins to continue\n }\n }\n }\n }\n\n /**\n * Execute generation phase with full context\n */\n async executeGeneration(\n contracts: ProcessedContract[],\n config: ResolvedConfig\n ): Promise<Map<string, GeneratedOutput>> {\n this.executionContext.phase = \"generate\";\n const outputs = new Map<string, GeneratedOutput>();\n\n // Create generation context\n const context: GenerateContext = {\n config,\n logger: this.logger,\n utils: this.utils,\n contracts,\n outputs,\n augment: (outputKey: string, contractName: string, content: any) => {\n this.augmentOutput(outputs, outputKey, contractName, content);\n },\n addOutput: (key: string, output: GeneratedOutput) => {\n outputs.set(key, output);\n },\n };\n\n // Execute beforeGenerate hooks\n await this.executeHook(\"beforeGenerate\", context);\n\n // Execute generate hooks\n await this.executeHook(\"generate\", context);\n\n // Execute afterGenerate hooks\n await this.executeHook(\"afterGenerate\", context);\n\n return outputs;\n }\n\n /**\n * Transform outputs through plugins\n */\n async transformOutputs(\n outputs: Map<string, GeneratedOutput>\n ): Promise<Map<string, GeneratedOutput>> {\n this.executionContext.phase = \"output\";\n const transformedOutputs = new Map<string, GeneratedOutput>();\n\n for (const [key, output] of outputs) {\n let transformedContent = output.content;\n\n for (const plugin of this.plugins) {\n if (plugin.transformOutput) {\n this.executionContext.currentPlugin = plugin;\n try {\n transformedContent = await plugin.transformOutput(\n transformedContent,\n output.type || \"other\"\n );\n this.recordHookResult(plugin.name, \"transformOutput\", {\n success: true,\n });\n } catch (error) {\n const err = error as Error;\n this.recordHookResult(plugin.name, \"transformOutput\", {\n success: false,\n error: err,\n });\n this.logger.warn(\n `Plugin \"${plugin.name}\" failed to transform output: ${err.message}`\n );\n }\n }\n }\n\n transformedOutputs.set(key, {\n ...output,\n content: transformedContent,\n });\n }\n\n return transformedOutputs;\n }\n\n /**\n * Write outputs to disk\n */\n async writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n for (const [, output] of outputs) {\n try {\n const resolvedPath = path.resolve(process.cwd(), output.path);\n await this.utils.ensureDir(path.dirname(resolvedPath));\n await this.utils.writeFile(resolvedPath, output.content);\n // Don't log here - let the main command handle success messaging\n } catch (error) {\n const err = error as Error;\n this.logger.error(`Failed to write ${output.path}: ${err.message}`);\n throw err;\n }\n }\n }\n\n /**\n * Get execution results for debugging\n */\n getExecutionResults(): Map<string, HookResult[]> {\n return new Map(this.executionContext.results);\n }\n\n /**\n * Augment existing output with additional content\n */\n private augmentOutput(\n outputs: Map<string, GeneratedOutput>,\n outputKey: string,\n contractName: string,\n content: any\n ): void {\n const existing = outputs.get(outputKey);\n if (!existing) {\n this.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n return;\n }\n\n // Simple augmentation - append content\n // In a real implementation, this would be more sophisticated\n const augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n outputs.set(outputKey, {\n ...existing,\n content: augmentedContent,\n });\n }\n\n /**\n * Record hook execution result\n */\n private recordHookResult(\n pluginName: string,\n hookName: string,\n result: Omit<HookResult, \"plugin\">\n ): void {\n const key = `${pluginName}:${hookName}`;\n const existing = this.executionContext.results.get(key) || [];\n existing.push({ ...result, plugin: pluginName });\n this.executionContext.results.set(key, existing);\n }\n\n /**\n * Create logger instance\n */\n private createLogger(): Logger {\n return {\n info: (message: string) => console.log(`ℹ️ ${message}`),\n warn: (message: string) => console.warn(`⚠️ ${message}`),\n error: (message: string) => console.error(`❌ ${message}`),\n debug: (message: string) => {\n if (process.env.DEBUG) {\n console.log(`🐛 ${message}`);\n }\n },\n success: (message: string) => console.log(`✅ ${message}`),\n };\n }\n\n /**\n * Create utils instance\n */\n private createUtils(): PluginUtils {\n return {\n toCamelCase: (str: string) => {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n },\n\n toKebabCase: (str: string) => {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n },\n\n validateAddress: (address: string) => {\n return validateStacksAddress(parseContractId(address).address);\n },\n\n parseContractId: (contractId: string) => {\n return parseContractId(contractId);\n },\n\n formatCode: async (code: string) => {\n const { formatCode } = await import(\"../utils/format\");\n return formatCode(code);\n },\n\n resolvePath: (relativePath: string) => {\n return path.resolve(process.cwd(), relativePath);\n },\n\n fileExists: async (filePath: string) => {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n },\n\n readFile: async (filePath: string) => {\n return fs.readFile(filePath, \"utf-8\");\n },\n\n writeFile: async (filePath: string, content: string) => {\n await fs.writeFile(filePath, content, \"utf-8\");\n },\n\n ensureDir: async (dirPath: string) => {\n await fs.mkdir(dirPath, { recursive: true });\n },\n };\n }\n}\n",
|
|
7
|
+
"/**\n * Parse a fully-qualified contract ID (\"address.contractName\") into its parts.\n * Throws if the input doesn't contain a dot separator.\n */\nexport function parseContractId(contractId: string): {\n address: string;\n contractName: string;\n} {\n const dotIndex = contractId.indexOf(\".\");\n if (dotIndex === -1) {\n throw new Error(\n `Invalid contract ID: \"${contractId}\" (expected \"address.contractName\")`\n );\n }\n return {\n address: contractId.slice(0, dotIndex),\n contractName: contractId.slice(dotIndex + 1),\n };\n}\n",
|
|
7
8
|
"/**\n * Plugin system types for @secondlayer/cli\n */\n\nimport type { SecondLayerConfig, ResolvedContract, NetworkName } from \"./config\";\n\n/**\n * Core plugin interface that all plugins must implement\n */\nexport interface SecondLayerPlugin {\n /** Plugin name (should be unique) */\n name: string;\n\n /** Plugin version */\n version: string;\n\n // Lifecycle hooks\n /** Called after config is resolved but before generation starts */\n configResolved?: (config: ResolvedConfig) => void | Promise<void>;\n\n /** Called before generation starts */\n beforeGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n /** Called during generation phase - plugins can add their own outputs */\n generate?: (context: GenerateContext) => void | Promise<void>;\n\n /** Called after all generation is complete */\n afterGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n // Transform hooks\n /** Transform user config before resolution */\n transformConfig?: (config: UserConfig) => UserConfig | Promise<UserConfig>;\n\n /** Transform individual contracts during processing */\n transformContract?: (\n contract: ContractConfig\n ) => ContractConfig | Promise<ContractConfig>;\n\n /** Transform generated output before writing to disk */\n transformOutput?: (\n output: string,\n type: OutputType\n ) => string | Promise<string>;\n}\n\n/**\n * User configuration (before plugin transformations)\n */\nexport type UserConfig = SecondLayerConfig;\n\n/**\n * Resolved configuration (after plugin transformations)\n */\nexport interface ResolvedConfig extends SecondLayerConfig {\n /** Resolved plugins array */\n plugins: SecondLayerPlugin[];\n}\n\n/**\n * Contract configuration that can be transformed by plugins\n */\nexport interface ContractConfig {\n name?: string;\n address?: string | Partial<Record<NetworkName, string>>;\n source?: string;\n abi?: any;\n metadata?: Record<string, any>;\n}\n\n/**\n * Contract config from Clarinet plugin\n */\nexport interface ClarinetContractConfig extends ContractConfig {\n _clarinetSource: true;\n}\n\n/**\n * Contract config from direct file input\n */\nexport interface DirectFileContractConfig extends ContractConfig {\n _directFile: true;\n}\n\n/**\n * Union of all contract config types\n */\nexport type PluginContractConfig =\n | ContractConfig\n | ClarinetContractConfig\n | DirectFileContractConfig;\n\n/**\n * Type guard for Clarinet contracts\n */\nexport function isClarinetContract(\n c: ContractConfig\n): c is ClarinetContractConfig {\n return \"_clarinetSource\" in c && c._clarinetSource === true;\n}\n\n/**\n * Type guard for direct file contracts\n */\nexport function isDirectFileContract(\n c: ContractConfig\n): c is DirectFileContractConfig {\n return \"_directFile\" in c && c._directFile === true;\n}\n\n/**\n * Processed contract with resolved ABI and metadata\n */\nexport interface ProcessedContract extends ResolvedContract {\n /** Additional metadata added by plugins */\n metadata?: Record<string, any>;\n}\n\n/**\n * Generated output from plugins\n */\nexport interface GeneratedOutput {\n /** File path where output should be written */\n path: string;\n\n /** Generated content */\n content: string;\n\n /** Output type for transformation hooks */\n type?: OutputType;\n\n /** Whether this output should overwrite existing files */\n overwrite?: boolean;\n}\n\n/**\n * Types of outputs that can be generated\n */\nexport type OutputType =\n | \"contracts\"\n | \"hooks\"\n | \"actions\"\n | \"types\"\n | \"utils\"\n | \"config\"\n | \"other\";\n\n/**\n * Base context available to all plugin hooks\n */\nexport interface PluginContext {\n /** Resolved configuration */\n config: ResolvedConfig;\n\n /** Logger for plugin output */\n logger: Logger;\n\n /** Utility functions for plugins */\n utils: PluginUtils;\n}\n\n/**\n * Context available during generation phase\n */\nexport interface GenerateContext extends PluginContext {\n /** Processed contracts ready for generation */\n contracts: ProcessedContract[];\n\n /** Map of output keys to generated content */\n outputs: Map<string, GeneratedOutput>;\n\n /** Function to augment existing outputs */\n augment: (outputKey: string, contractName: string, content: any) => void;\n\n /** Function to add new outputs */\n addOutput: (key: string, output: GeneratedOutput) => void;\n}\n\n/**\n * Logger interface for plugin output\n */\nexport interface Logger {\n info: (message: string) => void;\n warn: (message: string) => void;\n error: (message: string) => void;\n debug: (message: string) => void;\n success: (message: string) => void;\n}\n\n/**\n * Utility functions available to plugins\n */\nexport interface PluginUtils {\n /** Convert kebab-case to camelCase */\n toCamelCase: (str: string) => string;\n\n /** Convert camelCase to kebab-case */\n toKebabCase: (str: string) => string;\n\n /** Validate Stacks address format */\n validateAddress: (address: string) => boolean;\n\n /** Parse contract identifier (address.contract-name) */\n parseContractId: (contractId: string) => {\n address: string;\n contractName: string;\n };\n\n /** Format TypeScript code using prettier */\n formatCode: (code: string) => Promise<string>;\n\n /** Resolve file path relative to project root */\n resolvePath: (relativePath: string) => string;\n\n /** Check if file exists */\n fileExists: (path: string) => Promise<boolean>;\n\n /** Read file content */\n readFile: (path: string) => Promise<string>;\n\n /** Write file content */\n writeFile: (path: string, content: string) => Promise<void>;\n\n /** Create directory recursively */\n ensureDir: (path: string) => Promise<void>;\n}\n\n/**\n * Plugin factory function type for creating plugins with options\n */\nexport type PluginFactory<TOptions = any> = (\n options?: TOptions\n) => SecondLayerPlugin;\n\n/**\n * Plugin options base interface\n */\nexport interface PluginOptions {\n /** Include only specific contracts/functions */\n include?: string[];\n\n /** Exclude specific contracts/functions */\n exclude?: string[];\n\n /** Enable debug output */\n debug?: boolean;\n}\n\n/**\n * Hook execution result\n */\nexport interface HookResult<T = any> {\n /** Whether the hook was successful */\n success: boolean;\n\n /** Result data from the hook */\n data?: T;\n\n /** Error if hook failed */\n error?: Error;\n\n /** Plugin that executed the hook */\n plugin: string;\n}\n\n/**\n * Plugin execution context for internal use\n */\nexport interface PluginExecutionContext {\n /** Current plugin being executed */\n currentPlugin?: SecondLayerPlugin;\n\n /** Execution phase */\n phase: \"config\" | \"generate\" | \"output\";\n\n /** Start time for performance tracking */\n startTime: number;\n\n /** Plugin execution results */\n results: Map<string, HookResult[]>;\n}\n"
|
|
8
9
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAIA;AAOA,eAAe,QAAQ,GAAmB;AAAA,EACzC,IAAI,CAAC,OAAO;AAAA,IACX,QAAQ,MAAM,MAAM,OAAO;AAAA,MAC1B,cAAc,aAAa;AAAA,IAC5B,CAAC;AAAA,IAED,MAAM,mBAAmB;AAAA,MACxB,WAAW;AAAA,QACV,SAAS;AAAA,QACT,aAAa;AAAA,QACb,WAAW;AAAA,MACZ;AAAA,M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,MAAM,GAAG,OAAO,QAAQ;AAAA,UACxB,OAAO;AAAA,UACP,MAAM;AAAA,UACN,OAAO;AAAA;AAAA;AAAA,MAIX,UAAU,OAAO,aAAqB;AAAA,QACpC,OAAO,GAAG,SAAS,UAAU,OAAO;AAAA;AAAA,MAGtC,WAAW,OAAO,UAAkB,YAAoB;AAAA,QACtD,MAAM,GAAG,UAAU,UAAU,SAAS,OAAO;AAAA;AAAA,MAG/C,WAAW,OAAO,YAAoB;AAAA,QACpC,MAAM,GAAG,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA;AAAA,IAE/C;AAAA;AAEJ;",
|
|
11
|
+
"debugId": "F79C39134E35BDE464756E2164756E21",
|
|
11
12
|
"names": []
|
|
12
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/cli",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "CLI for generating type-safe contract interfaces for the Stacks blockchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "bunup",
|
|
27
27
|
"dev": "bunup --watch",
|
|
28
|
-
"test": "
|
|
28
|
+
"test": "bun test",
|
|
29
29
|
"typecheck": "tsc --noEmit",
|
|
30
30
|
"prepublishOnly": "bun run build"
|
|
31
31
|
},
|
|
@@ -39,26 +39,30 @@
|
|
|
39
39
|
"author": "",
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
42
|
+
"@inquirer/prompts": "^8.2.0",
|
|
43
|
+
"@secondlayer/sdk": "^0.3.0",
|
|
44
|
+
"@secondlayer/shared": "^0.2.0",
|
|
45
|
+
"@secondlayer/stacks": "workspace:*",
|
|
46
|
+
"@secondlayer/views": "^0.2.0",
|
|
47
|
+
"@biomejs/js-api": "^0.7.0",
|
|
48
|
+
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
44
49
|
"esbuild": "^0.19.0",
|
|
45
|
-
"
|
|
50
|
+
"zod": "^3.24.1"
|
|
46
51
|
},
|
|
47
52
|
"devDependencies": {
|
|
48
53
|
"@antfu/ni": "^24.4.0",
|
|
49
54
|
"@hirosystems/clarinet-sdk": "^3.0.2",
|
|
50
|
-
"@stacks/connect": "^8.1.9",
|
|
51
55
|
"@tanstack/react-query": "^5.77.0",
|
|
52
56
|
"@types/bun": "^1.1.14",
|
|
53
57
|
"@types/react": "^19.1.5",
|
|
54
58
|
"chalk": "^5.3.0",
|
|
55
|
-
"commander": "^
|
|
59
|
+
"commander": "^14.0.0",
|
|
56
60
|
"execa": "^9.5.3",
|
|
57
61
|
"fast-glob": "^3.3.3",
|
|
58
62
|
"got": "^13.0.0",
|
|
59
63
|
"react": "^19.1.0"
|
|
60
64
|
},
|
|
61
65
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
66
|
+
"node": ">=20.19.0"
|
|
63
67
|
}
|
|
64
68
|
}
|