mcp-probe-kit 3.2.0 → 3.6.0
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.
- package/README.md +25 -7
- package/build/index.js +45 -79
- package/build/lib/__tests__/agents-md-template.unit.test.js +1 -0
- package/build/lib/__tests__/dev-workflow.unit.test.js +22 -0
- package/build/lib/__tests__/handles.unit.test.js +19 -0
- package/build/lib/__tests__/mcp-apps.unit.test.d.ts +1 -0
- package/build/lib/__tests__/mcp-apps.unit.test.js +52 -0
- package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.d.ts +1 -0
- package/build/lib/__tests__/mcp-tool-skill-registry.unit.test.js +18 -0
- package/build/lib/__tests__/memory-client.unit.test.js +105 -0
- package/build/lib/__tests__/memory-orchestration.unit.test.d.ts +1 -0
- package/build/lib/__tests__/memory-orchestration.unit.test.js +88 -0
- package/build/lib/__tests__/memory-payload.unit.test.d.ts +1 -0
- package/build/lib/__tests__/memory-payload.unit.test.js +35 -0
- package/build/lib/__tests__/quality-constraints.unit.test.d.ts +1 -0
- package/build/lib/__tests__/quality-constraints.unit.test.js +54 -0
- package/build/lib/__tests__/spec-gate.unit.test.d.ts +1 -0
- package/build/lib/__tests__/spec-gate.unit.test.js +54 -0
- package/build/lib/__tests__/spec-validator.unit.test.js +106 -74
- package/build/lib/__tests__/task-defaults.unit.test.d.ts +1 -0
- package/build/lib/__tests__/task-defaults.unit.test.js +27 -0
- package/build/lib/__tests__/workflow-skill-installer.unit.test.d.ts +1 -0
- package/build/lib/__tests__/workflow-skill-installer.unit.test.js +110 -0
- package/build/lib/agents-md-template.js +40 -32
- package/build/lib/cursor-history-client.d.ts +54 -0
- package/build/lib/cursor-history-client.js +240 -0
- package/build/lib/dev-workflow.d.ts +36 -0
- package/build/lib/dev-workflow.js +497 -0
- package/build/lib/handles.d.ts +31 -0
- package/build/lib/handles.js +36 -0
- package/build/lib/mcp-apps.d.ts +14 -0
- package/build/lib/mcp-apps.js +234 -0
- package/build/lib/mcp-tool-skill-registry.d.ts +46 -0
- package/build/lib/mcp-tool-skill-registry.js +256 -0
- package/build/lib/memory-client.d.ts +19 -0
- package/build/lib/memory-client.js +69 -0
- package/build/lib/memory-orchestration.d.ts +5 -0
- package/build/lib/memory-orchestration.js +20 -0
- package/build/lib/merge-agents-md.d.ts +2 -2
- package/build/lib/merge-agents-md.js +7 -4
- package/build/lib/output-schema-registry.d.ts +11 -0
- package/build/lib/output-schema-registry.js +80 -0
- package/build/lib/quality-constraints.d.ts +54 -0
- package/build/lib/quality-constraints.js +155 -0
- package/build/lib/skill-bridge.js +12 -12
- package/build/lib/spec-gate.d.ts +32 -0
- package/build/lib/spec-gate.js +83 -0
- package/build/lib/spec-validator.js +16 -3
- package/build/lib/task-defaults.d.ts +6 -0
- package/build/lib/task-defaults.js +20 -0
- package/build/lib/template-loader.js +83 -23
- package/build/lib/tool-annotations.js +3 -0
- package/build/lib/toolset-manager.js +2 -0
- package/build/lib/workflow-skill-installer.d.ts +38 -0
- package/build/lib/workflow-skill-installer.js +158 -0
- package/build/lib/workflow-skill-template.d.ts +9 -0
- package/build/lib/workflow-skill-template.js +85 -0
- package/build/lib/workflow-skill-version.d.ts +15 -0
- package/build/lib/workflow-skill-version.js +68 -0
- package/build/resources/ui-ux-data/guidelines/vercel-web-interface.json +1632 -1632
- package/build/resources/ui-ux-data/metadata.json +30 -30
- package/build/resources/ui-ux-data/shadcn/blocks.json +2541 -2541
- package/build/resources/ui-ux-data/shadcn/components.json +997 -997
- package/build/resources/ui-ux-data/themes/presets.json +483 -483
- package/build/schemas/index.d.ts +110 -0
- package/build/schemas/index.js +1 -0
- package/build/schemas/memory-tools.d.ts +83 -0
- package/build/schemas/memory-tools.js +43 -0
- package/build/schemas/orchestration-tools.d.ts +8 -0
- package/build/schemas/orchestration-tools.js +8 -0
- package/build/schemas/output/code-insight-tools.d.ts +65 -0
- package/build/schemas/output/code-insight-tools.js +42 -0
- package/build/schemas/output/memory-tools.d.ts +576 -0
- package/build/schemas/output/memory-tools.js +148 -0
- package/build/schemas/project-tools.d.ts +19 -0
- package/build/schemas/project-tools.js +20 -0
- package/build/tools/__tests__/cursor-history.unit.test.d.ts +1 -0
- package/build/tools/__tests__/cursor-history.unit.test.js +38 -0
- package/build/tools/__tests__/delete_memory_asset.unit.test.d.ts +1 -0
- package/build/tools/__tests__/delete_memory_asset.unit.test.js +87 -0
- package/build/tools/__tests__/search_memory.unit.test.js +1 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +34 -1
- package/build/tools/__tests__/update_memory_asset.unit.test.d.ts +1 -0
- package/build/tools/__tests__/update_memory_asset.unit.test.js +82 -0
- package/build/tools/__tests__/workflow.unit.test.d.ts +1 -0
- package/build/tools/__tests__/workflow.unit.test.js +24 -0
- package/build/tools/check_spec.js +16 -16
- package/build/tools/code_insight.js +46 -42
- package/build/tools/code_review.js +11 -4
- package/build/tools/cursor_read_conversation.d.ts +7 -0
- package/build/tools/cursor_read_conversation.js +36 -0
- package/build/tools/delete_memory_asset.d.ts +7 -0
- package/build/tools/delete_memory_asset.js +57 -0
- package/build/tools/fix_bug.js +161 -161
- package/build/tools/gencommit.js +60 -60
- package/build/tools/index.d.ts +3 -0
- package/build/tools/index.js +3 -0
- package/build/tools/init_project_context.js +432 -432
- package/build/tools/search_memory.js +5 -2
- package/build/tools/start_bugfix.js +37 -4
- package/build/tools/start_feature.js +4 -3
- package/build/tools/start_product.js +1 -1
- package/build/tools/start_ui.js +22 -4
- package/build/tools/ui-ux-tools.d.ts +3 -0
- package/build/tools/ui-ux-tools.js +302 -290
- package/build/tools/update_memory_asset.d.ts +7 -0
- package/build/tools/update_memory_asset.js +98 -0
- package/build/tools/workflow.d.ts +13 -0
- package/build/tools/workflow.js +69 -0
- package/build/utils/__tests__/vercel-guidelines-sync.unit.test.js +12 -12
- package/build/utils/design-reasoning-engine.d.ts +2 -0
- package/build/utils/design-reasoning-engine.js +3 -0
- package/build/utils/themes-sync.js +8 -8
- package/package.json +6 -3
- package/build/resources/index.d.ts +0 -4
- package/build/resources/index.js +0 -4
- package/build/resources/tool-params-guide.d.ts +0 -571
- package/build/resources/tool-params-guide.js +0 -488
- package/build/tools/analyze_project.d.ts +0 -1
- package/build/tools/analyze_project.js +0 -527
- package/build/tools/check_deps.d.ts +0 -13
- package/build/tools/check_deps.js +0 -204
- package/build/tools/convert.d.ts +0 -13
- package/build/tools/convert.js +0 -599
- package/build/tools/css_order.d.ts +0 -13
- package/build/tools/css_order.js +0 -81
- package/build/tools/debug.d.ts +0 -13
- package/build/tools/debug.js +0 -131
- package/build/tools/design2code.d.ts +0 -20
- package/build/tools/design2code.js +0 -426
- package/build/tools/detect_shell.d.ts +0 -6
- package/build/tools/detect_shell.js +0 -151
- package/build/tools/explain.d.ts +0 -13
- package/build/tools/explain.js +0 -390
- package/build/tools/fix.d.ts +0 -13
- package/build/tools/fix.js +0 -303
- package/build/tools/gen_mock.d.ts +0 -22
- package/build/tools/gen_mock.js +0 -269
- package/build/tools/gen_skill.d.ts +0 -13
- package/build/tools/gen_skill.js +0 -560
- package/build/tools/genapi.d.ts +0 -13
- package/build/tools/genapi.js +0 -174
- package/build/tools/genchangelog.d.ts +0 -13
- package/build/tools/genchangelog.js +0 -250
- package/build/tools/gendoc.d.ts +0 -13
- package/build/tools/gendoc.js +0 -232
- package/build/tools/genpr.d.ts +0 -13
- package/build/tools/genpr.js +0 -194
- package/build/tools/genreadme.d.ts +0 -13
- package/build/tools/genreadme.js +0 -626
- package/build/tools/gensql.d.ts +0 -13
- package/build/tools/gensql.js +0 -320
- package/build/tools/genui.d.ts +0 -13
- package/build/tools/genui.js +0 -803
- package/build/tools/init_component_catalog.d.ts +0 -22
- package/build/tools/init_component_catalog.js +0 -809
- package/build/tools/init_setting.d.ts +0 -13
- package/build/tools/init_setting.js +0 -47
- package/build/tools/perf.d.ts +0 -13
- package/build/tools/perf.js +0 -409
- package/build/tools/render_ui.d.ts +0 -22
- package/build/tools/render_ui.js +0 -384
- package/build/tools/resolve_conflict.d.ts +0 -13
- package/build/tools/resolve_conflict.js +0 -349
- package/build/tools/security_scan.d.ts +0 -22
- package/build/tools/security_scan.js +0 -323
- package/build/tools/split.d.ts +0 -13
- package/build/tools/split.js +0 -599
- package/build/tools/start_api.d.ts +0 -13
- package/build/tools/start_api.js +0 -193
- package/build/tools/start_doc.d.ts +0 -13
- package/build/tools/start_doc.js +0 -207
- package/build/tools/start_refactor.d.ts +0 -13
- package/build/tools/start_refactor.js +0 -188
- package/build/tools/start_release.d.ts +0 -13
- package/build/tools/start_release.js +0 -167
- package/build/tools/start_review.d.ts +0 -13
- package/build/tools/start_review.js +0 -175
- /package/build/{utils/design-docs-generator.d.ts → lib/__tests__/dev-workflow.unit.test.d.ts} +0 -0
- /package/build/{utils/design-docs-generator.js → lib/__tests__/handles.unit.test.d.ts} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createMemoryClient } from './memory-client.js';
|
|
2
2
|
import { getMemoryConfig } from './memory-config.js';
|
|
3
|
+
import { buildMemoryAssetHandles, DEFAULT_GRAPH_RESOURCE_URI, mergeHandles, } from './handles.js';
|
|
3
4
|
function kindSearchPreferences(kind) {
|
|
4
5
|
switch (kind) {
|
|
5
6
|
case 'bugfix':
|
|
@@ -195,6 +196,25 @@ export function renderMemoryGuideSection(context) {
|
|
|
195
196
|
}
|
|
196
197
|
return blocks.join('\n');
|
|
197
198
|
}
|
|
199
|
+
export function buildMemoryInjectionHandles(context) {
|
|
200
|
+
if (!context.enabled || context.results.length === 0) {
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
memory_assets: buildMemoryAssetHandles(context.results.map((item) => ({
|
|
205
|
+
id: item.id,
|
|
206
|
+
name: item.name,
|
|
207
|
+
type: item.type,
|
|
208
|
+
summary: item.summary,
|
|
209
|
+
}))),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export function buildOrchestrationHandles(memoryContext, options) {
|
|
213
|
+
const memoryHandles = memoryContext ? buildMemoryInjectionHandles(memoryContext) : {};
|
|
214
|
+
return mergeHandles(memoryHandles, {
|
|
215
|
+
graph_resource: options?.graphResourceUri ?? DEFAULT_GRAPH_RESOURCE_URI,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
198
218
|
export function buildMemoryPlanStep(kind = 'default') {
|
|
199
219
|
if (kind === 'bugfix') {
|
|
200
220
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type AgentsMdMergeMode = "created" | "prepended" | "replaced-and-moved-to-top" | "skipped-empty";
|
|
2
|
-
export declare function wrapMcpProbeBlock(innerMarkdown: string): string;
|
|
3
|
-
export declare function mergeAgentsMdBlock(existingContent: string | null | undefined, generatedInner: string): {
|
|
2
|
+
export declare function wrapMcpProbeBlock(innerMarkdown: string, contextVersion?: string): string;
|
|
3
|
+
export declare function mergeAgentsMdBlock(existingContent: string | null | undefined, generatedInner: string, contextVersion?: string): {
|
|
4
4
|
content: string;
|
|
5
5
|
mergeMode: AgentsMdMergeMode;
|
|
6
6
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { VERSION } from "../version.js";
|
|
2
|
+
import { formatAgentsContextVersionMarker } from "./workflow-skill-version.js";
|
|
1
3
|
const BLOCK_BEGIN = "<!-- mcp-probe:context begin — auto-generated; re-run init_project_context updates this block only -->";
|
|
2
4
|
const BLOCK_END = "<!-- mcp-probe:context end -->";
|
|
3
|
-
export function wrapMcpProbeBlock(innerMarkdown) {
|
|
4
|
-
|
|
5
|
+
export function wrapMcpProbeBlock(innerMarkdown, contextVersion = VERSION) {
|
|
6
|
+
const versionLine = formatAgentsContextVersionMarker(contextVersion);
|
|
7
|
+
return `${BLOCK_BEGIN}\n${versionLine}\n${innerMarkdown.trim()}\n${BLOCK_END}`;
|
|
5
8
|
}
|
|
6
9
|
function stripExistingBlock(content) {
|
|
7
10
|
const beginIdx = content.indexOf(BLOCK_BEGIN);
|
|
@@ -28,8 +31,8 @@ function stripExistingBlock(content) {
|
|
|
28
31
|
const after = content.slice(endIdx + BLOCK_END.length).trimStart();
|
|
29
32
|
return [before, after].filter(Boolean).join("\n\n").trim();
|
|
30
33
|
}
|
|
31
|
-
export function mergeAgentsMdBlock(existingContent, generatedInner) {
|
|
32
|
-
const block = wrapMcpProbeBlock(generatedInner);
|
|
34
|
+
export function mergeAgentsMdBlock(existingContent, generatedInner, contextVersion = VERSION) {
|
|
35
|
+
const block = wrapMcpProbeBlock(generatedInner, contextVersion);
|
|
33
36
|
if (!existingContent?.trim()) {
|
|
34
37
|
return { content: `${block}\n`, mergeMode: "created" };
|
|
35
38
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/list 的 outputSchema 注册表(与 tools-manifest.json structuredOutput.schemas 对齐)
|
|
3
|
+
*/
|
|
4
|
+
type JsonSchema = Record<string, unknown>;
|
|
5
|
+
export declare function getOutputSchemaForTool(toolName: string): JsonSchema | undefined;
|
|
6
|
+
export declare function withOutputSchema<T extends {
|
|
7
|
+
name: string;
|
|
8
|
+
}>(tool: T): T & {
|
|
9
|
+
outputSchema?: JsonSchema;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/list 的 outputSchema 注册表(与 tools-manifest.json structuredOutput.schemas 对齐)
|
|
3
|
+
*/
|
|
4
|
+
import { CodeReviewReportSchema, BugAnalysisSchema, TestSuiteSchema, RefactorPlanSchema, } from '../schemas/output/core-tools.js';
|
|
5
|
+
import { FeatureSpecSchema, ProjectInitSchema, ProjectContextSchema, EstimateSchema, } from '../schemas/output/project-tools.js';
|
|
6
|
+
import { DesignSystemSchema, UISearchResultSchema, SyncReportSchema, } from '../schemas/output/ui-ux-tools.js';
|
|
7
|
+
import { InterviewReportSchema } from '../schemas/output/product-design-tools.js';
|
|
8
|
+
import { CommitGuidanceSchema, FeatureReportSchema, BugFixReportSchema, UIReportSchema, OnboardingReportSchema, RalphLoopReportSchema, WorkflowReportSchema, } from '../schemas/structured-output.js';
|
|
9
|
+
import { MemorySearchSchema, MemoryAssetDetailSchema, MemorizeResultSchema, DeleteMemoryResultSchema, UpdateMemoryResultSchema, PatternExtractionSchema, } from '../schemas/output/memory-tools.js';
|
|
10
|
+
import { CodeInsightSchema } from '../schemas/output/code-insight-tools.js';
|
|
11
|
+
const SpecValidationReportSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
passed: { type: 'boolean' },
|
|
15
|
+
errorCount: { type: 'number' },
|
|
16
|
+
warningCount: { type: 'number' },
|
|
17
|
+
issues: {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
file: { type: 'string' },
|
|
23
|
+
severity: { type: 'string', enum: ['error', 'warning'] },
|
|
24
|
+
code: { type: 'string' },
|
|
25
|
+
message: { type: 'string' },
|
|
26
|
+
},
|
|
27
|
+
required: ['file', 'severity', 'message'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
frIds: { type: 'array', items: { type: 'string' } },
|
|
31
|
+
summary: { type: 'string' },
|
|
32
|
+
},
|
|
33
|
+
required: ['passed', 'errorCount', 'warningCount', 'issues', 'summary'],
|
|
34
|
+
};
|
|
35
|
+
const UserQuestionSchema = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
question: { type: 'string' },
|
|
39
|
+
options: { type: 'array', items: { type: 'string' } },
|
|
40
|
+
context: { type: 'string' },
|
|
41
|
+
},
|
|
42
|
+
required: ['question'],
|
|
43
|
+
};
|
|
44
|
+
const OUTPUT_SCHEMA_BY_TOOL = {
|
|
45
|
+
gencommit: CommitGuidanceSchema,
|
|
46
|
+
code_insight: CodeInsightSchema,
|
|
47
|
+
code_review: CodeReviewReportSchema,
|
|
48
|
+
fix_bug: BugAnalysisSchema,
|
|
49
|
+
gentest: TestSuiteSchema,
|
|
50
|
+
refactor: RefactorPlanSchema,
|
|
51
|
+
add_feature: FeatureSpecSchema,
|
|
52
|
+
check_spec: SpecValidationReportSchema,
|
|
53
|
+
estimate: EstimateSchema,
|
|
54
|
+
start_feature: FeatureReportSchema,
|
|
55
|
+
start_bugfix: BugFixReportSchema,
|
|
56
|
+
start_onboard: OnboardingReportSchema,
|
|
57
|
+
start_ui: UIReportSchema,
|
|
58
|
+
start_product: WorkflowReportSchema,
|
|
59
|
+
start_ralph: RalphLoopReportSchema,
|
|
60
|
+
init_project: ProjectInitSchema,
|
|
61
|
+
init_project_context: ProjectContextSchema,
|
|
62
|
+
interview: InterviewReportSchema,
|
|
63
|
+
ask_user: UserQuestionSchema,
|
|
64
|
+
ui_design_system: DesignSystemSchema,
|
|
65
|
+
ui_search: UISearchResultSchema,
|
|
66
|
+
sync_ui_data: SyncReportSchema,
|
|
67
|
+
search_memory: MemorySearchSchema,
|
|
68
|
+
read_memory_asset: MemoryAssetDetailSchema,
|
|
69
|
+
memorize_asset: MemorizeResultSchema,
|
|
70
|
+
delete_memory_asset: DeleteMemoryResultSchema,
|
|
71
|
+
update_memory_asset: UpdateMemoryResultSchema,
|
|
72
|
+
scan_and_extract_patterns: PatternExtractionSchema,
|
|
73
|
+
};
|
|
74
|
+
export function getOutputSchemaForTool(toolName) {
|
|
75
|
+
return OUTPUT_SCHEMA_BY_TOOL[toolName];
|
|
76
|
+
}
|
|
77
|
+
export function withOutputSchema(tool) {
|
|
78
|
+
const outputSchema = getOutputSchemaForTool(tool.name);
|
|
79
|
+
return outputSchema ? { ...tool, outputSchema } : tool;
|
|
80
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 质量约束「单一真相源」
|
|
3
|
+
*
|
|
4
|
+
* 目标:把散落在 task 模板、code_review、UI 工具里的软性质量要求,
|
|
5
|
+
* 收敛到一个集中管理的硬约束模块。三个落点工具都从这里 import,
|
|
6
|
+
* 改一处、处处生效,杜绝规则漂移。
|
|
7
|
+
*
|
|
8
|
+
* 设计哲学(借鉴 taste-skill / impeccable):
|
|
9
|
+
* 凡是想让下游 AI 真正照做的规则,必须用「机器可判定的硬约束 +
|
|
10
|
+
* 精确字符串黑名单 + 二元禁令 + 交付前 checklist」,
|
|
11
|
+
* 禁用「尽量 / 建议 / sparingly」这类会被 AI 忽略的软措辞。
|
|
12
|
+
*
|
|
13
|
+
* 本模块为纯常量 + 字符串渲染,无 I/O、零运行时依赖,便于单测。
|
|
14
|
+
*/
|
|
15
|
+
export interface CodeLimits {
|
|
16
|
+
/** 单文件最大行数;超出必须拆分模块/组件 */
|
|
17
|
+
maxFileLines: number;
|
|
18
|
+
/** 单函数最大行数;超出必须拆分方法 */
|
|
19
|
+
maxFunctionLines: number;
|
|
20
|
+
/** 最大嵌套层数;超出用提前返回(early return)展平 */
|
|
21
|
+
maxNestingDepth: number;
|
|
22
|
+
/** 最大参数个数;超出改用参数对象 */
|
|
23
|
+
maxParameters: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const CODE_LIMITS: CodeLimits;
|
|
26
|
+
/**
|
|
27
|
+
* 占位/省略式代码模式——出现即判「未完成的破碎输出」。
|
|
28
|
+
* 措辞二元:零容忍,不存在「少量允许」。
|
|
29
|
+
*/
|
|
30
|
+
export declare const BANNED_CODE_PATTERNS: string[];
|
|
31
|
+
/**
|
|
32
|
+
* 每条都是带数值/比例的硬约束,区别于含糊的「保持一致」。
|
|
33
|
+
* 精选自 impeccable,挑机器可判定、收益最高的条款。
|
|
34
|
+
*/
|
|
35
|
+
export declare const UI_HARD_RULES: string[];
|
|
36
|
+
/**
|
|
37
|
+
* 命中即「AI slop」。这些是 taste-skill / impeccable 生产测试中
|
|
38
|
+
* 最高频的 AI 设计破绽(tells)。
|
|
39
|
+
*/
|
|
40
|
+
export declare const UI_BANNED_LIST: string[];
|
|
41
|
+
/** 代码量硬约束清单 */
|
|
42
|
+
export declare function renderCodeLimits(): string;
|
|
43
|
+
/** 完整性黑名单(占位符/省略式代码) */
|
|
44
|
+
export declare function renderBannedPatterns(): string;
|
|
45
|
+
/** UI 设计硬红线 */
|
|
46
|
+
export declare function renderUiHardRules(): string;
|
|
47
|
+
/** UI 禁用黑名单 */
|
|
48
|
+
export declare function renderUiBannedList(): string;
|
|
49
|
+
/**
|
|
50
|
+
* 交付前自检矩阵(Pre-Flight Checklist)。
|
|
51
|
+
* 把所有约束收口成一个生成结束前必须逐条诚实勾选的闭环。
|
|
52
|
+
* 任意一项不能诚实勾选 = 未完成。
|
|
53
|
+
*/
|
|
54
|
+
export declare function renderPreFlightChecklist(): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 质量约束「单一真相源」
|
|
3
|
+
*
|
|
4
|
+
* 目标:把散落在 task 模板、code_review、UI 工具里的软性质量要求,
|
|
5
|
+
* 收敛到一个集中管理的硬约束模块。三个落点工具都从这里 import,
|
|
6
|
+
* 改一处、处处生效,杜绝规则漂移。
|
|
7
|
+
*
|
|
8
|
+
* 设计哲学(借鉴 taste-skill / impeccable):
|
|
9
|
+
* 凡是想让下游 AI 真正照做的规则,必须用「机器可判定的硬约束 +
|
|
10
|
+
* 精确字符串黑名单 + 二元禁令 + 交付前 checklist」,
|
|
11
|
+
* 禁用「尽量 / 建议 / sparingly」这类会被 AI 忽略的软措辞。
|
|
12
|
+
*
|
|
13
|
+
* 本模块为纯常量 + 字符串渲染,无 I/O、零运行时依赖,便于单测。
|
|
14
|
+
*/
|
|
15
|
+
export const CODE_LIMITS = {
|
|
16
|
+
maxFileLines: 500,
|
|
17
|
+
maxFunctionLines: 50,
|
|
18
|
+
maxNestingDepth: 4,
|
|
19
|
+
maxParameters: 3,
|
|
20
|
+
};
|
|
21
|
+
// ============================================================
|
|
22
|
+
// 二、代码完整性黑名单(精确字符串,机械可扫描)
|
|
23
|
+
// ============================================================
|
|
24
|
+
/**
|
|
25
|
+
* 占位/省略式代码模式——出现即判「未完成的破碎输出」。
|
|
26
|
+
* 措辞二元:零容忍,不存在「少量允许」。
|
|
27
|
+
*/
|
|
28
|
+
export const BANNED_CODE_PATTERNS = [
|
|
29
|
+
'// ...',
|
|
30
|
+
'/* ... */',
|
|
31
|
+
'// TODO',
|
|
32
|
+
'// FIXME(遗留未实现)',
|
|
33
|
+
'// rest of code',
|
|
34
|
+
'// rest of the code',
|
|
35
|
+
'// implement here',
|
|
36
|
+
'// your code here',
|
|
37
|
+
'// similar to above',
|
|
38
|
+
'// same as before',
|
|
39
|
+
'裸露的省略号 ...(作为代码占位)',
|
|
40
|
+
'the rest follows the same pattern',
|
|
41
|
+
'and so on',
|
|
42
|
+
'以此类推(作为代码省略)',
|
|
43
|
+
'其余代码省略',
|
|
44
|
+
'此处省略',
|
|
45
|
+
];
|
|
46
|
+
// ============================================================
|
|
47
|
+
// 三、UI 设计硬红线(带数值,可机器判定)
|
|
48
|
+
// ============================================================
|
|
49
|
+
/**
|
|
50
|
+
* 每条都是带数值/比例的硬约束,区别于含糊的「保持一致」。
|
|
51
|
+
* 精选自 impeccable,挑机器可判定、收益最高的条款。
|
|
52
|
+
*/
|
|
53
|
+
export const UI_HARD_RULES = [
|
|
54
|
+
'间距系统:强制 4pt 基准阶梯 [4, 8, 12, 16, 24, 32, 48, 64, 96]px。同组元素 8-12px,跨区块 48-96px。任何不在阶梯内的 padding/margin/gap 判为漂移。',
|
|
55
|
+
'触控目标:≥ 44×44px。视觉元素更小时用 padding 或伪元素扩大命中区。',
|
|
56
|
+
'对比度(WCAG):正文 ≥ 4.5:1;大文本(≥18px 或 bold ≥14px)≥ 3:1;UI 组件/图标 ≥ 3:1;placeholder 同样 ≥ 4.5:1(不可用默认浅灰)。',
|
|
57
|
+
'字阶比例:相邻级别 ≥ 1.25(品牌站)或 1.125-1.2(产品界面)。禁止扁平字阶(14/15/16px 相邻)。最多 5 级。',
|
|
58
|
+
'主正文流字号:≥ 16px / 1rem,且用 rem 而非 px(脚注、表格密集数据、图例等辅助文本可更小)。',
|
|
59
|
+
'Hero 字号天花板:clamp() 的 max ≤ 6rem(96px)。clamp max ≤ 2.5 × min,否则破坏浏览器缩放与回流。',
|
|
60
|
+
'Display 标题字间距:≥ -0.04em,再紧字母会粘连。',
|
|
61
|
+
'色彩空间:用 OKLCH,禁用 HSL。中性色加微着色 chroma 0.005-0.015,朝品牌色(不默认朝暖橙 hue 60 / 冷蓝 hue 250)。',
|
|
62
|
+
'色彩权重:遵守 60-30-10(60% 中性底 / 30% 次要 / 10% 强调)。一个页面锁定单一强调色,逐组件审计一致性。',
|
|
63
|
+
'行高:标题 1.1-1.2,正文 1.5-1.7。深色背景上字重降一档、行高 +0.05-0.1。',
|
|
64
|
+
'交互八态完整性:每个交互元素必须设计 Default / Hover / Focus / Active / Disabled / Loading / Error / Success 八态,缺一即 P1。',
|
|
65
|
+
'Focus 可见性:禁止裸 outline:none。用 :focus-visible,2-3px 粗,对比 ≥ 3:1,outline-offset 在元素外侧。',
|
|
66
|
+
'动效:时长 150-300ms;缓动用 ease-out-expo/quart/quint;禁 bounce/elastic;必须有 @media (prefers-reduced-motion: reduce) 分支。',
|
|
67
|
+
'认知负荷:营销/落地页类界面任意决策点 ≤ 4 个可见选项(导航 ≤ 5 顶级项、表单每组 ≤ 4 字段、定价常见 ≤ 3-4 档)。数据密集型后台(监控大盘、交易看板)按信息需求放宽,不强套此限。',
|
|
68
|
+
'z-index:建立语义层级(dropdown → sticky → modal-backdrop → modal → toast → tooltip)。禁止任意值 999 / 9999。',
|
|
69
|
+
];
|
|
70
|
+
// ============================================================
|
|
71
|
+
// 四、UI 禁用黑名单(match-and-refuse,二元禁令)
|
|
72
|
+
// ============================================================
|
|
73
|
+
/**
|
|
74
|
+
* 命中即「AI slop」。这些是 taste-skill / impeccable 生产测试中
|
|
75
|
+
* 最高频的 AI 设计破绽(tells)。
|
|
76
|
+
*/
|
|
77
|
+
export const UI_BANNED_LIST = [
|
|
78
|
+
'默认字体 Inter / Roboto / Open Sans(无明确理由时禁用)。',
|
|
79
|
+
'AI 默认紫蓝渐变(紫→蓝光辉),最典型的 AI 破绽。',
|
|
80
|
+
'gradient text(background-clip:text + 渐变)作为标题默认效果。',
|
|
81
|
+
'side-stripe 装饰边框(border-left/right > 1px 纯装饰)。',
|
|
82
|
+
'默认 glassmorphism(无真实层次的毛玻璃)。',
|
|
83
|
+
'相同卡片等距网格(无层次的 N 等分 card grid)。',
|
|
84
|
+
'嵌套卡片(nested cards 永远是错的)。',
|
|
85
|
+
'卡片圆角 ≥ 32px(卡片圆角上限 12-16px)。',
|
|
86
|
+
'ghost-card:同元素 border 1px + box-shadow blur ≥16px。',
|
|
87
|
+
'cream / sand / beige 米色正文背景(2026 年的饱和 AI 默认底色)。',
|
|
88
|
+
'hero-metric 模板(巨大数字 + 小标签的套路化英雄区)。',
|
|
89
|
+
'每段都有的 tiny uppercase eyebrow 小标签(每 3 区块最多 1 个)。',
|
|
90
|
+
'01 / 02 / 03 编号式小标题装饰。',
|
|
91
|
+
'英文排版/UI 文案中滥用 em-dash("—"):英文语境最高频的 AI 破绽,禁止用作随意连接符(中文正文的破折号属合法标点,不在此列)。',
|
|
92
|
+
'占位文案 "Lorem Ipsum" / "John Doe" / "Acme"。',
|
|
93
|
+
'AI 陈词滥调文案:Elevate / Seamless / Unleash / Delve / 赋能 / 一站式。',
|
|
94
|
+
'同页重复 CTA 意图(如 "Get in touch" + "Let\'s talk" 并存)。',
|
|
95
|
+
];
|
|
96
|
+
// ============================================================
|
|
97
|
+
// 渲染函数:返回 markdown 片段,供各工具拼进指南
|
|
98
|
+
// ============================================================
|
|
99
|
+
/** 代码量硬约束清单 */
|
|
100
|
+
export function renderCodeLimits() {
|
|
101
|
+
return `**代码量硬约束(超出即判 HIGH,必须重构)**:
|
|
102
|
+
- [ ] 单文件 ≤ ${CODE_LIMITS.maxFileLines} 行:超出必须拆分为多个模块/组件
|
|
103
|
+
- [ ] 单函数 ≤ ${CODE_LIMITS.maxFunctionLines} 行:超出必须拆分方法
|
|
104
|
+
- [ ] 嵌套 ≤ ${CODE_LIMITS.maxNestingDepth} 层:超出用提前返回(early return)展平
|
|
105
|
+
- [ ] 参数 ≤ ${CODE_LIMITS.maxParameters} 个:超出改用参数对象`;
|
|
106
|
+
}
|
|
107
|
+
/** 完整性黑名单(占位符/省略式代码) */
|
|
108
|
+
export function renderBannedPatterns() {
|
|
109
|
+
const list = BANNED_CODE_PATTERNS.map((p) => `- \`${p}\``).join('\n');
|
|
110
|
+
return `**完整性检查(命中即判 CRITICAL:「部分输出 = 破碎输出」)**:
|
|
111
|
+
|
|
112
|
+
下列占位/省略模式零容忍,扫描到任意一个即判定该交付物未完成:
|
|
113
|
+
|
|
114
|
+
${list}
|
|
115
|
+
|
|
116
|
+
> 二元规则:不存在「少量允许」。任何用占位符、省略注释代替真实实现的行为都是破碎输出。`;
|
|
117
|
+
}
|
|
118
|
+
/** UI 设计硬红线 */
|
|
119
|
+
export function renderUiHardRules() {
|
|
120
|
+
const list = UI_HARD_RULES.map((r, i) => `${i + 1}. ${r}`).join('\n');
|
|
121
|
+
return `## UI 设计硬红线(带数值,可逐条核验)
|
|
122
|
+
|
|
123
|
+
${list}`;
|
|
124
|
+
}
|
|
125
|
+
/** UI 禁用黑名单 */
|
|
126
|
+
export function renderUiBannedList() {
|
|
127
|
+
const list = UI_BANNED_LIST.map((b) => `- ❌ ${b}`).join('\n');
|
|
128
|
+
return `## UI 禁用黑名单(命中即 AI slop,二元禁令)
|
|
129
|
+
|
|
130
|
+
${list}`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 交付前自检矩阵(Pre-Flight Checklist)。
|
|
134
|
+
* 把所有约束收口成一个生成结束前必须逐条诚实勾选的闭环。
|
|
135
|
+
* 任意一项不能诚实勾选 = 未完成。
|
|
136
|
+
*/
|
|
137
|
+
export function renderPreFlightChecklist() {
|
|
138
|
+
return `## 交付前自检矩阵(Pre-Flight Check)
|
|
139
|
+
|
|
140
|
+
> 生成结束前必须逐条诚实勾选。任意一项不能勾选 = 未完成,禁止交付。
|
|
141
|
+
|
|
142
|
+
**完整性**:
|
|
143
|
+
- [ ] 无任何占位符 / 省略注释 / TODO(对照完整性黑名单)
|
|
144
|
+
- [ ] 交付物数量与需求一致(Scope-lock:先数清楚再交付)
|
|
145
|
+
|
|
146
|
+
**代码量**:
|
|
147
|
+
- [ ] 所有文件 ≤ ${CODE_LIMITS.maxFileLines} 行,函数 ≤ ${CODE_LIMITS.maxFunctionLines} 行
|
|
148
|
+
|
|
149
|
+
**UI(若涉及界面)**:
|
|
150
|
+
- [ ] 间距落在 4pt 阶梯内
|
|
151
|
+
- [ ] 对比度达标(正文 ≥ 4.5:1)
|
|
152
|
+
- [ ] 交互元素八态齐全
|
|
153
|
+
- [ ] 未命中 UI 禁用黑名单(无 em-dash、无 AI 紫蓝渐变、无米色底等)
|
|
154
|
+
- [ ] 单一强调色、统一圆角阶梯(一致性锁)`;
|
|
155
|
+
}
|
|
@@ -84,17 +84,17 @@ export function renderSkillBridgeSection(status) {
|
|
|
84
84
|
const conclusion = status.ready
|
|
85
85
|
? "全部 skill 可用,建议按顺序调用后再执行 MCP 工具步骤。"
|
|
86
86
|
: "部分 skill 缺失:继续执行 MCP 主流程,不阻塞;安装缺失 skill 后下次运行可获得更高质量输出。";
|
|
87
|
-
return `## 🧩 Skill Bridge(UI/PRD 增强)
|
|
88
|
-
|
|
89
|
-
按顺序调用(宿主支持时):
|
|
90
|
-
${orderLines}
|
|
91
|
-
|
|
92
|
-
当前状态:
|
|
93
|
-
${stateLines}
|
|
94
|
-
|
|
95
|
-
${conclusion}
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
87
|
+
return `## 🧩 Skill Bridge(UI/PRD 增强)
|
|
88
|
+
|
|
89
|
+
按顺序调用(宿主支持时):
|
|
90
|
+
${orderLines}
|
|
91
|
+
|
|
92
|
+
当前状态:
|
|
93
|
+
${stateLines}
|
|
94
|
+
|
|
95
|
+
${conclusion}
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
99
|
`;
|
|
100
100
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface SpecGateContext {
|
|
2
|
+
featureName: string;
|
|
3
|
+
docsDir: string;
|
|
4
|
+
specDir: string;
|
|
5
|
+
detected: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function specArtifactsExist(projectRoot: string, docsDir: string, featureName: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 解析 Bug 修复关联的 feature_name:
|
|
10
|
+
* 1) 显式传入优先
|
|
11
|
+
* 2) specs 下仅有一个目录时自动采用
|
|
12
|
+
* 3) 错误描述中唯一匹配某个 spec 目录名
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveBugfixFeatureName(explicitFeatureName: string, projectRoot: string, docsDir: string, hintText: string): string | null;
|
|
15
|
+
export declare function resolveBugfixSpecGate(input: {
|
|
16
|
+
featureName?: string;
|
|
17
|
+
projectRoot: string;
|
|
18
|
+
docsDir: string;
|
|
19
|
+
hintText: string;
|
|
20
|
+
}): SpecGateContext | null;
|
|
21
|
+
export declare function buildCheckSpecPlanStep(featureName: string, docsDir: string): {
|
|
22
|
+
id: string;
|
|
23
|
+
tool: string;
|
|
24
|
+
when: string;
|
|
25
|
+
args: {
|
|
26
|
+
feature_name: string;
|
|
27
|
+
docs_dir: string;
|
|
28
|
+
};
|
|
29
|
+
outputs: string[];
|
|
30
|
+
note: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function renderSpecGatePromptSection(specGate: SpecGateContext): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
export function specArtifactsExist(projectRoot, docsDir, featureName) {
|
|
4
|
+
const specDir = path.join(projectRoot, docsDir, 'specs', featureName);
|
|
5
|
+
return (fs.existsSync(path.join(specDir, 'requirements.md')) ||
|
|
6
|
+
fs.existsSync(path.join(specDir, 'design.md')) ||
|
|
7
|
+
fs.existsSync(path.join(specDir, 'tasks.md')));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 解析 Bug 修复关联的 feature_name:
|
|
11
|
+
* 1) 显式传入优先
|
|
12
|
+
* 2) specs 下仅有一个目录时自动采用
|
|
13
|
+
* 3) 错误描述中唯一匹配某个 spec 目录名
|
|
14
|
+
*/
|
|
15
|
+
export function resolveBugfixFeatureName(explicitFeatureName, projectRoot, docsDir, hintText) {
|
|
16
|
+
const explicit = explicitFeatureName.trim();
|
|
17
|
+
if (explicit) {
|
|
18
|
+
return explicit;
|
|
19
|
+
}
|
|
20
|
+
const specsRoot = path.join(projectRoot, docsDir, 'specs');
|
|
21
|
+
if (!fs.existsSync(specsRoot)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const dirs = fs
|
|
25
|
+
.readdirSync(specsRoot, { withFileTypes: true })
|
|
26
|
+
.filter((entry) => entry.isDirectory())
|
|
27
|
+
.map((entry) => entry.name);
|
|
28
|
+
if (dirs.length === 1) {
|
|
29
|
+
return dirs[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
const lowerHint = hintText.toLowerCase();
|
|
32
|
+
const matched = dirs.filter((name) => {
|
|
33
|
+
const lowerName = name.toLowerCase();
|
|
34
|
+
if (lowerHint.includes(lowerName)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return lowerName
|
|
38
|
+
.split(/[-_]+/)
|
|
39
|
+
.filter((part) => part.length > 3)
|
|
40
|
+
.some((part) => lowerHint.includes(part));
|
|
41
|
+
});
|
|
42
|
+
return matched.length === 1 ? (matched[0] ?? null) : null;
|
|
43
|
+
}
|
|
44
|
+
export function resolveBugfixSpecGate(input) {
|
|
45
|
+
const featureName = resolveBugfixFeatureName(input.featureName ?? '', input.projectRoot, input.docsDir, input.hintText);
|
|
46
|
+
if (!featureName || !specArtifactsExist(input.projectRoot, input.docsDir, featureName)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
featureName,
|
|
51
|
+
docsDir: input.docsDir,
|
|
52
|
+
specDir: `${input.docsDir}/specs/${featureName}`,
|
|
53
|
+
detected: !input.featureName?.trim(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function buildCheckSpecPlanStep(featureName, docsDir) {
|
|
57
|
+
return {
|
|
58
|
+
id: 'check-spec',
|
|
59
|
+
tool: 'check_spec',
|
|
60
|
+
when: '修复与回归测试通过后,且本次 Bug 关联功能规格存在时',
|
|
61
|
+
args: {
|
|
62
|
+
feature_name: featureName,
|
|
63
|
+
docs_dir: docsDir,
|
|
64
|
+
},
|
|
65
|
+
outputs: [`${docsDir}/specs/${featureName}/`],
|
|
66
|
+
note: '若修复改动影响 requirements/design/tasks,先更新规格文档再重跑 check_spec;未通过不得视为修复闭环',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function renderSpecGatePromptSection(specGate) {
|
|
70
|
+
const detectNote = specGate.detected
|
|
71
|
+
? `\n- 自动识别关联规格: \`${specGate.specDir}/\``
|
|
72
|
+
: `\n- 关联规格: \`${specGate.specDir}/\``;
|
|
73
|
+
return `
|
|
74
|
+
|
|
75
|
+
## 📐 步骤 3: 规格闸门(修复后)
|
|
76
|
+
|
|
77
|
+
**调用**: \`check_spec\`
|
|
78
|
+
\`\`\`json
|
|
79
|
+
{ "feature_name": "${specGate.featureName}", "docs_dir": "${specGate.docsDir}" }
|
|
80
|
+
\`\`\`
|
|
81
|
+
${detectNote}
|
|
82
|
+
**未通过**:按报告补全 requirements/design/tasks 后**重跑 check_spec**;规格与实现不一致时不得结案。`;
|
|
83
|
+
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* 本模块为纯逻辑、无 I/O,便于单测。
|
|
9
9
|
*/
|
|
10
|
-
/**
|
|
11
|
-
const PLACEHOLDER_RE = /\[填写[::][^\]]*\]/g;
|
|
10
|
+
/** 匹配未填写的占位符:`[填写:xxx]` / `[填写:xxx]` / 裸 `[填写]` 都算 */
|
|
11
|
+
const PLACEHOLDER_RE = /\[填写[::]?[^\]]*\]/g;
|
|
12
12
|
function countPlaceholders(content) {
|
|
13
13
|
const matches = content.match(PLACEHOLDER_RE);
|
|
14
14
|
return matches ? matches.length : 0;
|
|
@@ -29,7 +29,7 @@ export function extractFrIds(content) {
|
|
|
29
29
|
const REQUIRED_SECTIONS = {
|
|
30
30
|
requirements: ['功能概述', '需求列表', '非功能需求', '依赖关系'],
|
|
31
31
|
design: ['概述', '技术方案', '文件结构'],
|
|
32
|
-
tasks: ['任务列表', '需求覆盖矩阵'],
|
|
32
|
+
tasks: ['交付物清单', '任务列表', '需求覆盖矩阵', '文件变更清单'],
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* 校验三份规格文档。传入各文件的全文(不存在传 null)。
|
|
@@ -93,6 +93,19 @@ export function validateSpecDocuments(input) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
// tasks:详细度校验——每条任务应附「证据块」,避免宽泛任务导致 AI 偷懒
|
|
97
|
+
if (tasks && tasks.trim()) {
|
|
98
|
+
const taskItemCount = (tasks.match(/^\s*-\s*\[\s*\]\s*\d+\.\d+/gm) || []).length;
|
|
99
|
+
const evidenceCount = (tasks.match(/证据块/g) || []).length;
|
|
100
|
+
if (taskItemCount > 0 && evidenceCount < taskItemCount) {
|
|
101
|
+
issues.push({
|
|
102
|
+
file: 'tasks',
|
|
103
|
+
severity: 'warning',
|
|
104
|
+
code: 'thin_task',
|
|
105
|
+
message: `tasks.md 有 ${taskItemCount} 条任务,但仅 ${evidenceCount} 条标注「证据块」;过于宽泛的任务易导致实现时偷懒/跳步`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
96
109
|
const errorCount = issues.filter((item) => item.severity === 'error').length;
|
|
97
110
|
const warningCount = issues.filter((item) => item.severity === 'warning').length;
|
|
98
111
|
const passed = errorCount === 0;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 长耗时工具默认走 MCP Task,避免阻塞 stdio 宿主。
|
|
3
|
+
*/
|
|
4
|
+
export declare function isAutoTaskTool(toolName: string): boolean;
|
|
5
|
+
export declare function isAutoTaskEnabled(): boolean;
|
|
6
|
+
export declare function shouldAutoEscalateToTask(toolName: string, hasExplicitTaskRequest: boolean): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 长耗时工具默认走 MCP Task,避免阻塞 stdio 宿主。
|
|
3
|
+
*/
|
|
4
|
+
const AUTO_TASK_TOOLS = new Set(['code_insight', 'scan_and_extract_patterns']);
|
|
5
|
+
export function isAutoTaskTool(toolName) {
|
|
6
|
+
return AUTO_TASK_TOOLS.has(toolName);
|
|
7
|
+
}
|
|
8
|
+
export function isAutoTaskEnabled() {
|
|
9
|
+
const raw = process.env.MCP_DISABLE_AUTO_TASK?.trim();
|
|
10
|
+
if (raw && /^(1|true|yes|on)$/i.test(raw)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
export function shouldAutoEscalateToTask(toolName, hasExplicitTaskRequest) {
|
|
16
|
+
if (hasExplicitTaskRequest) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return isAutoTaskEnabled() && isAutoTaskTool(toolName);
|
|
20
|
+
}
|