@majkapp/plugin-kit 3.3.0 → 3.3.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.
@@ -16,20 +16,76 @@ const cli = createPromptable({
16
16
  title: '@majkapp/plugin-kit',
17
17
  description: 'Build MAJK plugins with functions, UI screens, and services',
18
18
  docsDir: join(__dirname, '../docs'),
19
- packageCommand: 'npx @majkapp/plugin-kit',
20
- views: {
21
- llm: 'INDEX.md',
22
- functions: 'FUNCTIONS.md',
23
- screens: 'SCREENS.md',
24
- hooks: 'HOOKS.md',
25
- context: 'CONTEXT.md',
26
- services: 'SERVICES.md',
27
- lifecycle: 'LIFECYCLE.md',
28
- testing: 'TESTING.md',
29
- config: 'CONFIG.md',
30
- api: 'API.md',
31
- full: 'FULL.md'
32
- }
19
+ packageCommand: 'npx @majkapp/plugin-kit'
33
20
  });
34
21
 
35
- cli.parse(process.argv);
22
+ // Main entry point - quick start
23
+ cli.addCommand('--llm',
24
+ cli.createFullDocCommand('INDEX.md'),
25
+ {
26
+ description: 'Quick start: Build your first plugin',
27
+ aliases: ['--start', '--quick']
28
+ }
29
+ );
30
+
31
+ // Function patterns
32
+ cli.addCommand('--functions',
33
+ cli.createFullDocCommand('FUNCTIONS.md'),
34
+ { description: 'Function patterns with examples' }
35
+ );
36
+
37
+ // Screen configuration
38
+ cli.addCommand('--screens',
39
+ cli.createFullDocCommand('SCREENS.md'),
40
+ { description: 'Configure UI screens' }
41
+ );
42
+
43
+ // Generated React hooks
44
+ cli.addCommand('--hooks',
45
+ cli.createFullDocCommand('HOOKS.md'),
46
+ { description: 'Auto-generated React hooks' }
47
+ );
48
+
49
+ // Context API
50
+ cli.addCommand('--context',
51
+ cli.createFullDocCommand('CONTEXT.md'),
52
+ { description: 'Context API reference' }
53
+ );
54
+
55
+ // Service grouping
56
+ cli.addCommand('--services',
57
+ cli.createFullDocCommand('SERVICES.md'),
58
+ { description: 'Organize functions by service' }
59
+ );
60
+
61
+ // Lifecycle hooks
62
+ cli.addCommand('--lifecycle',
63
+ cli.createFullDocCommand('LIFECYCLE.md'),
64
+ { description: 'Plugin lifecycle hooks' }
65
+ );
66
+
67
+ // Testing guide
68
+ cli.addCommand('--testing',
69
+ cli.createFullDocCommand('TESTING.md'),
70
+ { description: 'Testing guide' }
71
+ );
72
+
73
+ // Configuration
74
+ cli.addCommand('--config',
75
+ cli.createFullDocCommand('CONFIG.md'),
76
+ { description: 'Project configuration' }
77
+ );
78
+
79
+ // API reference
80
+ cli.addCommand('--api',
81
+ cli.createFullDocCommand('API.md'),
82
+ { description: 'Complete API reference' }
83
+ );
84
+
85
+ // Full documentation
86
+ cli.addCommand('--full',
87
+ cli.createFullDocCommand('FULL.md'),
88
+ { description: 'Complete documentation' }
89
+ );
90
+
91
+ cli.run();
package/docs/INDEX.md CHANGED
@@ -104,11 +104,130 @@ my-plugin/
104
104
  │ └── plugin/
105
105
  │ ├── functions/unit/ # Function tests
106
106
  │ └── ui/unit/ # UI tests with bot
107
- ├── vite.config.js # EXACT format required (see CONFIG.md)
108
- ├── package.json
107
+ ├── vite.config.js # EXACT format required (see below)
108
+ ├── package.json # REQUIRED: majk metadata section
109
109
  └── tsconfig.json
