funolio-agent 1.0.75 → 1.1.65
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/dist/auth/credential-reader.d.ts.map +1 -1
- package/dist/auth/credential-reader.js +4 -3
- package/dist/auth/credential-reader.js.map +1 -1
- package/dist/auth/token-refresh.d.ts +8 -0
- package/dist/auth/token-refresh.d.ts.map +1 -1
- package/dist/auth/token-refresh.js +82 -52
- package/dist/auth/token-refresh.js.map +1 -1
- package/dist/auto-organizer.d.ts.map +1 -1
- package/dist/auto-organizer.js +6 -7
- package/dist/auto-organizer.js.map +1 -1
- package/dist/bench-prefix.d.ts +16 -0
- package/dist/bench-prefix.d.ts.map +1 -0
- package/dist/bench-prefix.js +25 -0
- package/dist/bench-prefix.js.map +1 -0
- package/dist/bot-manager.d.ts.map +1 -1
- package/dist/bot-manager.js +23 -14
- package/dist/bot-manager.js.map +1 -1
- package/dist/chat-sync.d.ts +42 -0
- package/dist/chat-sync.d.ts.map +1 -0
- package/dist/chat-sync.js +95 -0
- package/dist/chat-sync.js.map +1 -0
- package/dist/clerk-model.d.ts +7 -0
- package/dist/clerk-model.d.ts.map +1 -1
- package/dist/clerk-model.js +42 -8
- package/dist/clerk-model.js.map +1 -1
- package/dist/cli-bootstrap-history.d.ts +10 -0
- package/dist/cli-bootstrap-history.d.ts.map +1 -0
- package/dist/cli-bootstrap-history.js +112 -0
- package/dist/cli-bootstrap-history.js.map +1 -0
- package/dist/cli-models.d.ts +8 -0
- package/dist/cli-models.d.ts.map +1 -0
- package/dist/cli-models.js +91 -0
- package/dist/cli-models.js.map +1 -0
- package/dist/cli-session-epoch.d.ts +13 -3
- package/dist/cli-session-epoch.d.ts.map +1 -1
- package/dist/cli-session-epoch.js +53 -4
- package/dist/cli-session-epoch.js.map +1 -1
- package/dist/codex-app-server-manager.d.ts +64 -4
- package/dist/codex-app-server-manager.d.ts.map +1 -1
- package/dist/codex-app-server-manager.js +755 -55
- package/dist/codex-app-server-manager.js.map +1 -1
- package/dist/commands/pool.d.ts +32 -0
- package/dist/commands/pool.d.ts.map +1 -1
- package/dist/commands/pool.js +145 -66
- package/dist/commands/pool.js.map +1 -1
- package/dist/commands/start.d.ts +21 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +484 -63
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +5 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +170 -58
- package/dist/config.js.map +1 -1
- package/dist/context-window.d.ts +37 -1
- package/dist/context-window.d.ts.map +1 -1
- package/dist/context-window.js +202 -16
- package/dist/context-window.js.map +1 -1
- package/dist/live-activity.d.ts +3 -1
- package/dist/live-activity.d.ts.map +1 -1
- package/dist/live-activity.js.map +1 -1
- package/dist/local-chat-execution.d.ts +114 -0
- package/dist/local-chat-execution.d.ts.map +1 -0
- package/dist/local-chat-execution.js +349 -0
- package/dist/local-chat-execution.js.map +1 -0
- package/dist/local-cli-pty-manager.d.ts +138 -3
- package/dist/local-cli-pty-manager.d.ts.map +1 -1
- package/dist/local-cli-pty-manager.js +1415 -111
- package/dist/local-cli-pty-manager.js.map +1 -1
- package/dist/local-conversation-gateway.d.ts +110 -0
- package/dist/local-conversation-gateway.d.ts.map +1 -0
- package/dist/local-conversation-gateway.js +175 -0
- package/dist/local-conversation-gateway.js.map +1 -0
- package/dist/local-data.d.ts +235 -5
- package/dist/local-data.d.ts.map +1 -1
- package/dist/local-data.js +1066 -87
- package/dist/local-data.js.map +1 -1
- package/dist/local-db.d.ts +6 -0
- package/dist/local-db.d.ts.map +1 -1
- package/dist/local-db.js +376 -4
- package/dist/local-db.js.map +1 -1
- package/dist/local-funnel.d.ts.map +1 -1
- package/dist/local-funnel.js +6 -5
- package/dist/local-funnel.js.map +1 -1
- package/dist/local-server.d.ts +30 -0
- package/dist/local-server.d.ts.map +1 -1
- package/dist/local-server.js +2898 -319
- package/dist/local-server.js.map +1 -1
- package/dist/managed-process-registry.d.ts +59 -0
- package/dist/managed-process-registry.d.ts.map +1 -0
- package/dist/managed-process-registry.js +390 -0
- package/dist/managed-process-registry.js.map +1 -0
- package/dist/mcp/claude-config-writer.d.ts +5 -5
- package/dist/mcp/claude-config-writer.d.ts.map +1 -1
- package/dist/mcp/claude-config-writer.js +19 -11
- package/dist/mcp/claude-config-writer.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/sync-cli-config.d.ts +42 -4
- package/dist/mcp/sync-cli-config.d.ts.map +1 -1
- package/dist/mcp/sync-cli-config.js +497 -17
- package/dist/mcp/sync-cli-config.js.map +1 -1
- package/dist/message-loop.d.ts.map +1 -1
- package/dist/message-loop.js +43 -1
- package/dist/message-loop.js.map +1 -1
- package/dist/mqtt-client.d.ts +34 -0
- package/dist/mqtt-client.d.ts.map +1 -1
- package/dist/mqtt-client.js +270 -45
- package/dist/mqtt-client.js.map +1 -1
- package/dist/mqtt-data-relay.d.ts +44 -0
- package/dist/mqtt-data-relay.d.ts.map +1 -0
- package/dist/mqtt-data-relay.js +106 -0
- package/dist/mqtt-data-relay.js.map +1 -0
- package/dist/orchestration/capabilities.d.ts +13 -0
- package/dist/orchestration/capabilities.d.ts.map +1 -0
- package/dist/orchestration/capabilities.js +152 -0
- package/dist/orchestration/capabilities.js.map +1 -0
- package/dist/orchestration/dispatch-executor.d.ts +83 -0
- package/dist/orchestration/dispatch-executor.d.ts.map +1 -0
- package/dist/orchestration/dispatch-executor.js +266 -0
- package/dist/orchestration/dispatch-executor.js.map +1 -0
- package/dist/orchestration/dispatch-hint.d.ts +134 -0
- package/dist/orchestration/dispatch-hint.d.ts.map +1 -0
- package/dist/orchestration/dispatch-hint.js +247 -0
- package/dist/orchestration/dispatch-hint.js.map +1 -0
- package/dist/orchestration/dispatch-runner.d.ts +106 -0
- package/dist/orchestration/dispatch-runner.d.ts.map +1 -0
- package/dist/orchestration/dispatch-runner.js +604 -0
- package/dist/orchestration/dispatch-runner.js.map +1 -0
- package/dist/orchestration/dispatch-tools.d.ts +167 -0
- package/dist/orchestration/dispatch-tools.d.ts.map +1 -0
- package/dist/orchestration/dispatch-tools.js +328 -0
- package/dist/orchestration/dispatch-tools.js.map +1 -0
- package/dist/orchestration/front-door-policy.d.ts +35 -10
- package/dist/orchestration/front-door-policy.d.ts.map +1 -1
- package/dist/orchestration/front-door-policy.js +30 -267
- package/dist/orchestration/front-door-policy.js.map +1 -1
- package/dist/orchestration/orchestrator-dispatch-prompt.d.ts +43 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.d.ts.map +1 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.js +267 -0
- package/dist/orchestration/orchestrator-dispatch-prompt.js.map +1 -0
- package/dist/orchestration/orchestrator-operating-prompt.d.ts +14 -0
- package/dist/orchestration/orchestrator-operating-prompt.d.ts.map +1 -1
- package/dist/orchestration/orchestrator-operating-prompt.js +157 -31
- package/dist/orchestration/orchestrator-operating-prompt.js.map +1 -1
- package/dist/orchestration/plan-import.d.ts +39 -0
- package/dist/orchestration/plan-import.d.ts.map +1 -0
- package/dist/orchestration/plan-import.js +547 -0
- package/dist/orchestration/plan-import.js.map +1 -0
- package/dist/orchestration/worker-operating-prompt.d.ts +2 -0
- package/dist/orchestration/worker-operating-prompt.d.ts.map +1 -1
- package/dist/orchestration/worker-operating-prompt.js +36 -46
- package/dist/orchestration/worker-operating-prompt.js.map +1 -1
- package/dist/orchestrator.d.ts +195 -3
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +1970 -432
- package/dist/orchestrator.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +8 -4
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/claude-cli.d.ts.map +1 -1
- package/dist/providers/claude-cli.js +28 -3
- package/dist/providers/claude-cli.js.map +1 -1
- package/dist/providers/codex-cli.d.ts +10 -6
- package/dist/providers/codex-cli.d.ts.map +1 -1
- package/dist/providers/codex-cli.js +190 -17
- package/dist/providers/codex-cli.js.map +1 -1
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +15 -5
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/index.d.ts +15 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +13 -5
- package/dist/providers/openai.js.map +1 -1
- package/dist/server-adapter.d.ts +8 -0
- package/dist/server-adapter.d.ts.map +1 -1
- package/dist/server-adapter.js +7 -0
- package/dist/server-adapter.js.map +1 -1
- package/dist/service-mode.d.ts +1 -1
- package/dist/service-mode.d.ts.map +1 -1
- package/dist/service-mode.js +64 -1
- package/dist/service-mode.js.map +1 -1
- package/dist/service-setup-only.d.ts +8 -0
- package/dist/service-setup-only.d.ts.map +1 -0
- package/dist/service-setup-only.js +37 -0
- package/dist/service-setup-only.js.map +1 -0
- package/dist/slash-commands.d.ts +21 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/slash-commands.js +99 -0
- package/dist/slash-commands.js.map +1 -0
- package/dist/subagent/index.d.ts +4 -2
- package/dist/subagent/index.d.ts.map +1 -1
- package/dist/subagent/index.js.map +1 -1
- package/dist/summarization-pipeline.d.ts.map +1 -1
- package/dist/summarization-pipeline.js +1 -9
- package/dist/summarization-pipeline.js.map +1 -1
- package/dist/token-counter.d.ts.map +1 -1
- package/dist/token-counter.js +11 -4
- package/dist/token-counter.js.map +1 -1
- package/dist/tool-filter.d.ts.map +1 -1
- package/dist/tool-filter.js +10 -6
- package/dist/tool-filter.js.map +1 -1
- package/dist/tools/admin-tools.d.ts.map +1 -1
- package/dist/tools/admin-tools.js +13 -4
- package/dist/tools/admin-tools.js.map +1 -1
- package/dist/tools/run-command.d.ts.map +1 -1
- package/dist/tools/run-command.js +5 -1
- package/dist/tools/run-command.js.map +1 -1
- package/dist/tools/search-conversation-history.d.ts.map +1 -1
- package/dist/tools/search-conversation-history.js +12 -2
- package/dist/tools/search-conversation-history.js.map +1 -1
- package/dist/tools/todo-tasks.d.ts.map +1 -1
- package/dist/tools/todo-tasks.js +77 -5
- package/dist/tools/todo-tasks.js.map +1 -1
- package/dist/usage-log.d.ts +62 -0
- package/dist/usage-log.d.ts.map +1 -0
- package/dist/usage-log.js +98 -0
- package/dist/usage-log.js.map +1 -0
- package/dist/wizard-state.d.ts +13 -0
- package/dist/wizard-state.d.ts.map +1 -1
- package/dist/wizard-state.js +61 -3
- package/dist/wizard-state.js.map +1 -1
- package/dist/wizard-support.d.ts.map +1 -1
- package/dist/wizard-support.js +27 -1
- package/dist/wizard-support.js.map +1 -1
- package/dist/workflow-engine.d.ts +40 -1
- package/dist/workflow-engine.d.ts.map +1 -1
- package/dist/workflow-engine.js +753 -93
- package/dist/workflow-engine.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-operating-prompt.js","sourceRoot":"","sources":["../../src/orchestration/orchestrator-operating-prompt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orchestrator-operating-prompt.js","sourceRoot":"","sources":["../../src/orchestration/orchestrator-operating-prompt.ts"],"names":[],"mappings":";;;AA6CA,4EAiXC;AAQD,sFASC;AAED,gFA+CC;AA7cY,QAAA,8BAA8B,GAAG,gBAAgB,CAAC;AA0B/D,SAAgB,gCAAgC,CAAC,KAiBhD;IACC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,YAAY,CAAC;IAC9D,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;IAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,WAA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PlanImportAvailableBot {
|
|
4
|
+
name: string;
|
|
5
|
+
provider?: string | null;
|
|
6
|
+
model?: string | null;
|
|
7
|
+
rolePriorities: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface PlanImportStageHint {
|
|
10
|
+
role: string;
|
|
11
|
+
botName: string;
|
|
12
|
+
}
|
|
13
|
+
export type PlanImportExecutionOrder = 'per_item_pipeline' | 'batch_by_stage';
|
|
14
|
+
export interface BuildPlanImportPromptInput {
|
|
15
|
+
filePath: string;
|
|
16
|
+
fileContent: string;
|
|
17
|
+
mode: PlanImportMode;
|
|
18
|
+
stages: PlanImportStageHint[];
|
|
19
|
+
plannerInstructions?: string | null;
|
|
20
|
+
executionOrder?: PlanImportExecutionOrder | null;
|
|
21
|
+
availableBots: PlanImportAvailableBot[];
|
|
22
|
+
projectName?: string | null;
|
|
23
|
+
projectFolder?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ParsedPlanImportResponse {
|
|
26
|
+
workflow: CreateWorkflowArgs | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface PlanImportWorkflowValidationResult {
|
|
30
|
+
ok: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function detectExecutionOrder(plannerInstructions: string | null | undefined): PlanImportExecutionOrder;
|
|
34
|
+
export declare function buildPlanImportSystemPrompt(input: BuildPlanImportPromptInput): string;
|
|
35
|
+
export declare function buildPlanImportUserPrompt(input: BuildPlanImportPromptInput): string;
|
|
36
|
+
export declare function extractPlanImportResponse(rawText: string): ParsedPlanImportResponse;
|
|
37
|
+
export declare function validateBatchByStageOrdering(workflow: CreateWorkflowArgs, stages: PlanImportStageHint[]): PlanImportWorkflowValidationResult;
|
|
38
|
+
export declare function validatePlanImportWorkflow(workflow: CreateWorkflowArgs): PlanImportWorkflowValidationResult;
|
|
39
|
+
//# sourceMappingURL=plan-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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;AA0ED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,0BAA0B,GAAG,MAAM,CA0ErF;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,0BAA0B,GAAG,MAAM,CAsBnF;AA2LD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,wBAAwB,CA4BnF;AAmBD,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,kBAAkB,EAC5B,MAAM,EAAE,mBAAmB,EAAE,GAC5B,kCAAkC,CAgDpC;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,kCAAkC,CA2B3G"}
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectExecutionOrder = detectExecutionOrder;
|
|
4
|
+
exports.buildPlanImportSystemPrompt = buildPlanImportSystemPrompt;
|
|
5
|
+
exports.buildPlanImportUserPrompt = buildPlanImportUserPrompt;
|
|
6
|
+
exports.extractPlanImportResponse = extractPlanImportResponse;
|
|
7
|
+
exports.validateBatchByStageOrdering = validateBatchByStageOrdering;
|
|
8
|
+
exports.validatePlanImportWorkflow = validatePlanImportWorkflow;
|
|
9
|
+
const MAX_PROMPT_FILE_CHARS = 120_000;
|
|
10
|
+
const PLAN_IMPORT_AUTH_FAILURE_RE = /\b(failed to authenticate|api error:\s*401|not logged in|please run \/login|login required|invalid authorization|invalid api key|missing api key|invalid authentication credentials|invalid bearer token|token expired|session expired|credentials expired|expired credentials|reauthenticate)\b/i;
|
|
11
|
+
const PLAN_IMPORT_AUTH_FAILURE_JSON_RE = /"type"\s*:\s*"authentication_error"|authentication_error/i;
|
|
12
|
+
const STRUCTURED_FIELD_LABELS = new Map([
|
|
13
|
+
['title', 'title'],
|
|
14
|
+
['bot', 'bot_name'],
|
|
15
|
+
['bot_name', 'bot_name'],
|
|
16
|
+
['bot name', 'bot_name'],
|
|
17
|
+
['role', 'role'],
|
|
18
|
+
['task_instructions', 'task_instructions'],
|
|
19
|
+
['task instructions', 'task_instructions'],
|
|
20
|
+
['instructions', 'task_instructions'],
|
|
21
|
+
['success_criteria', 'success_criteria'],
|
|
22
|
+
['success criteria', 'success_criteria'],
|
|
23
|
+
['done when', 'success_criteria'],
|
|
24
|
+
['handoff_to_next', 'handoff_to_next'],
|
|
25
|
+
['handoff to next', 'handoff_to_next'],
|
|
26
|
+
['handoff', 'handoff_to_next'],
|
|
27
|
+
]);
|
|
28
|
+
const TASK_INSTRUCTION_SECTION_LABELS = new Set([
|
|
29
|
+
'files',
|
|
30
|
+
'do',
|
|
31
|
+
'verify',
|
|
32
|
+
'checks',
|
|
33
|
+
'check',
|
|
34
|
+
'test',
|
|
35
|
+
'tests',
|
|
36
|
+
'implement',
|
|
37
|
+
'changes',
|
|
38
|
+
'change',
|
|
39
|
+
]);
|
|
40
|
+
const SUCCESS_CRITERIA_SECTION_LABELS = new Set([
|
|
41
|
+
'done when',
|
|
42
|
+
'acceptance criteria',
|
|
43
|
+
'acceptance checks',
|
|
44
|
+
'success criteria',
|
|
45
|
+
'success_criteria',
|
|
46
|
+
]);
|
|
47
|
+
function truncateFileContent(raw) {
|
|
48
|
+
if (raw.length <= MAX_PROMPT_FILE_CHARS)
|
|
49
|
+
return { text: raw, truncated: false };
|
|
50
|
+
return {
|
|
51
|
+
text: `${raw.slice(0, MAX_PROMPT_FILE_CHARS)}\n\n[TRUNCATED AFTER ${MAX_PROMPT_FILE_CHARS} CHARACTERS]`,
|
|
52
|
+
truncated: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const BATCH_BY_STAGE_PATTERNS = [
|
|
56
|
+
/\ball\s+cod(?:e|ing)\s+first\b/i,
|
|
57
|
+
/\bqa\s+at\s+the\s+end\b/i,
|
|
58
|
+
/\bdo\s+not\s+alternate\b/i,
|
|
59
|
+
/\bdon'?t\s+alternate\b/i,
|
|
60
|
+
/\bno\s+alternating\b/i,
|
|
61
|
+
/\bone\s+qa\s+(?:after|at\s+the\s+end|following)\b/i,
|
|
62
|
+
/\bcoding\s+(?:steps?\s+)?first\s*,?\s*then\s+qa\b/i,
|
|
63
|
+
/\bcomplete\s+all\s+cod(?:e|ing)\b/i,
|
|
64
|
+
/\bfinish\s+all\s+cod(?:e|ing)\b/i,
|
|
65
|
+
/\bbatch\s+by\s+stage\b/i,
|
|
66
|
+
/\bnot\s+per[- ]?item\b/i,
|
|
67
|
+
/\bconsolidated?\s+qa\b/i,
|
|
68
|
+
/\bsingle\s+qa\s+(?:task|pass|step)\b/i,
|
|
69
|
+
/\bone\s+(?:final\s+)?(?:qa|review)\s+(?:task|pass|step)\b/i,
|
|
70
|
+
/\breview(?:s)?\s+all\s+(?:changes?|coding|work)\s+together\b/i,
|
|
71
|
+
];
|
|
72
|
+
function detectExecutionOrder(plannerInstructions) {
|
|
73
|
+
if (!plannerInstructions || !plannerInstructions.trim())
|
|
74
|
+
return 'per_item_pipeline';
|
|
75
|
+
for (const pattern of BATCH_BY_STAGE_PATTERNS) {
|
|
76
|
+
if (pattern.test(plannerInstructions))
|
|
77
|
+
return 'batch_by_stage';
|
|
78
|
+
}
|
|
79
|
+
return 'per_item_pipeline';
|
|
80
|
+
}
|
|
81
|
+
function executionOrderSection(order, stages) {
|
|
82
|
+
if (stages.length < 2)
|
|
83
|
+
return '';
|
|
84
|
+
if (order === 'per_item_pipeline') {
|
|
85
|
+
const stageNames = stages.map((s) => s.role);
|
|
86
|
+
return [
|
|
87
|
+
'',
|
|
88
|
+
'EXECUTION ORDER: PER ITEM PIPELINE',
|
|
89
|
+
'For each implementation unit, create every selected stage before moving to the next implementation unit.',
|
|
90
|
+
`Correct: ${stageNames.join(', ')} for item 1, then ${stageNames.join(', ')} for item 2.`,
|
|
91
|
+
`Wrong: all ${stageNames[0]} tasks first, then all ${stageNames[1]} tasks.`,
|
|
92
|
+
'',
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
const stageNames = stages.map((s) => s.role);
|
|
96
|
+
return [
|
|
97
|
+
'',
|
|
98
|
+
'EXECUTION ORDER: BATCH BY STAGE',
|
|
99
|
+
`You MUST create all tasks for the first stage (${stageNames[0]}) before creating any tasks for the next stage (${stageNames[1]}).`,
|
|
100
|
+
'Do NOT interleave stages per implementation unit.',
|
|
101
|
+
`Wrong: ${stageNames[0]}, ${stageNames[1]}, ${stageNames[0]}, ${stageNames[1]}`,
|
|
102
|
+
`Correct: ${stageNames[0]}, ${stageNames[0]}, ${stageNames[0]}, ..., ${stageNames[1]}`,
|
|
103
|
+
stages.length > 2
|
|
104
|
+
? `Then continue in stage order: ${stageNames.slice(2).join(', ')}.`
|
|
105
|
+
: '',
|
|
106
|
+
'If the user asked for one consolidated QA/Review task at the end, create exactly one QA task that reviews the integrated result of all preceding coding work.',
|
|
107
|
+
'',
|
|
108
|
+
].filter(Boolean).join('\n');
|
|
109
|
+
}
|
|
110
|
+
function plannerInstructionsSection(instructions) {
|
|
111
|
+
if (!instructions || !instructions.trim())
|
|
112
|
+
return '';
|
|
113
|
+
return [
|
|
114
|
+
'',
|
|
115
|
+
'PLANNER INSTRUCTIONS (from user)',
|
|
116
|
+
instructions.trim(),
|
|
117
|
+
'',
|
|
118
|
+
].join('\n');
|
|
119
|
+
}
|
|
120
|
+
function stageFlowSection(stages) {
|
|
121
|
+
if (stages.length === 0)
|
|
122
|
+
return 'Selected stage flow: (none)';
|
|
123
|
+
const lines = ['Selected stage flow (apply in this exact order when creating tasks):'];
|
|
124
|
+
stages.forEach((stage, index) => {
|
|
125
|
+
lines.push(`- ${index + 1}. ${stage.role} -> ${stage.botName}`);
|
|
126
|
+
});
|
|
127
|
+
return lines.join('\n');
|
|
128
|
+
}
|
|
129
|
+
function planningPolicySection() {
|
|
130
|
+
return [
|
|
131
|
+
'IMPORT POLICY',
|
|
132
|
+
'- Respect explicit Code / QA / Verify / bot assignments already written in the file when they are clear.',
|
|
133
|
+
'- If the file does not explicitly spell out every later stage, derive missing QA / Verify work from verify/test/confirm/acceptance/done-when language.',
|
|
134
|
+
'- Split broad or compound source items into smaller ordered implementation units when needed to make the workflow executable.',
|
|
135
|
+
'- The selected stage flow is the default pipeline the user wants.',
|
|
136
|
+
'- If the selected stage flow only contains Code, do not add QA or Verify automatically.',
|
|
137
|
+
'- If the selected stage flow contains Code -> QA -> Verify, create those stages in that order when the source content supports them.',
|
|
138
|
+
'- Fully materialize every imported TODO up front. Do not rely on future worker handoff to supply the main instructions.',
|
|
139
|
+
'- Worker handoff is additive context only. task_instructions and success_criteria must already stand on their own.',
|
|
140
|
+
].join('\n');
|
|
141
|
+
}
|
|
142
|
+
function availableBotsSection(bots) {
|
|
143
|
+
if (bots.length === 0)
|
|
144
|
+
return 'Available bots: (none)';
|
|
145
|
+
const lines = ['Available bots and routing roles:'];
|
|
146
|
+
for (const bot of bots) {
|
|
147
|
+
const label = [bot.provider, bot.model].filter(Boolean).join(' / ');
|
|
148
|
+
lines.push(`- ${bot.name}${label ? ` [${label}]` : ''} -> ${bot.rolePriorities.join(', ') || '(no roles)'}`);
|
|
149
|
+
}
|
|
150
|
+
return lines.join('\n');
|
|
151
|
+
}
|
|
152
|
+
function buildPlanImportSystemPrompt(input) {
|
|
153
|
+
const fileName = input.filePath.split(/[\\/]/).pop() || input.filePath;
|
|
154
|
+
return [
|
|
155
|
+
'You are Funolio Plan Import.',
|
|
156
|
+
'Your only job is to convert a user-selected plan file into a strict ordered workflow step list.',
|
|
157
|
+
'You are the planner. The application will not invent steps for you.',
|
|
158
|
+
'',
|
|
159
|
+
'REQUIRED BEHAVIOR',
|
|
160
|
+
'- Read the file content carefully and preserve the source order of actionable steps.',
|
|
161
|
+
'- The source file may be numbered, loosely structured, or plain narrative text. You must still normalize it into ordered implementation units.',
|
|
162
|
+
'- Create a granular workflow. Do not collapse many source steps into one summary task.',
|
|
163
|
+
'- For each implementation unit, emit the concrete tasks needed by the selected stage flow and the file content.',
|
|
164
|
+
'- Do not merge implementation and QA into one step. If the workflow requires both, output separate sequential TODOs.',
|
|
165
|
+
'- Use clear task titles and concrete task_instructions.',
|
|
166
|
+
'- task_instructions must mention specific files, targets, implementation actions, and verification goals whenever the file provides them.',
|
|
167
|
+
'- success_criteria must be concrete and short.',
|
|
168
|
+
'- Every imported task must be fully usable on its own before any worker handoff exists.',
|
|
169
|
+
'- handoff_to_next is optional; use it when the next worker needs a crisp baton-pass.',
|
|
170
|
+
'- If the file is ambiguous or not structured enough, return a single line: error: <specific reason>.',
|
|
171
|
+
'',
|
|
172
|
+
'OUTPUT FORMAT',
|
|
173
|
+
'- Return only structured workflow step blocks. Do not add prose before or after them.',
|
|
174
|
+
'- Preferred success format:',
|
|
175
|
+
' BEGIN_WORKFLOW',
|
|
176
|
+
' Step 1',
|
|
177
|
+
' title: <short title>',
|
|
178
|
+
' bot_name: <bot name>',
|
|
179
|
+
' role: <role label>',
|
|
180
|
+
' task_instructions:',
|
|
181
|
+
' Files:',
|
|
182
|
+
' - <specific files or targets>',
|
|
183
|
+
' Do:',
|
|
184
|
+
' - <specific implementation actions>',
|
|
185
|
+
' Verify:',
|
|
186
|
+
' - <verification actions when this is a QA / Verify task or when verification is required>',
|
|
187
|
+
' success_criteria:',
|
|
188
|
+
' - <done-when / acceptance checks>',
|
|
189
|
+
' handoff_to_next: <optional single or multi-line handoff>',
|
|
190
|
+
'',
|
|
191
|
+
' Step 2',
|
|
192
|
+
' title: ...',
|
|
193
|
+
' ...',
|
|
194
|
+
' END_WORKFLOW',
|
|
195
|
+
'- Use the exact field names title, bot_name, role, task_instructions, success_criteria, handoff_to_next.',
|
|
196
|
+
'- Leave out handoff_to_next when it is not needed.',
|
|
197
|
+
'- Keep one blank line between steps when possible.',
|
|
198
|
+
'- Legacy JSON is tolerated by the application, but you should not choose JSON unless explicitly required.',
|
|
199
|
+
'- Failure format: error: The file is not structured into actionable steps.',
|
|
200
|
+
'',
|
|
201
|
+
'SCHEMA RULES',
|
|
202
|
+
'- The only step fields that will be used are: title, task_instructions, success_criteria, role, bot_name, handoff_to_next.',
|
|
203
|
+
'- Do not invent extra fields. They will be ignored.',
|
|
204
|
+
'- Each step requires task_instructions.',
|
|
205
|
+
'- task_instructions must include a "Files:" section plus either a "Do:" section or a "Verify:" section.',
|
|
206
|
+
'- For Code / Coding / Build / Implement roles, prefer "Files:" + "Do:".',
|
|
207
|
+
'- For QA / Verify / Review roles, prefer "Files:" + "Verify:".',
|
|
208
|
+
'- success_criteria should read like concise "Done When" acceptance checks.',
|
|
209
|
+
'- Each step must contain at least one of bot_name or role.',
|
|
210
|
+
'- Only use bot_name values that exist in the available bot list.',
|
|
211
|
+
'- Only use role values that exist in the selected stage flow or clearly exist in the source file when explicit roles must be preserved.',
|
|
212
|
+
'- Do not emit empty placeholder steps.',
|
|
213
|
+
'- Keep all source steps in order; do not skip steps unless they are pure headings with no action.',
|
|
214
|
+
'',
|
|
215
|
+
planningPolicySection(),
|
|
216
|
+
executionOrderSection(input.executionOrder || 'per_item_pipeline', input.stages),
|
|
217
|
+
plannerInstructionsSection(input.plannerInstructions),
|
|
218
|
+
`Selected file: ${fileName}`,
|
|
219
|
+
`Project: ${input.projectName || '(none)'}`,
|
|
220
|
+
`Workspace: ${input.projectFolder || '(none)'}`,
|
|
221
|
+
'',
|
|
222
|
+
stageFlowSection(input.stages),
|
|
223
|
+
'',
|
|
224
|
+
availableBotsSection(input.availableBots),
|
|
225
|
+
].join('\n');
|
|
226
|
+
}
|
|
227
|
+
function buildPlanImportUserPrompt(input) {
|
|
228
|
+
const fileName = input.filePath.split(/[\\/]/).pop() || input.filePath;
|
|
229
|
+
const { text, truncated } = truncateFileContent(input.fileContent);
|
|
230
|
+
const effectiveOrder = input.executionOrder || 'per_item_pipeline';
|
|
231
|
+
return [
|
|
232
|
+
`Convert the selected plan file "${fileName}" into a create_workflow payload.`,
|
|
233
|
+
'',
|
|
234
|
+
'[USER IMPORT SETTINGS]',
|
|
235
|
+
`Execution order: ${effectiveOrder}`,
|
|
236
|
+
'Selected stage flow:',
|
|
237
|
+
...(input.stages.length > 0
|
|
238
|
+
? input.stages.map((stage, index) => `${index + 1}. ${stage.role} -> ${stage.botName}`)
|
|
239
|
+
: ['(none)']),
|
|
240
|
+
input.plannerInstructions?.trim()
|
|
241
|
+
? `\nPlanner instructions: ${input.plannerInstructions.trim()}`
|
|
242
|
+
: '',
|
|
243
|
+
truncated ? 'Important: the file content was truncated before being sent to you. Only use what is present below.' : '',
|
|
244
|
+
'',
|
|
245
|
+
'[FILE CONTENT START]',
|
|
246
|
+
text,
|
|
247
|
+
'[FILE CONTENT END]',
|
|
248
|
+
].filter(Boolean).join('\n');
|
|
249
|
+
}
|
|
250
|
+
function normalizeWorkflowShape(raw) {
|
|
251
|
+
if (!raw || typeof raw !== 'object') {
|
|
252
|
+
return { workflow: null, error: 'Planner response was not a JSON object.' };
|
|
253
|
+
}
|
|
254
|
+
const serialized = JSON.stringify(raw);
|
|
255
|
+
if (PLAN_IMPORT_AUTH_FAILURE_RE.test(serialized) || PLAN_IMPORT_AUTH_FAILURE_JSON_RE.test(serialized)) {
|
|
256
|
+
return { workflow: null, error: 'Planner authentication failed.' };
|
|
257
|
+
}
|
|
258
|
+
if (typeof raw.error === 'string' && raw.error.trim()) {
|
|
259
|
+
return { workflow: null, error: raw.error.trim() };
|
|
260
|
+
}
|
|
261
|
+
if (Array.isArray(raw.steps)) {
|
|
262
|
+
return { workflow: { steps: raw.steps }, error: null };
|
|
263
|
+
}
|
|
264
|
+
if (raw.tool === 'create_workflow' && raw.arguments && Array.isArray(raw.arguments.steps)) {
|
|
265
|
+
return { workflow: { steps: raw.arguments.steps }, error: null };
|
|
266
|
+
}
|
|
267
|
+
return { workflow: null, error: 'Planner JSON did not include a valid steps array.' };
|
|
268
|
+
}
|
|
269
|
+
function stripOuterCodeFence(raw) {
|
|
270
|
+
const fenced = raw.match(/^```(?:json|text|markdown)?\s*([\s\S]*?)\s*```$/i);
|
|
271
|
+
return fenced?.[1]?.trim() || raw;
|
|
272
|
+
}
|
|
273
|
+
function extractBalancedJsonObject(raw) {
|
|
274
|
+
let inString = false;
|
|
275
|
+
let escaped = false;
|
|
276
|
+
let depth = 0;
|
|
277
|
+
let start = -1;
|
|
278
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
279
|
+
const ch = raw[i];
|
|
280
|
+
if (inString) {
|
|
281
|
+
if (escaped) {
|
|
282
|
+
escaped = false;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (ch === '\\') {
|
|
286
|
+
escaped = true;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (ch === '"') {
|
|
290
|
+
inString = false;
|
|
291
|
+
}
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (ch === '"') {
|
|
295
|
+
inString = true;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (ch === '{') {
|
|
299
|
+
if (depth === 0)
|
|
300
|
+
start = i;
|
|
301
|
+
depth += 1;
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (ch === '}') {
|
|
305
|
+
if (depth === 0)
|
|
306
|
+
continue;
|
|
307
|
+
depth -= 1;
|
|
308
|
+
if (depth === 0 && start >= 0) {
|
|
309
|
+
return raw.slice(start, i + 1);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
function normalizeStructuredFieldLabel(raw) {
|
|
316
|
+
const normalized = raw.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
317
|
+
return STRUCTURED_FIELD_LABELS.get(normalized) || null;
|
|
318
|
+
}
|
|
319
|
+
function parseStructuredWorkflow(rawText) {
|
|
320
|
+
const raw = stripOuterCodeFence(String(rawText || '').trim());
|
|
321
|
+
if (!raw)
|
|
322
|
+
return null;
|
|
323
|
+
const explicitError = raw.match(/^\s*error\s*:\s*(.+)\s*$/is);
|
|
324
|
+
if (explicitError) {
|
|
325
|
+
return { workflow: null, error: explicitError[1].trim() };
|
|
326
|
+
}
|
|
327
|
+
const workflowSlice = (() => {
|
|
328
|
+
const begin = raw.search(/^\s*BEGIN_WORKFLOW\s*$/im);
|
|
329
|
+
if (begin >= 0) {
|
|
330
|
+
const endMatch = /^\s*END_WORKFLOW\s*$/im.exec(raw.slice(begin));
|
|
331
|
+
const end = endMatch
|
|
332
|
+
? begin + endMatch.index + endMatch[0].length
|
|
333
|
+
: raw.length;
|
|
334
|
+
return raw.slice(begin, end);
|
|
335
|
+
}
|
|
336
|
+
return raw;
|
|
337
|
+
})().trim();
|
|
338
|
+
if (!/^\s*Step\b/im.test(workflowSlice))
|
|
339
|
+
return null;
|
|
340
|
+
const steps = [];
|
|
341
|
+
let currentStep = null;
|
|
342
|
+
let currentField = null;
|
|
343
|
+
let currentFieldLines = [];
|
|
344
|
+
let sawStructuredField = false;
|
|
345
|
+
const flushField = () => {
|
|
346
|
+
if (!currentStep || !currentField)
|
|
347
|
+
return;
|
|
348
|
+
const value = currentFieldLines.join('\n').trim();
|
|
349
|
+
if (value)
|
|
350
|
+
currentStep[currentField] = value;
|
|
351
|
+
currentField = null;
|
|
352
|
+
currentFieldLines = [];
|
|
353
|
+
};
|
|
354
|
+
const flushStep = () => {
|
|
355
|
+
flushField();
|
|
356
|
+
if (!currentStep)
|
|
357
|
+
return;
|
|
358
|
+
if (currentStep.title
|
|
359
|
+
|| currentStep.bot_name
|
|
360
|
+
|| currentStep.role
|
|
361
|
+
|| currentStep.task_instructions
|
|
362
|
+
|| currentStep.success_criteria
|
|
363
|
+
|| currentStep.handoff_to_next) {
|
|
364
|
+
steps.push({
|
|
365
|
+
title: currentStep.title?.trim() || undefined,
|
|
366
|
+
bot_name: currentStep.bot_name?.trim() || undefined,
|
|
367
|
+
role: currentStep.role?.trim() || undefined,
|
|
368
|
+
task_instructions: currentStep.task_instructions?.trim() || '',
|
|
369
|
+
success_criteria: currentStep.success_criteria?.trim() || undefined,
|
|
370
|
+
handoff_to_next: currentStep.handoff_to_next?.trim() || undefined,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
currentStep = null;
|
|
374
|
+
};
|
|
375
|
+
for (const line of workflowSlice.split(/\r?\n/)) {
|
|
376
|
+
if (/^\s*(BEGIN_WORKFLOW|END_WORKFLOW)\s*$/i.test(line))
|
|
377
|
+
continue;
|
|
378
|
+
const stepMatch = line.match(/^\s*Step(?:\s+|\s*#?)(\d+)?\s*(?:[:\-]\s*(.*))?$/i);
|
|
379
|
+
if (stepMatch) {
|
|
380
|
+
flushStep();
|
|
381
|
+
currentStep = {};
|
|
382
|
+
const headerTitle = String(stepMatch[2] || '').trim();
|
|
383
|
+
if (headerTitle)
|
|
384
|
+
currentStep.title = headerTitle;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const fieldMatch = line.match(/^\s*([A-Za-z_][A-Za-z0-9_ ]{1,40})\s*:\s*(.*)$/);
|
|
388
|
+
const normalizedFieldLabel = fieldMatch
|
|
389
|
+
? fieldMatch[1].trim().toLowerCase().replace(/\s+/g, ' ')
|
|
390
|
+
: '';
|
|
391
|
+
if (fieldMatch && currentField === 'task_instructions' && TASK_INSTRUCTION_SECTION_LABELS.has(normalizedFieldLabel)) {
|
|
392
|
+
currentFieldLines.push(`${fieldMatch[1].trim()}:`);
|
|
393
|
+
const inlineValue = String(fieldMatch[2] || '').trim();
|
|
394
|
+
if (inlineValue)
|
|
395
|
+
currentFieldLines.push(inlineValue);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (fieldMatch && currentField === 'success_criteria' && SUCCESS_CRITERIA_SECTION_LABELS.has(normalizedFieldLabel)) {
|
|
399
|
+
currentFieldLines.push(`${fieldMatch[1].trim()}:`);
|
|
400
|
+
const inlineValue = String(fieldMatch[2] || '').trim();
|
|
401
|
+
if (inlineValue)
|
|
402
|
+
currentFieldLines.push(inlineValue);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
const structuredField = fieldMatch ? normalizeStructuredFieldLabel(fieldMatch[1]) : null;
|
|
406
|
+
if (structuredField) {
|
|
407
|
+
if (!currentStep)
|
|
408
|
+
currentStep = {};
|
|
409
|
+
flushField();
|
|
410
|
+
currentField = structuredField;
|
|
411
|
+
currentFieldLines = [];
|
|
412
|
+
sawStructuredField = true;
|
|
413
|
+
const inlineValue = String(fieldMatch?.[2] || '').trim();
|
|
414
|
+
if (inlineValue)
|
|
415
|
+
currentFieldLines.push(inlineValue);
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (currentField) {
|
|
419
|
+
currentFieldLines.push(line);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
flushStep();
|
|
423
|
+
if (!sawStructuredField || steps.length === 0)
|
|
424
|
+
return null;
|
|
425
|
+
return { workflow: { steps }, error: null };
|
|
426
|
+
}
|
|
427
|
+
function extractPlanImportResponse(rawText) {
|
|
428
|
+
const raw = String(rawText || '').trim();
|
|
429
|
+
if (!raw)
|
|
430
|
+
return { workflow: null, error: 'Planner returned an empty response.' };
|
|
431
|
+
const fenced = raw.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
432
|
+
const candidate = (fenced?.[1] || raw).trim();
|
|
433
|
+
try {
|
|
434
|
+
return normalizeWorkflowShape(JSON.parse(candidate));
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
const extracted = extractBalancedJsonObject(candidate);
|
|
438
|
+
if (extracted) {
|
|
439
|
+
try {
|
|
440
|
+
return normalizeWorkflowShape(JSON.parse(extracted));
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
// Fall through to structured parsing and auth classification below.
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
const structured = parseStructuredWorkflow(raw);
|
|
448
|
+
if (structured)
|
|
449
|
+
return structured;
|
|
450
|
+
if (PLAN_IMPORT_AUTH_FAILURE_RE.test(raw) || PLAN_IMPORT_AUTH_FAILURE_JSON_RE.test(raw)) {
|
|
451
|
+
return { workflow: null, error: 'Planner authentication failed.' };
|
|
452
|
+
}
|
|
453
|
+
return { workflow: null, error: 'Planner did not return a valid workflow step list.' };
|
|
454
|
+
}
|
|
455
|
+
function isQaLikeRole(role, title) {
|
|
456
|
+
const combined = `${role || ''} ${title || ''}`.trim().toLowerCase();
|
|
457
|
+
return /\b(qa|verify|verification|review|validate|validation|test)\b/.test(combined);
|
|
458
|
+
}
|
|
459
|
+
function normalizeStageRole(rawRole) {
|
|
460
|
+
const role = String(rawRole || '').trim().toLowerCase();
|
|
461
|
+
if (!role)
|
|
462
|
+
return 'code';
|
|
463
|
+
if (/\b(qa|verify|verification|review|validate|validation|test)\b/.test(role))
|
|
464
|
+
return 'qa';
|
|
465
|
+
if (/\b(cod(?:e|ing)|implement|implementation|build|fix|develop|development)\b/.test(role))
|
|
466
|
+
return 'code';
|
|
467
|
+
return role.replace(/[^a-z0-9]+/g, ' ').trim();
|
|
468
|
+
}
|
|
469
|
+
function hasStructuredSection(text, labels) {
|
|
470
|
+
return labels.some((label) => new RegExp(`(^|\\n)\\s*${label}\\s*:`, 'i').test(text));
|
|
471
|
+
}
|
|
472
|
+
function validateBatchByStageOrdering(workflow, stages) {
|
|
473
|
+
if (stages.length < 2)
|
|
474
|
+
return { ok: true };
|
|
475
|
+
const stageOrder = new Map();
|
|
476
|
+
stages.forEach((stage, idx) => {
|
|
477
|
+
const key = normalizeStageRole(stage.role);
|
|
478
|
+
if (!stageOrder.has(key))
|
|
479
|
+
stageOrder.set(key, idx);
|
|
480
|
+
});
|
|
481
|
+
let lastStageIndex = -1;
|
|
482
|
+
let lastStageRole = '';
|
|
483
|
+
let transitioned = false;
|
|
484
|
+
for (let i = 0; i < workflow.steps.length; i += 1) {
|
|
485
|
+
const step = workflow.steps[i];
|
|
486
|
+
const role = String(step.role || '').trim().toLowerCase();
|
|
487
|
+
const title = String(step.title || '').trim().toLowerCase();
|
|
488
|
+
const qaLike = isQaLikeRole(role, title);
|
|
489
|
+
const effectiveRole = qaLike ? 'qa' : normalizeStageRole(role || title || 'code');
|
|
490
|
+
let matched = stageOrder.get(effectiveRole);
|
|
491
|
+
if (matched === undefined) {
|
|
492
|
+
for (const [key, idx] of stageOrder) {
|
|
493
|
+
if (effectiveRole.includes(key) || key.includes(effectiveRole)) {
|
|
494
|
+
matched = idx;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (matched === undefined)
|
|
500
|
+
continue;
|
|
501
|
+
if (matched < lastStageIndex) {
|
|
502
|
+
return {
|
|
503
|
+
ok: false,
|
|
504
|
+
error: `Batch-by-stage ordering violated: step ${i + 1} (${step.role || effectiveRole}) appears after ${lastStageRole} tasks. All tasks for one stage must come before the next stage. Do not interleave stages.`,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (matched > lastStageIndex && transitioned) {
|
|
508
|
+
// A forward transition is fine, but going back was caught above.
|
|
509
|
+
}
|
|
510
|
+
if (matched > lastStageIndex) {
|
|
511
|
+
transitioned = true;
|
|
512
|
+
}
|
|
513
|
+
lastStageIndex = matched;
|
|
514
|
+
lastStageRole = step.role || effectiveRole;
|
|
515
|
+
}
|
|
516
|
+
return { ok: true };
|
|
517
|
+
}
|
|
518
|
+
function validatePlanImportWorkflow(workflow) {
|
|
519
|
+
if (!workflow || !Array.isArray(workflow.steps) || workflow.steps.length === 0) {
|
|
520
|
+
return { ok: false, error: 'Planner did not return any workflow steps.' };
|
|
521
|
+
}
|
|
522
|
+
for (let index = 0; index < workflow.steps.length; index += 1) {
|
|
523
|
+
const step = workflow.steps[index];
|
|
524
|
+
const instructions = String(step.task_instructions || '').trim();
|
|
525
|
+
const successCriteria = String(step.success_criteria || '').trim();
|
|
526
|
+
if (!instructions) {
|
|
527
|
+
return { ok: false, error: `Imported workflow step ${index + 1} is missing task instructions.` };
|
|
528
|
+
}
|
|
529
|
+
if (!hasStructuredSection(instructions, ['Files'])) {
|
|
530
|
+
return { ok: false, error: `Imported workflow step ${index + 1} must include a Files: section.` };
|
|
531
|
+
}
|
|
532
|
+
const qaLike = isQaLikeRole(step.role, step.title);
|
|
533
|
+
if (qaLike) {
|
|
534
|
+
if (!hasStructuredSection(instructions, ['Verify', 'Checks', 'Check', 'Test'])) {
|
|
535
|
+
return { ok: false, error: `Imported workflow step ${index + 1} must include a Verify: section for QA/Verify work.` };
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else if (!hasStructuredSection(instructions, ['Do', 'Implement', 'Changes', 'Change'])) {
|
|
539
|
+
return { ok: false, error: `Imported workflow step ${index + 1} must include a Do: section for implementation work.` };
|
|
540
|
+
}
|
|
541
|
+
if (!successCriteria || successCriteria.length < 12) {
|
|
542
|
+
return { ok: false, error: `Imported workflow step ${index + 1} must include concrete success criteria.` };
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return { ok: true };
|
|
546
|
+
}
|
|
547
|
+
//# sourceMappingURL=plan-import.js.map
|