galadrim-feedback 0.0.91 → 1.0.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.
Files changed (4) hide show
  1. package/README.md +199 -24
  2. package/bin/cli.js +189 -0
  3. package/index.d.ts +1 -1
  4. package/package.json +9 -2
package/README.md CHANGED
@@ -1,26 +1,112 @@
1
- # Installation Guide for Galadrim Feedback
1
+ # Galadrim Feedback
2
2
 
3
- ## Prérequis
3
+ ## Project Configuration
4
4
 
5
- Avant d'installer **Galadrim Feedback**, assurez-vous d'avoir **axios** installé dans votre projet.
5
+ Go to https://feedback.galadrim.ovh/admin
6
+
7
+ Log in with credentials from Passbolt: Back-Office - Galadrim Feedback
8
+
9
+ Create a project
10
+
11
+ Copy the project ID
12
+
13
+ ## Installation
14
+
15
+ ### 🚀 Super Quick Install (Recommended)
16
+
17
+ Use our CLI to automatically copy the installation prompt:
18
+
19
+ ```bash
20
+ npx galadrim-feedback cursor-init --project-id="project_id"
21
+ ```
22
+
23
+ This will copy the complete installation prompt to your clipboard. Then simply paste it into Cursor and let it handle the installation automatically!
24
+
25
+ <details>
26
+ <summary><h3>🤖 Quick Install with Cursor</h3></summary>
27
+
28
+ ```
29
+ Install and configure Galadrim Feedback in this React project:
30
+
31
+ 1. Install dependencies:
32
+ - Run: yarn add axios galadrim-feedback
33
+
34
+ 2. Detect and configure Babel plugin based on project setup:
35
+ - First, check if this project uses React Router by looking for @react-router dependencies in package.json
36
+ - If React Router is detected:
37
+ * Install: yarn add babel-plugin-react-generate-paths vite-plugin-babel
38
+ * Create/update .babelrc with:
39
+ {
40
+ "presets": ["@babel/preset-typescript"],
41
+ "plugins": ["babel-plugin-react-generate-paths"]
42
+ }
43
+ * Update vite.config.ts to add babel plugin:
44
+ import babel from "vite-plugin-babel";
45
+ Add babel plugin with include: ["./app/**/*.tsx", "./app/**/*.ts"], filter: (name) => name.endsWith(".tsx")
46
+ - Else if vite.config.ts exists:
47
+ * Update vite.config.ts to add babel-plugin-react-generate-paths to the react plugin configuration
48
+ - Else if .babelrc exists:
49
+ * Add "babel-plugin-react-generate-paths" to the plugins array in .babelrc
50
+
51
+ 3. Configure FeedbackRoot component:
52
+ - Run `pwd` command in the frontend root directory and use this absolute path for rootDir prop
53
+ - Detect navigation package used in the project:
54
+ * If using React Router (react-router-dom):
55
+ - Import: import { useNavigate } from "react-router-dom";
56
+ - Hook: const navigate = useNavigate();
57
+ - Navigate prop: navigate={(path) => navigate(path)}
58
+ * If using Next.js router (next/router):
59
+ - Import: import { useRouter } from "next/router";
60
+ - Hook: const router = useRouter();
61
+ - Navigate prop: navigate={(path) => router.push(path)}
62
+ * If using Next.js app router (next/navigation):
63
+ - Import: import { useRouter } from "next/navigation";
64
+ - Hook: const router = useRouter();
65
+ - Navigate prop: navigate={(path) => router.push(path)}
66
+ - Add FeedbackRoot to the main App component with:
67
+ * Import FeedbackRoot from "galadrim-feedback"
68
+ * Import "galadrim-feedback/dist/styles.css"
69
+ * Add <FeedbackRoot> component with these props:
70
+ - rootDir="{absolute path from pwd command}"
71
+ - projectId="your-project-id" (placeholder - user needs to get this from admin)
72
+ - navigate={(path) => navigate(path)} (using detected navigation method)
73
+ - position="bottom-right"
74
+ * Place it inside the router context but outside main content areas
75
+
76
+ 4. Verification:
77
+ - Show all modified files
78
+ - Confirm the navigation setup works with the detected router
79
+ - List any manual steps needed (like getting projectId from admin)
80
+
81
+ Be very specific about file paths and exact code to add. Show the complete import statements and component setup.
82
+ ```
83
+
84
+ </details>
85
+
86
+ <details>
87
+ <summary><h3>Manual Installation</h3></summary>
88
+
89
+ ### Prerequisites
90
+
91
+ Before installing **Galadrim Feedback**, make sure you have **axios** installed in your project.
6
92
 
