xcoder-dna 0.0.0-stage → 1.3.1
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/LICENSE +21 -0
- package/README.md +87 -2
- package/dist/agents/ai-chat-debate.d.ts +36 -0
- package/dist/agents/ai-chat-debate.js +300 -0
- package/dist/agents/ai-chat-report-writer.d.ts +7 -0
- package/dist/agents/ai-chat-report-writer.js +100 -0
- package/dist/agents/duplicate-detector.d.ts +41 -0
- package/dist/agents/duplicate-detector.js +65 -0
- package/dist/agents/genesis-agent.d.ts +61 -0
- package/dist/agents/genesis-agent.js +340 -0
- package/dist/agents/samurai-agent.d.ts +53 -0
- package/dist/agents/samurai-agent.js +279 -0
- package/dist/agents/sub-agent.d.ts +56 -0
- package/dist/agents/sub-agent.js +353 -0
- package/dist/backlog/backlog-requirement-validator.d.ts +10 -0
- package/dist/backlog/backlog-requirement-validator.js +60 -0
- package/dist/backlog/backlog-store.d.ts +29 -0
- package/dist/backlog/backlog-store.js +148 -0
- package/dist/backlog/po-agent.d.ts +16 -0
- package/dist/backlog/po-agent.js +121 -0
- package/dist/backlog/types.d.ts +25 -0
- package/dist/backlog/types.js +4 -0
- package/dist/bench/run.d.ts +11 -0
- package/dist/bench/run.js +185 -0
- package/dist/bench/types.d.ts +50 -0
- package/dist/bench/types.js +1 -0
- package/dist/cli/swarm.d.ts +10 -0
- package/dist/cli/swarm.js +100 -0
- package/dist/cli/task.d.ts +14 -0
- package/dist/cli/task.js +121 -0
- package/dist/cli/wbc-arg.d.ts +6 -0
- package/dist/cli/wbc-arg.js +40 -0
- package/dist/cli/wbc.d.ts +45 -0
- package/dist/cli/wbc.js +98 -0
- package/dist/commands/license.d.ts +9 -0
- package/dist/commands/license.js +140 -0
- package/dist/commands/release.d.ts +44 -0
- package/dist/commands/release.js +180 -0
- package/dist/commands/test.d.ts +50 -0
- package/dist/commands/test.js +385 -0
- package/dist/config/loadConfig.d.ts +82 -0
- package/dist/config/loadConfig.js +240 -0
- package/dist/config/secure-mode.d.ts +29 -0
- package/dist/config/secure-mode.js +63 -0
- package/dist/config/user-config.d.ts +39 -0
- package/dist/config/user-config.js +202 -0
- package/dist/engine/reasoning-engine.d.ts +21 -0
- package/dist/engine/reasoning-engine.js +59 -0
- package/dist/events/bus.d.ts +22 -0
- package/dist/events/bus.js +18 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +77 -0
- package/dist/indexing/ignoreRules.d.ts +1 -0
- package/dist/indexing/ignoreRules.js +53 -0
- package/dist/instance-swarm/instance-swarm-orchestrator.d.ts +57 -0
- package/dist/instance-swarm/instance-swarm-orchestrator.js +204 -0
- package/dist/instance-swarm/protocol-name-resolver.d.ts +23 -0
- package/dist/instance-swarm/protocol-name-resolver.js +64 -0
- package/dist/license/gate.d.ts +31 -0
- package/dist/license/gate.js +188 -0
- package/dist/license/http-client.d.ts +43 -0
- package/dist/license/http-client.js +195 -0
- package/dist/license/manager.d.ts +39 -0
- package/dist/license/manager.js +175 -0
- package/dist/license/receipt.d.ts +27 -0
- package/dist/license/receipt.js +108 -0
- package/dist/license/state-codec.d.ts +72 -0
- package/dist/license/state-codec.js +218 -0
- package/dist/license/state-paths.d.ts +17 -0
- package/dist/license/state-paths.js +64 -0
- package/dist/license/store.d.ts +44 -0
- package/dist/license/store.js +223 -0
- package/dist/license/trust-anchor.d.ts +24 -0
- package/dist/license/trust-anchor.js +74 -0
- package/dist/license/types.d.ts +34 -0
- package/dist/license/types.js +19 -0
- package/dist/llm/budget.d.ts +23 -0
- package/dist/llm/budget.js +58 -0
- package/dist/llm/client.d.ts +53 -0
- package/dist/llm/client.js +122 -0
- package/dist/llm/factory.d.ts +14 -0
- package/dist/llm/factory.js +32 -0
- package/dist/orchestrator/defect-logger.d.ts +31 -0
- package/dist/orchestrator/defect-logger.js +101 -0
- package/dist/orchestrator/defect-manager.d.ts +118 -0
- package/dist/orchestrator/defect-manager.js +338 -0
- package/dist/orchestrator/defect-migration.d.ts +14 -0
- package/dist/orchestrator/defect-migration.js +174 -0
- package/dist/orchestrator/defect-store.d.ts +48 -0
- package/dist/orchestrator/defect-store.js +76 -0
- package/dist/orchestrator/healing.d.ts +14 -0
- package/dist/orchestrator/healing.js +11 -0
- package/dist/orchestrator/interactive-steering.d.ts +64 -0
- package/dist/orchestrator/interactive-steering.js +107 -0
- package/dist/orchestrator/interrupt-handler.d.ts +30 -0
- package/dist/orchestrator/interrupt-handler.js +70 -0
- package/dist/orchestrator/lesson-manager.d.ts +25 -0
- package/dist/orchestrator/lesson-manager.js +122 -0
- package/dist/orchestrator/progress-summary.d.ts +15 -0
- package/dist/orchestrator/progress-summary.js +106 -0
- package/dist/orchestrator/reasoning-score.d.ts +49 -0
- package/dist/orchestrator/reasoning-score.js +117 -0
- package/dist/orchestrator/swarm.d.ts +36 -0
- package/dist/orchestrator/swarm.js +77 -0
- package/dist/orchestrator/task-factory.d.ts +15 -0
- package/dist/orchestrator/task-factory.js +176 -0
- package/dist/orchestrator/validation-gate.d.ts +23 -0
- package/dist/orchestrator/validation-gate.js +155 -0
- package/dist/protocol/react-contract.d.ts +136 -0
- package/dist/protocol/react-contract.js +698 -0
- package/dist/protocol/wks-protocol-manager.d.ts +22 -0
- package/dist/protocol/wks-protocol-manager.js +72 -0
- package/dist/sdlc-runtime/conversation-runner.d.ts +8 -0
- package/dist/sdlc-runtime/conversation-runner.js +64 -0
- package/dist/sdlc-runtime/dag-utils.d.ts +15 -0
- package/dist/sdlc-runtime/dag-utils.js +67 -0
- package/dist/sdlc-runtime/defect-integration.d.ts +7 -0
- package/dist/sdlc-runtime/defect-integration.js +99 -0
- package/dist/sdlc-runtime/execution-loop.d.ts +38 -0
- package/dist/sdlc-runtime/execution-loop.js +274 -0
- package/dist/sdlc-runtime/lesson-recorder.d.ts +9 -0
- package/dist/sdlc-runtime/lesson-recorder.js +27 -0
- package/dist/sdlc-runtime/plan-initializer.d.ts +47 -0
- package/dist/sdlc-runtime/plan-initializer.js +135 -0
- package/dist/sdlc-runtime/progress-persister.d.ts +10 -0
- package/dist/sdlc-runtime/progress-persister.js +34 -0
- package/dist/sdlc-runtime/protocol-loader.d.ts +10 -0
- package/dist/sdlc-runtime/protocol-loader.js +21 -0
- package/dist/sdlc-runtime/reporting.d.ts +24 -0
- package/dist/sdlc-runtime/reporting.js +68 -0
- package/dist/sdlc-runtime/sdlc-orchestrator.d.ts +59 -0
- package/dist/sdlc-runtime/sdlc-orchestrator.js +170 -0
- package/dist/sdlc-runtime/sdlc-skill.d.ts +44 -0
- package/dist/sdlc-runtime/sdlc-skill.js +148 -0
- package/dist/sdlc-runtime/steering-handler.d.ts +14 -0
- package/dist/sdlc-runtime/steering-handler.js +51 -0
- package/dist/sdlc-runtime/trace-recorder.d.ts +10 -0
- package/dist/sdlc-runtime/trace-recorder.js +7 -0
- package/dist/security/index.d.ts +16 -0
- package/dist/security/index.js +12 -0
- package/dist/security/input-screen.d.ts +30 -0
- package/dist/security/input-screen.js +75 -0
- package/dist/security/tool-call-guard.d.ts +16 -0
- package/dist/security/tool-call-guard.js +163 -0
- package/dist/security/untrusted-content.d.ts +34 -0
- package/dist/security/untrusted-content.js +63 -0
- package/dist/skills/advanced-dfir/SKILL.md +85 -0
- package/dist/skills/advanced-pentest-lab/SKILL.md +88 -0
- package/dist/skills/analyst/SKILL.md +55 -0
- package/dist/skills/architect/SKILL.md +54 -0
- package/dist/skills/aws/SKILL.md +92 -0
- package/dist/skills/azure/SKILL.md +90 -0
- package/dist/skills/bylaw-context.d.ts +45 -0
- package/dist/skills/bylaw-context.js +61 -0
- package/dist/skills/bylaw-review.d.ts +20 -0
- package/dist/skills/bylaw-review.js +101 -0
- package/dist/skills/conversation/SKILL.md +29 -0
- package/dist/skills/design-patterns/SKILL.md +190 -0
- package/dist/skills/devops/SKILL.md +55 -0
- package/dist/skills/directives.d.ts +20 -0
- package/dist/skills/directives.js +313 -0
- package/dist/skills/docker/SKILL.md +76 -0
- package/dist/skills/docker-expert/SKILL.md +56 -0
- package/dist/skills/enterprise-systems-analyst/SKILL.md +83 -0
- package/dist/skills/enterprise-systems-analyst/references/crm.md +41 -0
- package/dist/skills/enterprise-systems-analyst/references/erp.md +40 -0
- package/dist/skills/enterprise-systems-analyst/references/financial-systems.md +35 -0
- package/dist/skills/enterprise-systems-analyst/references/hcm.md +38 -0
- package/dist/skills/enterprise-systems-analyst/references/mrp.md +37 -0
- package/dist/skills/enterprise-systems-analyst/references/scm.md +32 -0
- package/dist/skills/ethical-hacking-methodology/SKILL.md +119 -0
- package/dist/skills/externalSkillLoader.d.ts +25 -0
- package/dist/skills/externalSkillLoader.js +65 -0
- package/dist/skills/externalSkillRegistry.d.ts +33 -0
- package/dist/skills/externalSkillRegistry.js +94 -0
- package/dist/skills/filesystem-management/SKILL.md +61 -0
- package/dist/skills/first-run-seed.d.ts +26 -0
- package/dist/skills/first-run-seed.js +75 -0
- package/dist/skills/git-vcs/SKILL.md +84 -0
- package/dist/skills/kafka/SKILL.md +89 -0
- package/dist/skills/kubernetes/SKILL.md +93 -0
- package/dist/skills/kubernetes-expert/SKILL.md +54 -0
- package/dist/skills/openshift/SKILL.md +93 -0
- package/dist/skills/pentester/SKILL.md +59 -0
- package/dist/skills/performance-tester/SKILL.md +57 -0
- package/dist/skills/playwright-ui-tester/SKILL.md +67 -0
- package/dist/skills/programmer/SKILL.md +58 -0
- package/dist/skills/project-scaffolding/SKILL.md +133 -0
- package/dist/skills/qa-engineer/SKILL.md +91 -0
- package/dist/skills/rca/SKILL.md +58 -0
- package/dist/skills/redhat/SKILL.md +92 -0
- package/dist/skills/rosa/SKILL.md +80 -0
- package/dist/skills/scrum-framework/SKILL.md +74 -0
- package/dist/skills/scrum-framework/references/artifacts_and_quality.md +79 -0
- package/dist/skills/scrum-framework/references/roles_and_events.md +105 -0
- package/dist/skills/scrum-master-agent/SKILL.md +74 -0
- package/dist/skills/scrum-master-agent/references/behaviors.md +56 -0
- package/dist/skills/sdlc-skill.d.ts +1 -0
- package/dist/skills/sdlc-skill.js +4 -0
- package/dist/skills/secops/SKILL.md +52 -0
- package/dist/skills/secure-architect.bylaws.d.ts +68 -0
- package/dist/skills/secure-architect.bylaws.js +525 -0
- package/dist/skills/seed-skills.d.ts +48 -0
- package/dist/skills/seed-skills.js +213 -0
- package/dist/skills/skill-authoring/SKILL.md +123 -0
- package/dist/skills/skill-header.d.ts +51 -0
- package/dist/skills/skill-header.js +163 -0
- package/dist/skills/skill-path-guard.d.ts +41 -0
- package/dist/skills/skill-path-guard.js +95 -0
- package/dist/skills/skillRouter.d.ts +51 -0
- package/dist/skills/skillRouter.js +90 -0
- package/dist/skills/skills-root.d.ts +64 -0
- package/dist/skills/skills-root.js +168 -0
- package/dist/skills/software-architect/SKILL.md +77 -0
- package/dist/skills/software-engineer/SKILL.md +74 -0
- package/dist/skills/solid-principles/SKILL.md +94 -0
- package/dist/skills/task-planning/SKILL.md +115 -0
- package/dist/skills/tester/SKILL.md +54 -0
- package/dist/skills/ubuntu/SKILL.md +87 -0
- package/dist/skills/ui-ux-design/SKILL.md +114 -0
- package/dist/skills/workspace-context/SKILL.md +103 -0
- package/dist/sprint/controller.d.ts +37 -0
- package/dist/sprint/controller.js +220 -0
- package/dist/sprint/dag-builder.d.ts +14 -0
- package/dist/sprint/dag-builder.js +105 -0
- package/dist/sprint/reporter.d.ts +11 -0
- package/dist/sprint/reporter.js +97 -0
- package/dist/sprint/state-store.d.ts +10 -0
- package/dist/sprint/state-store.js +71 -0
- package/dist/sprint/types.d.ts +24 -0
- package/dist/sprint/types.js +4 -0
- package/dist/store/file-version-store.d.ts +24 -0
- package/dist/store/file-version-store.js +73 -0
- package/dist/store/task-store.d.ts +90 -0
- package/dist/store/task-store.js +166 -0
- package/dist/task-ingest/architect-detailer.d.ts +43 -0
- package/dist/task-ingest/architect-detailer.js +141 -0
- package/dist/task-ingest/detail-schema.d.ts +9 -0
- package/dist/task-ingest/detail-schema.js +195 -0
- package/dist/task-ingest/detailed-run.d.ts +36 -0
- package/dist/task-ingest/detailed-run.js +108 -0
- package/dist/task-ingest/extract-id.d.ts +9 -0
- package/dist/task-ingest/extract-id.js +24 -0
- package/dist/task-ingest/index.d.ts +23 -0
- package/dist/task-ingest/index.js +14 -0
- package/dist/task-ingest/ingest.d.ts +45 -0
- package/dist/task-ingest/ingest.js +163 -0
- package/dist/task-ingest/list-ingested.d.ts +13 -0
- package/dist/task-ingest/list-ingested.js +30 -0
- package/dist/task-ingest/pending-filter.d.ts +30 -0
- package/dist/task-ingest/pending-filter.js +59 -0
- package/dist/task-ingest/scanner.d.ts +56 -0
- package/dist/task-ingest/scanner.js +216 -0
- package/dist/task-ingest/source-reader.d.ts +25 -0
- package/dist/task-ingest/source-reader.js +93 -0
- package/dist/task-ingest/spec-builder.d.ts +34 -0
- package/dist/task-ingest/spec-builder.js +89 -0
- package/dist/task-ingest/wbs-extract.d.ts +50 -0
- package/dist/task-ingest/wbs-extract.js +226 -0
- package/dist/task-ingest/wbs-parser.d.ts +36 -0
- package/dist/task-ingest/wbs-parser.js +170 -0
- package/dist/tools/apiTestTool.d.ts +37 -0
- package/dist/tools/apiTestTool.js +128 -0
- package/dist/tools/ast-tools.d.ts +183 -0
- package/dist/tools/ast-tools.js +853 -0
- package/dist/tools/browse-tool.d.ts +105 -0
- package/dist/tools/browse-tool.js +394 -0
- package/dist/tools/credential.d.ts +17 -0
- package/dist/tools/credential.js +32 -0
- package/dist/tools/dependency-graph.d.ts +23 -0
- package/dist/tools/dependency-graph.js +164 -0
- package/dist/tools/edit-tool.d.ts +34 -0
- package/dist/tools/edit-tool.js +95 -0
- package/dist/tools/file-header-manager.d.ts +27 -0
- package/dist/tools/file-header-manager.js +153 -0
- package/dist/tools/fs-tools.d.ts +154 -0
- package/dist/tools/fs-tools.js +337 -0
- package/dist/tools/git-tools.d.ts +79 -0
- package/dist/tools/git-tools.js +348 -0
- package/dist/tools/github-tool.d.ts +48 -0
- package/dist/tools/github-tool.js +147 -0
- package/dist/tools/globTool.d.ts +20 -0
- package/dist/tools/globTool.js +34 -0
- package/dist/tools/grepTool.d.ts +19 -0
- package/dist/tools/grepTool.js +44 -0
- package/dist/tools/index-freshness.d.ts +58 -0
- package/dist/tools/index-freshness.js +190 -0
- package/dist/tools/index-glob.d.ts +48 -0
- package/dist/tools/index-glob.js +175 -0
- package/dist/tools/load-skill-tool.d.ts +15 -0
- package/dist/tools/load-skill-tool.js +114 -0
- package/dist/tools/patch-tools.d.ts +58 -0
- package/dist/tools/patch-tools.js +153 -0
- package/dist/tools/playwright-tool.d.ts +66 -0
- package/dist/tools/playwright-tool.js +121 -0
- package/dist/tools/project-detect.d.ts +20 -0
- package/dist/tools/project-detect.js +87 -0
- package/dist/tools/prompt-guidance.d.ts +22 -0
- package/dist/tools/prompt-guidance.js +23 -0
- package/dist/tools/scheduleTool.d.ts +19 -0
- package/dist/tools/scheduleTool.js +181 -0
- package/dist/tools/search-tools.d.ts +27 -0
- package/dist/tools/search-tools.js +78 -0
- package/dist/tools/sed-tool.d.ts +66 -0
- package/dist/tools/sed-tool.js +402 -0
- package/dist/tools/shell-result.d.ts +11 -0
- package/dist/tools/shell-result.js +1 -0
- package/dist/tools/shell-tool.d.ts +45 -0
- package/dist/tools/shell-tool.js +141 -0
- package/dist/tools/siteCrawlerTool.d.ts +32 -0
- package/dist/tools/siteCrawlerTool.js +205 -0
- package/dist/tools/tool-registry.d.ts +67 -0
- package/dist/tools/tool-registry.js +596 -0
- package/dist/tools/validate-tool.d.ts +23 -0
- package/dist/tools/validate-tool.js +201 -0
- package/dist/tools/workspace-index.d.ts +46 -0
- package/dist/tools/workspace-index.js +173 -0
- package/dist/types.d.ts +222 -0
- package/dist/types.js +7 -0
- package/dist/updater/index.d.ts +14 -0
- package/dist/updater/index.js +120 -0
- package/dist/util/banner.d.ts +25 -0
- package/dist/util/banner.js +140 -0
- package/dist/util/command-suggester.d.ts +6 -0
- package/dist/util/command-suggester.js +25 -0
- package/dist/util/confirm-interrupt.d.ts +10 -0
- package/dist/util/confirm-interrupt.js +31 -0
- package/dist/util/continue-trigger.d.ts +11 -0
- package/dist/util/continue-trigger.js +20 -0
- package/dist/util/env-info.d.ts +18 -0
- package/dist/util/env-info.js +37 -0
- package/dist/util/file-access-log.d.ts +35 -0
- package/dist/util/file-access-log.js +140 -0
- package/dist/util/footer-manager.d.ts +124 -0
- package/dist/util/footer-manager.js +195 -0
- package/dist/util/footer-renderer.d.ts +67 -0
- package/dist/util/footer-renderer.js +319 -0
- package/dist/util/footer-state.d.ts +34 -0
- package/dist/util/footer-state.js +18 -0
- package/dist/util/footer-text.d.ts +51 -0
- package/dist/util/footer-text.js +74 -0
- package/dist/util/ids.d.ts +1 -0
- package/dist/util/ids.js +4 -0
- package/dist/util/levenshtein.d.ts +6 -0
- package/dist/util/levenshtein.js +34 -0
- package/dist/util/logger.d.ts +10 -0
- package/dist/util/logger.js +41 -0
- package/dist/util/logs.d.ts +26 -0
- package/dist/util/logs.js +88 -0
- package/dist/util/output-handler.d.ts +89 -0
- package/dist/util/output-handler.js +193 -0
- package/dist/util/output-interceptor.d.ts +18 -0
- package/dist/util/output-interceptor.js +49 -0
- package/dist/util/output-paths.d.ts +43 -0
- package/dist/util/output-paths.js +121 -0
- package/dist/util/package-json.d.ts +6 -0
- package/dist/util/package-json.js +36 -0
- package/dist/util/process-kill.d.ts +27 -0
- package/dist/util/process-kill.js +148 -0
- package/dist/util/protocol-error-logger.d.ts +33 -0
- package/dist/util/protocol-error-logger.js +73 -0
- package/dist/util/redact.d.ts +25 -0
- package/dist/util/redact.js +103 -0
- package/dist/util/scroll-region-guard.d.ts +33 -0
- package/dist/util/scroll-region-guard.js +63 -0
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.js +49 -0
- package/dist/util/terminal-output.d.ts +34 -0
- package/dist/util/terminal-output.js +1 -0
- package/dist/util/terminal-silent.d.ts +6 -0
- package/dist/util/terminal-silent.js +20 -0
- package/dist/util/terminal.d.ts +56 -0
- package/dist/util/terminal.js +124 -0
- package/dist/util/text-sanitize.d.ts +8 -0
- package/dist/util/text-sanitize.js +45 -0
- package/dist/util/thinking-spinner.d.ts +27 -0
- package/dist/util/thinking-spinner.js +189 -0
- package/dist/util/tool-error-logger.d.ts +33 -0
- package/dist/util/tool-error-logger.js +77 -0
- package/dist/util/tty.d.ts +13 -0
- package/dist/util/tty.js +16 -0
- package/dist/util/xcoder-paths.d.ts +56 -0
- package/dist/util/xcoder-paths.js +63 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +4 -0
- package/dist/worker-agent/to-subtask-node.d.ts +35 -0
- package/dist/worker-agent/to-subtask-node.js +41 -0
- package/dist/worker-agent/worker-orchestrator.d.ts +104 -0
- package/dist/worker-agent/worker-orchestrator.js +201 -0
- package/package.json +38 -3
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { getStageRole, classifyIntake } from "../sdlc-runtime/sdlc-skill.js";
|
|
2
|
+
import { shortId } from "../util/ids.js";
|
|
3
|
+
export function deliverableFor(stage) {
|
|
4
|
+
const map = {
|
|
5
|
+
requirements: "A requirements document: goal, non-goals, constraints, first-pass acceptance criteria.",
|
|
6
|
+
design: "A design document: components, interfaces/contracts, and stated tradeoffs.",
|
|
7
|
+
code: "Working implementation matching the design, with files_touched listing every file written.",
|
|
8
|
+
refactor: "A corrected implementation targeting the specific defect, with files_touched listed.",
|
|
9
|
+
test: "A test suite plus a run of it, with pass/fail counts in self_check.",
|
|
10
|
+
ui_api_test: "A test run result: which steps passed/failed against the live URL.",
|
|
11
|
+
fix_defect: "Confirmation the original defect no longer reproduces, via a real test run.",
|
|
12
|
+
document: "Human-readable documentation of what was built/changed and why.",
|
|
13
|
+
deploy: "A deployment result plus an independent verification (health check, smoke test).",
|
|
14
|
+
conversation: "A direct answer. No further deliverable contract.",
|
|
15
|
+
quality_gate: "A pass/fail verdict with a reason: { passed: boolean, reason: string }.",
|
|
16
|
+
};
|
|
17
|
+
return map[stage];
|
|
18
|
+
}
|
|
19
|
+
export function acceptanceCriteriaFor(stage) {
|
|
20
|
+
const base = {
|
|
21
|
+
requirements: [
|
|
22
|
+
{ id: "AC1", type: "rubric", description: "Goal is stated as a concrete, checkable outcome, not a restatement of the input." },
|
|
23
|
+
{ id: "AC2", type: "rubric", description: "Non-goals and constraints are explicit." },
|
|
24
|
+
{ id: "AC3", type: "file-exists", description: "A detailed technical requirement document was persisted to .xcoder/backlog/", pathGlob: ".xcoder/backlog/*requirements*.md" },
|
|
25
|
+
],
|
|
26
|
+
design: [
|
|
27
|
+
{ id: "AC1", type: "rubric", description: "Every component named in requirements has a defined interface." },
|
|
28
|
+
{ id: "AC2", type: "rubric", description: "At least one tradeoff is stated explicitly, not left implicit." },
|
|
29
|
+
],
|
|
30
|
+
code: [
|
|
31
|
+
{ id: "AC1", type: "schema", description: "Every file referenced in the design was actually written (files_touched is non-empty)." },
|
|
32
|
+
{ id: "AC2", type: "command", description: "The project's own build/typecheck command exits 0.", command: "npm run typecheck" },
|
|
33
|
+
],
|
|
34
|
+
refactor: [
|
|
35
|
+
{ id: "AC1", type: "command", description: "The project's own build/typecheck command exits 0.", command: "npm run typecheck" },
|
|
36
|
+
{ id: "AC2", type: "command", description: "The project's own test command exits 0, including a case for the reported defect.", command: "npm test" },
|
|
37
|
+
],
|
|
38
|
+
test: [
|
|
39
|
+
{ id: "AC1", type: "schema", description: "self_check.ran === true." },
|
|
40
|
+
{ id: "AC2", type: "schema", description: "self_check.passed === true." },
|
|
41
|
+
{ id: "AC3", type: "command", description: "The full regression suite passes independently.", command: "npm run regression" },
|
|
42
|
+
],
|
|
43
|
+
ui_api_test: [
|
|
44
|
+
{ id: "AC1", type: "schema", description: "Every declared step reported ok === true." },
|
|
45
|
+
],
|
|
46
|
+
fix_defect: [
|
|
47
|
+
{ id: "AC1", type: "command", description: "A targeted re-run confirms the original defect no longer reproduces.", command: "npm test" },
|
|
48
|
+
],
|
|
49
|
+
document: [
|
|
50
|
+
{ id: "AC1", type: "rubric", description: "Documentation references concrete specifics from upstream context, not generic boilerplate." },
|
|
51
|
+
],
|
|
52
|
+
deploy: [
|
|
53
|
+
{ id: "AC1", type: "rubric", description: "An independent post-deploy check (not the deploy command's own exit code) confirms health." },
|
|
54
|
+
],
|
|
55
|
+
conversation: [],
|
|
56
|
+
quality_gate: [
|
|
57
|
+
{ id: "AC1", type: "schema", description: "deliverable contains passed: boolean and reason: string" },
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
return base[stage];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Builds the initial DAG for a non-conversation task. Deliberately linear
|
|
64
|
+
* for v1 (matching the brief's stage sequences) rather than inventing
|
|
65
|
+
* parallel branches Xcoder SDLC has no evidence justify — the swarm dispatcher
|
|
66
|
+
* (see `orchestrator/swarm.ts`) is what actually gives you fan-out, once a
|
|
67
|
+
* `replan` action splits a stage into independent nodes (e.g. multiple
|
|
68
|
+
* files to implement in parallel). Nodes are fully self-contained: a Sub
|
|
69
|
+
* Agent needs nothing beyond the node it's handed.
|
|
70
|
+
*/
|
|
71
|
+
export function buildInitialPlan(spec) {
|
|
72
|
+
const rule = classifyIntake(spec.inputs);
|
|
73
|
+
const nodes = [];
|
|
74
|
+
let previousId = null;
|
|
75
|
+
for (const stage of rule.sequence) {
|
|
76
|
+
const id = `${stage}-${shortId("st")}`;
|
|
77
|
+
const role = getStageRole(stage, spec.inputs);
|
|
78
|
+
const node = {
|
|
79
|
+
id,
|
|
80
|
+
stage,
|
|
81
|
+
role,
|
|
82
|
+
engine: "react-v1",
|
|
83
|
+
dependsOn: previousId ? [previousId] : [],
|
|
84
|
+
goal: buildGoalText(stage, spec),
|
|
85
|
+
upstreamContext: {},
|
|
86
|
+
deliverableSpec: deliverableFor(stage),
|
|
87
|
+
acceptanceCriteria: acceptanceCriteriaFor(stage),
|
|
88
|
+
status: previousId ? "pending" : "ready",
|
|
89
|
+
healing: { attempts: 0, maxAttempts: spec.constraints.maxHealingAttempts, log: [] },
|
|
90
|
+
};
|
|
91
|
+
nodes.push(node);
|
|
92
|
+
previousId = id;
|
|
93
|
+
}
|
|
94
|
+
// If any code or refactor stages are present, ensure the document stage
|
|
95
|
+
// also covers the blueprint update requirement
|
|
96
|
+
const hasCode = nodes.some((n) => n.stage === "code" || n.stage === "refactor");
|
|
97
|
+
if (hasCode) {
|
|
98
|
+
const existingDoc = nodes.find((n) => n.stage === "document");
|
|
99
|
+
if (existingDoc) {
|
|
100
|
+
// Extend existing document node's goal to include blueprint update
|
|
101
|
+
existingDoc.goal = `${existingDoc.goal}. Also update .xcoder/blueprint.md with the current architecture, workflow, and features.`;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const id = `document-${shortId("st")}`;
|
|
105
|
+
const docNode = {
|
|
106
|
+
id,
|
|
107
|
+
stage: "document",
|
|
108
|
+
role: "architect",
|
|
109
|
+
engine: "react-v1",
|
|
110
|
+
dependsOn: previousId ? [previousId] : [],
|
|
111
|
+
goal: "Update .xcoder/blueprint.md with the current architecture, workflow, and features. Document what was changed in this task.",
|
|
112
|
+
upstreamContext: {},
|
|
113
|
+
deliverableSpec: deliverableFor("document"),
|
|
114
|
+
acceptanceCriteria: [
|
|
115
|
+
...acceptanceCriteriaFor("document"),
|
|
116
|
+
{ id: "BP1", type: "file-exists", description: "Blueprint doc exists", pathGlob: ".xcoder/blueprint.md" },
|
|
117
|
+
],
|
|
118
|
+
status: previousId ? "pending" : "ready",
|
|
119
|
+
healing: { attempts: 0, maxAttempts: spec.constraints.maxHealingAttempts, log: [] },
|
|
120
|
+
};
|
|
121
|
+
nodes.push(docNode);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return nodes;
|
|
125
|
+
}
|
|
126
|
+
function buildGoalText(stage, spec, defectPath, upstreamFolders) {
|
|
127
|
+
const { inputs } = spec;
|
|
128
|
+
switch (stage) {
|
|
129
|
+
case "requirements":
|
|
130
|
+
return `Explore and write requirements for: ${spec.goal}`;
|
|
131
|
+
case "design":
|
|
132
|
+
return `Design a solution for: ${spec.goal}${inputs.design ? `\n\nStarting point/reference: ${inputs.design}` : ""}`;
|
|
133
|
+
case "code":
|
|
134
|
+
return `Implement: ${spec.goal}${inputs.design ? `\n\nDesign to implement against: ${inputs.design}` : ""}`;
|
|
135
|
+
case "refactor":
|
|
136
|
+
return `Fix the following defect in the existing code at "${inputs.code}":\n${inputs.defectDetail}\n\nGoal: ${spec.goal}`;
|
|
137
|
+
case "test": {
|
|
138
|
+
const base = `Write and run unit tests for the code at "${inputs.code}". Goal: ${spec.goal}`;
|
|
139
|
+
if (upstreamFolders && upstreamFolders.length > 0) {
|
|
140
|
+
const vitestArgs = upstreamFolders
|
|
141
|
+
.map((f) => `"src/${f}/**/*.test.ts"`)
|
|
142
|
+
.join(" ");
|
|
143
|
+
const scopeLine = `FOLDER_SCOPE: Run tests only for these top-level src/ folders: ${upstreamFolders.join(", ")}. Use npx vitest with per-folder file paths: npx vitest run --config vitest.config.ts ${vitestArgs}. Per-folder timeout 60s.`;
|
|
144
|
+
return `${scopeLine}\n\n${base}`;
|
|
145
|
+
}
|
|
146
|
+
return base;
|
|
147
|
+
}
|
|
148
|
+
case "ui_api_test":
|
|
149
|
+
return `Run UI/API validation against ${inputs.url}. Goal: ${spec.goal}${inputs.credentialRef ? ` (credential available via ref "${inputs.credentialRef}")` : ""}`;
|
|
150
|
+
case "fix_defect":
|
|
151
|
+
if (defectPath) {
|
|
152
|
+
return `Confirm the defect described in ${defectPath} no longer reproduces, via a real test run.`;
|
|
153
|
+
}
|
|
154
|
+
return `Confirm the defect fixed in the prior stage no longer reproduces.`;
|
|
155
|
+
case "document":
|
|
156
|
+
return `Document what was built/changed for: ${spec.goal}`;
|
|
157
|
+
case "deploy":
|
|
158
|
+
return `Deploy and verify: ${spec.goal}`;
|
|
159
|
+
case "conversation":
|
|
160
|
+
return spec.goal;
|
|
161
|
+
case "quality_gate":
|
|
162
|
+
return spec.goal; // quality-gate nodes have their own goal from DAG builder
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export function isConversation(spec) {
|
|
166
|
+
return classifyIntake(spec.inputs).startStage === "conversation";
|
|
167
|
+
}
|
|
168
|
+
export function buildTaskSpec(rawTask, cliInputs, constraints) {
|
|
169
|
+
return {
|
|
170
|
+
taskId: shortId("task"),
|
|
171
|
+
goal: rawTask,
|
|
172
|
+
inputs: { freeText: rawTask, ...cliInputs },
|
|
173
|
+
constraints,
|
|
174
|
+
createdAt: new Date().toISOString(),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SubtaskNode, SubtaskResult } from "../types.js";
|
|
2
|
+
export interface ValidationOutcome {
|
|
3
|
+
passed: boolean;
|
|
4
|
+
report: string;
|
|
5
|
+
perCriterion: {
|
|
6
|
+
id: string;
|
|
7
|
+
passed: boolean;
|
|
8
|
+
detail: string;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Deliberately validates against THIS SUBTASK's own acceptance criteria —
|
|
13
|
+
* never the overall task goal. A "write unit tests" subtask can't be
|
|
14
|
+
* judged against "build a REST API"; it has its own local spec (see
|
|
15
|
+
* `task-factory.ts`'s `acceptanceCriteriaFor`), and that's what this checks.
|
|
16
|
+
* Task-level rollup (did the whole thing satisfy the original goal) is a
|
|
17
|
+
* separate, later step — see `sdlc-orchestrator.ts`'s summarize step.
|
|
18
|
+
*
|
|
19
|
+
* Also deliberately independent of the Sub Agent's own `self_check` — an
|
|
20
|
+
* agent grading its own homework is exactly the failure mode a validation
|
|
21
|
+
* gate exists to catch.
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateSubtask(node: SubtaskNode, result: SubtaskResult, workspaceRoot: string): Promise<ValidationOutcome>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// xcoder:version 5 | xcoder:task task-f1ac77 | xcoder:updated 2026-10-17T04:10:33.907Z | xcoder:subtask code-st-1d0003
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { runCommandTool } from "../tools/shell-tool.js";
|
|
5
|
+
import { inferLayers } from "../skills/secure-architect.bylaws.js";
|
|
6
|
+
import { reviewDeliverable, describeReview } from "../skills/bylaw-review.js";
|
|
7
|
+
/**
|
|
8
|
+
* Deliberately validates against THIS SUBTASK's own acceptance criteria —
|
|
9
|
+
* never the overall task goal. A "write unit tests" subtask can't be
|
|
10
|
+
* judged against "build a REST API"; it has its own local spec (see
|
|
11
|
+
* `task-factory.ts`'s `acceptanceCriteriaFor`), and that's what this checks.
|
|
12
|
+
* Task-level rollup (did the whole thing satisfy the original goal) is a
|
|
13
|
+
* separate, later step — see `sdlc-orchestrator.ts`'s summarize step.
|
|
14
|
+
*
|
|
15
|
+
* Also deliberately independent of the Sub Agent's own `self_check` — an
|
|
16
|
+
* agent grading its own homework is exactly the failure mode a validation
|
|
17
|
+
* gate exists to catch.
|
|
18
|
+
*/
|
|
19
|
+
export async function validateSubtask(node, result, workspaceRoot) {
|
|
20
|
+
const perCriterion = [];
|
|
21
|
+
for (const ac of node.acceptanceCriteria) {
|
|
22
|
+
perCriterion.push(await checkCriterion(ac, result, workspaceRoot, node.goal));
|
|
23
|
+
}
|
|
24
|
+
const passed = perCriterion.every((c) => c.passed);
|
|
25
|
+
const report = passed
|
|
26
|
+
? "all acceptance criteria met"
|
|
27
|
+
: `failed: ${perCriterion
|
|
28
|
+
.filter((c) => !c.passed)
|
|
29
|
+
.map((c) => `[${c.id}] ${c.detail}`)
|
|
30
|
+
.join("; ")}`;
|
|
31
|
+
return { passed, report, perCriterion };
|
|
32
|
+
}
|
|
33
|
+
async function checkCriterion(ac, result, workspaceRoot, goal = "") {
|
|
34
|
+
if (result.deliverable === null && result.raoTrace.length === 0) {
|
|
35
|
+
return { id: ac.id, passed: false, detail: "subtask produced no deliverable at all" };
|
|
36
|
+
}
|
|
37
|
+
switch (ac.type) {
|
|
38
|
+
case "schema": {
|
|
39
|
+
// A conservative structural check: does the subtask claim to have
|
|
40
|
+
// produced *something* concrete for this criterion (a non-empty
|
|
41
|
+
// files_touched, or a self_check that actually ran)?
|
|
42
|
+
if (ac.description.toLowerCase().includes("files_touched")) {
|
|
43
|
+
const ok = result.filesTouched.length > 0;
|
|
44
|
+
return { id: ac.id, passed: ok, detail: ok ? "files_touched is non-empty" : "no files were reported written" };
|
|
45
|
+
}
|
|
46
|
+
if (ac.description.toLowerCase().includes("self_check.passed")) {
|
|
47
|
+
const ok = result.selfCheck?.passed === true;
|
|
48
|
+
return { id: ac.id, passed: ok, detail: ok ? "self_check reported passed" : "self_check missing or not passed" };
|
|
49
|
+
}
|
|
50
|
+
// Generic structural fallback: deliverable must be present and non-empty.
|
|
51
|
+
const ok = result.deliverable !== null && result.deliverable !== undefined && result.deliverable !== "";
|
|
52
|
+
return { id: ac.id, passed: ok, detail: ok ? "deliverable present" : "deliverable is empty/null" };
|
|
53
|
+
}
|
|
54
|
+
case "command": {
|
|
55
|
+
if (!ac.command) {
|
|
56
|
+
// No explicit re-check command declared on the node — fall back to
|
|
57
|
+
// trusting the agent's own self_check ran, but flag that this is
|
|
58
|
+
// weaker than an independent re-run.
|
|
59
|
+
const ran = result.selfCheck?.ran === true;
|
|
60
|
+
const passed = ran && result.selfCheck?.passed === true;
|
|
61
|
+
return {
|
|
62
|
+
id: ac.id,
|
|
63
|
+
passed,
|
|
64
|
+
detail: passed
|
|
65
|
+
? "no independent command configured; agent-reported self_check passed"
|
|
66
|
+
: "no independent command configured and self_check did not report a pass",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const cmdResult = await runCommandTool(ac.command, workspaceRoot, 120_000);
|
|
70
|
+
return {
|
|
71
|
+
id: ac.id,
|
|
72
|
+
passed: cmdResult.ok,
|
|
73
|
+
detail: cmdResult.ok
|
|
74
|
+
? `\`${ac.command}\` exited 0`
|
|
75
|
+
: `\`${ac.command}\` exited ${cmdResult.exitCode}: ${cmdResult.stderr.slice(0, 300)}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
case "file-exists": {
|
|
79
|
+
if (!ac.pathGlob) {
|
|
80
|
+
return { id: ac.id, passed: false, detail: "file-exists criterion missing pathGlob" };
|
|
81
|
+
}
|
|
82
|
+
const pattern = path.resolve(workspaceRoot, ac.pathGlob);
|
|
83
|
+
const globResult = await globFiles(pattern);
|
|
84
|
+
if (globResult.length > 0) {
|
|
85
|
+
return {
|
|
86
|
+
id: ac.id,
|
|
87
|
+
passed: true,
|
|
88
|
+
detail: `Found ${globResult.length} file(s) matching "${ac.pathGlob}": ${globResult[0]}`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
id: ac.id,
|
|
93
|
+
passed: false,
|
|
94
|
+
detail: `No files found matching "${ac.pathGlob}" in workspace`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
case "bylaw-review": {
|
|
98
|
+
// Deliberately independent of the agent's own `passed` flag: the
|
|
99
|
+
// verdict is computed by the bylaws module from the findings the
|
|
100
|
+
// agent reported. A gate that grades its own homework is not a gate.
|
|
101
|
+
const layers = ac.bylawLayers ?? inferLayers(goal);
|
|
102
|
+
const review = reviewDeliverable(result.deliverable, layers);
|
|
103
|
+
return {
|
|
104
|
+
id: ac.id,
|
|
105
|
+
passed: review.approved,
|
|
106
|
+
detail: review.approved
|
|
107
|
+
? "bylaw review approved (" + layers.join(", ") + ")"
|
|
108
|
+
: describeReview(review),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
case "rubric": {
|
|
112
|
+
// A lightweight heuristic rubric check for v1: the deliverable must
|
|
113
|
+
// be non-trivial (not a one-word non-answer) and the summary must
|
|
114
|
+
// reference the criterion's own key terms loosely. A true LLM-critic
|
|
115
|
+
// rubric pass (a separate model call judging semantic correctness)
|
|
116
|
+
// is a documented extension point — see README "Extending validation".
|
|
117
|
+
const text = JSON.stringify(result.deliverable ?? "") + " " + result.summary;
|
|
118
|
+
const ok = text.trim().length > 20;
|
|
119
|
+
return { id: ac.id, passed: ok, detail: ok ? "heuristic rubric check passed (non-trivial deliverable)" : "deliverable too thin to satisfy rubric" };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Minimal glob resolver using Node.js fs — avoids pulling in a heavy glob
|
|
125
|
+
* dependency for the straightforward wildcard patterns we need here.
|
|
126
|
+
*/
|
|
127
|
+
async function globFiles(pattern) {
|
|
128
|
+
const dir = path.dirname(pattern);
|
|
129
|
+
const base = path.basename(pattern);
|
|
130
|
+
// Convert glob wildcards to a regex: * → .*, ? → .
|
|
131
|
+
const escaped = base.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
132
|
+
const re = new RegExp("^" + escaped.replace(/\*/g, ".*").replace(/\?/g, ".") + "$");
|
|
133
|
+
const matches = [];
|
|
134
|
+
try {
|
|
135
|
+
const entries = await fs.readdir(dir);
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
if (re.test(entry)) {
|
|
138
|
+
try {
|
|
139
|
+
const full = path.join(dir, entry);
|
|
140
|
+
const stat = await fs.stat(full);
|
|
141
|
+
if (stat.isFile()) {
|
|
142
|
+
matches.push(full);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// skip unreadable entries
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// directory doesn't exist — no matches
|
|
153
|
+
}
|
|
154
|
+
return matches;
|
|
155
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { SubtaskNode } from "../types.js";
|
|
3
|
+
import type { ToolManifestEntry } from "../tools/tool-registry.js";
|
|
4
|
+
import { type EnvironmentInfo } from "../util/env-info.js";
|
|
5
|
+
import { type DetectedCommands } from "../tools/project-detect.js";
|
|
6
|
+
export interface AgentSystemPromptOptions {
|
|
7
|
+
agentName: string;
|
|
8
|
+
roleDescription: string;
|
|
9
|
+
directive: string;
|
|
10
|
+
skills: string[];
|
|
11
|
+
tools: ToolManifestEntry[];
|
|
12
|
+
environment: EnvironmentInfo;
|
|
13
|
+
detectedCommands: DetectedCommands;
|
|
14
|
+
goal?: string;
|
|
15
|
+
upstreamContext?: string;
|
|
16
|
+
protocolOverride?: string;
|
|
17
|
+
isStandalone?: boolean;
|
|
18
|
+
/** Injected between skills and tools — loaded from .xcoder/lesson.md. */
|
|
19
|
+
lessonContext?: string;
|
|
20
|
+
/** Injected immediately after the role directive, before the tool manifest.
|
|
21
|
+
* Rendered per-subtask by src/skills/bylaw-context.ts. Absent => prompt unchanged. */
|
|
22
|
+
bylawContext?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* THE CONTRACT.
|
|
26
|
+
*
|
|
27
|
+
* Every turn, in both directions, is exactly this shape. No prose outside
|
|
28
|
+
* the JSON, no partial objects, no both-action-and-final_answer. A message
|
|
29
|
+
* that doesn't parse against this schema is never silently "interpreted" —
|
|
30
|
+
* it's bounced back to the model as a typed protocol_error observation, and
|
|
31
|
+
* that costs it an iteration. This is what "protocol to adhere to" means in
|
|
32
|
+
* practice: the parser is the enforcement mechanism, not the prompt wording.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ReactMessageSchema: z.ZodObject<{
|
|
35
|
+
thought: z.ZodString;
|
|
36
|
+
action: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
37
|
+
tool: z.ZodString;
|
|
38
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
39
|
+
}, z.core.$strip>>>;
|
|
40
|
+
final_answer: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
41
|
+
summary: z.ZodString;
|
|
42
|
+
deliverable: z.ZodUnknown;
|
|
43
|
+
files_touched: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
44
|
+
self_check: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
ran: z.ZodBoolean;
|
|
46
|
+
passed: z.ZodBoolean;
|
|
47
|
+
detail: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type ReactMessage = z.infer<typeof ReactMessageSchema>;
|
|
52
|
+
export type ParsedReactMessage = {
|
|
53
|
+
ok: true;
|
|
54
|
+
message: ReactMessage;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Layer 1: Strip outermost XML envelope tags from model output.
|
|
61
|
+
* Handles tags like <thought>, <thinking>, <response>, <answer>
|
|
62
|
+
* (case-insensitive, outer-tags only). This prevents "Unexpected token '<'"
|
|
63
|
+
* parse errors when the model wraps JSON inside XML-style tags.
|
|
64
|
+
*/
|
|
65
|
+
export declare function stripXmlTags(raw: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Layer 1.5: Escape raw control characters (newline, tab, CR, etc.) that
|
|
68
|
+
* appear *inside* JSON string literals.
|
|
69
|
+
*
|
|
70
|
+
* Root cause this repairs: the JSON spec forbids literal U+0000–U+001F
|
|
71
|
+
* inside a string value — they must be written as `\n`, `\t`, `\uXXXX`,
|
|
72
|
+
* etc. Models very frequently violate this when a string value itself
|
|
73
|
+
* contains multi-line content (e.g. `action.input.content` for a
|
|
74
|
+
* write_file call carrying markdown/code). `JSON.parse` rejects the whole
|
|
75
|
+
* payload with "Bad control character in string literal" and none of the
|
|
76
|
+
* other layers repair it — XML-stripping and outermost-extraction only
|
|
77
|
+
* fix structural wrapping, not the string contents. Left unrepaired, the
|
|
78
|
+
* model has to reproduce the *entire* (often large) payload again with
|
|
79
|
+
* manual escaping, and frequently fails repeatedly, burning tokens each
|
|
80
|
+
* retry.
|
|
81
|
+
*
|
|
82
|
+
* Uses the same string-aware, escape-aware single pass as
|
|
83
|
+
* extractOutermostJson so it never touches control characters that sit
|
|
84
|
+
* outside of a string literal (e.g. the newlines a model puts between
|
|
85
|
+
* prose and the JSON block, which are harmless and should be left alone).
|
|
86
|
+
*/
|
|
87
|
+
export declare function sanitizeControlCharacters(raw: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* Layer 2: Extract the outermost balanced {...} JSON block from a string.
|
|
90
|
+
* Uses a single-pass O(n) brace counter with string-awareness (handles
|
|
91
|
+
* escaped quotes inside strings). Returns the JSON substring, or empty
|
|
92
|
+
* string if no balanced braces are found.
|
|
93
|
+
*/
|
|
94
|
+
export declare function extractOutermostJson(raw: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Layer 3: Normalize known LLM JSON-shape drifts before Zod validation.
|
|
97
|
+
* Operates on the already-parsed (but not yet schema-validated) object.
|
|
98
|
+
*
|
|
99
|
+
* Four drifts repaired, in fixed order:
|
|
100
|
+
* 1. Missing top-level `thought` — backfilled from prose preceding the JSON.
|
|
101
|
+
* 2. Bare `{tool, input}` — auto-wrapped as `{action: {tool, input}}`.
|
|
102
|
+
* 3. `thought` nested inside `action` — hoisted to top level.
|
|
103
|
+
* 4. Legacy `command` key inside `action` — renamed to `tool` (only when `tool` is absent).
|
|
104
|
+
*
|
|
105
|
+
* @param raw - The post-Layer-1 string (still contains prose prefix if present).
|
|
106
|
+
* @param json - The parsed JSON `unknown` object from Layer 2.
|
|
107
|
+
* @returns - `{ normalized: unknown; applied: boolean; steps: string[] }`
|
|
108
|
+
*/
|
|
109
|
+
export declare function normalizeReactShape(raw: string, json: unknown): {
|
|
110
|
+
normalized: unknown;
|
|
111
|
+
applied: boolean;
|
|
112
|
+
steps: string[];
|
|
113
|
+
};
|
|
114
|
+
export declare function parseReactMessage(raw: string): ParsedReactMessage;
|
|
115
|
+
/**
|
|
116
|
+
* Build a system prompt for any agent (Sub Agent or Samurai) from a common
|
|
117
|
+
* set of inputs. The prompt format is shared across both agent types — only
|
|
118
|
+
* the identity block, goal/context section, and framing differ.
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildAgentSystemPrompt(opts: AgentSystemPromptOptions): string;
|
|
121
|
+
/**
|
|
122
|
+
* Thin wrapper around buildAgentSystemPrompt that maps a SubtaskNode onto
|
|
123
|
+
* the generic AgentSystemPromptOptions shape. Kept for backward
|
|
124
|
+
* compatibility with the existing SubAgent caller.
|
|
125
|
+
*/
|
|
126
|
+
export declare function buildSystemPrompt(opts: {
|
|
127
|
+
role: string;
|
|
128
|
+
directive: string;
|
|
129
|
+
skills: string[];
|
|
130
|
+
tools: ToolManifestEntry[];
|
|
131
|
+
subtask: SubtaskNode;
|
|
132
|
+
environment: EnvironmentInfo;
|
|
133
|
+
detectedCommands: DetectedCommands;
|
|
134
|
+
/** Optional workspace-level protocol section injected into the prompt. */
|
|
135
|
+
protocolOverride?: string;
|
|
136
|
+
}): string;
|