create-claude-code-visualizer 0.1.1 ā 0.1.3
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/index.js +42 -44
- package/package.json +1 -1
- package/templates/app/src/app/api/ai/title/route.ts +2 -22
package/index.js
CHANGED
|
@@ -43,10 +43,11 @@ function copyIfNotExists(src, dest) {
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function copyDirAdditive(src, dest) {
|
|
46
|
+
function copyDirAdditive(src, dest, skipPrefix) {
|
|
47
47
|
fs.mkdirSync(dest, { recursive: true });
|
|
48
48
|
let added = 0;
|
|
49
49
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
50
|
+
if (skipPrefix && entry.name.startsWith(skipPrefix)) continue;
|
|
50
51
|
const srcPath = path.join(src, entry.name);
|
|
51
52
|
const destPath = path.join(dest, entry.name);
|
|
52
53
|
if (entry.isDirectory()) {
|
|
@@ -176,10 +177,11 @@ async function main() {
|
|
|
176
177
|
);
|
|
177
178
|
log(`Commands: added ${addedCommands} new`);
|
|
178
179
|
|
|
179
|
-
// Skills
|
|
180
|
+
// Skills (skip gws-* skills ā those are installed with Google Workspace setup)
|
|
180
181
|
const addedSkills = copyDirAdditive(
|
|
181
182
|
path.join(srcClaude, "skills"),
|
|
182
|
-
path.join(dstClaude, "skills")
|
|
183
|
+
path.join(dstClaude, "skills"),
|
|
184
|
+
"gws-"
|
|
183
185
|
);
|
|
184
186
|
log(`Skills: added ${addedSkills} new`);
|
|
185
187
|
|
|
@@ -289,47 +291,45 @@ PROJECT_ROOT=${projectRoot}
|
|
|
289
291
|
|
|
290
292
|
if (setupGws) {
|
|
291
293
|
console.log("");
|
|
292
|
-
info("Installing Google Workspace CLI...");
|
|
293
|
-
run("npm install @anthropic-ai/claude-code-google-workspace", { cwd: projectRoot });
|
|
294
|
-
|
|
295
|
-
// Check if gws auth is needed
|
|
296
|
-
const hasAuth = runCapture("npx gws auth status");
|
|
297
|
-
if (!hasAuth) {
|
|
298
|
-
console.log("");
|
|
299
|
-
const { gwsAuth } = await prompts({
|
|
300
|
-
type: "select",
|
|
301
|
-
name: "gwsAuth",
|
|
302
|
-
message: "Google Workspace authentication",
|
|
303
|
-
choices: [
|
|
304
|
-
{ title: "Full setup (creates GCP project + OAuth)", value: "setup" },
|
|
305
|
-
{ title: "Login only (you already have OAuth configured)", value: "login" },
|
|
306
|
-
{ title: "Skip for now", value: "skip" },
|
|
307
|
-
],
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
if (gwsAuth === "setup") {
|
|
311
|
-
run("npx gws auth setup --login", { cwd: projectRoot });
|
|
312
|
-
} else if (gwsAuth === "login") {
|
|
313
|
-
run("npx gws auth login", { cwd: projectRoot });
|
|
314
|
-
} else {
|
|
315
|
-
info("Skipping auth. Run later: npx gws auth setup --login");
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
log("Already authenticated with Google Workspace");
|
|
319
|
-
}
|
|
320
294
|
|
|
321
|
-
// Install
|
|
295
|
+
// Install the Google Workspace CLI
|
|
296
|
+
info("Installing Google Workspace CLI (@googleworkspace/cli)...");
|
|
297
|
+
run("npm install @googleworkspace/cli", { cwd: projectRoot });
|
|
298
|
+
log("Google Workspace CLI installed");
|
|
299
|
+
|
|
300
|
+
// Authenticate
|
|
322
301
|
console.log("");
|
|
323
|
-
const {
|
|
324
|
-
type: "
|
|
325
|
-
name: "
|
|
326
|
-
message: "
|
|
327
|
-
|
|
302
|
+
const { gwsAuth } = await prompts({
|
|
303
|
+
type: "select",
|
|
304
|
+
name: "gwsAuth",
|
|
305
|
+
message: "Google Workspace authentication",
|
|
306
|
+
choices: [
|
|
307
|
+
{ title: "Login now (opens browser for OAuth)", value: "login" },
|
|
308
|
+
{ title: "Skip for now (run 'npx gws auth login' later)", value: "skip" },
|
|
309
|
+
],
|
|
328
310
|
});
|
|
329
311
|
|
|
330
|
-
if (
|
|
331
|
-
run("npx
|
|
312
|
+
if (gwsAuth === "login") {
|
|
313
|
+
run("npx gws auth login", { cwd: projectRoot });
|
|
314
|
+
} else {
|
|
315
|
+
info("Skipping auth. Run later: cd " + projectDir + " && npx gws auth login");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Install GWS skills from bundled templates
|
|
319
|
+
console.log("");
|
|
320
|
+
info("Installing Google Workspace skills...");
|
|
321
|
+
const gwsSkillsSrc = path.join(srcClaude, "skills");
|
|
322
|
+
const gwsSkillsDst = path.join(dstClaude, "skills");
|
|
323
|
+
let addedGws = 0;
|
|
324
|
+
for (const entry of fs.readdirSync(gwsSkillsSrc, { withFileTypes: true })) {
|
|
325
|
+
if (!entry.name.startsWith("gws-") || !entry.isDirectory()) continue;
|
|
326
|
+
const destPath = path.join(gwsSkillsDst, entry.name);
|
|
327
|
+
if (!fs.existsSync(destPath)) {
|
|
328
|
+
copyDir(path.join(gwsSkillsSrc, entry.name), destPath);
|
|
329
|
+
addedGws++;
|
|
330
|
+
}
|
|
332
331
|
}
|
|
332
|
+
log(`GWS Skills: added ${addedGws} new`);
|
|
333
333
|
|
|
334
334
|
// Add gws permission to settings
|
|
335
335
|
const settingsPath = path.join(dstClaude, "settings.local.json");
|
|
@@ -367,11 +367,9 @@ PROJECT_ROOT=${projectRoot}
|
|
|
367
367
|
console.log("");
|
|
368
368
|
|
|
369
369
|
if (!setupGws) {
|
|
370
|
-
info("To add Google Workspace later:");
|
|
371
|
-
console.log(`
|
|
372
|
-
console.log("
|
|
373
|
-
console.log(" npx gws auth setup --login");
|
|
374
|
-
console.log(" npx skills add https://github.com/googleworkspace/cli");
|
|
370
|
+
info("To add Google Workspace later, re-run:");
|
|
371
|
+
console.log(` npx create-claude-code-visualizer ${projectDir === "." ? "" : projectDir}`);
|
|
372
|
+
console.log(" (and choose Yes for Google Workspace)");
|
|
375
373
|
console.log("");
|
|
376
374
|
}
|
|
377
375
|
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from "next/server";
|
|
2
2
|
import { supabase } from "@/lib/supabase";
|
|
3
|
-
|
|
4
|
-
const GEMINI_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-lite-preview:generateContent";
|
|
3
|
+
import { callHaiku } from "@/lib/ai";
|
|
5
4
|
|
|
6
5
|
const SYSTEM_PROMPT =
|
|
7
6
|
"You name chat conversations. Given the user's first message, generate a very short chat title (2-5 words max). Start with a relevant emoji. Return ONLY the title, nothing else. Examples:\nš Fix login bug\nš Sales dashboard layout\nš Deploy to production\nāļø Write blog post\nš§ Email template help";
|
|
8
7
|
|
|
9
8
|
async function generateTitle(message: string): Promise<string> {
|
|
10
|
-
const
|
|
11
|
-
if (!apiKey) throw new Error("GEMINI_API_KEY not set");
|
|
12
|
-
|
|
13
|
-
const res = await fetch(`${GEMINI_URL}?key=${apiKey}`, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: { "Content-Type": "application/json" },
|
|
16
|
-
body: JSON.stringify({
|
|
17
|
-
system_instruction: { parts: [{ text: SYSTEM_PROMPT }] },
|
|
18
|
-
contents: [{ parts: [{ text: message }] }],
|
|
19
|
-
generationConfig: { maxOutputTokens: 30, temperature: 0.7 },
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!res.ok) {
|
|
24
|
-
const body = await res.text();
|
|
25
|
-
throw new Error(`Gemini API error ${res.status}: ${body}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const data = await res.json();
|
|
29
|
-
const text = data.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
9
|
+
const text = await callHaiku(SYSTEM_PROMPT, [{ role: "user", content: message }], 30);
|
|
30
10
|
return text.trim().replace(/^["']|["']$/g, "");
|
|
31
11
|
}
|
|
32
12
|
|