create-modoock-app 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +125 -121
- package/package.json +1 -1
- package/template/.cursor/hooks/gate-ui-pack.mjs +37 -14
- package/template/.cursor/rules/agents.mdc +2 -1
- package/template/.cursor/rules/honey.mdc +16 -9
- package/template/AGENTS.md +55 -25
- 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/app/globals.css +1 -0
- 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
|
@@ -3,7 +3,10 @@ import fs from "node:fs";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const KB_ROOT = "node_modules/@modoock/knowledge-base/knowledge-base";
|
|
7
|
+
const CATALOG = `${KB_ROOT}/metadata/catalog.yaml`;
|
|
8
|
+
const PACKAGE_UI_INDEX =
|
|
9
|
+
"node_modules/@modoock/components/components/ui/index.ts";
|
|
7
10
|
const allow = { permission: "allow" };
|
|
8
11
|
const emit = (o) => process.stdout.write(JSON.stringify(o));
|
|
9
12
|
|
|
@@ -23,9 +26,12 @@ try {
|
|
|
23
26
|
|
|
24
27
|
const rel = (file) => {
|
|
25
28
|
if (!file) return "";
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
const abs = path.resolve(root, String(file));
|
|
30
|
+
const r = path.relative(root, abs);
|
|
31
|
+
if (r && !r.startsWith("..") && !path.isAbsolute(r)) {
|
|
32
|
+
return r.split(path.sep).join("/");
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
let input = p.tool_input;
|
|
@@ -47,6 +53,23 @@ try {
|
|
|
47
53
|
}
|
|
48
54
|
};
|
|
49
55
|
|
|
56
|
+
const componentIndexes = () => {
|
|
57
|
+
const indexes = [];
|
|
58
|
+
if (fs.existsSync(path.join(root, PACKAGE_UI_INDEX))) {
|
|
59
|
+
indexes.push(PACKAGE_UI_INDEX);
|
|
60
|
+
}
|
|
61
|
+
const localDir = path.join(root, "components");
|
|
62
|
+
if (fs.existsSync(localDir)) {
|
|
63
|
+
for (const d of fs.readdirSync(localDir, { withFileTypes: true })) {
|
|
64
|
+
const ip = `components/${d.name}/index.ts`;
|
|
65
|
+
if (d.isDirectory() && fs.existsSync(path.join(root, ip))) {
|
|
66
|
+
indexes.push(ip);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return indexes;
|
|
71
|
+
};
|
|
72
|
+
|
|
50
73
|
if (event === "precompact") {
|
|
51
74
|
if (stampFile) fs.rmSync(stampFile, { force: true });
|
|
52
75
|
emit({});
|
|
@@ -67,7 +90,9 @@ try {
|
|
|
67
90
|
fileRel === "app" ||
|
|
68
91
|
fileRel === "components" ||
|
|
69
92
|
fileRel.startsWith("app/") ||
|
|
70
|
-
fileRel.startsWith("components/")
|
|
93
|
+
fileRel.startsWith("components/") ||
|
|
94
|
+
fileRel.startsWith("builder/app/") ||
|
|
95
|
+
fileRel.startsWith("builder/components/");
|
|
71
96
|
if (!fileRel || !ui || !cid) {
|
|
72
97
|
emit(allow);
|
|
73
98
|
} else {
|
|
@@ -81,17 +106,15 @@ try {
|
|
|
81
106
|
if (!t || t.startsWith("#")) continue;
|
|
82
107
|
const m = t.match(/^(?:-\s+)?path:\s+(.+)$/);
|
|
83
108
|
if (m) cur = m[1].trim().replace(/^['"]|['"]$/g, "");
|
|
84
|
-
else if (/^load:\s*ui\s*$/.test(t) && cur
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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);
|
|
109
|
+
else if (/^load:\s*ui\s*$/.test(t) && cur) {
|
|
110
|
+
const resolved = cur.startsWith("knowledge-base/")
|
|
111
|
+
? `${KB_ROOT}/${cur.slice("knowledge-base/".length)}`
|
|
112
|
+
: cur;
|
|
113
|
+
if (fs.existsSync(path.join(root, resolved))) need.push(resolved);
|
|
114
|
+
}
|
|
93
115
|
}
|
|
94
116
|
}
|
|
117
|
+
need.push(...componentIndexes());
|
|
95
118
|
const missing = [...new Set(need)].filter((x) => !loadStamp().has(x));
|
|
96
119
|
emit(
|
|
97
120
|
missing.length
|
|
@@ -6,4 +6,5 @@ alwaysApply: true
|
|
|
6
6
|
Follow `AGENTS.md`. If it is already in this conversation, do not re-open it.
|
|
7
7
|
`.cursor/rules/honey.mdc` is required; if it is already in this conversation, do not re-open it.
|
|
8
8
|
Do not treat `CLAUDE.md` as a second rulebook.
|
|
9
|
-
Then `knowledge-base/metadata/catalog.yaml`.
|
|
9
|
+
Then `node_modules/@modoock/knowledge-base/knowledge-base/metadata/catalog.yaml`.
|
|
10
|
+
UI primitives: `node_modules/@modoock/components/components/ui` (read-only). New components: project `components/` only.
|
|
@@ -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
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
# Development instructions
|
|
2
2
|
|
|
3
|
-
This file is the canonical router. Product constraints live in
|
|
3
|
+
This file is the canonical router. Product constraints live in the `@modoock/knowledge-base` package. Do not copy them here. Only open the files that match the task.
|
|
4
4
|
|
|
5
5
|
`CLAUDE.md` imports this file (`@AGENTS.md`) and `.cursor/rules/honey.mdc`. `.cursor/rules/agents.mdc` is a Cursor pointer — do not copy this procedure there. A Next.js footer may be appended here by `next dev`; do not copy it.
|
|
6
6
|
|
|
7
|
+
## Package sources (read-only)
|
|
8
|
+
|
|
9
|
+
| Source | Path on disk | Rule |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Knowledge base | `node_modules/@modoock/knowledge-base/knowledge-base/` | Read only. Never edit files under `node_modules/`. |
|
|
12
|
+
| Design System UI | `node_modules/@modoock/components/components/ui/` | Read only. Reuse via `@/components/ui`. Never add or edit UI primitives here. |
|
|
13
|
+
|
|
14
|
+
Alias in this app: `@/components/ui` → package UI. Project-local code lives under `./components/` (layout, shared, and any **new** component the developer approves).
|
|
15
|
+
|
|
7
16
|
## Context load
|
|
8
17
|
|
|
9
18
|
| Layer | When | What |
|
|
10
19
|
| --- | --- | --- |
|
|
11
20
|
| Always | every turn | this file, `.cursor/rules/honey.mdc` |
|
|
12
|
-
| UI files | `app/**` or `components/**` | every catalog `path` with `load: ui`, then `
|
|
21
|
+
| UI files | `app/**` or project `components/**` | every catalog `path` with `load: ui`, then the component `index.ts` files below |
|
|
13
22
|
| On demand | `description` matches the need | that `path`, then its `open:` |
|
|
14
|
-
| After coding | verification |
|
|
23
|
+
| After coding | verification | `…/knowledge-base/validation/` for the change type |
|
|
15
24
|
|
|
16
25
|
Do not load the whole knowledge-base. Cursor hook denies writes under `app/` and `components/` until the UI pack (table above) is `Read` this conversation.
|
|
17
26
|
|
|
@@ -19,6 +28,8 @@ Do not load the whole knowledge-base. Cursor hook denies writes under `app/` and
|
|
|
19
28
|
|
|
20
29
|
## Knowledge Base layout
|
|
21
30
|
|
|
31
|
+
Resolved under `node_modules/@modoock/knowledge-base/knowledge-base/`:
|
|
32
|
+
|
|
22
33
|
```
|
|
23
34
|
knowledge-base/
|
|
24
35
|
├── rules/ # constraints (global, architecture, ui, accessibility, …)
|
|
@@ -28,54 +39,73 @@ knowledge-base/
|
|
|
28
39
|
└── metadata/ # catalog.yaml — the need → path index
|
|
29
40
|
```
|
|
30
41
|
|
|
42
|
+
When opening a catalog `path` such as `knowledge-base/rules/…`, read the file at
|
|
43
|
+
`node_modules/@modoock/knowledge-base/<path>`.
|
|
44
|
+
|
|
31
45
|
## Which file to open
|
|
32
46
|
|
|
33
|
-
Open `knowledge-base/metadata/catalog.yaml`.
|
|
47
|
+
Open `node_modules/@modoock/knowledge-base/knowledge-base/metadata/catalog.yaml`.
|
|
48
|
+
UI edit: every `load: ui` `path` (prefix with `node_modules/@modoock/knowledge-base/`).
|
|
49
|
+
Then any `description` that matches — exact `path` (no `.mdc` guess). After each catalog `path`, also open that entry's `open:`.
|
|
50
|
+
|
|
51
|
+
What exists (canonical indexes):
|
|
52
|
+
|
|
53
|
+
- **Package UI (read-only):** `node_modules/@modoock/components/components/ui/index.ts`
|
|
54
|
+
- **Project layout:** `components/layout/index.ts`
|
|
55
|
+
- **Project shared:** `components/shared/index.ts`
|
|
56
|
+
- **Project UI (local only):** `components/ui/index.ts` — only for new app-level UI after human validation; do **not** duplicate package primitives here
|
|
34
57
|
|
|
35
58
|
If no file covers the need, follow **New rules**. Missing `.mdc` for an existing export is not a gap.
|
|
36
59
|
|
|
37
60
|
## Before coding
|
|
38
61
|
|
|
62
|
+
Break the request down first. All six are required. Do not write this breakdown to a file.
|
|
63
|
+
|
|
64
|
+
1. **Problem** — the request as written. Do not expand it.
|
|
65
|
+
2. **Numbers** — files, props, and data the request names.
|
|
66
|
+
3. **Diagram** — the route and components already in the code. Do not draw a new one.
|
|
67
|
+
4. **Instructions** — catalog paths that match (`load: ui`, then `description`, then `open:`). Apply those files. Nothing else.
|
|
68
|
+
5. **Already solved** — the closest `knowledge-base/patterns/` entry and one page that already does it.
|
|
69
|
+
6. **Comment** — only if a part is uncovered: ask per **Mandatory human validation**, then wait.
|
|
70
|
+
|
|
39
71
|
- 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.
|
|
72
|
+
- Reuse: package `components.mdc` + package UI `index.ts`. Composition: `knowledge-base/rules/architecture/composition.mdc`. Project APIs: `components/layout/index.ts`, `components/shared/index.ts`.
|
|
73
|
+
- Apply **Mandatory human validation**.
|
|
43
74
|
|
|
44
75
|
## Mandatory human validation
|
|
45
76
|
|
|
46
|
-
|
|
77
|
+
Compose with existing primitives (group, order, space, hierarchy, empty/loading/error). Do not ask for that.
|
|
47
78
|
|
|
48
|
-
|
|
79
|
+
Ask and wait only for:
|
|
80
|
+
- a new public component in the **project** `components/ui` | `components/layout` | `components/shared` (never in `node_modules/@modoock/components`)
|
|
81
|
+
- a new token or global variable
|
|
82
|
+
- an interaction not named in the catalog / `patterns/`
|
|
83
|
+
- an ambiguous product requirement (purpose, data, action)
|
|
49
84
|
|
|
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).
|
|
85
|
+
Yes → implement under `./components/…`. No → leave out. Do not hide a Design System piece as page-local to skip the ask. Do not patch `@modoock/components` or `@modoock/knowledge-base`.
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
- **What:**
|
|
59
|
-
- **Where:** `components/ui` | `components/layout` | `components/shared`
|
|
60
|
-
- **Why:**
|
|
61
|
-
- **Reuse:** one sentence
|
|
87
|
+
New component block:
|
|
88
|
+
- **What:** Name
|
|
89
|
+
- **Where:** `components/ui` | `components/layout` | `components/shared` (project root only)
|
|
90
|
+
- **Why:** which package / project `index.ts` exports do not fit
|
|
91
|
+
- **Reuse:** one sentence
|
|
62
92
|
|
|
63
93
|
## New rules
|
|
64
94
|
|
|
65
95
|
When a recurring case is not covered:
|
|
66
96
|
|
|
67
|
-
- Propose a new rule, why it is recurring, and where it
|
|
68
|
-
- Do not add or modify a rule until the developer says yes. Then add it.
|
|
97
|
+
- Propose a new rule, why it is recurring, and where it would belong in the knowledge-base package (do not edit `node_modules`).
|
|
98
|
+
- Do not add or modify a rule until the developer says yes. Then add it only if the developer provides a writable knowledge-base location; otherwise stop.
|
|
69
99
|
|
|
70
100
|
## Verification
|
|
71
101
|
|
|
72
|
-
Layers (do not mix): `npm run lint` = ESLint. `npm run typecheck` = TypeScript, including JSX props on the public type. `npm run sg:scan` = structural facts the scanner can prove — keep it strict and dumb. `knowledge-base/validation/` = Design System / UX / architecture. The agent = context and judgment.
|
|
102
|
+
Layers (do not mix): `npm run lint` = ESLint. `npm run typecheck` = TypeScript, including JSX props on the public type. `npm run sg:scan` = structural facts the scanner can prove — keep it strict and dumb. Package `knowledge-base/validation/` = Design System / UX / architecture. The agent = context and judgment.
|
|
73
103
|
|
|
74
104
|
After a modification:
|
|
75
105
|
|
|
76
|
-
- 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`.
|
|
106
|
+
- Check the change against package `knowledge-base/validation/` for the files that match. For a read-only pass on the diff, use `.cursor/agents/code-reviewer.md`.
|
|
77
107
|
- Check that existing features are not unnecessarily affected.
|
|
78
|
-
- If a new component has been created
|
|
108
|
+
- If a new component has been created in the **project**, export it from that folder's `index.ts` (`components/ui/`, `components/layout/`, or `components/shared/`). Never export into the package under `node_modules`.
|
|
79
109
|
- 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
110
|
- Report any problems or hypotheses that require a decision from the developer.
|
|
81
111
|
|
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);
|
package/template/app/globals.css
CHANGED
|
@@ -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
|
+
"./node_modules/@modoock/components/components/ui"
|
|
29
|
+
],
|
|
30
|
+
"@/components/ui/*": [
|
|
31
|
+
"./node_modules/@modoock/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
|
]
|