110
110
  ```
111
111
 
112
+ ## package.json (REQUIRED)
113
+
114
+ **CRITICAL:** Your package.json MUST include the `majk` metadata section and use an npm organization scope:
115
+
116
+ ```json
117
+ {
118
+ "name": "@yourorg/my-plugin",
119
+ "version": "1.0.0",
120
+ "description": "My awesome MAJK plugin",
121
+ "main": "index.js",
122
+ "keywords": ["majk", "plugin"],
123
+ "majk": {
124
+ "type": "in-process",
125
+ "entry": "index.js"
126
+ },
127
+ "scripts": {
128
+ "generate": "npx plugin-kit generate -e ./index.js -o ./ui/src/generated",
129
+ "dev": "vite",
130
+ "build": "tsc && npm run generate && vite build",
131
+ "preview": "vite preview",
132
+ "test": "npm run test:plugin",
133
+ "test:plugin": "npm run test:plugin:functions && npm run test:plugin:ui",
134
+ "test:plugin:functions": "npx majk-test --type functions",
135
+ "test:plugin:ui": "node tests/plugin/ui/unit/basic-navigation.test.js",
136
+ "clean": "rm -rf dist index.js index.d.ts ui/src/generated"
137
+ },
138
+ "dependencies": {
139
+ "@majkapp/plugin-kit": "^3.3.0",
140
+ "@majkapp/plugin-theme": "^1.0.0",
141
+ "@majkapp/plugin-ui": "^1.4.0",
142
+ "react": "^18.3.1",
143
+ "react-dom": "^18.3.1"
144
+ },
145
+ "devDependencies": {
146
+ "@majkapp/plugin-test": "^1.0.2",
147
+ "@types/react": "^18.3.1",
148
+ "@types/react-dom": "^18.3.1",
149
+ "@vitejs/plugin-react": "^4.3.4",
150
+ "typescript": "^5.3.3",
151
+ "vite": "^6.0.3"
152
+ }
153
+ }
154
+ ```
155
+
156
+ ### Package Naming (REQUIRED)
157
+
158
+ **Your plugin name MUST use an npm organization scope** (format: `@org/plugin-name`).
159
+
160
+ Replace `@yourorg` with your organization:
161
+ - If you have an npm organization: `@mycompany/my-plugin`
162
+ - If you don't have one: Use `@majkical/my-plugin`
163
+
164
+ Example: `@majkical/weather-widget`
165
+
166
+ ### majk Metadata Section
167
+
168
+ The `majk` object tells MAJK how to load your plugin:
169
+
170
+ **`type`**: `"in-process"` or `"remote"`
171
+ - `"in-process"` - Plugin runs in MAJK's Node.js process (most common)
172
+ - `"remote"` - Plugin runs in separate process (for isolation)
173
+
174
+ **`entry`**: Path to compiled plugin file (relative to package root)
175
+ - Usually `"index.js"` (compiled from `src/index.ts`)
176
+ - MAJK loads this file to get your plugin definition
177
+
178
+ ### Important Scripts
179
+
180
+ **`generate`** - Generate TypeScript client from plugin
181
+ ```bash
182
+ npm run generate # Regenerate after adding/changing functions
183
+ ```
184
+
185
+ **`build`** - Complete build pipeline
186
+ ```bash
187
+ npm run build # 1. Compile TS → index.js
188
+ # 2. Generate client
189
+ # 3. Build React UI → dist/
190
+ ```
191
+
192
+ **`test:plugin:functions`** - Test plugin functions
193
+ ```bash
194
+ npm run test:plugin:functions # Run all function tests
195
+ ```
196
+
197
+ **`test:plugin:ui`** - Test plugin UI with bot
198
+ ```bash
199
+ npm run test:plugin:ui # Run UI tests with browser automation
200
+ ```
201
+
202
+ ## vite.config.js (REQUIRED FORMAT)
203
+
204
+ **CRITICAL:** Use this EXACT format for your vite.config.js:
205
+
206
+ ```javascript
207
+ import { defineConfig } from 'vite';
208
+ import react from '@vitejs/plugin-react';
209
+
210
+ export default defineConfig({
211
+ plugins: [react()],
212
+ root: 'ui', // React source is in ui/ directory
213
+ base: '', // IMPORTANT: Empty string, NOT './'
214
+ server: {
215
+ port: 3000,
216
+ strictPort: false,
217
+ },
218
+ build: {
219
+ outDir: '../dist', // Build output to dist/ (parent of ui/)
220
+ assetsDir: 'assets',
221
+ emptyOutDir: true,
222
+ },
223
+ });
224
+ ```
225
+
226
+ **Why `base: ''`?**
227
+ - MAJK loads plugins in iframes with dynamic paths
228
+ - Empty base ensures assets load correctly
229
+ - `base: './'` will cause 404 errors for assets
230
+
112
231
  ## Best Practice: Decoupled Business Logic
113
232
 
114
233
  **ALWAYS separate business logic from plugin code.** This makes testing easier and allows logic reuse.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@majkapp/plugin-kit",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Pure plugin definition library for MAJK - outputs plugin definitions, not HTTP servers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
8
- "plugin-kit": "./bin/promptable-cli.js",
8
+ "plugin-kit": "./dist/generator/cli.js",
9
9
  "majk-plugin-kit": "./dist/generator/cli.js"
10
10
  },
11
11
  "repository": {