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,35 @@
|
|
|
1
|
+
import type { SubtaskNode } from "../types.js";
|
|
2
|
+
import type { WorkerSubtask } from "./worker-orchestrator.js";
|
|
3
|
+
/**
|
|
4
|
+
* Context handed to the adapter for one attempt. Everything here is
|
|
5
|
+
* traceability-only except `maxAttempts`, which is carried into the node's
|
|
6
|
+
* `healing` block purely so downstream logs read correctly.
|
|
7
|
+
*/
|
|
8
|
+
export interface ToSubtaskNodeContext {
|
|
9
|
+
taskId: string;
|
|
10
|
+
/** 1-based attempt number of the wave being dispatched. */
|
|
11
|
+
attempt: number;
|
|
12
|
+
maxAttempts: number;
|
|
13
|
+
/** Errors from previous attempts, folded into `healing.log` for traceability only. */
|
|
14
|
+
priorErrors: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Adapts a generic `WorkerSubtask` onto the `SubtaskNode` shape every Sub
|
|
18
|
+
* Agent already understands.
|
|
19
|
+
*
|
|
20
|
+
* Every constant below is justified by reading `agents/sub-agent.ts`, not
|
|
21
|
+
* guessed:
|
|
22
|
+
*
|
|
23
|
+
* - `engine: "react-v1"` — hard requirement. `SubAgent.run()` synthesises a
|
|
24
|
+
* not-implemented result for any other engine name, so this is not
|
|
25
|
+
* caller-controllable and is deliberately absent from `WorkerSubtask`.
|
|
26
|
+
* - `stage: "code"` — cosmetic on this path. `SubAgent` reads `stage` only
|
|
27
|
+
* when tagging a lesson/text for a stuck loop; it gates nothing. If that
|
|
28
|
+
* ever changes, this constant becomes a real bug (design tradeoff T4).
|
|
29
|
+
* - `role` — genuinely matters: it indexes the role directives and per-role
|
|
30
|
+
* protocol overrides. Caller-controllable, defaulting to `programmer`.
|
|
31
|
+
* - `dependsOn: []` — worker subtasks are independent (design tradeoff T3).
|
|
32
|
+
* - `acceptanceCriteria: []` — there is no SDLC validation gate on this path,
|
|
33
|
+
* and `SubAgent` does not read the field.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toSubtaskNode(sub: WorkerSubtask, ctx: ToSubtaskNodeContext): SubtaskNode;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts a generic `WorkerSubtask` onto the `SubtaskNode` shape every Sub
|
|
3
|
+
* Agent already understands.
|
|
4
|
+
*
|
|
5
|
+
* Every constant below is justified by reading `agents/sub-agent.ts`, not
|
|
6
|
+
* guessed:
|
|
7
|
+
*
|
|
8
|
+
* - `engine: "react-v1"` — hard requirement. `SubAgent.run()` synthesises a
|
|
9
|
+
* not-implemented result for any other engine name, so this is not
|
|
10
|
+
* caller-controllable and is deliberately absent from `WorkerSubtask`.
|
|
11
|
+
* - `stage: "code"` — cosmetic on this path. `SubAgent` reads `stage` only
|
|
12
|
+
* when tagging a lesson/text for a stuck loop; it gates nothing. If that
|
|
13
|
+
* ever changes, this constant becomes a real bug (design tradeoff T4).
|
|
14
|
+
* - `role` — genuinely matters: it indexes the role directives and per-role
|
|
15
|
+
* protocol overrides. Caller-controllable, defaulting to `programmer`.
|
|
16
|
+
* - `dependsOn: []` — worker subtasks are independent (design tradeoff T3).
|
|
17
|
+
* - `acceptanceCriteria: []` — there is no SDLC validation gate on this path,
|
|
18
|
+
* and `SubAgent` does not read the field.
|
|
19
|
+
*/
|
|
20
|
+
export function toSubtaskNode(sub, ctx) {
|
|
21
|
+
const goal = (sub.goal ?? "").trim();
|
|
22
|
+
const deliverableSpec = (sub.deliverableSpec ?? "").trim() || goal;
|
|
23
|
+
const role = sub.role ?? "programmer";
|
|
24
|
+
return {
|
|
25
|
+
id: sub.id,
|
|
26
|
+
stage: "code",
|
|
27
|
+
role,
|
|
28
|
+
engine: "react-v1",
|
|
29
|
+
dependsOn: [],
|
|
30
|
+
goal,
|
|
31
|
+
upstreamContext: sub.upstreamContext ?? {},
|
|
32
|
+
deliverableSpec,
|
|
33
|
+
acceptanceCriteria: [],
|
|
34
|
+
status: "ready",
|
|
35
|
+
healing: {
|
|
36
|
+
attempts: Math.max(0, ctx.attempt - 1),
|
|
37
|
+
maxAttempts: ctx.maxAttempts,
|
|
38
|
+
log: [...ctx.priorErrors],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { dispatchSwarm } from "../orchestrator/swarm.js";
|
|
2
|
+
import type { LlmClient } from "../llm/client.js";
|
|
3
|
+
import type { Role, SubtaskResult, TokenUsage } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* One unit of work. There is intentionally no `stage`, `engine`,
|
|
6
|
+
* `dependsOn`, `acceptanceCriteria` or `healing` field — an `SdlcStage`
|
|
7
|
+
* cannot be supplied to this path by construction.
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkerSubtask {
|
|
10
|
+
/** Stable id, echoed in the report. Unique within a request. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Self-contained work order. */
|
|
13
|
+
goal: string;
|
|
14
|
+
/** Owning role. Optional: defaults to "programmer". Prompt routing only. */
|
|
15
|
+
role?: Role;
|
|
16
|
+
/** Inlined upstream context, as in `SubtaskNode`. */
|
|
17
|
+
upstreamContext?: Record<string, unknown>;
|
|
18
|
+
/** Optional; defaults to `goal`. */
|
|
19
|
+
deliverableSpec?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface WorkerRunRequest {
|
|
22
|
+
taskDescription: string;
|
|
23
|
+
/** Ordered; request order is preserved in the report, execution is concurrent. */
|
|
24
|
+
subtasks: WorkerSubtask[];
|
|
25
|
+
/** Default 3. Clamped to >= 1. */
|
|
26
|
+
concurrency?: number;
|
|
27
|
+
/** Total attempts per subtask (not retries). Default 2. Clamped to >= 1. */
|
|
28
|
+
maxAttempts?: number;
|
|
29
|
+
/** Optional run id; otherwise `worker-<timestamp>`. */
|
|
30
|
+
taskId?: string;
|
|
31
|
+
/** Stops *new* waves. In-flight agents finish (no real-time cancellation). */
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}
|
|
34
|
+
export type WorkerSubtaskStatus = "done" | "failed";
|
|
35
|
+
export interface WorkerAttemptRecord {
|
|
36
|
+
/** 1-based. */
|
|
37
|
+
attempt: number;
|
|
38
|
+
ok: boolean;
|
|
39
|
+
error: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface WorkerSubtaskReport {
|
|
42
|
+
id: string;
|
|
43
|
+
status: WorkerSubtaskStatus;
|
|
44
|
+
/** Always >= 1; equals `history.length`. */
|
|
45
|
+
attempts: number;
|
|
46
|
+
summary: string;
|
|
47
|
+
/** Last failure message; `null` when the subtask is done. */
|
|
48
|
+
error: string | null;
|
|
49
|
+
filesTouched: string[];
|
|
50
|
+
tokenUsage: TokenUsage;
|
|
51
|
+
iterations: number;
|
|
52
|
+
crashed: boolean;
|
|
53
|
+
/** One entry per attempt, in order — this is what makes retries assertable. */
|
|
54
|
+
history: WorkerAttemptRecord[];
|
|
55
|
+
}
|
|
56
|
+
export type WorkerRunStatus = "completed" | "partial" | "failed";
|
|
57
|
+
export interface WorkerRunReport {
|
|
58
|
+
taskId: string;
|
|
59
|
+
taskDescription: string;
|
|
60
|
+
status: WorkerRunStatus;
|
|
61
|
+
/** Request order, always one entry per requested subtask. */
|
|
62
|
+
subtasks: WorkerSubtaskReport[];
|
|
63
|
+
totals: {
|
|
64
|
+
subtasks: number;
|
|
65
|
+
done: number;
|
|
66
|
+
failed: number;
|
|
67
|
+
totalAttempts: number;
|
|
68
|
+
inputTokens: number;
|
|
69
|
+
outputTokens: number;
|
|
70
|
+
durationMs: number;
|
|
71
|
+
};
|
|
72
|
+
/** Run-level problems (adapter/validation), never raw agent stacks. */
|
|
73
|
+
errors: string[];
|
|
74
|
+
}
|
|
75
|
+
export interface WorkerOrchestratorOptions {
|
|
76
|
+
workspaceRoot: string;
|
|
77
|
+
llm: LlmClient;
|
|
78
|
+
/** Swarm worker client; defaults to `llm`. */
|
|
79
|
+
subAgentLlm?: LlmClient;
|
|
80
|
+
quiet?: boolean;
|
|
81
|
+
/** Injection seam for tests — defaults to the real `dispatchSwarm`. */
|
|
82
|
+
dispatch?: typeof dispatchSwarm;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The single place "what counts as a failed attempt" is decided. Centralising
|
|
86
|
+
* it keeps the retry loop unchanged if the policy is ever revisited, and lets
|
|
87
|
+
* tests assert the predicate directly.
|
|
88
|
+
*/
|
|
89
|
+
export declare function isFailure(result: SubtaskResult): boolean;
|
|
90
|
+
export declare class WorkerOrchestrator {
|
|
91
|
+
private readonly workspaceRoot;
|
|
92
|
+
private readonly llm;
|
|
93
|
+
private readonly subAgentLlm?;
|
|
94
|
+
private readonly quiet;
|
|
95
|
+
private readonly dispatch;
|
|
96
|
+
constructor(opts: WorkerOrchestratorOptions);
|
|
97
|
+
/**
|
|
98
|
+
* Runs every subtask, retrying failures in bounded waves.
|
|
99
|
+
*
|
|
100
|
+
* NEVER rejects — for any input, and for any failure of any worker agent.
|
|
101
|
+
* Unusable input surfaces as a `failed` report with run-level `errors`.
|
|
102
|
+
*/
|
|
103
|
+
run(request: WorkerRunRequest): Promise<WorkerRunReport>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// xcoder:version 1 | xcoder:task task-c4a64f | xcoder:updated 2026-10-17T02:20:47.001Z | xcoder:subtask code-st-348a21
|
|
2
|
+
// Generic worker orchestrator — non-SDLC task delegation.
|
|
3
|
+
//
|
|
4
|
+
// Deliberately NOT a copy of `sdlc-orchestrator.ts`: there is no TaskSpec,
|
|
5
|
+
// no WBS DAG, no escalations, no orchestrator trace, and no `SdlcStage` in
|
|
6
|
+
// the public input. Concurrency and crash isolation are delegated to the
|
|
7
|
+
// existing `dispatchSwarm`; the only logic here is the retry policy and
|
|
8
|
+
// report assembly.
|
|
9
|
+
import { dispatchSwarm } from "../orchestrator/swarm.js";
|
|
10
|
+
import { toSubtaskNode } from "./to-subtask-node.js";
|
|
11
|
+
/**
|
|
12
|
+
* The single place "what counts as a failed attempt" is decided. Centralising
|
|
13
|
+
* it keeps the retry loop unchanged if the policy is ever revisited, and lets
|
|
14
|
+
* tests assert the predicate directly.
|
|
15
|
+
*/
|
|
16
|
+
export function isFailure(result) {
|
|
17
|
+
return result.crashed === true || result.iterationsExhausted === true;
|
|
18
|
+
}
|
|
19
|
+
function emptyResult(error) {
|
|
20
|
+
return {
|
|
21
|
+
summary: error,
|
|
22
|
+
deliverable: null,
|
|
23
|
+
filesTouched: [],
|
|
24
|
+
raoTrace: [],
|
|
25
|
+
tokenUsage: { inputTokens: 0, outputTokens: 0 },
|
|
26
|
+
iterations: 0,
|
|
27
|
+
crashed: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function errOf(result) {
|
|
31
|
+
const summary = (result.summary ?? "").trim();
|
|
32
|
+
if (summary)
|
|
33
|
+
return summary;
|
|
34
|
+
if (result.crashed)
|
|
35
|
+
return "subtask crashed";
|
|
36
|
+
if (result.iterationsExhausted)
|
|
37
|
+
return "subtask exhausted its iteration budget";
|
|
38
|
+
return "subtask failed";
|
|
39
|
+
}
|
|
40
|
+
export class WorkerOrchestrator {
|
|
41
|
+
workspaceRoot;
|
|
42
|
+
llm;
|
|
43
|
+
subAgentLlm;
|
|
44
|
+
quiet;
|
|
45
|
+
dispatch;
|
|
46
|
+
constructor(opts) {
|
|
47
|
+
this.workspaceRoot = opts.workspaceRoot;
|
|
48
|
+
this.llm = opts.llm;
|
|
49
|
+
this.subAgentLlm = opts.subAgentLlm;
|
|
50
|
+
this.quiet = opts.quiet ?? false;
|
|
51
|
+
this.dispatch = opts.dispatch ?? dispatchSwarm;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Runs every subtask, retrying failures in bounded waves.
|
|
55
|
+
*
|
|
56
|
+
* NEVER rejects — for any input, and for any failure of any worker agent.
|
|
57
|
+
* Unusable input surfaces as a `failed` report with run-level `errors`.
|
|
58
|
+
*/
|
|
59
|
+
async run(request) {
|
|
60
|
+
const startedAt = Date.now();
|
|
61
|
+
const taskId = (request?.taskId ?? "").trim() || `worker-${startedAt}`;
|
|
62
|
+
const taskDescription = request?.taskDescription ?? "";
|
|
63
|
+
const errors = [];
|
|
64
|
+
const requested = Array.isArray(request?.subtasks) ? request.subtasks : [];
|
|
65
|
+
if (!Array.isArray(request?.subtasks)) {
|
|
66
|
+
errors.push("request.subtasks must be an array; nothing was dispatched");
|
|
67
|
+
}
|
|
68
|
+
const concurrency = Math.max(1, Math.floor(request?.concurrency ?? 3) || 1);
|
|
69
|
+
const maxAttempts = Math.max(1, Math.floor(request?.maxAttempts ?? 2) || 1);
|
|
70
|
+
const signal = request?.signal;
|
|
71
|
+
// De-duplicate by id defensively: dispatchSwarm keys results by subtask id,
|
|
72
|
+
// so a duplicate would silently mis-map results.
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
const subtasks = [];
|
|
75
|
+
for (const sub of requested) {
|
|
76
|
+
const id = (sub?.id ?? "").trim();
|
|
77
|
+
if (!id) {
|
|
78
|
+
errors.push(`skipped a subtask with no id (goal: ${(sub?.goal ?? "").slice(0, 80)})`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (seen.has(id)) {
|
|
82
|
+
errors.push(`skipped duplicate subtask id '${id}'`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
seen.add(id);
|
|
86
|
+
subtasks.push(sub);
|
|
87
|
+
}
|
|
88
|
+
const history = new Map();
|
|
89
|
+
const finals = new Map();
|
|
90
|
+
for (const sub of subtasks)
|
|
91
|
+
history.set(sub.id, []);
|
|
92
|
+
let pending = [...subtasks];
|
|
93
|
+
let attempt = 1;
|
|
94
|
+
while (pending.length > 0 && attempt <= maxAttempts && !signal?.aborted) {
|
|
95
|
+
const priorErrorsOf = (id) => (history.get(id) ?? [])
|
|
96
|
+
.map((h) => h.error)
|
|
97
|
+
.filter((e) => typeof e === "string" && e.length > 0);
|
|
98
|
+
const nodes = pending.map((sub) => toSubtaskNode(sub, {
|
|
99
|
+
taskId,
|
|
100
|
+
attempt,
|
|
101
|
+
maxAttempts,
|
|
102
|
+
priorErrors: priorErrorsOf(sub.id),
|
|
103
|
+
}));
|
|
104
|
+
let dispatched = [];
|
|
105
|
+
try {
|
|
106
|
+
dispatched = await this.dispatch(nodes, {
|
|
107
|
+
taskId,
|
|
108
|
+
workspaceRoot: this.workspaceRoot,
|
|
109
|
+
llm: this.llm,
|
|
110
|
+
subAgentLlm: this.subAgentLlm,
|
|
111
|
+
concurrency,
|
|
112
|
+
signal,
|
|
113
|
+
quiet: this.quiet,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
// `dispatchSwarm` is contractually non-throwing; reaching here means
|
|
118
|
+
// something structural broke. Attribute it to every subtask in the
|
|
119
|
+
// wave rather than losing the run.
|
|
120
|
+
const message = e?.message ?? String(e);
|
|
121
|
+
errors.push(`dispatch failed on attempt ${attempt}: ${message}`);
|
|
122
|
+
dispatched = [];
|
|
123
|
+
}
|
|
124
|
+
const byId = new Map();
|
|
125
|
+
for (const out of dispatched ?? []) {
|
|
126
|
+
if (out && typeof out.subtaskId === "string" && out.result) {
|
|
127
|
+
byId.set(out.subtaskId, out.result);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const retry = [];
|
|
131
|
+
for (const sub of pending) {
|
|
132
|
+
const result = byId.get(sub.id) ?? emptyResult("no result returned for this subtask");
|
|
133
|
+
const failed = isFailure(result);
|
|
134
|
+
const rec = {
|
|
135
|
+
attempt,
|
|
136
|
+
ok: !failed,
|
|
137
|
+
error: failed ? errOf(result) : null,
|
|
138
|
+
};
|
|
139
|
+
history.get(sub.id)?.push(rec);
|
|
140
|
+
if (failed && attempt < maxAttempts) {
|
|
141
|
+
retry.push(sub);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
finals.set(sub.id, { result, error: failed ? rec.error : null });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
pending = retry;
|
|
148
|
+
attempt += 1;
|
|
149
|
+
}
|
|
150
|
+
// Anything still pending after the loop ended (abort, or an attempt wave
|
|
151
|
+
// that produced no result) is finalised as failed — never left absent.
|
|
152
|
+
for (const sub of pending) {
|
|
153
|
+
const reason = signal?.aborted ? "aborted before dispatch" : "attempts exhausted without a result";
|
|
154
|
+
const recs = history.get(sub.id) ?? [];
|
|
155
|
+
recs.push({ attempt: recs.length + 1, ok: false, error: reason });
|
|
156
|
+
history.set(sub.id, recs);
|
|
157
|
+
finals.set(sub.id, { result: emptyResult(reason), error: reason });
|
|
158
|
+
}
|
|
159
|
+
const reports = subtasks.map((sub) => {
|
|
160
|
+
const recs = history.get(sub.id) ?? [];
|
|
161
|
+
const final = finals.get(sub.id);
|
|
162
|
+
const result = final?.result ?? emptyResult("subtask was never dispatched");
|
|
163
|
+
const failed = final ? final.error !== null : true;
|
|
164
|
+
const hist = recs.length > 0 ? recs.map((r) => ({ ...r })) : [{ attempt: 1, ok: false, error: "not dispatched" }];
|
|
165
|
+
return {
|
|
166
|
+
id: sub.id,
|
|
167
|
+
status: failed ? "failed" : "done",
|
|
168
|
+
attempts: hist.length,
|
|
169
|
+
summary: result.summary ?? "",
|
|
170
|
+
error: failed ? (final?.error ?? "subtask was never dispatched") : null,
|
|
171
|
+
filesTouched: Array.isArray(result.filesTouched) ? [...result.filesTouched] : [],
|
|
172
|
+
tokenUsage: {
|
|
173
|
+
inputTokens: result.tokenUsage?.inputTokens ?? 0,
|
|
174
|
+
outputTokens: result.tokenUsage?.outputTokens ?? 0,
|
|
175
|
+
},
|
|
176
|
+
iterations: result.iterations ?? 0,
|
|
177
|
+
crashed: result.crashed === true,
|
|
178
|
+
history: hist,
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
const done = reports.filter((r) => r.status === "done").length;
|
|
182
|
+
const failedCount = reports.length - done;
|
|
183
|
+
const status = reports.length === 0 || failedCount === 0 ? "completed" : done === 0 ? "failed" : "partial";
|
|
184
|
+
return {
|
|
185
|
+
taskId,
|
|
186
|
+
taskDescription,
|
|
187
|
+
status,
|
|
188
|
+
subtasks: reports,
|
|
189
|
+
totals: {
|
|
190
|
+
subtasks: reports.length,
|
|
191
|
+
done,
|
|
192
|
+
failed: failedCount,
|
|
193
|
+
totalAttempts: reports.reduce((sum, r) => sum + r.attempts, 0),
|
|
194
|
+
inputTokens: reports.reduce((sum, r) => sum + r.tokenUsage.inputTokens, 0),
|
|
195
|
+
outputTokens: reports.reduce((sum, r) => sum + r.tokenUsage.outputTokens, 0),
|
|
196
|
+
durationMs: Date.now() - startedAt,
|
|
197
|
+
},
|
|
198
|
+
errors,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xcoder-dna",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Reusable Xcoder components: tools, skills, swarm, sub-agent runtime and shared orchestration primitives.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json && node -e \"fs.cpSync('skills', 'dist/skills', { recursive: true })\"",
|
|
23
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
24
|
+
"test": "vitest run"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@anthropic-ai/sdk": "^0.32.0",
|
|
28
|
+
"@clack/prompts": "^0.7.0",
|
|
29
|
+
"cheerio": "^1.2.0",
|
|
30
|
+
"cli-spinners": "^2.9.2",
|
|
31
|
+
"commander": "^12.1.0",
|
|
32
|
+
"dotenv": "^16.4.5",
|
|
33
|
+
"js-yaml": "^5.5.0",
|
|
34
|
+
"openai": "^7.4.0",
|
|
35
|
+
"ora": "^8.1.0",
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
},
|
|
38
|
+
"optionalDependencies": {
|
|
39
|
+
"playwright": "^1.62.1"
|
|
40
|
+
}
|
|
6
41
|
}
|