create-modoock-app 2.1.0 → 2.2.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/dist/cli.js +125 -121
- package/package.json +1 -1
- package/template/.cursor/hooks/gate-ui-pack.mjs +59 -11
- package/template/.cursor/rules/honey.mdc +16 -9
- package/template/AGENTS.md +29 -19
- package/template/README.md +3 -3
- package/template/app/(main)/components/page.tsx +2 -44
- package/template/app/(main)/page.tsx +1 -1
- package/template/app/auth/login/page.tsx +1 -1
- package/template/components/layout/app-layout.tsx +3 -3
- package/template/components/layout/header.tsx +2 -7
- package/template/components/layout/index.ts +3 -3
- package/template/components/layout/side-nav.tsx +52 -29
- package/template/components/ui/index.ts +0 -0
- package/template/next.config.ts +17 -0
- package/template/tsconfig.json +28 -0
package/dist/cli.js
CHANGED
|
@@ -1,121 +1,125 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const node_child_process_1 = require("node:child_process");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_child_process_1 = require("node:child_process");
|
|
10
|
+
const MODOOCK_PACKAGES = [
|
|
11
|
+
"@modoock/components",
|
|
12
|
+
"@modoock/knowledge-base",
|
|
13
|
+
];
|
|
14
|
+
function copyDirectory(source, destination) {
|
|
15
|
+
node_fs_1.default.mkdirSync(destination, { recursive: true });
|
|
16
|
+
for (const entry of node_fs_1.default.readdirSync(source, {
|
|
17
|
+
withFileTypes: true,
|
|
18
|
+
})) {
|
|
19
|
+
const sourcePath = node_path_1.default.join(source, entry.name);
|
|
20
|
+
const destinationPath = node_path_1.default.join(destination, entry.name);
|
|
21
|
+
if (entry.isDirectory()) {
|
|
22
|
+
copyDirectory(sourcePath, destinationPath);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
node_fs_1.default.copyFileSync(sourcePath, destinationPath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function getLatestVersion(packageName) {
|
|
30
|
+
try {
|
|
31
|
+
const version = (0, node_child_process_1.execSync)(`npm view ${packageName} version`, {
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
34
|
+
}).trim();
|
|
35
|
+
if (!version) {
|
|
36
|
+
throw new Error(`No stable version found for ${packageName}.`);
|
|
37
|
+
}
|
|
38
|
+
return version;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
throw new Error(`Could not resolve the latest stable version of ${packageName}.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getLatestModoockDependencies() {
|
|
45
|
+
const dependencies = {};
|
|
46
|
+
for (const packageName of MODOOCK_PACKAGES) {
|
|
47
|
+
console.log(`Resolving latest ${packageName}...`);
|
|
48
|
+
const version = getLatestVersion(packageName);
|
|
49
|
+
dependencies[packageName] = version;
|
|
50
|
+
console.log(` ${packageName}@${version}`);
|
|
51
|
+
}
|
|
52
|
+
return dependencies;
|
|
53
|
+
}
|
|
54
|
+
function updateProjectPackageJson(targetDirectory) {
|
|
55
|
+
const packageJsonPath = node_path_1.default.join(targetDirectory, "package.json");
|
|
56
|
+
const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
57
|
+
packageJson.name =
|
|
58
|
+
node_path_1.default.basename(targetDirectory);
|
|
59
|
+
const modoockDependencies = getLatestModoockDependencies();
|
|
60
|
+
packageJson.dependencies = {
|
|
61
|
+
...(packageJson.dependencies ?? {}),
|
|
62
|
+
...modoockDependencies,
|
|
63
|
+
};
|
|
64
|
+
node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
|
|
65
|
+
}
|
|
66
|
+
function installDependencies(targetDirectory) {
|
|
67
|
+
console.log("");
|
|
68
|
+
console.log("Installing dependencies...");
|
|
69
|
+
try {
|
|
70
|
+
(0, node_child_process_1.execSync)("npm install", {
|
|
71
|
+
cwd: targetDirectory,
|
|
72
|
+
stdio: "inherit",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
throw new Error("Failed to install project dependencies.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function main() {
|
|
80
|
+
const projectName = process.argv[2];
|
|
81
|
+
if (!projectName) {
|
|
82
|
+
console.error("Usage: npx create-modoock-app <project-name>");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
const targetDirectory = node_path_1.default.resolve(process.cwd(), projectName);
|
|
86
|
+
if (node_fs_1.default.existsSync(targetDirectory)) {
|
|
87
|
+
console.error(`Error: Directory "${projectName}" already exists.`);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const packageRoot = node_path_1.default.resolve(__dirname, "..");
|
|
91
|
+
const templateDirectory = node_path_1.default.join(packageRoot, "template");
|
|
92
|
+
console.log(`Creating Modooock project: ${node_path_1.default.basename(targetDirectory)}`);
|
|
93
|
+
try {
|
|
94
|
+
// Copy the project foundation.
|
|
95
|
+
copyDirectory(templateDirectory, targetDirectory);
|
|
96
|
+
// Configure the generated project.
|
|
97
|
+
updateProjectPackageJson(targetDirectory);
|
|
98
|
+
// Install all dependencies.
|
|
99
|
+
installDependencies(targetDirectory);
|
|
100
|
+
console.log("");
|
|
101
|
+
console.log("Done!");
|
|
102
|
+
console.log("");
|
|
103
|
+
console.log(`Project created at: ${targetDirectory}`);
|
|
104
|
+
console.log("");
|
|
105
|
+
console.log("Next steps:");
|
|
106
|
+
console.log(` cd ${projectName}`);
|
|
107
|
+
console.log(" npm run dev");
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error("");
|
|
111
|
+
if (error instanceof Error) {
|
|
112
|
+
console.error(error.message);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.error("Failed to create the project.");
|
|
116
|
+
}
|
|
117
|
+
// Do not leave a partially generated project.
|
|
118
|
+
node_fs_1.default.rmSync(targetDirectory, {
|
|
119
|
+
recursive: true,
|
|
120
|
+
force: true,
|
|
121
|
+
});
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
main();
|
package/package.json
CHANGED
|
@@ -4,6 +4,11 @@ import os from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
const CATALOG = "knowledge-base/metadata/catalog.yaml";
|
|
7
|
+
const CANONICAL_INDEXES = [
|
|
8
|
+
"components/components/ui/index.ts",
|
|
9
|
+
"create-modoock-app/template/components/layout/index.ts",
|
|
10
|
+
"create-modoock-app/template/components/shared/index.ts",
|
|
11
|
+
];
|
|
7
12
|
const allow = { permission: "allow" };
|
|
8
13
|
const emit = (o) => process.stdout.write(JSON.stringify(o));
|
|
9
14
|
|
|
@@ -21,11 +26,43 @@ try {
|
|
|
21
26
|
)
|
|
22
27
|
: "";
|
|
23
28
|
|
|
29
|
+
const monorepoRoot = (() => {
|
|
30
|
+
if (
|
|
31
|
+
fs.existsSync(path.join(root, "components", "components", "ui")) &&
|
|
32
|
+
fs.existsSync(path.join(root, "create-modoock-app", "template", "components"))
|
|
33
|
+
) {
|
|
34
|
+
return root;
|
|
35
|
+
}
|
|
36
|
+
const parent = path.join(root, "..");
|
|
37
|
+
if (
|
|
38
|
+
fs.existsSync(path.join(parent, "components", "components", "ui")) &&
|
|
39
|
+
fs.existsSync(path.join(parent, "create-modoock-app", "template", "components"))
|
|
40
|
+
) {
|
|
41
|
+
return parent;
|
|
42
|
+
}
|
|
43
|
+
return root;
|
|
44
|
+
})();
|
|
45
|
+
|
|
24
46
|
const rel = (file) => {
|
|
25
47
|
if (!file) return "";
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
48
|
+
const abs = path.resolve(root, String(file));
|
|
49
|
+
const r = path.relative(root, abs);
|
|
50
|
+
if (r && !r.startsWith("..") && !path.isAbsolute(r)) {
|
|
51
|
+
return r.split(path.sep).join("/");
|
|
52
|
+
}
|
|
53
|
+
// Allow stamping canonical sibling sources when workspace is builder/
|
|
54
|
+
const fromMono = path.relative(monorepoRoot, abs);
|
|
55
|
+
if (
|
|
56
|
+
fromMono &&
|
|
57
|
+
!fromMono.startsWith("..") &&
|
|
58
|
+
!path.isAbsolute(fromMono) &&
|
|
59
|
+
CANONICAL_INDEXES.some(
|
|
60
|
+
(ip) => fromMono.split(path.sep).join("/") === ip,
|
|
61
|
+
)
|
|
62
|
+
) {
|
|
63
|
+
return fromMono.split(path.sep).join("/");
|
|
64
|
+
}
|
|
65
|
+
return "";
|
|
29
66
|
};
|
|
30
67
|
|
|
31
68
|
let input = p.tool_input;
|
|
@@ -47,6 +84,21 @@ try {
|
|
|
47
84
|
}
|
|
48
85
|
};
|
|
49
86
|
|
|
87
|
+
const componentIndexes = () => {
|
|
88
|
+
const localDir = path.join(root, "components");
|
|
89
|
+
if (fs.existsSync(localDir)) {
|
|
90
|
+
const local = [];
|
|
91
|
+
for (const d of fs.readdirSync(localDir, { withFileTypes: true })) {
|
|
92
|
+
const ip = `components/${d.name}/index.ts`;
|
|
93
|
+
if (d.isDirectory() && fs.existsSync(path.join(root, ip))) local.push(ip);
|
|
94
|
+
}
|
|
95
|
+
if (local.length) return local;
|
|
96
|
+
}
|
|
97
|
+
return CANONICAL_INDEXES.filter((ip) =>
|
|
98
|
+
fs.existsSync(path.join(monorepoRoot, ip)),
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
50
102
|
if (event === "precompact") {
|
|
51
103
|
if (stampFile) fs.rmSync(stampFile, { force: true });
|
|
52
104
|
emit({});
|
|
@@ -67,7 +119,9 @@ try {
|
|
|
67
119
|
fileRel === "app" ||
|
|
68
120
|
fileRel === "components" ||
|
|
69
121
|
fileRel.startsWith("app/") ||
|
|
70
|
-
fileRel.startsWith("components/")
|
|
122
|
+
fileRel.startsWith("components/") ||
|
|
123
|
+
fileRel.startsWith("builder/app/") ||
|
|
124
|
+
fileRel.startsWith("builder/components/");
|
|
71
125
|
if (!fileRel || !ui || !cid) {
|
|
72
126
|
emit(allow);
|
|
73
127
|
} else {
|
|
@@ -85,13 +139,7 @@ try {
|
|
|
85
139
|
need.push(cur);
|
|
86
140
|
}
|
|
87
141
|
}
|
|
88
|
-
|
|
89
|
-
if (fs.existsSync(dir)) {
|
|
90
|
-
for (const d of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
91
|
-
const ip = `components/${d.name}/index.ts`;
|
|
92
|
-
if (d.isDirectory() && fs.existsSync(path.join(root, ip))) need.push(ip);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
142
|
+
need.push(...componentIndexes());
|
|
95
143
|
const missing = [...new Set(need)].filter((x) => !loadStamp().has(x));
|
|
96
144
|
emit(
|
|
97
145
|
missing.length
|
|
@@ -39,9 +39,11 @@ naming the main edge case (e.g. "raises `KeyError` on a missing key — use `.ge
|
|
|
39
39
|
a tradeoff, a correctness argument, or a learner who needs the explanation. Keep
|
|
40
40
|
Lever 1, ease Lever 2. Brevity that forces a follow-up round-trip costs more than it saved.
|
|
41
41
|
|
|
42
|
-
**Do not invent to stay terse.** An unspecified part
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
**Do not invent to stay terse.** An unspecified product part is a question
|
|
43
|
+
(AGENTS.md), not a Honey default: a new public component, a new token, an
|
|
44
|
+
interaction pattern the catalog does not name, or an ambiguous requirement.
|
|
45
|
+
"Implement" is not license to fill those gaps. Grouping, hierarchy, spacing,
|
|
46
|
+
order, and empty, loading, and error states with existing primitives are in scope.
|
|
45
47
|
|
|
46
48
|
## Lever 1 — minimum code that needs to exist
|
|
47
49
|
|
|
@@ -98,12 +100,16 @@ Never simplify away:
|
|
|
98
100
|
- **Visual/UX design when the deliverable is user-facing** — for landing pages,
|
|
99
101
|
marketing sites, and UI components, polish (layout depth, hero composition,
|
|
100
102
|
motion, responsive richness, on-brand visual hierarchy) *is* the requirement,
|
|
101
|
-
not "speculative."
|
|
102
|
-
|
|
103
|
+
not "speculative." On a screen, this outranks minimum markup: grouping,
|
|
104
|
+
spacing, and hierarchy stay. Minimum code still applies to logic. Markup that
|
|
105
|
+
looks unfinished isn't minimal. The ladder still trims *structure* (no dead
|
|
106
|
+
markup, no unused framework), never how it looks.
|
|
103
107
|
- **Anything the user explicitly asked for.**
|
|
104
108
|
- **The ask for a Design System primitive** — do not skip it to write less code.
|
|
105
|
-
- **Unspecified parts
|
|
106
|
-
|
|
109
|
+
- **Unspecified product parts** — a new public component, a new token, an
|
|
110
|
+
interaction pattern the catalog does not name, or an ambiguous requirement.
|
|
111
|
+
Do not generate them to finish the ticket. Ask (AGENTS.md). Screen composition
|
|
112
|
+
with existing primitives is in scope (AGENTS.md).
|
|
107
113
|
|
|
108
114
|
Leave one runnable check (test/assert/invocation) behind for non-trivial logic.
|
|
109
115
|
"Lazy" = no wasted code, not no proof it works.
|
|
@@ -115,8 +121,9 @@ Fewest words that stay clear. Cut the scaffolding:
|
|
|
115
121
|
- **Drop wind-up/wind-down** — no "Great question!", no "hope this helps!", no
|
|
116
122
|
restating the prompt, no announcing what you're about to do.
|
|
117
123
|
- **Drop hedging** — "use X", not "you might possibly consider perhaps X", when
|
|
118
|
-
X is already in the prompt or the repo. A choice
|
|
119
|
-
not hedging: ask
|
|
124
|
+
X is already in the prompt or the repo. A product choice AGENTS.md lists as a
|
|
125
|
+
question is not hedging: ask and wait. Screen composition with existing
|
|
126
|
+
primitives is in scope. Do not pick a product default to stay terse.
|
|
120
127
|
- **Fragments and lists** over paragraphs when they carry the same info faster.
|
|
121
128
|
- **Don't narrate readable code** — explain the *why* and the non-obvious, skip the *what*.
|
|
122
129
|
- **Answer first**; context only if load-bearing.
|
package/template/AGENTS.md
CHANGED
|
@@ -9,7 +9,7 @@ This file is the canonical router. Product constraints live in `knowledge-base/`
|
|
|
9
9
|
| Layer | When | What |
|
|
10
10
|
| --- | --- | --- |
|
|
11
11
|
| Always | every turn | this file, `.cursor/rules/honey.mdc` |
|
|
12
|
-
| UI files | `app/**` or
|
|
12
|
+
| UI files | `app/**` or component sources | every catalog `path` with `load: ui`, then the three component `index.ts` files below |
|
|
13
13
|
| On demand | `description` matches the need | that `path`, then its `open:` |
|
|
14
14
|
| After coding | verification | `knowledge-base/validation/` for the change type |
|
|
15
15
|
|
|
@@ -30,35 +30,45 @@ knowledge-base/
|
|
|
30
30
|
|
|
31
31
|
## Which file to open
|
|
32
32
|
|
|
33
|
-
Open `knowledge-base/metadata/catalog.yaml`. UI edit: every `load: ui` `path`. Then any `description` that matches — exact `path` (no `.mdc` guess). After each catalog `path`, also open that entry's `open:`. What exists
|
|
33
|
+
Open `knowledge-base/metadata/catalog.yaml`. UI edit: every `load: ui` `path`. Then any `description` that matches — exact `path` (no `.mdc` guess). After each catalog `path`, also open that entry's `open:`. What exists (canonical indexes, no `.mdc` required):
|
|
34
|
+
- `../components/components/ui/index.ts`
|
|
35
|
+
- `../create-modoock-app/template/components/layout/index.ts`
|
|
36
|
+
- `../create-modoock-app/template/components/shared/index.ts`
|
|
34
37
|
|
|
35
38
|
If no file covers the need, follow **New rules**. Missing `.mdc` for an existing export is not a gap.
|
|
36
39
|
|
|
37
40
|
## Before coding
|
|
38
41
|
|
|
42
|
+
Break the request down first. All six are required. Do not write this breakdown to a file.
|
|
43
|
+
|
|
44
|
+
1. **Problem** — the request as written. Do not expand it.
|
|
45
|
+
2. **Numbers** — files, props, and data the request names.
|
|
46
|
+
3. **Diagram** — the route and components already in the code. Do not draw a new one.
|
|
47
|
+
4. **Instructions** — catalog paths that match (`load: ui`, then `description`, then `open:`). Apply those files. Nothing else.
|
|
48
|
+
5. **Already solved** — the closest `knowledge-base/patterns/` entry and one page that already does it.
|
|
49
|
+
6. **Comment** — only if a part is uncovered: ask per **Mandatory human validation**, then wait.
|
|
50
|
+
|
|
39
51
|
- Inspect the existing code. Reproduce a failure before fixing it. Change one thing at a time, then verify.
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- Apply **Mandatory human validation**. Do not invent rules or unspecified behavior.
|
|
52
|
+
- Reuse: `knowledge-base/design-system/components.mdc`. Composition: `knowledge-base/rules/architecture/composition.mdc`. APIs: the three `index.ts` above.
|
|
53
|
+
- Apply **Mandatory human validation**.
|
|
43
54
|
|
|
44
55
|
## Mandatory human validation
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
Compose with existing primitives (group, order, space, hierarchy, empty/loading/error). Do not ask for that.
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
Ask and wait only for:
|
|
60
|
+
- a new public component in `../components/components/ui` | `../create-modoock-app/template/components/layout` | `../create-modoock-app/template/components/shared`
|
|
61
|
+
- a new token or global variable
|
|
62
|
+
- an interaction not named in the catalog / `patterns/`
|
|
63
|
+
- an ambiguous product requirement (purpose, data, action)
|
|
49
64
|
|
|
50
|
-
|
|
51
|
-
- An existing pattern, a similar page, or "the usual way" does not authorize inventing the unspecified parts.
|
|
52
|
-
- Honey (fewer words, fewer lines) does not override this. Asking is cheaper than generating the wrong thing.
|
|
53
|
-
- Covered parts may proceed in the same turn. Uncovered parts stay paused until the developer answers.
|
|
54
|
-
- Yes / a chosen option: implement that part. No: leave it out.
|
|
55
|
-
- Do not replace a question with a weaker workaround (for example keeping a reusable UI piece in the page file so you do not have to ask).
|
|
65
|
+
Yes → implement. No → leave out. Do not hide a Design System piece as page-local to skip the ask.
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
- **What:**
|
|
59
|
-
- **Where:**
|
|
60
|
-
- **Why:**
|
|
61
|
-
- **Reuse:** one sentence
|
|
67
|
+
New component block:
|
|
68
|
+
- **What:** Name
|
|
69
|
+
- **Where:** path above
|
|
70
|
+
- **Why:** which `index.ts` exports do not fit
|
|
71
|
+
- **Reuse:** one sentence
|
|
62
72
|
|
|
63
73
|
## New rules
|
|
64
74
|
|
|
@@ -75,7 +85,7 @@ After a modification:
|
|
|
75
85
|
|
|
76
86
|
- Check the change against `knowledge-base/validation/` for the files that match. For a read-only pass on the diff, use `.cursor/agents/code-reviewer.md`.
|
|
77
87
|
- Check that existing features are not unnecessarily affected.
|
|
78
|
-
- If a new component has been created, export it from the folder `index.ts` (
|
|
88
|
+
- If a new component has been created, export it from the folder `index.ts` at the canonical path (`../components/components/ui/`, `../create-modoock-app/template/components/layout/`, or `../create-modoock-app/template/components/shared/`).
|
|
79
89
|
- Run `npm run lint`, `npm run typecheck` and `npm run sg:scan` and fix any **error** before finishing. `typecheck` proves JSX props exist on the component type. Do not apply catalog auto-fixes (`ast-grep scan -U`) and do not rewrite existing app JSX to silence catalog warnings.
|
|
80
90
|
- Report any problems or hypotheses that require a decision from the developer.
|
|
81
91
|
|
package/template/README.md
CHANGED
|
@@ -217,7 +217,7 @@ Honey is **not** generated (`skills/honey/SKILL.md` / `scripts/build-rules.js` d
|
|
|
217
217
|
|
|
218
218
|
With no `load`: on demand only. `catalog.yaml` injects nothing. Cursor injects via `.cursor/rules/` (hints) and **gates** via `.cursor/hooks` (UI writes).
|
|
219
219
|
|
|
220
|
-
**Current pack** (`load: ui`): `components.mdc`, `tokens.mdc`, `
|
|
220
|
+
**Current pack** (`load: ui`): `components.mdc`, `tokens.mdc`, `layout.mdc`, `ui-copy.mdc`, `composition.mdc`.
|
|
221
221
|
|
|
222
222
|
**Current graph** (`open:`):
|
|
223
223
|
|
|
@@ -329,11 +329,11 @@ Do not copy the need → file table into the README or the router.
|
|
|
329
329
|
2. Inspect the code already there (components and usages).
|
|
330
330
|
3. Open `catalog.yaml`: every `load: ui` on a UI edit; then matching `description`s; then each `open:`. Cursor will block the UI write until the pack is read.
|
|
331
331
|
4. Read `components/*/index.ts` — that is the real catalog.
|
|
332
|
-
5. Reuse: existing export → pattern → composition.
|
|
332
|
+
5. Reuse: existing export → pattern → composition. Group, order, space, and states are in scope. A new public component, a new token, an interaction the catalog does not name, or an ambiguous product requirement → question, wait. Do not hide a Design System primitive in the page.
|
|
333
333
|
|
|
334
334
|
**During:**
|
|
335
335
|
|
|
336
|
-
-
|
|
336
|
+
- Screen composition uses existing primitives. A product or system change that `AGENTS.md` lists as a question pauses that part.
|
|
337
337
|
- Do not invent a rule, do not change `knowledge-base/` without agreement.
|
|
338
338
|
- Recurring uncovered case → propose a rule and its catalog `path`, wait.
|
|
339
339
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
ActionStack,
|
|
5
4
|
Badge,
|
|
6
5
|
ClickableButton,
|
|
7
6
|
Icon,
|
|
@@ -18,8 +17,8 @@ import {
|
|
|
18
17
|
Tabs,
|
|
19
18
|
Textarea,
|
|
20
19
|
Table,
|
|
21
|
-
} from "
|
|
22
|
-
import type { CardAction, Column } from "
|
|
20
|
+
} from "@modoock/components";
|
|
21
|
+
import type { CardAction, Column } from "@modoock/components";
|
|
23
22
|
import { useEffect, useState } from "react";
|
|
24
23
|
import type { ReactNode } from "react";
|
|
25
24
|
|
|
@@ -817,47 +816,6 @@ export default function CompsPage() {
|
|
|
817
816
|
</div>
|
|
818
817
|
</div>
|
|
819
818
|
|
|
820
|
-
{/* Vitrine ActionStack */}
|
|
821
|
-
<div className="page-container pt-section">
|
|
822
|
-
<div className="flex flex-wrap items-baseline justify-between gap-inline">
|
|
823
|
-
<h2 className="text-section-title text-foreground">Pile d'actions</h2>
|
|
824
|
-
<span className="text-small text-muted-foreground">
|
|
825
|
-
Composant <code className="font-mono">ActionStack</code>
|
|
826
|
-
</span>
|
|
827
|
-
</div>
|
|
828
|
-
<div className="mt-component grid gap-component md:grid-cols-2">
|
|
829
|
-
<InputDemoCard title="Actions disponibles">
|
|
830
|
-
<ActionStack
|
|
831
|
-
actions={[
|
|
832
|
-
{
|
|
833
|
-
key: "validate",
|
|
834
|
-
label: "Valider",
|
|
835
|
-
variant: "primary",
|
|
836
|
-
onClick: () => undefined,
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
key: "request",
|
|
840
|
-
label: "Demander des infos",
|
|
841
|
-
variant: "secondary",
|
|
842
|
-
onClick: () => undefined,
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
key: "reject",
|
|
846
|
-
label: "Rejeter",
|
|
847
|
-
variant: "danger",
|
|
848
|
-
onClick: () => undefined,
|
|
849
|
-
},
|
|
850
|
-
]}
|
|
851
|
-
/>
|
|
852
|
-
</InputDemoCard>
|
|
853
|
-
<InputDemoCard title="Aucune action" description="Message vide affiché.">
|
|
854
|
-
<ActionStack
|
|
855
|
-
actions={[]}
|
|
856
|
-
emptyMessage="Aucune action disponible pour ce dossier."
|
|
857
|
-
/>
|
|
858
|
-
</InputDemoCard>
|
|
859
|
-
</div>
|
|
860
|
-
</div>
|
|
861
819
|
|
|
862
820
|
<div className="page-container flex h-[min(32rem,70dvh)] flex-col pb-section pt-section">
|
|
863
821
|
<div className="mb-component flex shrink-0 flex-wrap items-baseline justify-between gap-inline">
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import Image from "next/image";
|
|
4
4
|
import { FormEvent, useState } from "react";
|
|
5
|
-
import { ClickableButton, Icon, Input } from "
|
|
5
|
+
import { ClickableButton, Icon, Input } from "@modoock/components";
|
|
6
6
|
|
|
7
7
|
export default function LoginPage() {
|
|
8
8
|
const [loading, setLoading] = useState(false);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Header from "./header";
|
|
5
|
+
import SideNav from "./side-nav";
|
|
6
6
|
|
|
7
|
-
export function AppLayout({ children }: { children: React.ReactNode }) {
|
|
7
|
+
export default function AppLayout({ children }: { children: React.ReactNode }) {
|
|
8
8
|
const [navCollapsed, setNavCollapsed] = useState(true);
|
|
9
9
|
|
|
10
10
|
return (
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { usePathname, useRouter } from "next/navigation";
|
|
4
|
-
import { ClickableButton, Icon } from "
|
|
4
|
+
import { ClickableButton, Icon } from "@modoock/components";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Titre (et sous-titre optionnel) affiché dans le header pour chaque route.
|
|
8
8
|
* Source unique du titre de page : les pages ne redéfinissent pas le leur.
|
|
9
9
|
*/
|
|
10
10
|
const HEADER_META: Record<string, { title: string; description?: string }> = {
|
|
11
|
-
"/": { title: "Beginning" },
|
|
12
11
|
"/components": { title: "Components" },
|
|
13
|
-
"/patients": {
|
|
14
|
-
title: "Patients",
|
|
15
|
-
description: "Registre des patients.",
|
|
16
|
-
},
|
|
17
12
|
"/design-system": {
|
|
18
13
|
title: "Design System",
|
|
19
14
|
description:
|
|
@@ -21,7 +16,7 @@ const HEADER_META: Record<string, { title: string; description?: string }> = {
|
|
|
21
16
|
},
|
|
22
17
|
};
|
|
23
18
|
|
|
24
|
-
export function Header({
|
|
19
|
+
export default function Header({
|
|
25
20
|
menuOpen,
|
|
26
21
|
onOpenMenu,
|
|
27
22
|
}: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AppLayout } from "./app-layout";
|
|
2
|
-
export { Header } from "./header";
|
|
3
|
-
export { SideNav } from "./side-nav";
|
|
1
|
+
export { default as AppLayout } from "./app-layout";
|
|
2
|
+
export { default as Header } from "./header";
|
|
3
|
+
export { default as SideNav } from "./side-nav";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
|
|
4
4
|
import { usePathname, useRouter } from "next/navigation";
|
|
5
|
-
import { Icon } from "
|
|
6
|
-
import type { IconName } from "
|
|
5
|
+
import { Icon } from "@modoock/components";
|
|
6
|
+
import type { IconName } from "@modoock/components";
|
|
7
7
|
|
|
8
8
|
const MD_NAV = "(min-width: 56rem)";
|
|
9
9
|
const DESKTOP_NAV = "(min-width: 1024px)";
|
|
@@ -33,7 +33,7 @@ interface SideNavProps {
|
|
|
33
33
|
onCollapsedChange: (collapsed: boolean) => void;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function SideNav({
|
|
36
|
+
export default function SideNav({
|
|
37
37
|
collapsed,
|
|
38
38
|
onCollapsedChange,
|
|
39
39
|
}: SideNavProps) {
|
|
@@ -111,6 +111,19 @@ export function SideNav({
|
|
|
111
111
|
setExpanded((prev) => ({ ...prev, [href]: !prev[href] }));
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const parent = NAV_ITEMS.find(
|
|
116
|
+
(item) =>
|
|
117
|
+
!!item.children?.length &&
|
|
118
|
+
(item.href === pathname ||
|
|
119
|
+
item.children.some((child) => child.href === pathname)),
|
|
120
|
+
);
|
|
121
|
+
if (!parent) return;
|
|
122
|
+
setExpanded((prev) =>
|
|
123
|
+
prev[parent.href] ? prev : { ...prev, [parent.href]: true },
|
|
124
|
+
);
|
|
125
|
+
}, [pathname]);
|
|
126
|
+
|
|
114
127
|
return (
|
|
115
128
|
<>
|
|
116
129
|
<div
|
|
@@ -170,35 +183,45 @@ export function SideNav({
|
|
|
170
183
|
|
|
171
184
|
return (
|
|
172
185
|
<div key={item.href} className="flex flex-col gap-1">
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
? toggleGroup(item.href)
|
|
178
|
-
: handleNavigate(item.href)
|
|
179
|
-
}
|
|
180
|
-
title={item.label}
|
|
181
|
-
aria-label={showLabels ? undefined : item.label}
|
|
182
|
-
aria-expanded={hasChildren && showLabels ? isOpen : undefined}
|
|
183
|
-
className={`flex items-center gap-3 rounded-small px-3 py-2 text-left text-body-medium transition-colors focus-visible:ring-2 focus-visible:ring-white [&_svg]:shrink-0 [&_svg]:text-current ${
|
|
184
|
-
isActive
|
|
185
|
-
? "bg-white/15 text-white"
|
|
186
|
-
: "text-white/80 hover:bg-white/10 hover:text-white"
|
|
187
|
-
} ${showLabels ? "" : "justify-center"}`}
|
|
186
|
+
<div
|
|
187
|
+
className={`flex items-center rounded-small ${
|
|
188
|
+
isActive ? "bg-white/15 text-white" : "text-white/80"
|
|
189
|
+
}`}
|
|
188
190
|
>
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
+
<button
|
|
192
|
+
type="button"
|
|
193
|
+
onClick={() => {
|
|
194
|
+
if (hasChildren) {
|
|
195
|
+
setExpanded((prev) => ({ ...prev, [item.href]: true }));
|
|
196
|
+
}
|
|
197
|
+
handleNavigate(item.href);
|
|
198
|
+
}}
|
|
199
|
+
title={item.label}
|
|
200
|
+
aria-label={showLabels ? undefined : item.label}
|
|
201
|
+
className={`flex min-w-0 flex-1 items-center gap-3 rounded-small px-3 py-2 text-left text-body-medium transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white [&_svg]:shrink-0 [&_svg]:text-current ${
|
|
202
|
+
showLabels ? "" : "justify-center"
|
|
203
|
+
}`}
|
|
204
|
+
>
|
|
205
|
+
<Icon name={item.icon} variant="white" aria-hidden="true" />
|
|
206
|
+
{showLabels ? <span className="truncate">{item.label}</span> : null}
|
|
207
|
+
</button>
|
|
191
208
|
{hasChildren && showLabels ? (
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
aria-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
209
|
+
<button
|
|
210
|
+
type="button"
|
|
211
|
+
onClick={() => toggleGroup(item.href)}
|
|
212
|
+
aria-expanded={isOpen}
|
|
213
|
+
aria-label={isOpen ? `Replier ${item.label}` : `Déplier ${item.label}`}
|
|
214
|
+
className="mr-1 grid size-8 shrink-0 place-items-center rounded-small transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white"
|
|
215
|
+
>
|
|
216
|
+
<Icon
|
|
217
|
+
name="ChevronDown"
|
|
218
|
+
variant="white"
|
|
219
|
+
aria-hidden="true"
|
|
220
|
+
className={`transition-transform ${isOpen ? "rotate-180" : ""}`}
|
|
221
|
+
/>
|
|
222
|
+
</button>
|
|
200
223
|
) : null}
|
|
201
|
-
</
|
|
224
|
+
</div>
|
|
202
225
|
|
|
203
226
|
{hasChildren && showLabels && isOpen ? (
|
|
204
227
|
<div className="ml-5 flex flex-col gap-1 border-l border-white/20 pl-2">
|
|
File without changes
|
package/template/next.config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { networkInterfaces } from "node:os";
|
|
3
4
|
|
|
4
5
|
function lanHostnames(): string[] {
|
|
@@ -14,8 +15,24 @@ function lanHostnames(): string[] {
|
|
|
14
15
|
return [...hosts];
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
const monorepoRoot = path.join(__dirname, "..", "..");
|
|
19
|
+
|
|
17
20
|
const nextConfig: NextConfig = {
|
|
18
21
|
allowedDevOrigins: lanHostnames(),
|
|
22
|
+
experimental: {
|
|
23
|
+
externalDir: true,
|
|
24
|
+
},
|
|
25
|
+
turbopack: {
|
|
26
|
+
root: monorepoRoot,
|
|
27
|
+
resolveAlias: {
|
|
28
|
+
"@/components/ui": "../../components/components/ui",
|
|
29
|
+
react: "./node_modules/react",
|
|
30
|
+
"react/jsx-runtime": "./node_modules/react/jsx-runtime.js",
|
|
31
|
+
"react/jsx-dev-runtime": "./node_modules/react/jsx-dev-runtime.js",
|
|
32
|
+
"react-dom": "./node_modules/react-dom",
|
|
33
|
+
"lucide-react": "./node_modules/lucide-react",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
19
36
|
};
|
|
20
37
|
|
|
21
38
|
export default nextConfig;
|
package/template/tsconfig.json
CHANGED
|
@@ -22,7 +22,35 @@
|
|
|
22
22
|
"name": "next"
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
|
+
"baseUrl": ".",
|
|
25
26
|
"paths": {
|
|
27
|
+
"@/components/ui": [
|
|
28
|
+
"../../components/components/ui"
|
|
29
|
+
],
|
|
30
|
+
"@/components/ui/*": [
|
|
31
|
+
"../../components/components/ui/*"
|
|
32
|
+
],
|
|
33
|
+
"react": [
|
|
34
|
+
"./node_modules/@types/react"
|
|
35
|
+
],
|
|
36
|
+
"react-dom": [
|
|
37
|
+
"./node_modules/@types/react-dom"
|
|
38
|
+
],
|
|
39
|
+
"react/jsx-runtime": [
|
|
40
|
+
"./node_modules/@types/react/jsx-runtime.d.ts"
|
|
41
|
+
],
|
|
42
|
+
"react/jsx-dev-runtime": [
|
|
43
|
+
"./node_modules/@types/react/jsx-dev-runtime.d.ts"
|
|
44
|
+
],
|
|
45
|
+
"lucide-react": [
|
|
46
|
+
"./node_modules/lucide-react"
|
|
47
|
+
],
|
|
48
|
+
"next": [
|
|
49
|
+
"./node_modules/next"
|
|
50
|
+
],
|
|
51
|
+
"next/*": [
|
|
52
|
+
"./node_modules/next/*"
|
|
53
|
+
],
|
|
26
54
|
"@/*": [
|
|
27
55
|
"./*"
|
|
28
56
|
]
|