Reorganise by feature, rename to Novelly, add Aspire and a pre-push hook
The layered split into Domain/Application/Infrastructure/Api was forcing organisation by layer: adding one capability meant touching four projects and four folders that each held a slice of it. Those four projects are now one feature-organised Novelly.Api, where each folder — Projects, Characters, Chapters, Beats, Scenes, Tags, Agent — holds its entity, DTOs, service and endpoints together. Common/ holds what genuinely crosses features (the patch semantics, the two exception types, DraftStatus) and Data/ holds the DbContext and migrations. Six .NET projects become five: the three layer projects are gone, and Novelly.AppHost and Novelly.ServiceDefaults are new. - Namespaces move from NovelSoftware.* to Novelly.*, including the entity type names recorded in the EF model snapshots. The migration ids are untouched, so an existing novel.db still migrates cleanly — verified against a fresh file. - Aspire orchestration mirrors the mic-check setup: the AppHost starts the API on :5080 and the Vite dev server on :5173, and the API picks up OpenTelemetry, health checks and service discovery from ServiceDefaults. /health and /alive now answer in development. - A Husky pre-push hook runs scripts/ci/prepush.sh: build, test, then a web build. The scripts are plain bash so CI can run the same steps. - The MCP server's env var is now NOVELLY_API_URL. Verified beyond the build: 44 tests pass, the web client builds, the API was exercised over curl (project/chapter/beat/tag round trip, tag cross-reference, 503 on the agent without a key while conversation listing still returns 200), the MCP server was driven over stdio JSON-RPC (26 tools, errors still surface the API's own message rather than being flattened), and the AppHost was run to confirm both resources come up and Vite proxies /api through to the API. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S56bfZMGe1hnhpWP4CjjNw
This commit is contained in:
co-authored by
Claude Opus 5
parent
30e0c6926e
commit
725758ccd9
@@ -0,0 +1,139 @@
|
||||
using System.ComponentModel;
|
||||
using ModelContextProtocol.Protocol;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
namespace Novelly.Mcp.Tools;
|
||||
|
||||
[McpServerToolType]
|
||||
public static class ManuscriptTools
|
||||
{
|
||||
[McpServerTool(Name = "list_chapters")]
|
||||
[Description("List a project's chapters in manuscript order, with scene and word counts.")]
|
||||
public static Task<CallToolResult> ListChapters(
|
||||
NovelApiClient api,
|
||||
[Description("The project's id.")] Guid projectId,
|
||||
CancellationToken ct) =>
|
||||
api.GetAsync($"/api/projects/{projectId}/chapters", ct);
|
||||
|
||||
[McpServerTool(Name = "get_chapter")]
|
||||
[Description("Read one chapter in full, including every scene and any drafted prose.")]
|
||||
public static Task<CallToolResult> GetChapter(
|
||||
NovelApiClient api,
|
||||
[Description("The chapter's id.")] Guid chapterId,
|
||||
CancellationToken ct) =>
|
||||
api.GetAsync($"/api/chapters/{chapterId}", ct);
|
||||
|
||||
[McpServerTool(Name = "create_chapter")]
|
||||
[Description("Add a chapter to a project. It goes at the end of the manuscript unless you supply a number.")]
|
||||
public static Task<CallToolResult> CreateChapter(
|
||||
NovelApiClient api,
|
||||
[Description("The project's id.")] Guid projectId,
|
||||
[Description("Chapter title.")] string title,
|
||||
CancellationToken ct,
|
||||
[Description("Position in the manuscript, 1-based.")] int? number = null,
|
||||
[Description("The chapter's outline summary paragraph.")] string? summary = null,
|
||||
[Description("Id of the point-of-view character.")] Guid? povCharacterId = null,
|
||||
[Description("Where and when the chapter takes place.")] string? setting = null,
|
||||
[Description("Planned, Outlined, Drafted, Revised or Final.")] string? status = null,
|
||||
[Description("Target length in words.")] int? targetWordCount = null,
|
||||
[Description("Tags for cross-referencing. Unknown tags are created.")] string[]? tags = null) =>
|
||||
api.PostAsync($"/api/projects/{projectId}/chapters", new
|
||||
{
|
||||
title,
|
||||
number,
|
||||
summary,
|
||||
povCharacterId,
|
||||
setting,
|
||||
status = status ?? "Planned",
|
||||
targetWordCount,
|
||||
tags
|
||||
}, ct);
|
||||
|
||||
[McpServerTool(Name = "update_chapter")]
|
||||
[Description("Revise a chapter's title, number, summary, POV character, setting, notes or status.")]
|
||||
public static Task<CallToolResult> UpdateChapter(
|
||||
NovelApiClient api,
|
||||
[Description("The chapter's id.")] Guid chapterId,
|
||||
CancellationToken ct,
|
||||
[Description("New title.")] string? title = null,
|
||||
[Description("Position in the manuscript.")] int? number = null,
|
||||
[Description("The chapter's outline summary paragraph.")] string? summary = null,
|
||||
[Description("Id of the point-of-view character.")] Guid? povCharacterId = null,
|
||||
[Description("Where and when the chapter takes place.")] string? setting = null,
|
||||
[Description("Anything else worth recording.")] string? notes = null,
|
||||
[Description("Planned, Outlined, Drafted, Revised or Final.")] string? status = null,
|
||||
[Description("Target length in words.")] int? targetWordCount = null,
|
||||
[Description("Tags for cross-referencing. Replaces the existing tags.")] string[]? tags = null) =>
|
||||
api.PatchAsync($"/api/chapters/{chapterId}",
|
||||
new { title, number, summary, povCharacterId, setting, notes, status, targetWordCount, tags }, ct);
|
||||
|
||||
[McpServerTool(Name = "list_scenes")]
|
||||
[Description("List a chapter's scenes in order.")]
|
||||
public static Task<CallToolResult> ListScenes(
|
||||
NovelApiClient api,
|
||||
[Description("The chapter's id.")] Guid chapterId,
|
||||
CancellationToken ct) =>
|
||||
api.GetAsync($"/api/chapters/{chapterId}/scenes", ct);
|
||||
|
||||
[McpServerTool(Name = "create_scene")]
|
||||
[Description("Add a scene to a chapter. The goal/conflict/outcome trio is what makes a scene "
|
||||
+ "draftable later, so fill those in when there is enough to work with.")]
|
||||
public static Task<CallToolResult> CreateScene(
|
||||
NovelApiClient api,
|
||||
[Description("The chapter's id.")] Guid chapterId,
|
||||
[Description("Scene title.")] string title,
|
||||
CancellationToken ct,
|
||||
[Description("Position within the chapter. Appended to the end when omitted.")] int? sortOrder = null,
|
||||
[Description("What happens in the scene.")] string? summary = null,
|
||||
[Description("What the POV character is trying to achieve.")] string? goal = null,
|
||||
[Description("What stands in the way.")] string? conflict = null,
|
||||
[Description("How it lands, and what it costs.")] string? outcome = null,
|
||||
[Description("Id of the point-of-view character.")] Guid? povCharacterId = null,
|
||||
[Description("Where the scene takes place.")] string? location = null,
|
||||
[Description("Drafted prose for the scene, if you are writing it now.")] string? prose = null,
|
||||
[Description("Planned, Outlined, Drafted, Revised or Final.")] string? status = null) =>
|
||||
api.PostAsync($"/api/chapters/{chapterId}/scenes", new
|
||||
{
|
||||
title,
|
||||
sortOrder,
|
||||
summary,
|
||||
goal,
|
||||
conflict,
|
||||
outcome,
|
||||
povCharacterId,
|
||||
location,
|
||||
prose,
|
||||
status = status ?? "Planned"
|
||||
}, ct);
|
||||
|
||||
[McpServerTool(Name = "update_scene")]
|
||||
[Description("Revise a scene. Supplying 'prose' writes or replaces the scene's draft text and "
|
||||
+ "recomputes its word count.")]
|
||||
public static Task<CallToolResult> UpdateScene(
|
||||
NovelApiClient api,
|
||||
[Description("The scene's id.")] Guid sceneId,
|
||||
CancellationToken ct,
|
||||
[Description("New title.")] string? title = null,
|
||||
[Description("Position within the chapter.")] int? sortOrder = null,
|
||||
[Description("What happens in the scene.")] string? summary = null,
|
||||
[Description("What the POV character is trying to achieve.")] string? goal = null,
|
||||
[Description("What stands in the way.")] string? conflict = null,
|
||||
[Description("How it lands, and what it costs.")] string? outcome = null,
|
||||
[Description("Id of the point-of-view character.")] Guid? povCharacterId = null,
|
||||
[Description("Where the scene takes place.")] string? location = null,
|
||||
[Description("Drafted prose for the scene.")] string? prose = null,
|
||||
[Description("Planned, Outlined, Drafted, Revised or Final.")] string? status = null) =>
|
||||
api.PatchAsync($"/api/scenes/{sceneId}", new
|
||||
{
|
||||
title,
|
||||
sortOrder,
|
||||
summary,
|
||||
goal,
|
||||
conflict,
|
||||
outcome,
|
||||
povCharacterId,
|
||||
location,
|
||||
prose,
|
||||
status
|
||||
}, ct);
|
||||
}
|
||||
Reference in New Issue
Block a user