7
93
  ```bash
8
94
  yarn add axios
9
95
  ```
10
96
 
11
- Ensuite, installez **Galadrim Feedback** :
97
+ Then, install **Galadrim Feedback**:
12
98
 
13
99
  ```bash
14
100
  yarn add galadrim-feedback
15
101
  ```
16
102
 
17
- ## Configuration Babel
103
+ ### Babel Configuration
18
104
 
19
- Ajoutez le plugin **babel-plugin-react-generate-paths** dans votre configuration Babel.
105
+ Add the **babel-plugin-react-generate-paths** plugin to your Babel configuration.
20
106
 
21
- ### Option 1: Dans `vite.config.ts`
107
+ #### Option 1: In `vite.config.ts`
22
108
 
23
- Si vous utilisez Vite, ajoutez le plugin dans le fichier `vite.config.ts` comme suit :
109
+ If you're using Vite, add the plugin in the `vite.config.ts` file as follows:
24
110
 
25
111
  ```typescript
26
112
  import { defineConfig } from "vite";
@@ -38,9 +124,9 @@ export default defineConfig({
38
124
  });
39
125
  ```
40
126
 
41
- ### Option 2: Dans `.babelrc`
127
+ #### Option 2: In `.babelrc`
42
128
 
43
- Si vous utilisez un fichier `.babelrc`, ajoutez le plugin dans la section `plugins` :
129
+ If you're using a `.babelrc` file, add the plugin to the `plugins` section:
44
130
 
45
131
  ```json
46
132
  {
@@ -48,7 +134,7 @@ Si vous utilisez un fichier `.babelrc`, ajoutez le plugin dans la section `plugi
48
134
  }
49
135
  ```
50
136
 
51
- ### Pour React router :
137
+ #### For React Router:
52
138
 
53
139
  ```typescript
54
140
  // vite.config.ts
