mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
pr comment changes
This commit is contained in:
parent
59a060a770
commit
0485c73ba2
@ -123,72 +123,4 @@ export async function createDocsTools() {
|
||||
},
|
||||
}),
|
||||
};
|
||||
return {
|
||||
list_available_docs: tool({
|
||||
description:
|
||||
"Use this tool to learn about what Stack Auth is, available documentation, and see if you can use it for what you're working on. It returns a list of all available Stack Auth Documentation pages.",
|
||||
inputSchema: z.object({}),
|
||||
execute: async () => {
|
||||
return await postDocsToolAction({ action: "list_available_docs" });
|
||||
},
|
||||
}),
|
||||
|
||||
search_docs: tool({
|
||||
description:
|
||||
"Search through all Stack Auth documentation including API docs, guides, and examples. Returns ranked results with snippets and relevance scores.",
|
||||
inputSchema: z.object({
|
||||
search_query: z.string().describe("The search query to find relevant documentation"),
|
||||
result_limit: z.number().optional().describe("Maximum number of results to return (default: 50)"),
|
||||
}),
|
||||
execute: async ({ search_query, result_limit = 50 }) => {
|
||||
return await postDocsToolAction({
|
||||
action: "search_docs",
|
||||
search_query,
|
||||
result_limit,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
get_docs_by_id: tool({
|
||||
description:
|
||||
"Use this tool to retrieve a specific Stack Auth Documentation page by its ID. It gives you the full content of the page so you can know exactly how to use specific Stack Auth APIs. Whenever using Stack Auth, you should always check the documentation first to have the most up-to-date information. When you write code using Stack Auth documentation you should reference the content you used in your comments.",
|
||||
inputSchema: z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
execute: async ({ id }) => {
|
||||
return await postDocsToolAction({ action: "get_docs_by_id", id });
|
||||
},
|
||||
}),
|
||||
|
||||
get_stack_auth_setup_instructions: tool({
|
||||
description:
|
||||
"Use this tool when the user wants to set up authentication in a new project. It provides step-by-step instructions for installing and configuring Stack Auth authentication.",
|
||||
inputSchema: z.object({}),
|
||||
execute: async () => {
|
||||
return await postDocsToolAction({ action: "get_stack_auth_setup_instructions" });
|
||||
},
|
||||
}),
|
||||
|
||||
search: tool({
|
||||
description:
|
||||
"Search for Stack Auth documentation pages.\n\nUse this tool to find documentation pages that contain a specific keyword or phrase.",
|
||||
inputSchema: z.object({
|
||||
query: z.string(),
|
||||
}),
|
||||
execute: async ({ query }) => {
|
||||
return await postDocsToolAction({ action: "search", query });
|
||||
},
|
||||
}),
|
||||
|
||||
fetch: tool({
|
||||
description:
|
||||
"Fetch a particular Stack Auth Documentation page by its ID.\n\nThis tool is identical to `get_docs_by_id`.",
|
||||
inputSchema: z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
execute: async ({ id }) => {
|
||||
return await postDocsToolAction({ action: "fetch", id });
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@ -11,10 +11,10 @@
|
||||
"lint": "eslint --ext .ts,.tsx .",
|
||||
"clean": "rimraf .next && rimraf node_modules",
|
||||
"spacetime:generate": "spacetime generate --lang typescript --out-dir src/module_bindings --module-path spacetimedb",
|
||||
"spacetime:inject-token": "sed -i.bak \"s/__SPACETIMEDB_LOG_TOKEN__/${STACK_MCP_LOG_TOKEN:-change-me}/\" spacetimedb/src/index.ts",
|
||||
"spacetime:restore-token": "mv spacetimedb/src/index.ts.bak spacetimedb/src/index.ts",
|
||||
"spacetime:publish:local": "pnpm spacetime:inject-token && spacetime publish stack-auth-llm --server local -p spacetimedb --yes --no-config --delete-data=on-conflict; EXIT=$?; pnpm spacetime:restore-token; exit $EXIT",
|
||||
"spacetime:publish:prod": "pnpm spacetime:inject-token && spacetime publish stack-auth-llm --server maincloud -p spacetimedb --yes --no-config; EXIT=$?; pnpm spacetime:restore-token; exit $EXIT"
|
||||
"spacetime:inject-token": "node scripts/spacetime-token.mjs inject",
|
||||
"spacetime:restore-token": "node scripts/spacetime-token.mjs restore",
|
||||
"spacetime:publish:local": "node scripts/spacetime-publish.mjs local",
|
||||
"spacetime:publish:prod": "node scripts/spacetime-publish.mjs prod"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stackframe/react": "workspace:*",
|
||||
|
||||
36
apps/internal-tool/scripts/spacetime-publish.mjs
Normal file
36
apps/internal-tool/scripts/spacetime-publish.mjs
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform SpacetimeDB publish that injects the token, publishes, and
|
||||
// always restores the original file — even on failure.
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const target = process.argv[2]; // "local" or "prod"
|
||||
|
||||
const configs = {
|
||||
local: ["publish", "stack-auth-llm", "--server", "local", "-p", "spacetimedb", "--yes", "--no-config", "--delete-data=on-conflict"],
|
||||
prod: ["publish", "stack-auth-llm", "--server", "maincloud", "-p", "spacetimedb", "--yes", "--no-config"],
|
||||
};
|
||||
|
||||
const args = configs[target];
|
||||
if (!args) {
|
||||
console.error("Usage: node scripts/spacetime-publish.mjs <local|prod>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (target === "prod" && !process.env.STACK_MCP_LOG_TOKEN) {
|
||||
console.error("Error: STACK_MCP_LOG_TOKEN must be set for prod publish");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Inject token
|
||||
const inject = spawnSync("node", ["scripts/spacetime-token.mjs", "inject"], { stdio: "inherit" });
|
||||
if (inject.status !== 0) {
|
||||
process.exit(inject.status ?? 1);
|
||||
}
|
||||
|
||||
try {
|
||||
const publish = spawnSync("spacetime", args, { stdio: "inherit" });
|
||||
process.exitCode = publish.status ?? 1;
|
||||
} finally {
|
||||
spawnSync("node", ["scripts/spacetime-token.mjs", "restore"], { stdio: "inherit" });
|
||||
}
|
||||
27
apps/internal-tool/scripts/spacetime-token.mjs
Normal file
27
apps/internal-tool/scripts/spacetime-token.mjs
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform token injection/restoration for SpacetimeDB publish.
|
||||
// Replaces the Unix-only sed/mv scripts so pnpm dev works on Windows too.
|
||||
|
||||
import { readFileSync, writeFileSync, existsSync, renameSync, unlinkSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
const TARGET = resolve("spacetimedb/src/index.ts");
|
||||
const BACKUP = TARGET + ".bak";
|
||||
const PLACEHOLDER = "__SPACETIMEDB_LOG_TOKEN__";
|
||||
|
||||
const action = process.argv[2];
|
||||
|
||||
if (action === "inject") {
|
||||
const token = process.env.STACK_MCP_LOG_TOKEN || "change-me";
|
||||
const content = readFileSync(TARGET, "utf8");
|
||||
writeFileSync(BACKUP, content, "utf8");
|
||||
writeFileSync(TARGET, content.replaceAll(PLACEHOLDER, token), "utf8");
|
||||
} else if (action === "restore") {
|
||||
if (existsSync(BACKUP)) {
|
||||
unlinkSync(TARGET);
|
||||
renameSync(BACKUP, TARGET);
|
||||
}
|
||||
} else {
|
||||
console.error("Usage: node scripts/spacetime-token.mjs <inject|restore>");
|
||||
process.exit(1);
|
||||
}
|
||||
@ -295,7 +295,7 @@ function QaReviewCard({ row }: { row: McpCallLogRow }) {
|
||||
{flags.length > 0 && (
|
||||
<div className="space-y-1.5">
|
||||
{flags.map((flag, i) => (
|
||||
<div key={i} className={`border-l-3 pl-3 py-1.5 rounded-r text-sm ${severityColors[flag.severity] ?? severityColors.low}`}>
|
||||
<div key={i} className={`border-l-4 pl-3 py-1.5 rounded-r text-sm ${severityColors[flag.severity] ?? severityColors.low}`}>
|
||||
<div className="flex items-center gap-2 mb-0.5">
|
||||
<span className="font-mono text-xs text-gray-600">{flag.type}</span>
|
||||
<span className="text-[10px] uppercase text-gray-400">{flag.severity}</span>
|
||||
|
||||
@ -23,6 +23,7 @@ export function useMcpCallLogs() {
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
let retryCount = 0;
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
console.log("[SpacetimeDB] Connecting to", HOST, "db:", DB_NAME);
|
||||
|
||||
@ -35,7 +36,8 @@ export function useMcpCallLogs() {
|
||||
return;
|
||||
}
|
||||
console.log(`[SpacetimeDB] Retrying in ${RETRY_DELAY_MS}ms (attempt ${retryCount}/${MAX_RETRIES})...`);
|
||||
setTimeout(() => {
|
||||
retryTimer = setTimeout(() => {
|
||||
retryTimer = null;
|
||||
if (!cancelled) {
|
||||
connect().catch(() => {});
|
||||
}
|
||||
@ -110,6 +112,14 @@ export function useMcpCallLogs() {
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (retryTimer !== null) {
|
||||
clearTimeout(retryTimer);
|
||||
retryTimer = null;
|
||||
}
|
||||
if (connRef.current) {
|
||||
connRef.current.disconnect();
|
||||
connRef.current = null;
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import typography from '@tailwindcss/typography';
|
||||
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: ['./src/**/*.{ts,tsx}'],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [require('@tailwindcss/typography')],
|
||||
plugins: [typography],
|
||||
};
|
||||
|
||||
@ -292,7 +292,7 @@ services:
|
||||
# ================= SpacetimeDB =================
|
||||
|
||||
spacetimedb:
|
||||
image: clockworklabs/spacetime:latest
|
||||
image: clockworklabs/spacetime:v2.1.0
|
||||
pull_policy: always
|
||||
ports:
|
||||
- "${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}39:3000"
|
||||
|
||||
@ -23,7 +23,7 @@ const handler = createMcpHandler(
|
||||
.string()
|
||||
.min(1)
|
||||
.describe(
|
||||
"The original user message/prompt that triggered this tool call. Copy the user's exact words.",
|
||||
"The original user message/prompt that triggered this tool call. Copy the user's exact words. Don't include any sensitive information.",
|
||||
),
|
||||
conversationId: z
|
||||
.string()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user