@openprd/cli 0.1.18 → 0.1.19

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.
@@ -1935,6 +1935,8 @@ function analyzePromptIntent(prompt) {
1935
1935
  && !codeVisualArtifactRequested;
1936
1936
  const learningMaterialIntent = detectLearningMaterialIntent(text);
1937
1937
  const learningMaterialRequest = learningMaterialIntent.requested;
1938
+ const canvasCollaborationRequest = /(画布|canvas|excalidraw)/i.test(text)
1939
+ && /(标注|批注|协同|改图|回填|贴到画布|放到画布|插入画布|插到画布|画布评审|画布反馈|一起看|openprd\s*canvas|annotation)/i.test(text);
1938
1940
  const visualReview = /效果图|实现截图|视觉对比|视觉评审|对标效果图|复刻|不一致|好丑|没对齐|对不上|不像/i.test(text);
1939
1941
  const directBugfixExecution = explicitExecution && bugfixOrDiagnostic;
1940
1942
  const newFeatureVerbMatched = /(新增|增加|新建)/.test(text);
@@ -2043,6 +2045,7 @@ function analyzePromptIntent(prompt) {
2043
2045
  learningMaterialRequest,
2044
2046
  learningGenre: learningMaterialIntent.genre,
2045
2047
  learningMaterialReason: learningMaterialIntent.reason,
2048
+ canvasCollaborationRequest,
2046
2049
  shouldInject: requiresIntake
2047
2050
  || requirementTier === 'l1'
2048
2051
  || explicitExecution
@@ -2059,6 +2062,7 @@ function analyzePromptIntent(prompt) {
2059
2062
  || browserSafetyRequest
2060
2063
  || productCopyRequest
2061
2064
  || learningMaterialRequest
2065
+ || canvasCollaborationRequest
2062
2066
  || /openprd/i.test(normalized)
2063
2067
  || /\bprd\b/i.test(normalized),
2064
2068
  };
@@ -3461,6 +3465,21 @@ function visualMockupMessage(intent, root = null) {
3461
3465
  ].join('\n');
3462
3466
  }
3463
3467
 
3468
+ function canvasCollaborationMessage(intent) {
3469
+ if (!intent?.canvasCollaborationRequest) {
3470
+ return null;
3471
+ }
3472
+ return [
3473
+ '当前请求涉及 OpenPrd 画布协同(生图上画布、人在画布上标注、标注结果回到对话继续改)。',
3474
+ '打开或复用画布:运行 `openprd canvas .`;无法自动识别当前对话时用 `--thread <id> --thread-title <name>` 或 `--session <id> --session-title <name>` 显式绑定,画布必须绑定当前对话。',
3475
+ '结构化读画布:需要知道用户正在圈哪些元素时,优先 `GET /api/selection` 读取选中元素的 ID、类型、坐标、尺寸和文本,不要只靠截图猜;需要全量场景再读 `GET /api/scene`。',
3476
+ '结构化写画布:把生成的新图放上画布时,优先 `POST /api/insert-image`,用 `anchorElementId` + `placement`(right/left/below/above)把新图放到指定元素旁边,不要覆盖原图;回填 AI 生图占位卡时继续用 `POST /api/images` 带 `placeholderId`。',
3477
+ '标注改图闭环:如果交接记录(handoff)的 `selection` 是 `annotation-edit`,或带有 `sourceImageElementIds` / `annotationElementIds`,说明用户在原图上画了标注要求改图。把截图里的标注当修改指令,生成修改后的新图,再用 `POST /api/insert-image` 以原图为 anchor 放到旁边,方便用户对比原图和新版。',
3478
+ '生图尺寸契约:handoff 或占位卡带 `sizeContract`(width/height/aspectRatio)时,生成图片必须按这个宽高比出图,避免回填时变形拉伸。',
3479
+ '每轮改图后主动确认:新图是否符合标注意图、是否继续下一轮标注迭代;用户可以继续在新图上标注,形成多轮改图闭环。',
3480
+ ].join('\n');
3481
+ }
3482
+
3464
3483
  function learningGenreFlag(intent = null) {
3465
3484
  return intent?.learningGenre ? ` --genre ${intent.learningGenre}` : '';
3466
3485
  }
@@ -3651,6 +3670,7 @@ function contextMessage(cwd, intent = null, gate = null, progress = null) {
3651
3670
  'OpenPrd 上下文只是建议,不是自动执行指令。请先判断用户当前意图。',
3652
3671
  lightweightRequirementMessage(intent),
3653
3672
  visualMockupMessage(intent, cwd),
3673
+ canvasCollaborationMessage(intent),
3654
3674
  learningReviewMessage(intent),
3655
3675
  largeUiVisualDirectionMessage(),
3656
3676
  visualLocalAdjustmentMessage(),
@@ -3673,6 +3693,7 @@ function contextMessage(cwd, intent = null, gate = null, progress = null) {
3673
3693
  'OpenPrd 上下文只是建议,不是自动执行指令。请先判断用户当前意图。',
3674
3694
  lightweightRequirementMessage(intent),
3675
3695
  visualMockupMessage(intent, cwd),
3696
+ canvasCollaborationMessage(intent),
3676
3697
  learningReviewMessage(intent),
3677
3698
  largeUiVisualDirectionMessage(),
3678
3699
  visualLocalAdjustmentMessage(),
@@ -3700,6 +3721,7 @@ function contextMessage(cwd, intent = null, gate = null, progress = null) {
3700
3721
  gateMessage,
3701
3722
  lightweightRequirementMessage(intent),
3702
3723
  visualMockupMessage(intent, cwd),
3724
+ canvasCollaborationMessage(intent),
3703
3725
  learningReviewMessage(intent),
3704
3726
  largeUiVisualDirectionMessage(intent),
3705
3727
  requirementRoutingSummary(),