@@ -78,28 +164,117 @@ export default defineConfig({
78
164
  }
79
165
  ```
80
166
 
81
- ## Intégration de FeedbackRoot
167
+ ### FeedbackRoot Integration
82
168
 
83
- Ajoutez le composant **FeedbackRoot** à la racine de votre application. Il doit être placé à l'intérieur du **router**.
169
+ Add the **FeedbackRoot** component to the root of your application. It must be placed inside the **router**.
84
170
 
85
171
  ```javascript
86
172
  import FeedbackRoot from "galadrim-feedback";
87
- import "galadrim-feedback/dist/styles.css"; // N'oubliez pas d'importer les styles CSS
173
+ import "galadrim-feedback/dist/styles.css"; // Don't forget to import the CSS styles
88
174
 
89
- // Ajoutez FeedbackRoot à votre application
175
+ // Add FeedbackRoot to your application
90
176
  <FeedbackRoot
91
177
  rootDir="/path/to/your/project"
92
- projectId="your-project-id" // L'id de votre projet dans Galadmin
93
- navigate={(path) => navigate(path)} // Fonction de navigation pour utiliser votre router
94
- position="bottom-right" // Position du bouton pour ouvrir le mode Feedback (bottom-right, bottom-left, top-right, top-left)
178
+ projectId="your-project-id" // Your project ID in Galadmin
179
+ navigate={(path) => navigate(path)} // Navigation function to use your router
180
+ position="bottom-right" // Position of the button to open Feedback mode (bottom-right, bottom-left, top-right, top-left)
95
181
  />;
96
182
  ```
97
183
 
98
- ### Explication des Props :
184
+ #### Props Explanation:
185
+
186
+ - **rootDir**: The path to your project root up to src (feedbacks will be linked to components with the path `src/path/to/your/component` which is combined with rootDir to open them in VSCode).
187
+ - **projectId**: Your project identifier in **Galadmin**. (request from an administrator)
188
+ - **navigate**: A function that takes a path and allows you to navigate using your **router**.
189
+ - **position**: The position of the button to open Feedback mode (bottom-right, bottom-left, top-right, top-left)
190
+
191
+ This concludes the installation of **Galadrim Feedback** in your project!
192
+
193
+ </details>
194
+
195
+ ## Account Creation
196
+
197
+ Once it's installed, you can sign up and then in the galadmin, you add yourself as a collaborator on the project
198
+
199
+ ## Galadrim Feedback MCP Server
200
+
201
+ A Model Context Protocol (MCP) server for the Galadrim feedback system. This server provides tools to fetch and manage feedbacks from a project via the backend API.
202
+
203
+ ### Cursor Configuration
204
+
205
+ To add this MCP server to Cursor, you need to configure it in your Cursor settings.
206
+
207
+ Add the following to your Cursor MCP settings:
208
+
209
+ ```json
210
+ {
211
+ "mcpServers": {
212
+ "galadrim-feedback": {
213
+ "command": "npx",
214
+ "args": ["galadrim-feedback-mcp@latest"]
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ ### Available Tools
221
+
222
+ #### `get_feedbacks`
223
+
224
+ Fetches all feedbacks for a specific project from the Galadrim feedback backend API.
225
+
226
+ #### `mark_as_resolved`
227
+
228
+ Marks a feedback as resolved.
229
+
230
+ #### `mark_multiple_as_resolved`
231
+
232
+ Marks multiple feedbacks as resolved.
233
+
234
+ ## CLI Commands
235
+
236
+ Galadrim Feedback includes a CLI tool for easier setup and management.
237
+
238
+ ### Available Commands
239
+
240
+ #### `cursor-init`
241
+
242
+ Automatically sends the installation prompt directly to your IDE or copies it to clipboard.
243
+
244
+ ```bash
245
+ npx galadrim-feedback cursor-init
246
+ ```
247
+
248
+ **What it does:**
249
+
250
+ - 🔍 **Auto-detects** running IDEs (Cursor, VS Code)
251
+ - 🚀 **Direct integration**:
252
+ - **macOS**: Uses AppleScript to interact directly with IDE
253
+ - **All platforms**: Creates temporary file with formatted prompt
254
+ - **Fallback**: Copies to clipboard if direct methods fail
255
+ - 📝 **Smart formatting**: Creates markdown file with copy-ready prompt
256
+ - 🧹 **Clean workflow**: Temporary files can be deleted after use
257
+
258
+ **Integration Methods:**
259
+
260
+ 1. **AppleScript (macOS)**: Attempts to open AI chat and paste prompt directly
261
+ 2. **File creation**: Opens a formatted `.md` file in your IDE
262
+ 3. **Clipboard fallback**: Traditional copy-to-clipboard as backup
263
+
264
+ #### `help`
265
+
266
+ Shows all available CLI commands and usage information.
267
+
268
+ ```bash
269
+ npx galadrim-feedback help
270
+ ```
271
+
272
+ ### Cross-Platform Support
273
+
274
+ The CLI automatically detects your operating system and uses the appropriate clipboard command:
99
275
 
100
- - **rootDir** : Le chemin vers la racine de votre projet jusqu'à src (les feedbacks seront liés au composant avec le chemin `src/path/to/your/component` auquel on ajoute le rootDir pour pouvoir les ouvrir dans VScode).
101
- - **projectId** : L'identifiant de votre projet dans **Galadmin**. (demandé à un administrateur)
102
- - **navigate** : Une fonction qui prend un chemin et vous permet de naviguer en utilisant votre **router**.
103
- - **position** : La position du bouton pour ouvrir le mode Feedback (bottom-right, bottom-left, top-right, top-left)
276
+ - **macOS**: `pbcopy`
277
+ - **Linux**: `xclip`
278
+ - **Windows**: `clip`
104
279
 
105
- Cela conclut l'installation de **Galadrim Feedback** dans votre projet !
280
+ If clipboard operations fail, the CLI will display the prompt text for manual copying.
package/bin/cli.js ADDED
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync, existsSync } from "fs";
4
+ import { fileURLToPath } from "url";
5
+ import { dirname, join } from "path";
6
+ import { spawn, exec } from "child_process";
7
+ import { promisify } from "util";
8
+ import * as vscode from "vscode-test";
9
+
10
+ const execAsync = promisify(exec);
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
13
+
14
+ const PROJECT_ID = process.argv
15
+ .find((arg) => arg.startsWith("--project-id="))
16
+ ?.split("=")[1]
17
+ .trim();
18
+
19
+ const CURSOR_PROMPT = `Install and configure Galadrim Feedback in this React project:
20
+
21
+ 1. Install dependencies:
22
+ - Run: yarn add axios galadrim-feedback
23
+
24
+ 2. Detect and configure Babel plugin based on project setup:
25
+ - First, check if this project uses React Router by looking for @react-router dependencies in package.json
26
+ - If React Router is detected:
27
+ * Install: yarn add babel-plugin-react-generate-paths vite-plugin-babel
28
+ * Create/update .babelrc with:
29
+ {
30
+ "presets": ["@babel/preset-typescript"],
31
+ "plugins": ["babel-plugin-react-generate-paths"]
32
+ }
33
+ * Update vite.config.ts to add babel plugin:
34
+ import babel from "vite-plugin-babel";
35
+ Add babel plugin with include: ["./app/**/*.tsx", "./app/**/*.ts"], filter: (name) => name.endsWith(".tsx")
36
+ - Else if vite.config.ts exists:
37
+ * Update vite.config.ts to add babel-plugin-react-generate-paths to the react plugin configuration
38
+ - Else if .babelrc exists:
39
+ * Add "babel-plugin-react-generate-paths" to the plugins array in .babelrc
40
+
41
+ 3. Configure FeedbackRoot component:
42
+ - Run \`pwd\` command in the frontend root directory and use this absolute path for rootDir prop
43
+ - Detect navigation package used in the project:
44
+ * If using React Router (react-router-dom):
45
+ - Import: import { useNavigate } from "react-router-dom";
46
+ - Hook: const navigate = useNavigate();
47
+ - Navigate prop: navigate={(path) => navigate(path)}
48
+ * If using Next.js router (next/router):
49
+ - Import: import { useRouter } from "next/router";
50
+ - Hook: const router = useRouter();
51
+ - Navigate prop: navigate={(path) => router.push(path)}
52
+ * If using Next.js app router (next/navigation):
53
+ - Import: import { useRouter } from "next/navigation";
54
+ - Hook: const router = useRouter();
55
+ - Navigate prop: navigate={(path) => router.push(path)}
56
+ - Add FeedbackRoot to the main App component with:
57
+ * Import FeedbackRoot from "galadrim-feedback"
58
+ * Import "galadrim-feedback/dist/styles.css"
59
+ * Add <FeedbackRoot> component with these props:
60
+ - rootDir="{absolute path from pwd command}"
61
+ - projectId="${PROJECT_ID}"
62
+ - navigate={(path) => navigate(path)} (using detected navigation method)
63
+ - position="bottom-right"
64
+ * Place it inside the router context but outside main content areas
65
+
66
+ 4. Verification:
67
+ - Show all modified files
68
+ - Confirm the navigation setup works with the detected router
69
+ - List any manual steps needed (like getting projectId from admin) (see https://feedback.galadrim.ovh/admin)
70
+
71
+ Be very specific about file paths and exact code to add. Show the complete import statements and component setup.`;
72
+
73
+ function showHelp() {
74
+ console.log(`
75
+ 🚀 Galadrim Feedback CLI
76
+
77
+ Usage:
78
+ npx galadrim-feedback <command> [--project-id <project-id>]
79
+
80
+ Commands:
81
+ cursor-init Send the installation prompt directly to Cursor/VS Code
82
+ help Show this help message
83
+
84
+ Examples:
85
+ npx galadrim-feedback cursor-init --project-id <project-id>
86
+ npx galadrim-feedback help
87
+ `);
88
+ }
89
+
90
+ function copyToClipboard(text) {
91
+ return new Promise((resolve, reject) => {
92
+ let copyCommand;
93
+
94
+ // Detect platform and use appropriate command
95
+ if (process.platform === "darwin") {
96
+ copyCommand = spawn("pbcopy", [], {
97
+ stdio: ["pipe", "inherit", "inherit"],
98
+ });
99
+ } else if (process.platform === "linux") {
100
+ copyCommand = spawn("xclip", ["-selection", "clipboard"], {
101
+ stdio: ["pipe", "inherit", "inherit"],
102
+ });
103
+ } else if (process.platform === "win32") {
104
+ copyCommand = spawn("clip", [], {
105
+ stdio: ["pipe", "inherit", "inherit"],
106
+ });
107
+ } else {
108
+ reject(new Error("Unsupported platform for clipboard operations"));
109
+ return;
110
+ }
111
+
112
+ copyCommand.stdin.write(text);
113
+ copyCommand.stdin.end();
114
+
115
+ copyCommand.on("close", (code) => {
116
+ if (code === 0) {
117
+ resolve();
118
+ } else {
119
+ reject(new Error(`Copy command failed with code ${code}`));
120
+ }
121
+ });
122
+
123
+ copyCommand.on("error", (err) => {
124
+ reject(err);
125
+ });
126
+ });
127
+ }
128
+
129
+ async function handleCursorInit() {
130
+ try {
131
+ // Fallback to clipboard
132
+ console.log(
133
+ "📋 Copying Galadrim Feedback installation prompt to clipboard..."
134
+ );
135
+
136
+ await copyToClipboard(CURSOR_PROMPT);
137
+
138
+ console.log("✅ Installation prompt copied to clipboard!");
139
+ console.log("");
140
+ console.log("🎯 Next steps:");
141
+ console.log("1. Open Cursor or VS Code in your React project");
142
+ console.log("2. Paste the prompt (Cmd+V / Ctrl+V) into the AI chat");
143
+ console.log(
144
+ "3. Let your AI assistant automatically configure Galadrim Feedback!"
145
+ );
146
+ console.log("");
147
+ console.log(
148
+ '💡 Make sure to replace "your-project-id" with your actual project ID from Galadmin.'
149
+ );
150
+ } catch (error) {
151
+ console.error("❌ Failed to copy to clipboard:", error.message);
152
+ console.log("");
153
+ console.log("📝 Manual copy - use this prompt in your AI assistant:");
154
+ console.log("");
155
+ console.log("```");
156
+ console.log(CURSOR_PROMPT);
157
+ console.log("```");
158
+ process.exit(1);
159
+ }
160
+ }
161
+
162
+ function main() {
163
+ const args = process.argv.slice(2);
164
+ const command = args[0];
165
+
166
+ switch (command) {
167
+ case "cursor-init":
168
+ handleCursorInit();
169
+ break;
170
+ case "help":
171
+ case "--help":
172
+ case "-h":
173
+ showHelp();
174
+ break;
175
+ case undefined:
176
+ console.log(
177
+ '❌ No command specified. Use "help" to see available commands.'
178
+ );
179
+ showHelp();
180
+ process.exit(1);
181
+ break;
182
+ default:
183
+ console.log(`❌ Unknown command: ${command}`);
184
+ showHelp();
185
+ process.exit(1);
186
+ }
187
+ }
188
+
189
+ main();
package/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface FeedbackRootProps {
6
6
  githubUrl?: string;
7
7
  rootDir: string;
8
8
  projectId: string;
9
- navigate: (path: string) => Promise<void>;
9
+ navigate: (path: string) => Promise<void> | void;
10
10
  position?: Position;
11
11
  pathname?: string;
12
12
  }
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "galadrim-feedback",
3
3
  "private": false,
4
- "version": "0.0.91",
4
+ "version": "1.0.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.es",
8
8
  "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "galadrim-feedback": "./bin/cli.js"
11
+ },
9
12
  "files": [
10
13
  "src",
11
14
  "dist",
15
+ "bin",
12
16
  "package.json",
13
17
  "*.d.ts",
14
18
  "libs",
@@ -22,11 +26,14 @@
22
26
  "dependencies": {
23
27
  "@babel/core": "^7.26.10",
24
28
  "@tanstack/react-query": "^5.59.19",
29
+ "@types/vscode": "^1.101.0",
25
30
  "babel-plugin-react-generate-paths": "^0.0.2",
26
31
  "moment": "^2.30.1",
27
32
  "react-spinners": "^0.17.0",
28
33
  "sse.js": "^2.6.0",
29
- "styled-components": "^6.1.17"
34
+ "styled-components": "^6.1.17",
35
+ "vscode": "^1.1.37",
36
+ "vscode-test": "^1.6.1"
30
37
  },
31
38
  "peerDependencies": {
32
39
  "axios": ">=1.8.4",