@domain-first/project-structure 8.3.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/287.js +118 -30
- package/dist/561.js +59 -33
- package/dist/agent-cli.d.ts +23 -1
- package/dist/agent-requests.d.ts +44 -0
- package/dist/index.cjs +146 -32
- package/dist/integration.cjs +175 -61
- package/dist/react-module-move.d.ts +26 -3
- package/dist/react.cjs +188 -62
- package/dist/react.js +13 -1
- package/package.json +1 -1
- package/skills/df-ps-react/SKILL.md +4 -4
- package/skills/df-ps-react/references/generators.md +4 -0
- package/skills/df-ps-scaffold/SKILL.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +4 -0
package/README.md
CHANGED
|
@@ -269,7 +269,7 @@ admin/panel/users → pages/admin/panel/admin-panel-users-page.tsx (AdminPane
|
|
|
269
269
|
|
|
270
270
|
With Next.js, a new page also gets its App Router route, `app/admin/panel/users/page.tsx`, which renders `AdminPanelUsersPage`. An existing route is never overwritten.
|
|
271
271
|
|
|
272
|
-
**Move or rename page** and **Move or rename widget** move the files and update every import in the project. **Delete page** and **Delete widget** remove them once nothing imports them, a Next.js page's own route included if you say so. With Next.js, moving a page also offers to move its route, `app/admin/users/` → `app/backoffice/users/`, since its URL changes with it.
|
|
272
|
+
**Move or rename page** and **Move or rename widget** move the files and update every import in the project. **Delete page** and **Delete widget** remove them once nothing imports them, a Next.js page's own route included if you say so. UI-kit components and shared hooks can be moved, renamed and deleted the same way. With Next.js, moving a page also offers to move its route, `app/admin/users/` → `app/backoffice/users/`, since its URL changes with it.
|
|
273
273
|
|
|
274
274
|
### How to add tooling
|
|
275
275
|
|
package/dist/287.js
CHANGED
|
@@ -2853,6 +2853,66 @@ const inMemoryRepositoryWiring = (ownerFolder, unit, wireFile)=>(implementation,
|
|
|
2853
2853
|
wireInMemoryDb(wireFile, implementation.className);
|
|
2854
2854
|
return true;
|
|
2855
2855
|
};
|
|
2856
|
+
const reactKindLayouts = {
|
|
2857
|
+
page: {
|
|
2858
|
+
folder: 'pages',
|
|
2859
|
+
nested: true,
|
|
2860
|
+
inFolder: false,
|
|
2861
|
+
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
2862
|
+
target: (reactFolder, { folders, fileName })=>node_path.join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`),
|
|
2863
|
+
classPrefix: '(use)?',
|
|
2864
|
+
classSuffix: 'Page'
|
|
2865
|
+
},
|
|
2866
|
+
widget: {
|
|
2867
|
+
folder: 'widgets',
|
|
2868
|
+
nested: true,
|
|
2869
|
+
inFolder: true,
|
|
2870
|
+
target: (reactFolder, { folders, folderName })=>node_path.join(reactFolder, 'widgets', ...folders, folderName),
|
|
2871
|
+
classPrefix: '(use)?',
|
|
2872
|
+
classSuffix: 'Widget|UIModel',
|
|
2873
|
+
storyTitle: (segments)=>[
|
|
2874
|
+
'Widgets',
|
|
2875
|
+
...segments
|
|
2876
|
+
].join('/')
|
|
2877
|
+
},
|
|
2878
|
+
'ui-kit': {
|
|
2879
|
+
folder: 'ui-kit',
|
|
2880
|
+
nested: false,
|
|
2881
|
+
inFolder: true,
|
|
2882
|
+
target: (reactFolder, { fileName })=>node_path.join(reactFolder, 'ui-kit', fileName),
|
|
2883
|
+
classPrefix: '()',
|
|
2884
|
+
classSuffix: 'Props(?![\\w$])|(?![\\w$])',
|
|
2885
|
+
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
2886
|
+
},
|
|
2887
|
+
hook: {
|
|
2888
|
+
folder: 'hooks',
|
|
2889
|
+
nested: false,
|
|
2890
|
+
inFolder: false,
|
|
2891
|
+
ownFile: (fileBase)=>new RegExp(`^use-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
2892
|
+
target: (reactFolder, { fileName })=>node_path.join(reactFolder, 'hooks', `use-${fileName}.ts`),
|
|
2893
|
+
classPrefix: '(use)',
|
|
2894
|
+
classSuffix: '(?![\\w$])'
|
|
2895
|
+
}
|
|
2896
|
+
};
|
|
2897
|
+
const reactKindTitles = {
|
|
2898
|
+
page: [
|
|
2899
|
+
'Page',
|
|
2900
|
+
'pages'
|
|
2901
|
+
],
|
|
2902
|
+
widget: [
|
|
2903
|
+
'Widget',
|
|
2904
|
+
'widgets'
|
|
2905
|
+
],
|
|
2906
|
+
'ui-kit': [
|
|
2907
|
+
'UI-kit component',
|
|
2908
|
+
'UI-kit components'
|
|
2909
|
+
],
|
|
2910
|
+
hook: [
|
|
2911
|
+
'Shared hook',
|
|
2912
|
+
'shared hooks'
|
|
2913
|
+
]
|
|
2914
|
+
};
|
|
2915
|
+
const reactModuleName = (kind, rawName)=>'hook' === kind ? rawName.trim().replace(/^use-/, '') : rawName;
|
|
2856
2916
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
2857
2917
|
const prefix = `${folders.join('-')}-`;
|
|
2858
2918
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -2866,8 +2926,36 @@ const declaredClassName = (filePath, suffix, name)=>{
|
|
|
2866
2926
|
const declared = content.match(new RegExp(`export\\s+(?:const|function)\\s+(\\w+)${suffix}\\b`))?.[1];
|
|
2867
2927
|
return declared ?? new NestedName(name).ClassName;
|
|
2868
2928
|
};
|
|
2929
|
+
const findUiKit = (reactFolder)=>{
|
|
2930
|
+
const root = node_path.join(reactFolder, 'ui-kit');
|
|
2931
|
+
if (!node_fs.existsSync(root)) return [];
|
|
2932
|
+
return node_fs.readdirSync(root, {
|
|
2933
|
+
withFileTypes: true
|
|
2934
|
+
}).filter((entry)=>entry.isDirectory() && node_fs.existsSync(node_path.join(root, entry.name, `${entry.name}.tsx`))).map(({ name })=>({
|
|
2935
|
+
kind: 'ui-kit',
|
|
2936
|
+
name,
|
|
2937
|
+
path: node_path.join(root, name),
|
|
2938
|
+
fileBase: name,
|
|
2939
|
+
ClassName: declaredClassName(node_path.join(root, name, `${name}.tsx`), '', name)
|
|
2940
|
+
}));
|
|
2941
|
+
};
|
|
2942
|
+
const findHooks = (reactFolder)=>{
|
|
2943
|
+
const root = node_path.join(reactFolder, 'hooks');
|
|
2944
|
+
if (!node_fs.existsSync(root)) return [];
|
|
2945
|
+
return node_fs.readdirSync(root).filter((file)=>/^use-.+\.tsx?$/.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
2946
|
+
const name = file.replace(/^use-/, '').replace(/\.tsx?$/, '');
|
|
2947
|
+
const content = node_fs.readFileSync(node_path.join(root, file), 'utf8');
|
|
2948
|
+
return {
|
|
2949
|
+
kind: 'hook',
|
|
2950
|
+
name,
|
|
2951
|
+
path: node_path.join(root, file),
|
|
2952
|
+
fileBase: name,
|
|
2953
|
+
ClassName: content.match(/export\s+(?:const|function)\s+use(\w+)\b/)?.[1] ?? new NestedName(name).ClassName
|
|
2954
|
+
};
|
|
2955
|
+
});
|
|
2956
|
+
};
|
|
2869
2957
|
const findReactModules = (reactFolder, kind)=>{
|
|
2870
|
-
const modules = 'page' === kind ? walk(node_path.join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
|
|
2958
|
+
const modules = 'ui-kit' === kind ? findUiKit(reactFolder) : 'hook' === kind ? findHooks(reactFolder) : 'page' === kind ? walk(node_path.join(reactFolder, 'pages')).filter((file)=>file.endsWith('-page.tsx')).map((file)=>{
|
|
2871
2959
|
const folders = node_path.relative(node_path.join(reactFolder, 'pages'), node_path.dirname(file)).split(node_path.sep).filter((segment)=>!!segment);
|
|
2872
2960
|
const fileBase = node_path.basename(file, '-page.tsx');
|
|
2873
2961
|
const name = react_module_move_nestedName(folders, fileBase);
|
|
@@ -2891,13 +2979,11 @@ const findReactModules = (reactFolder, kind)=>{
|
|
|
2891
2979
|
});
|
|
2892
2980
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
2893
2981
|
};
|
|
2894
|
-
const targetPath = (reactFolder, module, rawName)=>
|
|
2895
|
-
const { folders, folderName, fileName } = new NestedName(rawName);
|
|
2896
|
-
return 'page' === module.kind ? node_path.join(reactFolder, 'pages', ...folders, `${fileName}-page.tsx`) : node_path.join(reactFolder, 'widgets', ...folders, folderName);
|
|
2897
|
-
};
|
|
2982
|
+
const targetPath = (reactFolder, module, rawName)=>reactKindLayouts[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
2898
2983
|
const validateMove = (reactFolder, module, rawName)=>{
|
|
2899
2984
|
const nameError = NestedName.validate(rawName);
|
|
2900
2985
|
if (true !== nameError) return nameError;
|
|
2986
|
+
if (!reactKindLayouts[module.kind].nested && /[\\/]/.test(rawName)) return 'UI-kit components and shared hooks have no folders: enter a name without "/"';
|
|
2901
2987
|
const target = targetPath(reactFolder, module, rawName);
|
|
2902
2988
|
if (target !== module.path && node_fs.existsSync(target)) return `${node_path.relative(reactFolder, target)} already exists`;
|
|
2903
2989
|
if (target.startsWith(`${module.path}${node_path.sep}`)) return 'A widget cannot be moved into itself';
|
|
@@ -2911,13 +2997,14 @@ const routeFiles = (folder)=>node_fs.existsSync(folder) ? node_fs.readdirSync(fo
|
|
|
2911
2997
|
withFileTypes: true
|
|
2912
2998
|
}).filter((entry)=>entry.isFile()).map((entry)=>node_path.join(folder, entry.name)) : [];
|
|
2913
2999
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
2914
|
-
const
|
|
3000
|
+
const layout = reactKindLayouts[module.kind];
|
|
3001
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
2915
3002
|
const target = targetPath(reactFolder, module, rawName);
|
|
2916
3003
|
const newClassName = newName.ClassName;
|
|
2917
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.])`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
2918
|
-
const oldFolder =
|
|
2919
|
-
const newFolder =
|
|
2920
|
-
const ownsPath = (candidate)=>
|
|
3004
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(use-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, use = '')=>`${use}${newName.fileName}`);
|
|
3005
|
+
const oldFolder = layout.inFolder ? module.path : node_path.dirname(module.path);
|
|
3006
|
+
const newFolder = layout.inFolder ? target : node_path.dirname(target);
|
|
3007
|
+
const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${node_path.sep}`) : node_path.dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(node_path.basename(candidate));
|
|
2921
3008
|
const routeFileSet = new Set(route ? routeFiles(route.from) : []);
|
|
2922
3009
|
const routeTarget = (candidate)=>{
|
|
2923
3010
|
if (!route) return;
|
|
@@ -2937,7 +3024,7 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
2937
3024
|
segments[last] = renameFile(segments[last]);
|
|
2938
3025
|
return node_path.join(newFolder, ...segments);
|
|
2939
3026
|
};
|
|
2940
|
-
const moduleFiles =
|
|
3027
|
+
const moduleFiles = reactModuleFiles(module);
|
|
2941
3028
|
const moves = new Map([
|
|
2942
3029
|
...moduleFiles,
|
|
2943
3030
|
...routeFileSet
|
|
@@ -2945,14 +3032,14 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
2945
3032
|
file,
|
|
2946
3033
|
movedPath(file) ?? file
|
|
2947
3034
|
]));
|
|
2948
|
-
const
|
|
2949
|
-
const
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
const
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
].
|
|
3035
|
+
const classPattern = new RegExp(`(?<![\\w$])${layout.classPrefix}${escapeRegExp(module.ClassName)}(?=${layout.classSuffix})`, 'g');
|
|
3036
|
+
const oldTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
3037
|
+
module.ClassName
|
|
3038
|
+
] : module.name.split('/').map((segment)=>new NestedName(segment).ClassName));
|
|
3039
|
+
const titlePattern = oldTitle && new RegExp(`(['"\`])${escapeRegExp(oldTitle)}\\1`, 'g');
|
|
3040
|
+
const newTitle = layout.storyTitle?.('ui-kit' === module.kind ? [
|
|
3041
|
+
newClassName
|
|
3042
|
+
] : newName.classNameSegments);
|
|
2956
3043
|
return stageModuleMove({
|
|
2957
3044
|
projectRoot,
|
|
2958
3045
|
stopAt: reactFolder,
|
|
@@ -2960,8 +3047,8 @@ const moveReactModule = (projectRoot, reactFolder, module, rawName, route)=>{
|
|
|
2960
3047
|
moves,
|
|
2961
3048
|
movedPath,
|
|
2962
3049
|
rename: (content, { moved })=>{
|
|
2963
|
-
const renamed = content.replace(classPattern, (_, use
|
|
2964
|
-
return moved &&
|
|
3050
|
+
const renamed = content.replace(classPattern, (_, use)=>`${use ?? ''}${newClassName}`);
|
|
3051
|
+
return moved && titlePattern ? renamed.replace(titlePattern, (_, quote)=>`${quote}${newTitle}${quote}`) : renamed;
|
|
2965
3052
|
}
|
|
2966
3053
|
});
|
|
2967
3054
|
};
|
|
@@ -2971,9 +3058,10 @@ const pageRouteFolder = (appFolder, page)=>{
|
|
|
2971
3058
|
return node_fs.existsSync(routePage) && new RegExp(`(?<![\\w$])${page.ClassName}Page(?![\\w$])`).test(node_fs.readFileSync(routePage, 'utf8')) ? folder : void 0;
|
|
2972
3059
|
};
|
|
2973
3060
|
const reactModuleFiles = (module)=>{
|
|
2974
|
-
|
|
3061
|
+
const layout = reactKindLayouts[module.kind];
|
|
3062
|
+
if (layout.inFolder) return walk(module.path);
|
|
2975
3063
|
const folder = node_path.dirname(module.path);
|
|
2976
|
-
const own =
|
|
3064
|
+
const own = layout.ownFile(module.fileBase);
|
|
2977
3065
|
return node_fs.readdirSync(folder, {
|
|
2978
3066
|
withFileTypes: true
|
|
2979
3067
|
}).filter((entry)=>entry.isFile() && own.test(entry.name)).map((entry)=>node_path.join(folder, entry.name));
|
|
@@ -2987,7 +3075,7 @@ const deleteReactModule = (projectRoot, reactFolder, module, route)=>{
|
|
|
2987
3075
|
...routeFileList
|
|
2988
3076
|
]);
|
|
2989
3077
|
const stems = new Set(moduleFiles.map((file)=>file.replace(codeExtension, '')));
|
|
2990
|
-
const isModule = (resolved)=>stems.has(resolved) ||
|
|
3078
|
+
const isModule = (resolved)=>stems.has(resolved) || reactKindLayouts[module.kind].inFolder && (resolved === module.path || resolved.startsWith(`${module.path}${node_path.sep}`));
|
|
2991
3079
|
const { codeFiles, resolve } = projectImports(projectRoot);
|
|
2992
3080
|
const relative = (file)=>toPosix(node_path.relative(projectRoot, file));
|
|
2993
3081
|
const usedBy = [];
|
|
@@ -3078,11 +3166,11 @@ const deleteBackendUnitUseCase = async (ownerFolder)=>{
|
|
|
3078
3166
|
const deleteReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
3079
3167
|
const reactFolder = presentationReactFolder.path;
|
|
3080
3168
|
const modules = findReactModules(reactFolder, kind);
|
|
3081
|
-
if (!modules.length) return void report(`No ${kind}
|
|
3169
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
3082
3170
|
const module = await interaction_select({
|
|
3083
3171
|
key: 'module',
|
|
3084
3172
|
id: (value)=>value.name,
|
|
3085
|
-
message:
|
|
3173
|
+
message: `${reactKindTitles[kind][0]} to delete:`,
|
|
3086
3174
|
choices: modules.map((value)=>({
|
|
3087
3175
|
name: value.name,
|
|
3088
3176
|
value,
|
|
@@ -3524,11 +3612,11 @@ const promptRouteMove = async (root, page, newName)=>{
|
|
|
3524
3612
|
const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
3525
3613
|
const reactFolder = presentationReactFolder.path;
|
|
3526
3614
|
const modules = findReactModules(reactFolder, kind);
|
|
3527
|
-
if (!modules.length) return void report(`No ${kind}
|
|
3615
|
+
if (!modules.length) return void report(`No ${reactKindTitles[kind][1]} generated by df-react were found.`);
|
|
3528
3616
|
const module = await interaction_select({
|
|
3529
3617
|
key: 'module',
|
|
3530
3618
|
id: (value)=>value.name,
|
|
3531
|
-
message:
|
|
3619
|
+
message: `${reactKindTitles[kind][0]}:`,
|
|
3532
3620
|
choices: modules.map((value)=>({
|
|
3533
3621
|
name: value.name,
|
|
3534
3622
|
value,
|
|
@@ -3537,7 +3625,7 @@ const moveReactModuleUseCase = async (presentationReactFolder, kind)=>{
|
|
|
3537
3625
|
});
|
|
3538
3626
|
const name = await interaction_input({
|
|
3539
3627
|
key: 'name',
|
|
3540
|
-
message: 'New name (folders split by "/"):',
|
|
3628
|
+
message: reactKindLayouts[kind].nested ? 'New name (folders split by "/"):' : 'New name:',
|
|
3541
3629
|
default: module.name,
|
|
3542
3630
|
validate: (value)=>validateMove(reactFolder, module, value)
|
|
3543
3631
|
});
|
|
@@ -4794,4 +4882,4 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
|
|
|
4794
4882
|
break;
|
|
4795
4883
|
}
|
|
4796
4884
|
};
|
|
4797
|
-
export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
|
|
4885
|
+
export { RequestError, addIntegration, assertAnswersConsumed, configurationSections, deleteBackendUnitUseCase, deleteReactModuleUseCase, findBackendUnits, findContracts, findReactModules, findRestEndpointGenerator, initializeUseCase, integrationDescriptions, integrationIds, moduleId, moveBackendUnitUseCase, moveReactModuleUseCase, printNextSteps, reactKindTitles, runWithAnswers, savePendingChanges, savedImplementations, scaffoldNewAggregateUseCase, scaffoldNewApplicationPort, scaffoldNewApplicationService, scaffoldNewBoundedContextUseCase, scaffoldNewCommand, scaffoldNewDomainObject, scaffoldNewDomainService, scaffoldNewErrorUseCase, scaffoldNewHandlersRestEndpoint, scaffoldNewImplementation, scaffoldNewInfrastructureService, scaffoldNewPresentationService, scaffoldNewQuery, scaffoldNewUseCase, scaffoldReactPage, scaffoldReactSharedHook, scaffoldReactUIKitComponent, scaffoldReactWidget, systemImplementationChoices, unitId, wireDependency };
|
package/dist/561.js
CHANGED
|
@@ -3,7 +3,7 @@ import node_path from "node:path";
|
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import zod from "zod";
|
|
5
5
|
import { implementationLabelSchema, discardPendingChanges, filesToOverwrite, ConfigFile, Folder, implementationKinds, ProjectRoot, pendingChanges } from "./870.js";
|
|
6
|
-
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, scaffoldNewQuery, runWithAnswers, scaffoldNewCommand, moveBackendUnitUseCase, findReactModules, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, deleteBackendUnitUseCase, integrationIds, scaffoldNewImplementation, scaffoldNewApplicationService, savedImplementations, RequestError, deleteReactModuleUseCase, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges,
|
|
6
|
+
import { scaffoldNewHandlersRestEndpoint, addIntegration, findContracts, scaffoldNewAggregateUseCase, scaffoldNewInfrastructureService, scaffoldNewQuery, runWithAnswers, scaffoldNewCommand, moveBackendUnitUseCase, findReactModules, scaffoldReactUIKitComponent, scaffoldReactSharedHook, moveReactModuleUseCase, reactKindTitles, deleteBackendUnitUseCase, integrationIds, scaffoldNewImplementation, scaffoldNewApplicationService, savedImplementations, RequestError, deleteReactModuleUseCase, moduleId, assertAnswersConsumed, scaffoldNewDomainService, findRestEndpointGenerator, scaffoldNewErrorUseCase, scaffoldReactWidget, savePendingChanges, unitId, systemImplementationChoices, scaffoldReactPage, scaffoldNewPresentationService, findBackendUnits, scaffoldNewUseCase, integrationDescriptions, wireDependency, scaffoldNewDomainObject, scaffoldNewBoundedContextUseCase, scaffoldNewApplicationPort } from "./287.js";
|
|
7
7
|
import { findWiredModules, availableDependencies, hasNeighboringBoundedContext } from "./201.js";
|
|
8
8
|
const agent_requests_name = implementationLabelSchema;
|
|
9
9
|
const nestedName = zod.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*$/);
|
|
@@ -33,68 +33,68 @@ const named = {
|
|
|
33
33
|
...agent_requests_owner,
|
|
34
34
|
name: agent_requests_name
|
|
35
35
|
};
|
|
36
|
-
const
|
|
36
|
+
const agent_requests_operation = (value, shape)=>zod.strictObject({
|
|
37
37
|
operation: zod.literal(value),
|
|
38
38
|
...shape
|
|
39
39
|
});
|
|
40
40
|
const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
41
|
-
|
|
41
|
+
agent_requests_operation('bounded-context', {
|
|
42
42
|
...common,
|
|
43
43
|
name: agent_requests_name.refine((value)=>'shared-kernel' !== value, 'shared-kernel is reserved for the Shared Kernel.')
|
|
44
44
|
}),
|
|
45
|
-
|
|
45
|
+
agent_requests_operation('aggregate', {
|
|
46
46
|
...named,
|
|
47
47
|
withRepository: zod.boolean().optional(),
|
|
48
48
|
implementation: agent_requests_implementation.optional(),
|
|
49
49
|
testImplementation: agent_requests_implementation.optional(),
|
|
50
50
|
...wired
|
|
51
51
|
}),
|
|
52
|
-
|
|
52
|
+
agent_requests_operation('entity', {
|
|
53
53
|
...named,
|
|
54
54
|
aggregate: agent_requests_name.optional()
|
|
55
55
|
}),
|
|
56
|
-
|
|
56
|
+
agent_requests_operation('value-object', {
|
|
57
57
|
...named,
|
|
58
58
|
aggregate: agent_requests_name.optional()
|
|
59
59
|
}),
|
|
60
|
-
|
|
60
|
+
agent_requests_operation('error', {
|
|
61
61
|
...named,
|
|
62
62
|
namespace: agent_requests_name.optional()
|
|
63
63
|
}),
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
agent_requests_operation('error-namespace', named),
|
|
65
|
+
agent_requests_operation('domain-service', {
|
|
66
66
|
...named,
|
|
67
67
|
...wired
|
|
68
68
|
}),
|
|
69
|
-
|
|
69
|
+
agent_requests_operation('application-service', {
|
|
70
70
|
...named,
|
|
71
71
|
...wired
|
|
72
72
|
}),
|
|
73
|
-
|
|
73
|
+
agent_requests_operation('infrastructure-service', {
|
|
74
74
|
...named,
|
|
75
75
|
...wired
|
|
76
76
|
}),
|
|
77
|
-
|
|
77
|
+
agent_requests_operation('presentation-service', {
|
|
78
78
|
...named,
|
|
79
79
|
...wired
|
|
80
80
|
}),
|
|
81
|
-
|
|
81
|
+
agent_requests_operation('use-case', {
|
|
82
82
|
...named,
|
|
83
83
|
...wired
|
|
84
84
|
}),
|
|
85
|
-
|
|
85
|
+
agent_requests_operation('command', {
|
|
86
86
|
...named,
|
|
87
87
|
...implementations
|
|
88
88
|
}),
|
|
89
|
-
|
|
89
|
+
agent_requests_operation('query', {
|
|
90
90
|
...named,
|
|
91
91
|
...implementations
|
|
92
92
|
}),
|
|
93
|
-
|
|
93
|
+
agent_requests_operation('port', {
|
|
94
94
|
...named,
|
|
95
95
|
...implementations
|
|
96
96
|
}),
|
|
97
|
-
|
|
97
|
+
agent_requests_operation('implementation', {
|
|
98
98
|
...common,
|
|
99
99
|
...agent_requests_owner,
|
|
100
100
|
contract: id.describe('Exact contract ID from --describe.'),
|
|
@@ -102,7 +102,7 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
102
102
|
environments: zod.array(agent_requests_name).min(1).optional().describe('Required when the contract wire is envBranchedWire; omit it otherwise.'),
|
|
103
103
|
...wired
|
|
104
104
|
}),
|
|
105
|
-
|
|
105
|
+
agent_requests_operation('endpoint', {
|
|
106
106
|
...common,
|
|
107
107
|
...agent_requests_owner,
|
|
108
108
|
controller: agent_requests_name,
|
|
@@ -116,18 +116,18 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
116
116
|
path: zod.string().regex(/^(?:\/?(?:[a-zA-Z0-9_-]+|:[a-zA-Z][a-zA-Z0-9_]*))*\/?$/),
|
|
117
117
|
handler: id.optional().describe('Exact handler module ID from --describe. Required when the context has wired queries, commands or use cases; omit it otherwise.')
|
|
118
118
|
}),
|
|
119
|
-
|
|
119
|
+
agent_requests_operation('wire-dependency', {
|
|
120
120
|
...common,
|
|
121
121
|
...agent_requests_owner,
|
|
122
122
|
module: id.describe('Exact wiring target ID, including implementation class, from --describe.'),
|
|
123
123
|
dependencies: dependencies
|
|
124
124
|
}),
|
|
125
|
-
|
|
125
|
+
agent_requests_operation('delete', {
|
|
126
126
|
...common,
|
|
127
127
|
...agent_requests_owner,
|
|
128
128
|
module: id.describe('Exact unit ID from --describe. Refused while other files use it.')
|
|
129
129
|
}),
|
|
130
|
-
|
|
130
|
+
agent_requests_operation('move', {
|
|
131
131
|
...common,
|
|
132
132
|
...agent_requests_owner,
|
|
133
133
|
module: id.describe('Exact unit ID from --describe.'),
|
|
@@ -137,11 +137,11 @@ const scaffoldRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
137
137
|
})
|
|
138
138
|
]);
|
|
139
139
|
const reactRequestSchema = zod.discriminatedUnion('operation', [
|
|
140
|
-
|
|
140
|
+
agent_requests_operation('page', {
|
|
141
141
|
...common,
|
|
142
142
|
name: nestedName
|
|
143
143
|
}),
|
|
144
|
-
|
|
144
|
+
agent_requests_operation('widget', {
|
|
145
145
|
...common,
|
|
146
146
|
name: nestedName,
|
|
147
147
|
widgetType: zod["enum"]([
|
|
@@ -150,37 +150,55 @@ const reactRequestSchema = zod.discriminatedUnion('operation', [
|
|
|
150
150
|
'headless'
|
|
151
151
|
]).optional()
|
|
152
152
|
}),
|
|
153
|
-
|
|
153
|
+
agent_requests_operation('ui-kit-component', {
|
|
154
154
|
...common,
|
|
155
155
|
name: agent_requests_name
|
|
156
156
|
}),
|
|
157
|
-
|
|
157
|
+
agent_requests_operation('shared-hook', {
|
|
158
158
|
...common,
|
|
159
159
|
name: agent_requests_name
|
|
160
160
|
}),
|
|
161
|
-
|
|
161
|
+
agent_requests_operation('move-page', {
|
|
162
162
|
...common,
|
|
163
163
|
module: nestedName,
|
|
164
164
|
name: nestedName,
|
|
165
165
|
moveRoute: zod.boolean().optional().describe('With Next.js and a route at the page path: move it too (default true). Omit it without such a route.')
|
|
166
166
|
}),
|
|
167
|
-
|
|
167
|
+
agent_requests_operation('delete-page', {
|
|
168
168
|
...common,
|
|
169
169
|
module: nestedName,
|
|
170
170
|
deleteRoute: zod.boolean().optional().describe("With Next.js and the page's own route: delete it too (default true). Omit it without such a route.")
|
|
171
171
|
}),
|
|
172
|
-
|
|
172
|
+
agent_requests_operation('delete-widget', {
|
|
173
173
|
...common,
|
|
174
174
|
module: nestedName
|
|
175
175
|
}),
|
|
176
|
-
|
|
176
|
+
agent_requests_operation('move-ui-kit-component', {
|
|
177
|
+
...common,
|
|
178
|
+
module: agent_requests_name,
|
|
179
|
+
name: agent_requests_name
|
|
180
|
+
}),
|
|
181
|
+
agent_requests_operation('move-shared-hook', {
|
|
182
|
+
...common,
|
|
183
|
+
module: agent_requests_name,
|
|
184
|
+
name: agent_requests_name
|
|
185
|
+
}),
|
|
186
|
+
agent_requests_operation('delete-ui-kit-component', {
|
|
187
|
+
...common,
|
|
188
|
+
module: agent_requests_name
|
|
189
|
+
}),
|
|
190
|
+
agent_requests_operation('delete-shared-hook', {
|
|
191
|
+
...common,
|
|
192
|
+
module: agent_requests_name
|
|
193
|
+
}),
|
|
194
|
+
agent_requests_operation('move-widget', {
|
|
177
195
|
...common,
|
|
178
196
|
module: nestedName,
|
|
179
197
|
name: nestedName
|
|
180
198
|
})
|
|
181
199
|
]);
|
|
182
200
|
const relativePath = zod.string().regex(/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/).refine((value)=>!value.split('/').some((part)=>'.' === part || '..' === part), 'Use a project-relative path without . or .. segments.');
|
|
183
|
-
const integrationRequestSchema =
|
|
201
|
+
const integrationRequestSchema = agent_requests_operation('add', {
|
|
184
202
|
...common,
|
|
185
203
|
integrations: zod.array(zod["enum"](integrationIds)).min(1),
|
|
186
204
|
nextAdapter: zod.boolean().optional(),
|
|
@@ -306,7 +324,9 @@ const describeAgentCommand = (command)=>{
|
|
|
306
324
|
integrations: integrationDescriptionsSafe(configured),
|
|
307
325
|
reactModules: config?.frontend?.react ? [
|
|
308
326
|
'page',
|
|
309
|
-
'widget'
|
|
327
|
+
'widget',
|
|
328
|
+
'ui-kit',
|
|
329
|
+
'hook'
|
|
310
330
|
].flatMap((kind)=>findReactModules(node_path.join(root, config.project.rootFolder, 'presentation/react'), kind).map((module)=>({
|
|
311
331
|
kind,
|
|
312
332
|
name: module.name,
|
|
@@ -416,7 +436,9 @@ const executeReact = async (request)=>{
|
|
|
416
436
|
ConfigFile.Instance.data.project.rootFolder,
|
|
417
437
|
'presentation/react'
|
|
418
438
|
]);
|
|
419
|
-
|
|
439
|
+
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' : operation.endsWith('-shared-hook') ? 'hook' : void 0;
|
|
440
|
+
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
441
|
+
if (kind && !findReactModules(folder.path, kind).length) throw new RequestError('TARGET_NOT_FOUND', `No React ${reactKindTitles[kind][1]} here.`);
|
|
420
442
|
const actions = {
|
|
421
443
|
page: ()=>scaffoldReactPage(folder),
|
|
422
444
|
widget: ()=>scaffoldReactWidget(folder),
|
|
@@ -425,7 +447,11 @@ const executeReact = async (request)=>{
|
|
|
425
447
|
'move-page': ()=>moveReactModuleUseCase(folder, 'page'),
|
|
426
448
|
'move-widget': ()=>moveReactModuleUseCase(folder, 'widget'),
|
|
427
449
|
'delete-page': ()=>deleteReactModuleUseCase(folder, 'page'),
|
|
428
|
-
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget')
|
|
450
|
+
'delete-widget': ()=>deleteReactModuleUseCase(folder, 'widget'),
|
|
451
|
+
'move-ui-kit-component': ()=>moveReactModuleUseCase(folder, 'ui-kit'),
|
|
452
|
+
'move-shared-hook': ()=>moveReactModuleUseCase(folder, 'hook'),
|
|
453
|
+
'delete-ui-kit-component': ()=>deleteReactModuleUseCase(folder, 'ui-kit'),
|
|
454
|
+
'delete-shared-hook': ()=>deleteReactModuleUseCase(folder, 'hook')
|
|
429
455
|
};
|
|
430
456
|
return actions[request.operation]();
|
|
431
457
|
};
|
package/dist/agent-cli.d.ts
CHANGED
|
@@ -241,6 +241,28 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
241
241
|
module: z.ZodString;
|
|
242
242
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
243
243
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
245
|
+
operation: z.ZodLiteral<"move-ui-kit-component">;
|
|
246
|
+
module: z.ZodString;
|
|
247
|
+
name: z.ZodString;
|
|
248
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
249
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
250
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
251
|
+
operation: z.ZodLiteral<"move-shared-hook">;
|
|
252
|
+
module: z.ZodString;
|
|
253
|
+
name: z.ZodString;
|
|
254
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
255
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
256
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
257
|
+
operation: z.ZodLiteral<"delete-ui-kit-component">;
|
|
258
|
+
module: z.ZodString;
|
|
259
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
260
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
261
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
262
|
+
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
263
|
+
module: z.ZodString;
|
|
264
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
265
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
244
266
|
}, z.core.$strict>, z.ZodObject<{
|
|
245
267
|
operation: z.ZodLiteral<"move-widget">;
|
|
246
268
|
module: z.ZodString;
|
|
@@ -363,7 +385,7 @@ export declare const describeAgentCommand: (command: AgentCommand) => {
|
|
|
363
385
|
available: boolean;
|
|
364
386
|
}[];
|
|
365
387
|
reactModules: {
|
|
366
|
-
kind:
|
|
388
|
+
kind: "page" | "widget" | "ui-kit" | "hook";
|
|
367
389
|
name: string;
|
|
368
390
|
file: string;
|
|
369
391
|
}[];
|
package/dist/agent-requests.d.ts
CHANGED
|
@@ -220,6 +220,28 @@ export declare const reactRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
220
220
|
module: z.ZodString;
|
|
221
221
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
222
222
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
operation: z.ZodLiteral<"move-ui-kit-component">;
|
|
225
|
+
module: z.ZodString;
|
|
226
|
+
name: z.ZodString;
|
|
227
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
228
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
229
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
230
|
+
operation: z.ZodLiteral<"move-shared-hook">;
|
|
231
|
+
module: z.ZodString;
|
|
232
|
+
name: z.ZodString;
|
|
233
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
234
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
235
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
236
|
+
operation: z.ZodLiteral<"delete-ui-kit-component">;
|
|
237
|
+
module: z.ZodString;
|
|
238
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
239
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
241
|
+
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
242
|
+
module: z.ZodString;
|
|
243
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
223
245
|
}, z.core.$strict>, z.ZodObject<{
|
|
224
246
|
operation: z.ZodLiteral<"move-widget">;
|
|
225
247
|
module: z.ZodString;
|
|
@@ -482,6 +504,28 @@ export declare const requestSchemaFor: (command: AgentCommand) => z.ZodDiscrimin
|
|
|
482
504
|
module: z.ZodString;
|
|
483
505
|
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
484
506
|
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
507
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
508
|
+
operation: z.ZodLiteral<"move-ui-kit-component">;
|
|
509
|
+
module: z.ZodString;
|
|
510
|
+
name: z.ZodString;
|
|
511
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
512
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
513
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
514
|
+
operation: z.ZodLiteral<"move-shared-hook">;
|
|
515
|
+
module: z.ZodString;
|
|
516
|
+
name: z.ZodString;
|
|
517
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
518
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
519
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
520
|
+
operation: z.ZodLiteral<"delete-ui-kit-component">;
|
|
521
|
+
module: z.ZodString;
|
|
522
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
523
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
524
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
525
|
+
operation: z.ZodLiteral<"delete-shared-hook">;
|
|
526
|
+
module: z.ZodString;
|
|
527
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
528
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
485
529
|
}, z.core.$strict>, z.ZodObject<{
|
|
486
530
|
operation: z.ZodLiteral<"move-widget">;
|
|
487
531
|
module: z.ZodString;
|