@shrkcrft/generator 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/conflict-handler.d.ts +12 -0
- package/dist/conflict-handler.d.ts.map +1 -0
- package/dist/conflict-handler.js +25 -0
- package/dist/dry-run.d.ts +10 -0
- package/dist/dry-run.d.ts.map +1 -0
- package/dist/dry-run.js +178 -0
- package/dist/file-change.d.ts +46 -0
- package/dist/file-change.d.ts.map +1 -0
- package/dist/file-change.js +22 -0
- package/dist/folder-apply.d.ts +29 -0
- package/dist/folder-apply.d.ts.map +1 -0
- package/dist/folder-apply.js +117 -0
- package/dist/folder-safety.d.ts +12 -0
- package/dist/folder-safety.d.ts.map +1 -0
- package/dist/folder-safety.js +75 -0
- package/dist/generation-plan.d.ts +24 -0
- package/dist/generation-plan.d.ts.map +1 -0
- package/dist/generation-plan.js +1 -0
- package/dist/generation-request.d.ts +14 -0
- package/dist/generation-request.d.ts.map +1 -0
- package/dist/generation-request.js +1 -0
- package/dist/generator-engine.d.ts +12 -0
- package/dist/generator-engine.d.ts.map +1 -0
- package/dist/generator-engine.js +74 -0
- package/dist/grounding/extracted-plan.d.ts +42 -0
- package/dist/grounding/extracted-plan.d.ts.map +1 -0
- package/dist/grounding/extracted-plan.js +12 -0
- package/dist/grounding/extractor-registry.d.ts +21 -0
- package/dist/grounding/extractor-registry.d.ts.map +1 -0
- package/dist/grounding/extractor-registry.js +30 -0
- package/dist/grounding/extractor.d.ts +24 -0
- package/dist/grounding/extractor.d.ts.map +1 -0
- package/dist/grounding/extractor.js +8 -0
- package/dist/grounding/extractors/markdown-frontmatter-loose.d.ts +17 -0
- package/dist/grounding/extractors/markdown-frontmatter-loose.d.ts.map +1 -0
- package/dist/grounding/extractors/markdown-frontmatter-loose.js +160 -0
- package/dist/grounding/extractors/sharkcraft-spec-v1.d.ts +12 -0
- package/dist/grounding/extractors/sharkcraft-spec-v1.d.ts.map +1 -0
- package/dist/grounding/extractors/sharkcraft-spec-v1.js +56 -0
- package/dist/grounding/index.d.ts +6 -0
- package/dist/grounding/index.d.ts.map +1 -0
- package/dist/grounding/index.js +5 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/naming-strategy.d.ts +5 -0
- package/dist/naming-strategy.d.ts.map +1 -0
- package/dist/naming-strategy.js +28 -0
- package/dist/overwrite-strategy.d.ts +14 -0
- package/dist/overwrite-strategy.d.ts.map +1 -0
- package/dist/overwrite-strategy.js +15 -0
- package/dist/plan-signing.d.ts +37 -0
- package/dist/plan-signing.d.ts.map +1 -0
- package/dist/plan-signing.js +82 -0
- package/dist/planned-change.d.ts +167 -0
- package/dist/planned-change.d.ts.map +1 -0
- package/dist/planned-change.js +507 -0
- package/dist/saved-plan.d.ts +110 -0
- package/dist/saved-plan.d.ts.map +1 -0
- package/dist/saved-plan.js +281 -0
- package/dist/spec/index.d.ts +7 -0
- package/dist/spec/index.d.ts.map +1 -0
- package/dist/spec/index.js +6 -0
- package/dist/spec/spec-derive.d.ts +15 -0
- package/dist/spec/spec-derive.d.ts.map +1 -0
- package/dist/spec/spec-derive.js +294 -0
- package/dist/spec/spec-frontmatter.d.ts +37 -0
- package/dist/spec/spec-frontmatter.d.ts.map +1 -0
- package/dist/spec/spec-frontmatter.js +497 -0
- package/dist/spec/spec-id.d.ts +30 -0
- package/dist/spec/spec-id.d.ts.map +1 -0
- package/dist/spec/spec-id.js +38 -0
- package/dist/spec/spec-io.d.ts +56 -0
- package/dist/spec/spec-io.d.ts.map +1 -0
- package/dist/spec/spec-io.js +176 -0
- package/dist/spec/spec-model.d.ts +117 -0
- package/dist/spec/spec-model.d.ts.map +1 -0
- package/dist/spec/spec-model.js +225 -0
- package/dist/spec/spec-scaffold.d.ts +32 -0
- package/dist/spec/spec-scaffold.d.ts.map +1 -0
- package/dist/spec/spec-scaffold.js +106 -0
- package/dist/synthetic-plan.d.ts +14 -0
- package/dist/synthetic-plan.d.ts.map +1 -0
- package/dist/synthetic-plan.js +123 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SharkCraft contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @shrkcrft/generator
|
|
2
|
+
|
|
3
|
+
SharkCraft plan-first generator: GenerationPlan, FileChange, dry-run, safe writes.
|
|
4
|
+
|
|
5
|
+
Part of [SharkCraft](https://github.com/shrkcrft/sharkcraft) — a deterministic, local-first toolkit that gives AI coding agents durable project context. See the main repo for documentation, examples, and the `shrk` CLI.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @shrkcrft/generator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OverwriteStrategy } from './overwrite-strategy.js';
|
|
2
|
+
import { FileChangeType, type IFileChange } from './file-change.js';
|
|
3
|
+
export interface IConflictDecision {
|
|
4
|
+
type: FileChangeType;
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function decideForExisting(strategy: OverwriteStrategy, existingContent: string, newContent: string): IConflictDecision;
|
|
8
|
+
export declare function summarizeConflicts(changes: readonly IFileChange[]): {
|
|
9
|
+
hasConflicts: boolean;
|
|
10
|
+
count: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=conflict-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-handler.d.ts","sourceRoot":"","sources":["../src/conflict-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACjB,iBAAiB,CAkBnB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG;IACnE,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAGA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OverwriteStrategy } from "./overwrite-strategy.js";
|
|
2
|
+
import { FileChangeType } from "./file-change.js";
|
|
3
|
+
export function decideForExisting(strategy, existingContent, newContent) {
|
|
4
|
+
if (existingContent === newContent) {
|
|
5
|
+
return { type: FileChangeType.Skip, reason: 'No changes (identical contents)' };
|
|
6
|
+
}
|
|
7
|
+
switch (strategy) {
|
|
8
|
+
case OverwriteStrategy.Overwrite:
|
|
9
|
+
return { type: FileChangeType.Update, reason: 'overwrite strategy: overwrite' };
|
|
10
|
+
case OverwriteStrategy.Ask:
|
|
11
|
+
return { type: FileChangeType.Conflict, reason: 'overwrite strategy: ask (requires user)' };
|
|
12
|
+
case OverwriteStrategy.MergeLater:
|
|
13
|
+
return {
|
|
14
|
+
type: FileChangeType.Conflict,
|
|
15
|
+
reason: 'overwrite strategy: merge-later (would conflict)',
|
|
16
|
+
};
|
|
17
|
+
case OverwriteStrategy.Never:
|
|
18
|
+
default:
|
|
19
|
+
return { type: FileChangeType.Conflict, reason: 'overwrite strategy: never (file exists)' };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function summarizeConflicts(changes) {
|
|
23
|
+
const count = changes.filter((c) => c.type === FileChangeType.Conflict).length;
|
|
24
|
+
return { hasConflicts: count > 0, count };
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ITemplateDefinition } from '@shrkcrft/templates';
|
|
2
|
+
import type { IGenerationRequest } from './generation-request.js';
|
|
3
|
+
import type { IGenerationPlan } from './generation-plan.js';
|
|
4
|
+
export interface IDryRunResult {
|
|
5
|
+
plan: IGenerationPlan;
|
|
6
|
+
/** True if the plan can be safely written without conflicts. */
|
|
7
|
+
safe: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function planGeneration(template: ITemplateDefinition, request: IGenerationRequest): IDryRunResult;
|
|
10
|
+
//# sourceMappingURL=dry-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dry-run.d.ts","sourceRoot":"","sources":["../src/dry-run.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAW5D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,eAAe,CAAC;IACtB,gEAAgE;IAChE,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAmGf"}
|
package/dist/dry-run.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { safeResolveTargetPath } from '@shrkcrft/core';
|
|
3
|
+
import { renderTemplate, validateTemplateVariables, } from '@shrkcrft/templates';
|
|
4
|
+
import { OverwriteStrategy } from "./overwrite-strategy.js";
|
|
5
|
+
import { FileChangeType } from "./file-change.js";
|
|
6
|
+
import { decideForExisting, summarizeConflicts } from "./conflict-handler.js";
|
|
7
|
+
import { buildNameVariables } from "./naming-strategy.js";
|
|
8
|
+
import { evaluatePlannedChange, } from "./planned-change.js";
|
|
9
|
+
export function planGeneration(template, request) {
|
|
10
|
+
const warnings = [];
|
|
11
|
+
const overwriteStrategy = request.overwriteStrategy ?? OverwriteStrategy.Never;
|
|
12
|
+
const nameVars = request.name ? buildNameVariables(request.name) : {};
|
|
13
|
+
const merged = { ...nameVars, ...request.variables };
|
|
14
|
+
const validation = validateTemplateVariables(template.variables, merged);
|
|
15
|
+
if (!validation.valid) {
|
|
16
|
+
for (const issue of validation.issues)
|
|
17
|
+
warnings.push(`${issue.variable}: ${issue.message}`);
|
|
18
|
+
return {
|
|
19
|
+
plan: {
|
|
20
|
+
templateId: template.id,
|
|
21
|
+
templateName: template.name,
|
|
22
|
+
changes: [],
|
|
23
|
+
totalFiles: 0,
|
|
24
|
+
hasConflicts: false,
|
|
25
|
+
warnings,
|
|
26
|
+
postGenerationNotes: template.postGenerationNotes ?? [],
|
|
27
|
+
},
|
|
28
|
+
safe: false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const rendered = renderTemplate(template, validation.resolved);
|
|
32
|
+
const changes = [];
|
|
33
|
+
// 1) Legacy CREATE-only files() output — unchanged behaviour.
|
|
34
|
+
for (const file of rendered.files) {
|
|
35
|
+
let safe;
|
|
36
|
+
try {
|
|
37
|
+
safe = safeResolveTargetPath(file.targetPath, request.projectRoot);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
const err = e;
|
|
41
|
+
changes.push({
|
|
42
|
+
type: FileChangeType.Conflict,
|
|
43
|
+
absolutePath: err.rawPath,
|
|
44
|
+
relativePath: err.rawPath,
|
|
45
|
+
contents: file.content,
|
|
46
|
+
reason: `Refused unsafe target path (${err.code}): ${err.message}`,
|
|
47
|
+
sizeBytes: Buffer.byteLength(file.content, 'utf8'),
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const absolutePath = safe.absolutePath;
|
|
52
|
+
const relPath = safe.relativePath;
|
|
53
|
+
if (existsSync(absolutePath)) {
|
|
54
|
+
let existing = '';
|
|
55
|
+
try {
|
|
56
|
+
existing = readFileSync(absolutePath, 'utf8');
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// unreadable existing file — treat as conflict
|
|
60
|
+
}
|
|
61
|
+
const decision = decideForExisting(file.overwrite ? OverwriteStrategy.Overwrite : overwriteStrategy, existing, file.content);
|
|
62
|
+
changes.push({
|
|
63
|
+
type: decision.type,
|
|
64
|
+
absolutePath,
|
|
65
|
+
relativePath: relPath,
|
|
66
|
+
contents: decision.type === FileChangeType.Skip ? existing : file.content,
|
|
67
|
+
reason: decision.reason,
|
|
68
|
+
sizeBytes: Buffer.byteLength(file.content, 'utf8'),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
changes.push({
|
|
73
|
+
type: FileChangeType.Create,
|
|
74
|
+
absolutePath,
|
|
75
|
+
relativePath: relPath,
|
|
76
|
+
contents: file.content,
|
|
77
|
+
reason: 'New file (does not exist)',
|
|
78
|
+
sizeBytes: Buffer.byteLength(file.content, 'utf8'),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// 2) v2 planned changes — evaluate against live filesystem.
|
|
83
|
+
for (const tplChange of rendered.changes) {
|
|
84
|
+
const evaluated = planOne(tplChange, request.projectRoot);
|
|
85
|
+
changes.push(evaluated);
|
|
86
|
+
}
|
|
87
|
+
const { hasConflicts } = summarizeConflicts(changes);
|
|
88
|
+
return {
|
|
89
|
+
plan: {
|
|
90
|
+
templateId: template.id,
|
|
91
|
+
templateName: template.name,
|
|
92
|
+
changes,
|
|
93
|
+
totalFiles: changes.length,
|
|
94
|
+
hasConflicts,
|
|
95
|
+
warnings,
|
|
96
|
+
postGenerationNotes: rendered.postGenerationNotes,
|
|
97
|
+
},
|
|
98
|
+
safe: !hasConflicts && changes.length > 0,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function planOne(tplChange, projectRoot) {
|
|
102
|
+
const op = tplChange.operation;
|
|
103
|
+
let safe;
|
|
104
|
+
try {
|
|
105
|
+
safe = safeResolveTargetPath(tplChange.targetPath, projectRoot);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
const err = e;
|
|
109
|
+
const previewContent = previewContentForOperation(op);
|
|
110
|
+
return {
|
|
111
|
+
type: FileChangeType.Conflict,
|
|
112
|
+
absolutePath: err.rawPath,
|
|
113
|
+
relativePath: err.rawPath,
|
|
114
|
+
contents: previewContent,
|
|
115
|
+
reason: `Refused unsafe target path (${err.code}): ${err.message}`,
|
|
116
|
+
sizeBytes: Buffer.byteLength(previewContent, 'utf8'),
|
|
117
|
+
operation: op,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const change = {
|
|
121
|
+
targetPath: tplChange.targetPath,
|
|
122
|
+
operation: op,
|
|
123
|
+
};
|
|
124
|
+
const existing = existsSync(safe.absolutePath)
|
|
125
|
+
? readFileSafe(safe.absolutePath)
|
|
126
|
+
: null;
|
|
127
|
+
return evaluatePlannedChange({
|
|
128
|
+
change,
|
|
129
|
+
absolutePath: safe.absolutePath,
|
|
130
|
+
relativePath: safe.relativePath,
|
|
131
|
+
existing,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function readFileSafe(absolutePath) {
|
|
135
|
+
try {
|
|
136
|
+
return readFileSync(absolutePath, 'utf8');
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function previewContentForOperation(op) {
|
|
143
|
+
switch (op.kind) {
|
|
144
|
+
case 'create':
|
|
145
|
+
return op.content;
|
|
146
|
+
case 'append':
|
|
147
|
+
case 'insert-after':
|
|
148
|
+
case 'insert-before':
|
|
149
|
+
return op.snippet;
|
|
150
|
+
case 'replace':
|
|
151
|
+
return op.replaceWith;
|
|
152
|
+
case 'export':
|
|
153
|
+
return op.symbols && op.symbols.length > 0
|
|
154
|
+
? `export { ${op.symbols.join(', ')} } from '${op.from}';`
|
|
155
|
+
: `export * from '${op.from}';`;
|
|
156
|
+
case 'ensure-import': {
|
|
157
|
+
const parts = [];
|
|
158
|
+
if (op.defaultBinding)
|
|
159
|
+
parts.push(op.defaultBinding);
|
|
160
|
+
if (op.namespaceBinding)
|
|
161
|
+
parts.push(`* as ${op.namespaceBinding}`);
|
|
162
|
+
if (op.symbols && op.symbols.length > 0)
|
|
163
|
+
parts.push(`{ ${op.symbols.join(', ')} }`);
|
|
164
|
+
const keyword = op.typeOnly ? 'import type' : 'import';
|
|
165
|
+
return parts.length > 0
|
|
166
|
+
? `${keyword} ${parts.join(', ')} from '${op.from}';`
|
|
167
|
+
: `${keyword} '${op.from}';`;
|
|
168
|
+
}
|
|
169
|
+
case 'insert-enum-entry':
|
|
170
|
+
return `${op.enumName}.${op.entryName} = '${op.entryValue}'`;
|
|
171
|
+
case 'insert-object-entry':
|
|
172
|
+
return `${op.objectName}.${op.entryKey}: ${op.entryValue}`;
|
|
173
|
+
case 'insert-before-closing-brace':
|
|
174
|
+
return op.snippet;
|
|
175
|
+
case 'insert-between-anchors':
|
|
176
|
+
return op.snippet;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IPlannedOperation } from './planned-change.js';
|
|
2
|
+
export declare enum FileChangeType {
|
|
3
|
+
Create = "create",
|
|
4
|
+
/** Legacy v1 full-file overwrite when the same template is regenerated. */
|
|
5
|
+
Update = "update",
|
|
6
|
+
/** v2: append snippet at the end of an existing file. */
|
|
7
|
+
Append = "append",
|
|
8
|
+
/** v2: insert snippet immediately after an anchor in an existing file. */
|
|
9
|
+
InsertAfter = "insert-after",
|
|
10
|
+
/** v2: insert snippet immediately before an anchor in an existing file. */
|
|
11
|
+
InsertBefore = "insert-before",
|
|
12
|
+
/** v2: replace literal text in an existing file. */
|
|
13
|
+
Replace = "replace",
|
|
14
|
+
/** v2: append a barrel re-export to an existing index file. */
|
|
15
|
+
Export = "export",
|
|
16
|
+
/** Rename a folder. Apply-time only; preview-only by default. */
|
|
17
|
+
RenameFolder = "rename-folder",
|
|
18
|
+
/** Delete a folder. Hard-gated; preview-only by default. */
|
|
19
|
+
DeleteFolder = "delete-folder",
|
|
20
|
+
Skip = "skip",
|
|
21
|
+
Conflict = "conflict"
|
|
22
|
+
}
|
|
23
|
+
export interface IFileChange {
|
|
24
|
+
type: FileChangeType;
|
|
25
|
+
absolutePath: string;
|
|
26
|
+
relativePath: string;
|
|
27
|
+
/** Final contents that would be written. For Skip the existing file is shown unchanged. */
|
|
28
|
+
contents: string;
|
|
29
|
+
/** Reason why this change has this type. */
|
|
30
|
+
reason: string;
|
|
31
|
+
/** Size of contents in bytes. */
|
|
32
|
+
sizeBytes: number;
|
|
33
|
+
/**
|
|
34
|
+
* v2 only — the operation intent that produced this change. Absent on v1
|
|
35
|
+
* CREATE entries that come from `files()` templates. Used by:
|
|
36
|
+
* - `saved-plan` to persist intent (so signature covers the operation)
|
|
37
|
+
* - dry-run rendering to show structural info (anchor / snippet preview)
|
|
38
|
+
* - apply-time divergence detection
|
|
39
|
+
*
|
|
40
|
+
* Type-only import of `IPlannedOperation` is safe: TS erases the import
|
|
41
|
+
* at compile time, so there is no runtime cycle even though
|
|
42
|
+
* `planned-change.ts` imports `FileChangeType` from this file.
|
|
43
|
+
*/
|
|
44
|
+
operation?: IPlannedOperation;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=file-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-change.d.ts","sourceRoot":"","sources":["../src/file-change.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,2EAA2E;IAC3E,MAAM,WAAW;IACjB,yDAAyD;IACzD,MAAM,WAAW;IACjB,0EAA0E;IAC1E,WAAW,iBAAiB;IAC5B,2EAA2E;IAC3E,YAAY,kBAAkB;IAC9B,oDAAoD;IACpD,OAAO,YAAY;IACnB,+DAA+D;IAC/D,MAAM,WAAW;IACjB,iEAAiE;IACjE,YAAY,kBAAkB;IAC9B,4DAA4D;IAC5D,YAAY,kBAAkB;IAC9B,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var FileChangeType;
|
|
2
|
+
(function (FileChangeType) {
|
|
3
|
+
FileChangeType["Create"] = "create";
|
|
4
|
+
/** Legacy v1 full-file overwrite when the same template is regenerated. */
|
|
5
|
+
FileChangeType["Update"] = "update";
|
|
6
|
+
/** v2: append snippet at the end of an existing file. */
|
|
7
|
+
FileChangeType["Append"] = "append";
|
|
8
|
+
/** v2: insert snippet immediately after an anchor in an existing file. */
|
|
9
|
+
FileChangeType["InsertAfter"] = "insert-after";
|
|
10
|
+
/** v2: insert snippet immediately before an anchor in an existing file. */
|
|
11
|
+
FileChangeType["InsertBefore"] = "insert-before";
|
|
12
|
+
/** v2: replace literal text in an existing file. */
|
|
13
|
+
FileChangeType["Replace"] = "replace";
|
|
14
|
+
/** v2: append a barrel re-export to an existing index file. */
|
|
15
|
+
FileChangeType["Export"] = "export";
|
|
16
|
+
/** Rename a folder. Apply-time only; preview-only by default. */
|
|
17
|
+
FileChangeType["RenameFolder"] = "rename-folder";
|
|
18
|
+
/** Delete a folder. Hard-gated; preview-only by default. */
|
|
19
|
+
FileChangeType["DeleteFolder"] = "delete-folder";
|
|
20
|
+
FileChangeType["Skip"] = "skip";
|
|
21
|
+
FileChangeType["Conflict"] = "conflict";
|
|
22
|
+
})(FileChangeType || (FileChangeType = {}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FolderOpSafety } from './folder-safety.js';
|
|
2
|
+
export interface IFolderOpInput {
|
|
3
|
+
readonly kind: 'rename-folder' | 'delete-folder';
|
|
4
|
+
readonly targetPath: string;
|
|
5
|
+
readonly newPath?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IFolderOpOptions {
|
|
8
|
+
readonly projectRoot: string;
|
|
9
|
+
readonly dryRun?: boolean;
|
|
10
|
+
readonly allowFolderOps?: boolean;
|
|
11
|
+
readonly allowDeleteFolder?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface IFolderOpResult {
|
|
14
|
+
readonly op: IFolderOpInput;
|
|
15
|
+
readonly applied: boolean;
|
|
16
|
+
readonly safety: FolderOpSafety;
|
|
17
|
+
readonly reason?: string;
|
|
18
|
+
readonly absTarget: string;
|
|
19
|
+
readonly absNewPath?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface IFolderOpApplyReport {
|
|
22
|
+
readonly schema: 'sharkcraft.folder-op-apply/v1';
|
|
23
|
+
readonly projectRoot: string;
|
|
24
|
+
readonly dryRun: boolean;
|
|
25
|
+
readonly applied: readonly IFolderOpResult[];
|
|
26
|
+
readonly rejected: readonly IFolderOpResult[];
|
|
27
|
+
}
|
|
28
|
+
export declare function applyFolderOps(ops: readonly IFolderOpInput[], options: IFolderOpOptions): IFolderOpApplyReport;
|
|
29
|
+
//# sourceMappingURL=folder-apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder-apply.d.ts","sourceRoot":"","sources":["../src/folder-apply.ts"],"names":[],"mappings":"AAcA,OAAO,EAAuB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAAC;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;CAC/C;AAMD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,SAAS,cAAc,EAAE,EAC9B,OAAO,EAAE,gBAAgB,GACxB,oBAAoB,CAsGtB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folder operation applier.
|
|
3
|
+
*
|
|
4
|
+
* Executes `rename-folder` / `delete-folder` operations with strict safety
|
|
5
|
+
* gates. Refuses unsafe paths *before* touching the filesystem. The CLI
|
|
6
|
+
* `shrk apply` command can call this once its plan schema knows how to
|
|
7
|
+
* carry folder ops in a saved plan; today plugin-lifecycle plans pass an
|
|
8
|
+
* `IPluginLifecycleFolderOp[]` directly.
|
|
9
|
+
*
|
|
10
|
+
* Read-only by default; mutates only when `dryRun === false` AND the
|
|
11
|
+
* caller has supplied the explicit allow flags.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, renameSync, rmSync } from 'node:fs';
|
|
14
|
+
import * as nodePath from 'node:path';
|
|
15
|
+
import { checkFolderOpSafety, FolderOpSafety } from "./folder-safety.js";
|
|
16
|
+
function resolveAbs(projectRoot, p) {
|
|
17
|
+
return nodePath.isAbsolute(p) ? p : nodePath.resolve(projectRoot, p);
|
|
18
|
+
}
|
|
19
|
+
export function applyFolderOps(ops, options) {
|
|
20
|
+
const applied = [];
|
|
21
|
+
const rejected = [];
|
|
22
|
+
const dryRun = options.dryRun !== false; // default true — explicit opt-in to mutate
|
|
23
|
+
for (const op of ops) {
|
|
24
|
+
const safetyOptions = {};
|
|
25
|
+
if (options.allowDeleteFolder)
|
|
26
|
+
safetyOptions.allowDeleteFolder = true;
|
|
27
|
+
const safety = checkFolderOpSafety(options.projectRoot, op.targetPath, op.kind, safetyOptions);
|
|
28
|
+
const absTarget = resolveAbs(options.projectRoot, op.targetPath);
|
|
29
|
+
const absNewPath = op.newPath ? resolveAbs(options.projectRoot, op.newPath) : undefined;
|
|
30
|
+
const baseResult = {
|
|
31
|
+
op,
|
|
32
|
+
safety: safety.safety,
|
|
33
|
+
...(safety.reason ? { reason: safety.reason } : {}),
|
|
34
|
+
absTarget,
|
|
35
|
+
...(absNewPath ? { absNewPath } : {}),
|
|
36
|
+
};
|
|
37
|
+
// 1) Safety must be green.
|
|
38
|
+
if (safety.safety !== FolderOpSafety.Safe) {
|
|
39
|
+
rejected.push({ ...baseResult, applied: false });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// 2) Allow-flag must be present.
|
|
43
|
+
if (!options.allowFolderOps) {
|
|
44
|
+
rejected.push({
|
|
45
|
+
...baseResult,
|
|
46
|
+
applied: false,
|
|
47
|
+
safety: FolderOpSafety.Unsafe,
|
|
48
|
+
reason: 'Folder op rejected — pass `--allow-folder-ops` to enable.',
|
|
49
|
+
});
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// 3) Rename specifics.
|
|
53
|
+
if (op.kind === 'rename-folder') {
|
|
54
|
+
if (!absNewPath) {
|
|
55
|
+
rejected.push({
|
|
56
|
+
...baseResult,
|
|
57
|
+
applied: false,
|
|
58
|
+
safety: FolderOpSafety.Unsafe,
|
|
59
|
+
reason: 'rename-folder requires `newPath`.',
|
|
60
|
+
});
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (existsSync(absNewPath)) {
|
|
64
|
+
rejected.push({
|
|
65
|
+
...baseResult,
|
|
66
|
+
applied: false,
|
|
67
|
+
safety: FolderOpSafety.Unsafe,
|
|
68
|
+
reason: `rename-folder destination "${op.newPath}" already exists.`,
|
|
69
|
+
});
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (dryRun) {
|
|
73
|
+
applied.push({ ...baseResult, applied: false });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
renameSync(absTarget, absNewPath);
|
|
78
|
+
applied.push({ ...baseResult, applied: true });
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
rejected.push({
|
|
82
|
+
...baseResult,
|
|
83
|
+
applied: false,
|
|
84
|
+
safety: FolderOpSafety.Unsafe,
|
|
85
|
+
reason: `rename failed: ${e.message}`,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// 4) Delete specifics — already gated by checkFolderOpSafety via allowDeleteFolder.
|
|
91
|
+
if (op.kind === 'delete-folder') {
|
|
92
|
+
if (dryRun) {
|
|
93
|
+
applied.push({ ...baseResult, applied: false });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
rmSync(absTarget, { recursive: true, force: false });
|
|
98
|
+
applied.push({ ...baseResult, applied: true });
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
rejected.push({
|
|
102
|
+
...baseResult,
|
|
103
|
+
applied: false,
|
|
104
|
+
safety: FolderOpSafety.Unsafe,
|
|
105
|
+
reason: `delete failed: ${e.message}`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
schema: 'sharkcraft.folder-op-apply/v1',
|
|
112
|
+
projectRoot: options.projectRoot,
|
|
113
|
+
dryRun,
|
|
114
|
+
applied,
|
|
115
|
+
rejected,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum FolderOpSafety {
|
|
2
|
+
Safe = "safe",
|
|
3
|
+
Unsafe = "unsafe"
|
|
4
|
+
}
|
|
5
|
+
export interface IFolderOpSafetyResult {
|
|
6
|
+
readonly safety: FolderOpSafety;
|
|
7
|
+
readonly reason?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function checkFolderOpSafety(projectRoot: string, target: string, kind: 'rename-folder' | 'delete-folder', options?: {
|
|
10
|
+
allowDeleteFolder?: boolean;
|
|
11
|
+
}): IFolderOpSafetyResult;
|
|
12
|
+
//# sourceMappingURL=folder-safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder-safety.d.ts","sourceRoot":"","sources":["../src/folder-safety.ts"],"names":[],"mappings":"AAeA,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,GAAG,eAAe,EACvC,OAAO,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,GACxC,qBAAqB,CAqDvB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hard safety gates for folder rename/delete plan operations.
|
|
3
|
+
*
|
|
4
|
+
* Folder ops are preview-only by default. Apply must refuse:
|
|
5
|
+
* - paths outside the project root
|
|
6
|
+
* - paths inside `.git`, `node_modules`, home directories
|
|
7
|
+
* - empty / root / absolute paths
|
|
8
|
+
* - paths that resolve to the project root itself
|
|
9
|
+
*
|
|
10
|
+
* Read-only safety helpers; no side effects.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, statSync } from 'node:fs';
|
|
13
|
+
import * as nodePath from 'node:path';
|
|
14
|
+
import * as nodeOs from 'node:os';
|
|
15
|
+
export var FolderOpSafety;
|
|
16
|
+
(function (FolderOpSafety) {
|
|
17
|
+
FolderOpSafety["Safe"] = "safe";
|
|
18
|
+
FolderOpSafety["Unsafe"] = "unsafe";
|
|
19
|
+
})(FolderOpSafety || (FolderOpSafety = {}));
|
|
20
|
+
const FORBIDDEN_SEGMENTS = new Set(['.git', 'node_modules', '.svn', '.hg']);
|
|
21
|
+
export function checkFolderOpSafety(projectRoot, target, kind, options) {
|
|
22
|
+
if (!target || target === '/' || target === '.') {
|
|
23
|
+
return { safety: FolderOpSafety.Unsafe, reason: `Target path "${target}" is the project root or empty.` };
|
|
24
|
+
}
|
|
25
|
+
const abs = nodePath.isAbsolute(target) ? target : nodePath.resolve(projectRoot, target);
|
|
26
|
+
const normalisedRoot = nodePath.resolve(projectRoot);
|
|
27
|
+
const home = nodeOs.homedir();
|
|
28
|
+
// Must be inside project root.
|
|
29
|
+
const rel = nodePath.relative(normalisedRoot, abs);
|
|
30
|
+
if (rel.startsWith('..') || nodePath.isAbsolute(rel)) {
|
|
31
|
+
return {
|
|
32
|
+
safety: FolderOpSafety.Unsafe,
|
|
33
|
+
reason: `Target path "${target}" resolves to "${abs}" which is outside the project root "${normalisedRoot}".`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (abs === normalisedRoot) {
|
|
37
|
+
return { safety: FolderOpSafety.Unsafe, reason: 'Target path resolves to the project root.' };
|
|
38
|
+
}
|
|
39
|
+
if (abs === home || abs === '/') {
|
|
40
|
+
return { safety: FolderOpSafety.Unsafe, reason: `Target path resolves to "${abs}" — refuses to operate on home/root directories.` };
|
|
41
|
+
}
|
|
42
|
+
for (const seg of abs.split(nodePath.sep)) {
|
|
43
|
+
if (FORBIDDEN_SEGMENTS.has(seg)) {
|
|
44
|
+
return {
|
|
45
|
+
safety: FolderOpSafety.Unsafe,
|
|
46
|
+
reason: `Target path "${target}" contains forbidden segment "${seg}".`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (kind === 'delete-folder' && !options?.allowDeleteFolder) {
|
|
51
|
+
return {
|
|
52
|
+
safety: FolderOpSafety.Unsafe,
|
|
53
|
+
reason: 'delete-folder requires explicit `--allow-delete-folder` flag at apply time.',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Existing folder check for rename (must exist).
|
|
57
|
+
if (kind === 'rename-folder' && !existsSync(abs)) {
|
|
58
|
+
return {
|
|
59
|
+
safety: FolderOpSafety.Unsafe,
|
|
60
|
+
reason: `rename-folder target "${target}" does not exist.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (kind === 'delete-folder' && existsSync(abs)) {
|
|
64
|
+
try {
|
|
65
|
+
const st = statSync(abs);
|
|
66
|
+
if (!st.isDirectory()) {
|
|
67
|
+
return { safety: FolderOpSafety.Unsafe, reason: `delete-folder target "${target}" is not a directory.` };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// ignore
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { safety: FolderOpSafety.Safe };
|
|
75
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IFileChange } from './file-change.js';
|
|
2
|
+
import type { ISavedPlanFolderOp } from './saved-plan.js';
|
|
3
|
+
export interface IGenerationPlan {
|
|
4
|
+
templateId: string;
|
|
5
|
+
templateName: string;
|
|
6
|
+
changes: readonly IFileChange[];
|
|
7
|
+
totalFiles: number;
|
|
8
|
+
hasConflicts: boolean;
|
|
9
|
+
warnings: readonly string[];
|
|
10
|
+
postGenerationNotes: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Optional folder operations attached to the plan. Carried verbatim
|
|
13
|
+
* into saved plans and executed via `applyFolderOps()` during `shrk apply`
|
|
14
|
+
* when explicit allow flags are present.
|
|
15
|
+
*/
|
|
16
|
+
folderOps?: readonly ISavedPlanFolderOp[];
|
|
17
|
+
}
|
|
18
|
+
export interface IGenerationSummary {
|
|
19
|
+
written: number;
|
|
20
|
+
skipped: number;
|
|
21
|
+
conflicts: number;
|
|
22
|
+
totalBytes: number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=generation-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-plan.d.ts","sourceRoot":"","sources":["../src/generation-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TemplateVariableValues } from '@shrkcrft/templates';
|
|
2
|
+
import type { NamingStrategy, OverwriteStrategy } from './overwrite-strategy.js';
|
|
3
|
+
export interface IGenerationRequest {
|
|
4
|
+
templateId: string;
|
|
5
|
+
/** Primary "name" passed to the template — used as the kebab-case basename, etc. */
|
|
6
|
+
name?: string;
|
|
7
|
+
variables: TemplateVariableValues;
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
overwriteStrategy?: OverwriteStrategy;
|
|
10
|
+
namingStrategy?: NamingStrategy;
|
|
11
|
+
/** If false (default), no files are written — only the plan is returned. */
|
|
12
|
+
write?: boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=generation-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-request.d.ts","sourceRoot":"","sources":["../src/generation-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,sBAAsB,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AppError, type Result } from '@shrkcrft/core';
|
|
2
|
+
import type { ITemplateDefinition } from '@shrkcrft/templates';
|
|
3
|
+
import type { IGenerationRequest } from './generation-request.js';
|
|
4
|
+
import type { IGenerationPlan, IGenerationSummary } from './generation-plan.js';
|
|
5
|
+
import { type IFileChange } from './file-change.js';
|
|
6
|
+
export interface IGenerationResult {
|
|
7
|
+
plan: IGenerationPlan;
|
|
8
|
+
summary: IGenerationSummary;
|
|
9
|
+
written: readonly IFileChange[];
|
|
10
|
+
}
|
|
11
|
+
export declare function generate(template: ITemplateDefinition, request: IGenerationRequest): Result<IGenerationResult, AppError>;
|
|
12
|
+
//# sourceMappingURL=generator-engine.d.ts.map
|