d257c0fd67
CI & Build / Python lint (push) Successful in 3s
CI & Build / integration (push) Successful in 23s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 48s
CI & Build / Build & push image (push) Successful in 1m4s
Step 6 of the Drafter recall milestone (#227): a human-facing surface for the reusable-code snippets that agents record via MCP, plus the REST API behind it. Backend embeds snippets inline on create/update so they're recallable immediately, not only after a restart. Backend: - routes/snippets.py: GET/POST /api/snippets, GET/PATCH/DELETE /api/snippets/<id>. Share-aware per rule #78 (get_note_for_user + can_write_note), writes performed as the owner; list owner-scoped — mirrors routes/notes.py. Registered in app.py. - services/snippets.py: embed on create/update via a _embed_snippet fire-and-forget helper, covering BOTH the MCP tool and the REST route by construction. A snippet's value is immediate recall, so it can't wait for the startup-only backfill (see issue: MCP create path doesn't embed inline for notes/tasks generally). - tests/test_routes_snippets.py: structural registration + handler/service contract + PATCH-field ↔ update_snippet-kwarg parity (rule #33). Frontend (Vue 3 + TS): - api/snippets.ts: typed client, modeled on api/systems.ts. - views: SnippetListView (search, skeleton/empty/error states), SnippetDetailView (read + copy-to-clipboard, ConfirmDialog delete), SnippetEditorView (create/edit all fields, Ctrl/Cmd+S, Esc, autofocus, validation). v1 quality per rules #24/#27. - router: /snippets, /snippets/new, /snippets/:id, /snippets/:id/edit. - NoteType union widened to include 'snippet'; Snippets nav link added to AppHeader (desktop pill bar + mobile menu). - Design system: Moss --color-action-primary for action buttons, accent --color-primary reserved for tags/brand (Hybrid rule); focus rings; JetBrains Mono for code/name/signature/location. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pa2EsuB54BuWQ8GfJq9c7t
162 lines
3.9 KiB
TypeScript
162 lines
3.9 KiB
TypeScript
import { createRouter, createWebHistory } from "vue-router";
|
|
import { useAuthStore } from "@/stores/auth";
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{
|
|
// The dashboard ("what to work on") is the landing page; Knowledge
|
|
// remains as the exhaustive "Browse" surface.
|
|
path: "/",
|
|
redirect: "/dashboard",
|
|
},
|
|
{
|
|
path: "/dashboard",
|
|
name: "dashboard",
|
|
component: () => import("@/views/DashboardView.vue"),
|
|
},
|
|
{
|
|
path: "/knowledge",
|
|
name: "knowledge",
|
|
component: () => import("@/views/KnowledgeView.vue"),
|
|
},
|
|
{
|
|
path: "/login",
|
|
name: "login",
|
|
component: () => import("@/views/LoginView.vue"),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: "/register",
|
|
name: "register",
|
|
component: () => import("@/views/RegisterView.vue"),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: "/forgot-password",
|
|
name: "forgot-password",
|
|
component: () => import("@/views/ForgotPasswordView.vue"),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: "/reset-password",
|
|
name: "reset-password",
|
|
component: () => import("@/views/ResetPasswordView.vue"),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: "/register-invite",
|
|
name: "register-invite",
|
|
component: () => import("@/views/RegisterInviteView.vue"),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: "/notes",
|
|
redirect: "/knowledge",
|
|
},
|
|
{
|
|
path: "/notes/new",
|
|
name: "note-new",
|
|
component: () => import("@/views/NoteEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/notes/:id",
|
|
name: "note-view",
|
|
component: () => import("@/views/NoteViewerView.vue"),
|
|
},
|
|
{
|
|
path: "/notes/:id/edit",
|
|
name: "note-edit",
|
|
component: () => import("@/views/NoteEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/snippets",
|
|
name: "snippets",
|
|
component: () => import("@/views/SnippetListView.vue"),
|
|
},
|
|
{
|
|
path: "/snippets/new",
|
|
name: "snippet-new",
|
|
component: () => import("@/views/SnippetEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/snippets/:id",
|
|
name: "snippet-view",
|
|
component: () => import("@/views/SnippetDetailView.vue"),
|
|
},
|
|
{
|
|
path: "/snippets/:id/edit",
|
|
name: "snippet-edit",
|
|
component: () => import("@/views/SnippetEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/graph",
|
|
name: "graph",
|
|
component: () => import("@/views/GraphView.vue"),
|
|
},
|
|
{
|
|
path: "/projects",
|
|
name: "projects",
|
|
component: () => import("@/views/ProjectListView.vue"),
|
|
},
|
|
{
|
|
path: "/projects/:id",
|
|
name: "project-view",
|
|
component: () => import("@/views/ProjectView.vue"),
|
|
},
|
|
{
|
|
path: "/rules",
|
|
name: "rules",
|
|
component: () => import("@/views/RulesView.vue"),
|
|
},
|
|
{
|
|
path: "/tasks",
|
|
redirect: "/",
|
|
},
|
|
{
|
|
path: "/tasks/new",
|
|
name: "task-new",
|
|
component: () => import("@/views/TaskEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/tasks/:id",
|
|
name: "task-edit",
|
|
component: () => import("@/views/TaskEditorView.vue"),
|
|
},
|
|
{
|
|
path: "/shared",
|
|
name: "shared-with-me",
|
|
component: () => import("@/views/SharedWithMeView.vue"),
|
|
},
|
|
{
|
|
path: "/settings",
|
|
name: "settings",
|
|
component: () => import("@/views/SettingsView.vue"),
|
|
},
|
|
{
|
|
path: "/trash",
|
|
name: "trash",
|
|
component: () => import("@/views/TrashView.vue"),
|
|
},
|
|
{ path: "/admin/users", redirect: "/settings" },
|
|
{ path: "/admin/logs", redirect: "/settings" },
|
|
],
|
|
});
|
|
|
|
router.beforeEach(async (to) => {
|
|
if (to.meta.public) return;
|
|
|
|
const authStore = useAuthStore();
|
|
|
|
// Wait for initial auth check if still loading
|
|
if (authStore.loading && !authStore.isAuthenticated) {
|
|
await authStore.checkAuth();
|
|
}
|
|
|
|
if (!authStore.isAuthenticated) {
|
|
return { name: "login", query: { redirect: to.fullPath } };
|
|
}
|
|
});
|
|
|
|
export default router;
|