@coralai/sps-cli 0.58.40 → 0.58.42

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.
@@ -0,0 +1,31 @@
1
+ export interface PromptPreviewCard {
2
+ seq: number | string;
3
+ title: string;
4
+ desc: string;
5
+ skills?: string[];
6
+ }
7
+ export interface PromptPreviewResult {
8
+ /** 拼好的完整提示词字符串。 */
9
+ prompt: string;
10
+ meta: {
11
+ /** 'actual'=派发时落盘的真实那份;'preview'=按当前状态重建。 */
12
+ source: 'actual' | 'preview';
13
+ /** source=actual 时:派发时间(ISO);preview 时 null。 */
14
+ dispatchedAt?: string | null;
15
+ /** 本卡解析出的 skill 名(空=无)。 */
16
+ skills: string[];
17
+ /** 是否注入了记忆块。 */
18
+ memoryIncluded: boolean;
19
+ /** 是否把 CLAUDE.md/AGENTS.md 拼进了字符串(claude 后端为 false——它原生读)。 */
20
+ projectRulesIncluded: boolean;
21
+ /** git 模式(影响 How to Run:commit/push vs 完成/自检)。 */
22
+ git: boolean;
23
+ /** claude 原生读、**不在**字符串里但等于进了 context 的部分。 */
24
+ nativeContext: string[];
25
+ /** 阅读提示。 */
26
+ notes: string[];
27
+ };
28
+ }
29
+ /** 重建某卡的 worker 提示词预览。project 无效/配置缺失时抛,由调用方转 Result。 */
30
+ export declare function buildWorkerPromptPreview(project: string, card: PromptPreviewCard): PromptPreviewResult;
31
+ //# sourceMappingURL=promptPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptPreview.d.ts","sourceRoot":"","sources":["../../src/services/promptPreview.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,6CAA6C;QAC7C,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;QAC7B,gDAAgD;QAChD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,2BAA2B;QAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,gBAAgB;QAChB,cAAc,EAAE,OAAO,CAAC;QACxB,8DAA8D;QAC9D,oBAAoB,EAAE,OAAO,CAAC;QAC9B,kDAAkD;QAClD,GAAG,EAAE,OAAO,CAAC;QACb,8CAA8C;QAC9C,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,YAAY;QACZ,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;CACH;AAED,yDAAyD;AACzD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,mBAAmB,CAkFtG"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @module services/promptPreview
3
+ * @description 重建"派卡时注入 worker 的完整提示词",供控制台**预览**(不 dispatch、不落库)。
4
+ * 忠实镜像 StageEngine.buildStagePrompt + worker-manager.withMemoryInjection 的拼装:
5
+ * 记忆块(project+global,以卡片标题召回)→ `# Required Skills`(skill 名)→
6
+ * projectRules(仅非 claude 后端)→ `# Task`(title/seq/描述)→ `# How to Run`。
7
+ * 运行时才定的量(真实 worktree 路径 / 分支 / cardId)用占位;memory 用当前库状态。
8
+ * @layer services
9
+ * @boundedContext worker
10
+ */
11
+ import { existsSync, readFileSync } from 'node:fs';
12
+ import { resolve } from 'node:path';
13
+ import { loadProjectConf, resolveGitlabProjectId, resolveWorkflowTransport } from '../core/config.js';
14
+ import { buildMemoryInjection } from '../core/memory2/inject.js';
15
+ import { ProjectPipelineAdapter } from '../core/projectPipelineAdapter.js';
16
+ import { buildPhasePrompt, buildTaskPrompt } from '../core/taskPrompts.js';
17
+ import { formatSkillRequirement, resolveRequiredSkills } from '../engines/StageEngine.js';
18
+ import { findProjectRepoDir } from '../shared/projectRepo.js';
19
+ /** 重建某卡的 worker 提示词预览。project 无效/配置缺失时抛,由调用方转 Result。 */
20
+ export function buildWorkerPromptPreview(project, card) {
21
+ const config = loadProjectConf(project);
22
+ const repoDir = findProjectRepoDir(project) ?? config.PROJECT_DIR ?? `<repo:${project}>`;
23
+ const adapter = new ProjectPipelineAdapter(config, repoDir);
24
+ const stage = adapter.firstStage;
25
+ const gitEnabled = adapter.gitEnabled;
26
+ // ① skills —— card.skills → stage.profile → DEFAULT_WORKER_SKILLS
27
+ const skills = resolveRequiredSkills({ skills: card.skills }, { profile: stage?.profile }, config.raw.DEFAULT_WORKER_SKILLS);
28
+ const skillContent = skills.length ? formatSkillRequirement(skills) : '';
29
+ // ② projectRules —— claude(acp-sdk)原生读 CLAUDE.md,跳过拼接;非 claude 后端才读文件拼进去
30
+ const nativeReadsClaudeMd = resolveWorkflowTransport(config) === 'acp-sdk';
31
+ let projectRules = '';
32
+ if (!nativeReadsClaudeMd) {
33
+ for (const f of ['CLAUDE.md', 'AGENTS.md']) {
34
+ const p = resolve(repoDir, f);
35
+ if (existsSync(p)) {
36
+ const txt = readFileSync(p, 'utf-8').trim();
37
+ if (txt)
38
+ projectRules = projectRules ? `${projectRules}\n\n${txt}` : txt;
39
+ }
40
+ }
41
+ }
42
+ // 运行时才定的量用占位(真实值在 dispatch 时由 worktree/taskId 决定)
43
+ const worktreePath = `${config.WORKTREE_DIR || `~/.coral/worktrees/${project}`}/<task-branch>`;
44
+ const promptCtx = {
45
+ taskSeq: String(card.seq),
46
+ taskTitle: card.title,
47
+ taskDescription: card.desc || '(no description)',
48
+ cardId: '<runtime>',
49
+ worktreePath,
50
+ branchName: '<task-branch>',
51
+ targetBranch: config.GITLAB_MERGE_BRANCH || 'main',
52
+ mergeMode: config.MR_MODE,
53
+ gitlabProjectId: resolveGitlabProjectId(config),
54
+ skillContent,
55
+ projectRules: projectRules || undefined,
56
+ completionSignal: config.raw.COMPLETION_SIGNAL || undefined,
57
+ };
58
+ const core = gitEnabled
59
+ ? buildPhasePrompt({ ...promptCtx, phase: 'development' })
60
+ : buildTaskPrompt(promptCtx);
61
+ // ③ 记忆块 prepend(worker-manager.withMemoryInjection)——project + global,query=卡片标题
62
+ const memoryBlock = buildMemoryInjection([
63
+ { scope: 'project', project },
64
+ { scope: 'global' },
65
+ ], card.title || core, {});
66
+ const prompt = memoryBlock ? `${memoryBlock}\n\n${core}` : core;
67
+ const nativeContext = [];
68
+ if (nativeReadsClaudeMd) {
69
+ nativeContext.push('CLAUDE.md(项目规则)—— claude 原生读进 system prompt,故未拼进本串');
70
+ nativeContext.push('.claude/skills/ —— skill 的 SOP 正文由 claude 原生发现(本串只点名)');
71
+ }
72
+ return {
73
+ prompt,
74
+ meta: {
75
+ source: 'preview',
76
+ skills,
77
+ memoryIncluded: !!memoryBlock,
78
+ projectRulesIncluded: !!projectRules,
79
+ git: gitEnabled,
80
+ nativeContext,
81
+ notes: [
82
+ '预览:按当前卡片 + 项目配置 + 记忆库状态重建,与真实派卡基本一致。',
83
+ '运行时才确定的量(真实 worktree 路径 / 分支 / cardId)以占位符表示。',
84
+ ],
85
+ },
86
+ };
87
+ }
88
+ //# sourceMappingURL=promptPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptPreview.js","sourceRoot":"","sources":["../../src/services/promptPreview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,w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O,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhE,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,mBAAmB,EAAE,CAAC;QACxB,aAAa,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QACzE,aAAa,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO;QACL,MAAM;QACN,IAAI,EAAE;YACJ,MAAM,EAAE,SAAS;YACjB,MAAM;YACN,cAAc,EAAE,CAAC,CAAC,WAAW;YAC7B,oBAAoB,EAAE,CAAC,CAAC,YAAY;YACpC,GAAG,EAAE,UAAU;YACf,aAAa;YACb,KAAK,EAAE;gBACL,sCAAsC;gBACtC,+CAA+C;aAChD;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralai/sps-cli",
3
- "version": "0.58.40",
3
+ "version": "0.58.42",
4
4
  "description": "SPS CLI — AI-driven development pipeline orchestrator",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",