@jxtools/promptline 1.3.6 → 1.3.8
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/bin/promptline.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { existsSync, readFileSync, writeFileSync, copyFileSync, chmodSync } from
|
|
|
4
4
|
import { resolve, dirname, join } from 'path'
|
|
5
5
|
import { fileURLToPath } from 'url'
|
|
6
6
|
import { spawn, execSync } from 'child_process'
|
|
7
|
-
import { createInterface } from 'readline'
|
|
8
7
|
import { homedir } from 'os'
|
|
9
8
|
|
|
10
9
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
@@ -59,32 +58,7 @@ const hookFiles = [
|
|
|
59
58
|
'promptline-session-end.sh',
|
|
60
59
|
]
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!allHooksInstalled) {
|
|
65
|
-
const answer = await ask('Install PromptLine hooks for Claude Code? (Y/n) ')
|
|
66
|
-
|
|
67
|
-
if (answer.toLowerCase() === 'n') {
|
|
68
|
-
console.log(' Skipped. Run promptline again to install later.')
|
|
69
|
-
process.exit(0)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
installHooks()
|
|
73
|
-
} else {
|
|
74
|
-
const hooksOutdated = hookFiles.some(f => {
|
|
75
|
-
try {
|
|
76
|
-
const src = readFileSync(join(pkgDir, f), 'utf-8')
|
|
77
|
-
const dest = readFileSync(join(hooksDir, f), 'utf-8')
|
|
78
|
-
return src !== dest
|
|
79
|
-
} catch {
|
|
80
|
-
return true
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
if (hooksOutdated) {
|
|
85
|
-
installHooks()
|
|
86
|
-
}
|
|
87
|
-
}
|
|
61
|
+
installHooks()
|
|
88
62
|
|
|
89
63
|
// Start Vite dev server
|
|
90
64
|
const viteBin = resolve(pkgDir, 'node_modules', '.bin', 'vite')
|
|
@@ -127,16 +101,6 @@ process.on('SIGINT', () => {
|
|
|
127
101
|
|
|
128
102
|
// --- Helpers ---
|
|
129
103
|
|
|
130
|
-
function ask(question) {
|
|
131
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
132
|
-
return new Promise((resolve) => {
|
|
133
|
-
rl.question(question, (answer) => {
|
|
134
|
-
rl.close()
|
|
135
|
-
resolve(answer.trim() || 'y')
|
|
136
|
-
})
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
104
|
function installHooks() {
|
|
141
105
|
// Copy hook scripts
|
|
142
106
|
execSync(`mkdir -p "${hooksDir}"`)
|
|
@@ -191,5 +155,4 @@ function installHooks() {
|
|
|
191
155
|
}
|
|
192
156
|
|
|
193
157
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n')
|
|
194
|
-
console.log(`\x1b[32m✓\x1b[0m Hooks installed`)
|
|
195
158
|
}
|
package/package.json
CHANGED
|
@@ -37,6 +37,7 @@ export function SessionSection({ session, project, onMutate, defaultExpanded = t
|
|
|
37
37
|
|
|
38
38
|
async function handleClearPrompts(e: React.MouseEvent) {
|
|
39
39
|
e.stopPropagation();
|
|
40
|
+
if (!window.confirm('Clear all prompts?')) return;
|
|
40
41
|
try {
|
|
41
42
|
await api.clearPrompts(project, session.sessionId);
|
|
42
43
|
onMutate();
|
package/vite-plugin-api.ts
CHANGED
|
@@ -23,6 +23,10 @@ import {
|
|
|
23
23
|
|
|
24
24
|
const QUEUES_DIR = join(homedir(), '.promptline', 'queues');
|
|
25
25
|
|
|
26
|
+
export function isSafeSegment(s: string): boolean {
|
|
27
|
+
return s.length > 0 && !s.includes('/') && !s.includes('\\') && !s.includes('..');
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
function parseBody(req: IncomingMessage): Promise<Record<string, unknown>> {
|
|
27
31
|
return new Promise((resolve, reject) => {
|
|
28
32
|
let body = '';
|
|
@@ -160,6 +164,10 @@ async function handleApi(
|
|
|
160
164
|
// Parse URL segments: /api/projects/:project/sessions/:sessionId/prompts/:promptId
|
|
161
165
|
const segments = url.replace(/^\/api\//, '').split('/').map(decodeURIComponent);
|
|
162
166
|
|
|
167
|
+
if (!segments.every(isSafeSegment)) {
|
|
168
|
+
return jsonError(res, 400, 'Invalid path segment');
|
|
169
|
+
}
|
|
170
|
+
|
|
163
171
|
// GET /api/projects
|
|
164
172
|
if (segments[0] === 'projects' && segments.length === 1 && method === 'GET') {
|
|
165
173
|
return json(res, 200, listProjects(QUEUES_DIR));
|