@jk3labs/paperclip-plugin-file-browser 0.2.8 → 0.2.9

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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@jk3labs/paperclip-plugin-file-browser",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "A Paperclip plugin for browsing files in the default workspace",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "jest",
8
8
  "test:watch": "jest --watch",
@@ -17,8 +17,7 @@
17
17
  "license": "ISC",
18
18
  "files": [
19
19
  "dist",
20
- "index.js",
21
- "plugin.json"
20
+ "src/plugin.json"
22
21
  ],
23
22
  "dependencies": {
24
23
  "@types/archiver": "^7.0.0",
package/index.js DELETED
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- const express = require("express");
4
- const fs = require("fs-extra");
5
- const path = require("path");
6
-
7
- module.exports = (pluginContext) => {
8
- const router = express.Router();
9
-
10
- // Dynamic root lookup: Use Paperclip's workspace root
11
- const rootDir = pluginContext.workspaceRoot || process.env.PAPERCLIP_WORKSPACE_ROOT || process.cwd();
12
-
13
- /**
14
- * GET /files/list
15
- * List files and directories at the given path
16
- */
17
- router.get("/list", async (req, res) => {
18
- const { dir } = req.query;
19
- if (!dir) {
20
- return res.status(400).json({ error: "Query parameter 'dir' is required" });
21
- }
22
-
23
- const targetPath = path.join(rootDir, dir);
24
- try {
25
- const stats = await fs.stat(targetPath);
26
- if (!stats.isDirectory()) {
27
- return res.status(400).json({ error: "Path is not a directory" });
28
- }
29
-
30
- const items = await fs.readdir(targetPath);
31
- const detailedItems = await Promise.all(
32
- items.map(async (item) => {
33
- const itemPath = path.join(targetPath, item);
34
- const itemStats = await fs.stat(itemPath);
35
- return {
36
- name: item,
37
- path: path.relative(rootDir, itemPath),
38
- isDirectory: itemStats.isDirectory(),
39
- size: itemStats.size,
40
- modified: itemStats.mtime
41
- };
42
- })
43
- );
44
-
45
- res.json({
46
- path: dir,
47
- items: detailedItems
48
- });
49
- } catch (error) {
50
- res.status(500).json({ error: error.message });
51
- }
52
- });
53
-
54
- /**
55
- * GET /files/read
56
- * Read file content
57
- */
58
- router.get("/read", async (req, res) => {
59
- const { file } = req.query;
60
- if (!file) {
61
- return res.status(400).json({ error: "Query parameter 'file' is required" });
62
- }
63
-
64
- const filePath = path.join(rootDir, file);
65
- try {
66
- const stats = await fs.stat(filePath);
67
- if (!stats.isFile()) {
68
- return res.status(400).json({ error: "Path is not a file" });
69
- }
70
-
71
- const content = await fs.readFile(filePath, "utf-8");
72
- res.json({
73
- path: file,
74
- content
75
- });
76
- } catch (error) {
77
- res.status(500).json({ error: error.message });
78
- }
79
- });
80
-
81
- return router;
82
- };
File without changes