feat: 提交 task-045 至 task-058 收口产物
- 收口 rust final closure checklist,推进页面/块系统/Mindmap/CLI/AI tools 到最终 cutover 状态 - 按 ai-frontend-simplification-plan-v1 接入 Hermes bridge,合并 AI 面板并清理旧前端编排残留 - 补充 harness 任务与进度记录,加入 CLI smoke 夹具/脚本,并修正文档页 bridge SSR 自请求回退逻辑
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
use core_protocol::{InvocationKind, ToolExecutionMode};
|
||||
use mnote_cli::{
|
||||
plan_block_insert, plan_block_patch, plan_mindmap_get, plan_mindmap_op, plan_mindmap_put,
|
||||
plan_page_get, plan_page_save, plan_page_title, plan_search_blocks,
|
||||
plan_search_documents, plan_sidebar_dataset, plan_tool_run, render_plain_output, CliContext,
|
||||
CliError, CliJsonOutput,
|
||||
execute_output, plan_block_embed, plan_block_insert, plan_block_move, plan_block_patch,
|
||||
plan_mindmap_get, plan_mindmap_op, plan_mindmap_put, plan_page_create, plan_page_delete,
|
||||
plan_page_get, plan_page_move, plan_page_restore, plan_page_save, plan_page_title,
|
||||
plan_search_blocks, plan_search_documents, plan_sidebar_dataset, plan_tool_run,
|
||||
render_plain_output, BlockEmbedArgs, BlockMoveArgs, CliContext, CliError, CliJsonOutput,
|
||||
PageCreateArgs, PageDeleteArgs, PageMoveArgs, PageRestoreArgs,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "mnote-cli")]
|
||||
#[command(about = "Phase 2 最小 CLI 协议冻结器", long_about = None)]
|
||||
#[command(about = "Phase 8 最小真实执行 CLI", long_about = None)]
|
||||
struct Cli {
|
||||
#[command(flatten)]
|
||||
global: GlobalArgs,
|
||||
@@ -23,6 +25,9 @@ struct GlobalArgs {
|
||||
#[arg(long)]
|
||||
json: bool,
|
||||
|
||||
#[arg(long)]
|
||||
execute: bool,
|
||||
|
||||
#[arg(long, default_value = "cli_user")]
|
||||
actor_id: String,
|
||||
|
||||
@@ -66,6 +71,10 @@ enum PageAction {
|
||||
Get(PageGetArgs),
|
||||
Title(PageTitleArgs),
|
||||
Save(PageSaveArgs),
|
||||
Create(PageCreateCliArgs),
|
||||
Move(PageMoveCliArgs),
|
||||
Delete(PageDeleteCliArgs),
|
||||
Restore(PageRestoreCliArgs),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
@@ -107,6 +116,60 @@ struct PageSaveArgs {
|
||||
conflict_detection_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct PageCreateCliArgs {
|
||||
#[arg(long)]
|
||||
page_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
workspace_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
parent_id: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
title: String,
|
||||
|
||||
#[arg(long, default_value = "private")]
|
||||
access_scope: String,
|
||||
|
||||
#[arg(long, default_value = "[]")]
|
||||
content_json: String,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct PageMoveCliArgs {
|
||||
#[arg(long)]
|
||||
page_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
workspace_id: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
parent_id: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
sort_order: i64,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct PageDeleteCliArgs {
|
||||
#[arg(long)]
|
||||
page_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
workspace_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct PageRestoreCliArgs {
|
||||
#[arg(long)]
|
||||
page_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
workspace_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct BlockCommand {
|
||||
#[command(subcommand)]
|
||||
@@ -117,6 +180,8 @@ struct BlockCommand {
|
||||
enum BlockAction {
|
||||
Insert(BlockInsertArgs),
|
||||
Patch(BlockPatchArgs),
|
||||
Move(BlockMoveCliArgs),
|
||||
Embed(BlockEmbedCliArgs),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
@@ -161,6 +226,33 @@ struct BlockPatchArgs {
|
||||
conflict_detection_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct BlockMoveCliArgs {
|
||||
#[arg(long)]
|
||||
source_document_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
block_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
target_document_id: String,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct BlockEmbedCliArgs {
|
||||
#[arg(long)]
|
||||
source_document_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
block_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
target_document_id: String,
|
||||
|
||||
#[arg(long)]
|
||||
target_block_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct MindmapCommand {
|
||||
#[command(subcommand)]
|
||||
@@ -349,6 +441,40 @@ fn main() {
|
||||
&args.content_json,
|
||||
args.conflict_detection_key.as_deref(),
|
||||
),
|
||||
PageAction::Create(args) => plan_page_create(
|
||||
&context,
|
||||
&PageCreateArgs {
|
||||
page_id: &args.page_id,
|
||||
workspace_id: &args.workspace_id,
|
||||
parent_id: args.parent_id.as_deref(),
|
||||
title: &args.title,
|
||||
access_scope: &args.access_scope,
|
||||
content_json: &args.content_json,
|
||||
},
|
||||
),
|
||||
PageAction::Move(args) => plan_page_move(
|
||||
&context,
|
||||
&PageMoveArgs {
|
||||
page_id: &args.page_id,
|
||||
workspace_id: args.workspace_id.as_deref(),
|
||||
parent_id: args.parent_id.as_deref(),
|
||||
sort_order: args.sort_order,
|
||||
},
|
||||
),
|
||||
PageAction::Delete(args) => plan_page_delete(
|
||||
&context,
|
||||
&PageDeleteArgs {
|
||||
page_id: &args.page_id,
|
||||
workspace_id: args.workspace_id.as_deref(),
|
||||
},
|
||||
),
|
||||
PageAction::Restore(args) => plan_page_restore(
|
||||
&context,
|
||||
&PageRestoreArgs {
|
||||
page_id: &args.page_id,
|
||||
workspace_id: args.workspace_id.as_deref(),
|
||||
},
|
||||
),
|
||||
},
|
||||
Commands::Block(command) => match command.action {
|
||||
BlockAction::Insert(args) => plan_block_insert(
|
||||
@@ -369,6 +495,23 @@ fn main() {
|
||||
&args.snapshot_json,
|
||||
args.conflict_detection_key.as_deref(),
|
||||
),
|
||||
BlockAction::Move(args) => plan_block_move(
|
||||
&context,
|
||||
&BlockMoveArgs {
|
||||
source_document_id: &args.source_document_id,
|
||||
block_id: &args.block_id,
|
||||
target_document_id: &args.target_document_id,
|
||||
},
|
||||
),
|
||||
BlockAction::Embed(args) => plan_block_embed(
|
||||
&context,
|
||||
&BlockEmbedArgs {
|
||||
source_document_id: &args.source_document_id,
|
||||
block_id: &args.block_id,
|
||||
target_document_id: &args.target_document_id,
|
||||
target_block_id: args.target_block_id.as_deref(),
|
||||
},
|
||||
),
|
||||
},
|
||||
Commands::Mindmap(command) => match command.action {
|
||||
MindmapAction::Get(args) => plan_mindmap_get(
|
||||
@@ -421,7 +564,14 @@ fn main() {
|
||||
&args.args_json,
|
||||
),
|
||||
},
|
||||
};
|
||||
}
|
||||
.and_then(|output| {
|
||||
if cli.global.execute {
|
||||
execute_output(&output, &context)
|
||||
} else {
|
||||
Ok(output)
|
||||
}
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(output) => emit_success(&output, cli.global.json),
|
||||
|
||||
Reference in New Issue
Block a user