@jaimevalasek/aioson 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +153 -10
- package/docs/en/cli-reference.md +56 -1
- package/docs/en/i18n.md +18 -18
- package/docs/en/schemas/index.json +10 -0
- package/docs/en/schemas/parallel-assign.schema.json +9 -0
- package/docs/en/schemas/parallel-doctor.schema.json +36 -0
- package/docs/en/schemas/parallel-guard.schema.json +63 -0
- package/docs/en/schemas/parallel-merge.schema.json +84 -0
- package/docs/en/schemas/parallel-status.schema.json +91 -1
- package/docs/integrations/apps-publish-marketplace.md +94 -0
- package/docs/pt/README.md +9 -0
- package/docs/pt/agentes.md +324 -3
- package/docs/pt/clientes-ai.md +7 -3
- package/docs/pt/comandos-cli.md +160 -13
- package/docs/pt/compress-agents.md +304 -0
- package/docs/pt/design-docs-governance.md +59 -0
- package/docs/pt/feature-archive.md +191 -0
- package/docs/pt/genome-3.0-spec.md +115 -4
- package/docs/pt/genome-distribution.md +232 -0
- package/docs/pt/inicio-rapido.md +1 -0
- package/docs/pt/motor-hardening.md +492 -0
- package/docs/pt/runner-system.md +113 -0
- package/package.json +2 -1
- package/src/agent-manifests.js +66 -0
- package/src/agents.js +27 -7
- package/src/autonomy-policy.js +139 -0
- package/src/brain-query.js +161 -0
- package/src/cli.js +1377 -1099
- package/src/commands/agents.js +102 -7
- package/src/commands/artifact-validate.js +33 -4
- package/src/commands/auth.js +272 -0
- package/src/commands/brain-query.js +44 -0
- package/src/commands/briefing.js +344 -0
- package/src/commands/commit-prepare.js +547 -0
- package/src/commands/compress-agents.js +416 -0
- package/src/commands/context-health.js +4 -2
- package/src/commands/context-trim.js +17 -11
- package/src/commands/design-hybrid-options.js +3 -3
- package/src/commands/devlog-process.js +6 -4
- package/src/commands/dossier.js +423 -0
- package/src/commands/feature-archive.js +513 -0
- package/src/commands/feature-close.js +123 -18
- package/src/commands/gate-approve.js +198 -0
- package/src/commands/gate-check.js +24 -5
- package/src/commands/genome-doctor.js +166 -9
- package/src/commands/git-guard.js +170 -0
- package/src/commands/harness.js +121 -0
- package/src/commands/implementation-plan.js +47 -20
- package/src/commands/init.js +6 -2
- package/src/commands/install.js +6 -2
- package/src/commands/live.js +497 -56
- package/src/commands/locale-apply.js +9 -6
- package/src/commands/locale-diff.js +11 -112
- package/src/commands/mcp-doctor.js +2 -1
- package/src/commands/mcp-init.js +4 -10
- package/src/commands/memory.js +234 -0
- package/src/commands/parallel-assign.js +107 -27
- package/src/commands/parallel-doctor.js +416 -3
- package/src/commands/parallel-guard.js +241 -0
- package/src/commands/parallel-init.js +66 -4
- package/src/commands/parallel-merge.js +299 -0
- package/src/commands/parallel-status.js +147 -3
- package/src/commands/preflight.js +63 -4
- package/src/commands/qa-init.js +10 -5
- package/src/commands/revision.js +235 -0
- package/src/commands/scaffold-complete.js +188 -0
- package/src/commands/security-audit.js +275 -0
- package/src/commands/security-scan.js +376 -0
- package/src/commands/self-implement-loop.js +46 -2
- package/src/commands/setup-context.js +11 -10
- package/src/commands/squad-agent-create.js +51 -9
- package/src/commands/squad-investigate.js +53 -0
- package/src/commands/squad-plan.js +33 -1
- package/src/commands/squad-scaffold.js +4 -3
- package/src/commands/squad-score.js +71 -14
- package/src/commands/squad-status.js +22 -1
- package/src/commands/squad-validate.js +93 -2
- package/src/commands/store-genome.js +304 -0
- package/src/commands/store-skill.js +247 -0
- package/src/commands/store-squad.js +431 -0
- package/src/commands/store-system.js +392 -0
- package/src/commands/tool-capabilities.js +63 -0
- package/src/commands/update.js +3 -3
- package/src/commands/verify-gate.js +40 -0
- package/src/commands/workflow-execute.js +644 -155
- package/src/commands/workflow-harden.js +231 -0
- package/src/commands/workflow-heal.js +136 -0
- package/src/commands/workflow-next.js +460 -22
- package/src/commands/workflow-status.js +328 -138
- package/src/commands/workspace.js +144 -0
- package/src/constants.js +55 -75
- package/src/context-memory.js +133 -4
- package/src/context-writer.js +2 -1
- package/src/context.js +32 -2
- package/src/doctor.js +46 -6
- package/src/dossier/codemap-store.js +267 -0
- package/src/dossier/dossier-bootstrap.js +222 -0
- package/src/dossier/dossier-compact.js +159 -0
- package/src/dossier/lock.js +128 -0
- package/src/dossier/revision-store.js +313 -0
- package/src/dossier/schema.js +155 -0
- package/src/dossier/store.js +400 -0
- package/src/execution-gateway.js +3 -0
- package/src/friction-scanner.js +202 -0
- package/src/genome-schema.js +24 -1
- package/src/genomes.js +33 -0
- package/src/handoff-contract.js +363 -0
- package/src/handoff-validator.js +45 -0
- package/src/harness/circuit-breaker.js +135 -0
- package/src/i18n/messages/en.js +317 -22
- package/src/i18n/messages/es.js +259 -18
- package/src/i18n/messages/fr.js +260 -18
- package/src/i18n/messages/pt-BR.js +313 -22
- package/src/install-profile.js +0 -16
- package/src/installer.js +70 -6
- package/src/lib/git-commit-guard.js +691 -0
- package/src/lib/security/artifact-reader.js +167 -0
- package/src/lib/security/exit-codes.js +51 -0
- package/src/lib/security/findings-writer.js +176 -0
- package/src/lib/security/runtime-events.js +77 -0
- package/src/lib/security/secrets-regex.js +115 -0
- package/src/lib/store/security-scan.js +173 -0
- package/src/lib/terminal-checkbox.js +130 -0
- package/src/lib/tmux-launcher.js +163 -0
- package/src/lib/tool-capabilities.js +102 -0
- package/src/locales.js +12 -8
- package/src/parallel-workspace.js +756 -0
- package/src/parser.js +8 -1
- package/src/path-guard.js +47 -0
- package/src/preflight-engine.js +237 -26
- package/src/self-healing.js +142 -0
- package/src/session-handoff.js +111 -1
- package/src/squad/squad-scaffold.js +183 -19
- package/src/test-briefing.js +226 -0
- package/src/updater.js +1 -1
- package/src/utils.js +3 -0
- package/src/workflow-gates.js +185 -0
- package/template/.aioson/agents/analyst.md +76 -130
- package/template/.aioson/agents/architect.md +53 -86
- package/template/.aioson/agents/committer.md +161 -0
- package/template/.aioson/agents/copywriter.md +463 -0
- package/template/.aioson/agents/cypher.md +252 -0
- package/template/.aioson/agents/dev.md +112 -600
- package/template/.aioson/agents/deyvin.md +33 -235
- package/template/.aioson/agents/discover.md +235 -0
- package/template/.aioson/agents/discovery-design-doc.md +17 -252
- package/template/.aioson/agents/genome.md +76 -26
- package/template/.aioson/agents/manifests/analyst.manifest.json +26 -0
- package/template/.aioson/agents/manifests/architect.manifest.json +23 -0
- package/template/.aioson/agents/manifests/committer.manifest.json +23 -0
- package/template/.aioson/agents/manifests/dev.manifest.json +37 -0
- package/template/.aioson/agents/manifests/orchestrator.manifest.json +30 -0
- package/template/.aioson/agents/manifests/pentester.manifest.json +39 -0
- package/template/.aioson/agents/manifests/pm.manifest.json +26 -0
- package/template/.aioson/agents/manifests/product.manifest.json +23 -0
- package/template/.aioson/agents/manifests/qa.manifest.json +25 -0
- package/template/.aioson/agents/manifests/setup.manifest.json +20 -0
- package/template/.aioson/agents/manifests/ux-ui.manifest.json +24 -0
- package/template/.aioson/agents/neo.md +10 -8
- package/template/.aioson/agents/orache.md +2 -6
- package/template/.aioson/agents/orchestrator.md +81 -182
- package/template/.aioson/agents/pentester.md +235 -0
- package/template/.aioson/agents/pm.md +40 -104
- package/template/.aioson/agents/product.md +99 -344
- package/template/.aioson/agents/profiler-enricher.md +57 -6
- package/template/.aioson/agents/profiler-forge.md +17 -7
- package/template/.aioson/agents/profiler-researcher.md +29 -6
- package/template/.aioson/agents/qa.md +165 -410
- package/template/.aioson/agents/setup.md +52 -262
- package/template/.aioson/agents/sheldon.md +122 -754
- package/template/.aioson/agents/site-forge.md +111 -1583
- package/template/.aioson/agents/squad.md +139 -1820
- package/template/.aioson/agents/tester.md +10 -0
- package/template/.aioson/agents/ux-ui.md +103 -645
- package/template/.aioson/agents/validator.md +69 -0
- package/template/.aioson/brains/scripts/query.js +5 -1
- package/template/.aioson/config/autonomy-protocol.json +43 -0
- package/template/.aioson/config.md +43 -15
- package/template/.aioson/constitution.md +36 -33
- package/template/.aioson/context/design-doc.md +136 -0
- package/template/.aioson/context/project-map.md +57 -0
- package/template/.aioson/design-docs/code-reuse.md +48 -0
- package/template/.aioson/design-docs/componentization.md +47 -0
- package/template/.aioson/design-docs/file-size.md +52 -0
- package/template/.aioson/design-docs/folder-structure.md +51 -0
- package/template/.aioson/design-docs/naming.md +54 -0
- package/template/.aioson/docs/LAYERS.md +12 -2
- package/template/.aioson/docs/dev/execution-discipline.md +106 -0
- package/template/.aioson/docs/dev/stack-conventions.md +83 -0
- package/template/.aioson/docs/deyvin/continuity-recovery.md +57 -0
- package/template/.aioson/docs/deyvin/debugging-escalation.md +30 -0
- package/template/.aioson/docs/deyvin/pair-execution.md +44 -0
- package/template/.aioson/docs/deyvin/runtime-handoffs.md +36 -0
- package/template/.aioson/docs/product/conversation-playbook.md +116 -0
- package/template/.aioson/docs/product/prd-contract.md +107 -0
- package/template/.aioson/docs/product/quality-lens.md +57 -0
- package/template/.aioson/docs/product/research-loop.md +65 -0
- package/template/.aioson/docs/sheldon/enrichment-paths.md +134 -0
- package/template/.aioson/docs/sheldon/quality-lens.md +57 -0
- package/template/.aioson/docs/sheldon/research-loop.md +56 -0
- package/template/.aioson/docs/sheldon/web-intelligence.md +75 -0
- package/template/.aioson/docs/site-forge-build.md +195 -0
- package/template/.aioson/docs/site-forge-extraction.md +135 -0
- package/template/.aioson/docs/site-forge-qa.md +155 -0
- package/template/.aioson/docs/site-forge-recon.md +434 -0
- package/template/.aioson/docs/site-forge-transform.md +249 -0
- package/template/.aioson/docs/squad/content-output.md +91 -0
- package/template/.aioson/docs/squad/creation-flow.md +135 -0
- package/template/.aioson/docs/squad/domain-classification.md +117 -0
- package/template/.aioson/docs/squad/genome-bindings.md +47 -0
- package/template/.aioson/docs/squad/package-contract.md +234 -0
- package/template/.aioson/docs/squad/quality-lens.md +56 -0
- package/template/.aioson/docs/squad/research-loop.md +59 -0
- package/template/.aioson/docs/squad/session-operations.md +117 -0
- package/template/.aioson/docs/squad/workflow-quality.md +165 -0
- package/template/.aioson/docs/ux-ui/accessibility-audit.md +55 -0
- package/template/.aioson/docs/ux-ui/audit-mode.md +86 -0
- package/template/.aioson/docs/ux-ui/component-map.md +35 -0
- package/template/.aioson/docs/ux-ui/design-execution.md +111 -0
- package/template/.aioson/docs/ux-ui/design-gate.md +27 -0
- package/template/.aioson/docs/ux-ui/research-mode.md +39 -0
- package/template/.aioson/docs/ux-ui/site-delivery.md +156 -0
- package/template/.aioson/docs/ux-ui/token-contract.md +57 -0
- package/template/.aioson/genomes/copywriting.md +204 -0
- package/template/.aioson/genomes/copywriting.meta.json +48 -0
- package/template/.aioson/git-guard.json +11 -0
- package/template/.aioson/mcp/servers.md +0 -1
- package/template/.aioson/rules/agent-language-policy.md +93 -0
- package/template/.aioson/rules/aioson-context-boundary.md +63 -0
- package/template/.aioson/rules/canonical-path-contract.md +47 -0
- package/template/.aioson/rules/data-format-convention.md +24 -86
- package/template/.aioson/rules/disk-first-artifacts.md +44 -0
- package/template/.aioson/rules/output-brevity.md +44 -0
- package/template/.aioson/rules/prd-section-ownership.md +49 -0
- package/template/.aioson/rules/security-baseline.md +139 -0
- package/template/.aioson/rules/spec-level-ownership.md +61 -0
- package/template/.aioson/rules/squad-driver-pattern.md +81 -0
- package/template/.aioson/schemas/squad-blueprint.schema.json +24 -0
- package/template/.aioson/schemas/squad-manifest.schema.json +44 -0
- package/template/.aioson/skills/design/cognitive-core-ui/references/motion.md +2 -0
- package/template/.aioson/skills/marketing/references/anti-patterns.md +254 -0
- package/template/.aioson/skills/marketing/references/fascinations.md +192 -0
- package/template/.aioson/skills/marketing/references/five-acts.md +248 -0
- package/template/.aioson/skills/marketing/references/market-intelligence.md +198 -0
- package/template/.aioson/skills/marketing/references/offer-structure.md +203 -0
- package/template/.aioson/skills/marketing/references/one-belief.md +149 -0
- package/template/.aioson/skills/marketing/references/patterns.md +218 -0
- package/template/.aioson/skills/marketing/references/pms-research.md +193 -0
- package/template/.aioson/skills/marketing/vsl-craft.md +385 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/pm.md +30 -0
- package/template/.aioson/skills/process/secure-tdd/SKILL.md +97 -0
- package/template/.aioson/skills/process/secure-tdd/references/nextjs.md +81 -0
- package/template/.aioson/skills/process/secure-tdd/references/node-express.md +91 -0
- package/template/.aioson/skills/process/secure-tdd/references/planned-stacks.md +33 -0
- package/template/.aioson/skills/static/harness-validate/SKILL.md +46 -0
- package/template/.aioson/skills/static/landing-page-deploy.md +192 -0
- package/template/.aioson/skills/static/landing-page-forge.md +730 -0
- package/template/.aioson/skills/static/ui-ux-modern.md +1 -0
- package/template/.aioson/skills/static/web-research-cache.md +3 -0
- package/template/.aioson/tasks/squad-create.md +56 -7
- package/template/.aioson/tasks/squad-design.md +80 -2
- package/template/.aioson/tasks/squad-investigate.md +14 -1
- package/template/.aioson/templates/squads/digital-marketing-agency/template.json +96 -0
- package/template/.claude/commands/aioson/agent/committer.md +5 -0
- package/template/.claude/commands/aioson/agent/copywriter.md +5 -0
- package/template/.claude/commands/aioson/agent/cypher.md +5 -0
- package/template/.claude/commands/aioson/agent/pair.md +5 -0
- package/template/.claude/commands/aioson/agent/validator.md +5 -0
- package/template/.gemini/commands/aios-analyst.toml +6 -3
- package/template/.gemini/commands/aios-architect.toml +7 -6
- package/template/.gemini/commands/aios-committer.toml +7 -0
- package/template/.gemini/commands/aios-copywriter.toml +7 -0
- package/template/.gemini/commands/aios-cypher.toml +7 -0
- package/template/.gemini/commands/aios-dev.toml +8 -7
- package/template/.gemini/commands/aios-deyvin.toml +6 -5
- package/template/.gemini/commands/aios-discovery-design-doc.toml +6 -3
- package/template/.gemini/commands/aios-genome.toml +7 -0
- package/template/.gemini/commands/aios-neo.toml +5 -3
- package/template/.gemini/commands/aios-orache.toml +7 -0
- package/template/.gemini/commands/aios-orchestrator.toml +8 -7
- package/template/.gemini/commands/aios-pair.toml +6 -5
- package/template/.gemini/commands/aios-pm.toml +8 -7
- package/template/.gemini/commands/aios-product.toml +5 -3
- package/template/.gemini/commands/aios-qa.toml +6 -5
- package/template/.gemini/commands/aios-setup.toml +5 -2
- package/template/.gemini/commands/aios-sheldon.toml +7 -0
- package/template/.gemini/commands/aios-site-forge.toml +7 -0
- package/template/.gemini/commands/aios-squad.toml +7 -0
- package/template/.gemini/commands/aios-tester.toml +6 -5
- package/template/.gemini/commands/aios-ux-ui.toml +8 -7
- package/template/.gemini/commands/aios-validator.toml +7 -0
- package/template/AGENTS.md +12 -1
- package/template/CLAUDE.md +6 -1
- package/template/.aioson/locales/en/agents/analyst.md +0 -244
- package/template/.aioson/locales/en/agents/architect.md +0 -245
- package/template/.aioson/locales/en/agents/dev.md +0 -397
- package/template/.aioson/locales/en/agents/deyvin.md +0 -137
- package/template/.aioson/locales/en/agents/discovery-design-doc.md +0 -27
- package/template/.aioson/locales/en/agents/genome.md +0 -212
- package/template/.aioson/locales/en/agents/neo.md +0 -8
- package/template/.aioson/locales/en/agents/orache.md +0 -6
- package/template/.aioson/locales/en/agents/orchestrator.md +0 -189
- package/template/.aioson/locales/en/agents/pair.md +0 -5
- package/template/.aioson/locales/en/agents/pm.md +0 -84
- package/template/.aioson/locales/en/agents/product.md +0 -378
- package/template/.aioson/locales/en/agents/profiler-enricher.md +0 -5
- package/template/.aioson/locales/en/agents/profiler-forge.md +0 -5
- package/template/.aioson/locales/en/agents/profiler-researcher.md +0 -5
- package/template/.aioson/locales/en/agents/qa.md +0 -270
- package/template/.aioson/locales/en/agents/setup.md +0 -421
- package/template/.aioson/locales/en/agents/sheldon.md +0 -455
- package/template/.aioson/locales/en/agents/squad.md +0 -449
- package/template/.aioson/locales/en/agents/tester.md +0 -6
- package/template/.aioson/locales/en/agents/ux-ui.md +0 -668
- package/template/.aioson/locales/es/agents/analyst.md +0 -225
- package/template/.aioson/locales/es/agents/architect.md +0 -245
- package/template/.aioson/locales/es/agents/dev.md +0 -370
- package/template/.aioson/locales/es/agents/deyvin.md +0 -99
- package/template/.aioson/locales/es/agents/discovery-design-doc.md +0 -21
- package/template/.aioson/locales/es/agents/genome.md +0 -104
- package/template/.aioson/locales/es/agents/neo.md +0 -50
- package/template/.aioson/locales/es/agents/orache.md +0 -105
- package/template/.aioson/locales/es/agents/orchestrator.md +0 -194
- package/template/.aioson/locales/es/agents/pair.md +0 -7
- package/template/.aioson/locales/es/agents/pm.md +0 -90
- package/template/.aioson/locales/es/agents/product.md +0 -372
- package/template/.aioson/locales/es/agents/profiler-enricher.md +0 -7
- package/template/.aioson/locales/es/agents/profiler-forge.md +0 -7
- package/template/.aioson/locales/es/agents/profiler-researcher.md +0 -7
- package/template/.aioson/locales/es/agents/qa.md +0 -198
- package/template/.aioson/locales/es/agents/setup.md +0 -405
- package/template/.aioson/locales/es/agents/sheldon.md +0 -309
- package/template/.aioson/locales/es/agents/squad.md +0 -532
- package/template/.aioson/locales/es/agents/tester.md +0 -9
- package/template/.aioson/locales/es/agents/ux-ui.md +0 -212
- package/template/.aioson/locales/fr/agents/analyst.md +0 -225
- package/template/.aioson/locales/fr/agents/architect.md +0 -245
- package/template/.aioson/locales/fr/agents/dev.md +0 -370
- package/template/.aioson/locales/fr/agents/deyvin.md +0 -99
- package/template/.aioson/locales/fr/agents/discovery-design-doc.md +0 -21
- package/template/.aioson/locales/fr/agents/genome.md +0 -104
- package/template/.aioson/locales/fr/agents/neo.md +0 -50
- package/template/.aioson/locales/fr/agents/orache.md +0 -106
- package/template/.aioson/locales/fr/agents/orchestrator.md +0 -194
- package/template/.aioson/locales/fr/agents/pair.md +0 -7
- package/template/.aioson/locales/fr/agents/pm.md +0 -90
- package/template/.aioson/locales/fr/agents/product.md +0 -372
- package/template/.aioson/locales/fr/agents/profiler-enricher.md +0 -7
- package/template/.aioson/locales/fr/agents/profiler-forge.md +0 -7
- package/template/.aioson/locales/fr/agents/profiler-researcher.md +0 -7
- package/template/.aioson/locales/fr/agents/qa.md +0 -198
- package/template/.aioson/locales/fr/agents/setup.md +0 -405
- package/template/.aioson/locales/fr/agents/sheldon.md +0 -309
- package/template/.aioson/locales/fr/agents/squad.md +0 -532
- package/template/.aioson/locales/fr/agents/tester.md +0 -9
- package/template/.aioson/locales/fr/agents/ux-ui.md +0 -212
- package/template/.aioson/locales/pt-BR/agents/analyst.md +0 -319
- package/template/.aioson/locales/pt-BR/agents/architect.md +0 -284
- package/template/.aioson/locales/pt-BR/agents/dev.md +0 -483
- package/template/.aioson/locales/pt-BR/agents/deyvin.md +0 -184
- package/template/.aioson/locales/pt-BR/agents/discovery-design-doc.md +0 -198
- package/template/.aioson/locales/pt-BR/agents/genome.md +0 -297
- package/template/.aioson/locales/pt-BR/agents/neo.md +0 -208
- package/template/.aioson/locales/pt-BR/agents/orache.md +0 -137
- package/template/.aioson/locales/pt-BR/agents/orchestrator.md +0 -324
- package/template/.aioson/locales/pt-BR/agents/pair.md +0 -5
- package/template/.aioson/locales/pt-BR/agents/pm.md +0 -182
- package/template/.aioson/locales/pt-BR/agents/product.md +0 -466
- package/template/.aioson/locales/pt-BR/agents/profiler-enricher.md +0 -5
- package/template/.aioson/locales/pt-BR/agents/profiler-forge.md +0 -5
- package/template/.aioson/locales/pt-BR/agents/profiler-researcher.md +0 -5
- package/template/.aioson/locales/pt-BR/agents/qa.md +0 -300
- package/template/.aioson/locales/pt-BR/agents/setup.md +0 -533
- package/template/.aioson/locales/pt-BR/agents/sheldon.md +0 -323
- package/template/.aioson/locales/pt-BR/agents/squad.md +0 -1330
- package/template/.aioson/locales/pt-BR/agents/tester.md +0 -449
- package/template/.aioson/locales/pt-BR/agents/ux-ui.md +0 -669
- package/template/.aioson/skills/design-system/components/SKILL.md:Zone.Identifier +0 -0
- package/template/.aioson/skills/design-system/dashboards/SKILL.md:Zone.Identifier +0 -0
- package/template/.aioson/skills/design-system/foundations/SKILL.md:Zone.Identifier +0 -0
- package/template/.aioson/skills/design-system/motion/SKILL.md:Zone.Identifier +0 -0
- package/template/.aioson/skills/design-system/patterns/SKILL.md:Zone.Identifier +0 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
const PARALLEL_RELATIVE_DIR = '.aioson/context/parallel';
|
|
6
|
+
const WORKSPACE_MANIFEST_RELATIVE_PATH = `${PARALLEL_RELATIVE_DIR}/workspace.manifest.json`;
|
|
7
|
+
const OWNERSHIP_MAP_RELATIVE_PATH = `${PARALLEL_RELATIVE_DIR}/ownership-map.json`;
|
|
8
|
+
const MERGE_PLAN_RELATIVE_PATH = `${PARALLEL_RELATIVE_DIR}/merge-plan.json`;
|
|
9
|
+
|
|
10
|
+
function buildLaneKey(index) {
|
|
11
|
+
return `lane-${index}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function sanitizeScopeLabel(value) {
|
|
15
|
+
return String(value || '')
|
|
16
|
+
.replace(/\[(.*?)\]\((.*?)\)/g, '$1')
|
|
17
|
+
.replace(/[`*_#]/g, '')
|
|
18
|
+
.replace(/\s+/g, ' ')
|
|
19
|
+
.trim()
|
|
20
|
+
.replace(/[:.;]+$/, '');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function buildScopeKey(value) {
|
|
24
|
+
return sanitizeScopeLabel(value)
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
27
|
+
.replace(/^-+|-+$/g, '');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function normalizeProjectRelativePath(value) {
|
|
31
|
+
const text = String(value || '')
|
|
32
|
+
.trim()
|
|
33
|
+
.replace(/\\/g, '/')
|
|
34
|
+
.replace(/^\.\//, '')
|
|
35
|
+
.replace(/^\/+/, '')
|
|
36
|
+
.replace(/\/+/g, '/');
|
|
37
|
+
if (!text) return null;
|
|
38
|
+
if (text === '..' || text.startsWith('../')) return null;
|
|
39
|
+
if (text === '[unassigned]') return null;
|
|
40
|
+
if (text.includes('[assign')) return null;
|
|
41
|
+
if (text.includes('assign file paths')) return null;
|
|
42
|
+
if (text.endsWith('/**')) {
|
|
43
|
+
const base = text.slice(0, -3).replace(/\/+$/g, '');
|
|
44
|
+
return base ? `${base}/**` : null;
|
|
45
|
+
}
|
|
46
|
+
return text.replace(/\/+$/g, '') || null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseWritePathPattern(value) {
|
|
50
|
+
const normalized = normalizeProjectRelativePath(value);
|
|
51
|
+
if (!normalized) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (normalized.includes('*') && !normalized.endsWith('/**')) {
|
|
56
|
+
return {
|
|
57
|
+
value: normalized,
|
|
58
|
+
valid: false,
|
|
59
|
+
type: 'unsupported_glob'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (normalized.includes('**') && !normalized.endsWith('/**')) {
|
|
64
|
+
return {
|
|
65
|
+
value: normalized,
|
|
66
|
+
valid: false,
|
|
67
|
+
type: 'unsupported_glob'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (normalized.endsWith('/**')) {
|
|
72
|
+
const base = normalized.slice(0, -3);
|
|
73
|
+
if (!base) {
|
|
74
|
+
return {
|
|
75
|
+
value: normalized,
|
|
76
|
+
valid: false,
|
|
77
|
+
type: 'invalid_prefix'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
value: normalized,
|
|
82
|
+
valid: true,
|
|
83
|
+
type: 'prefix',
|
|
84
|
+
base
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
value: normalized,
|
|
90
|
+
valid: true,
|
|
91
|
+
type: 'exact',
|
|
92
|
+
base: normalized
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function unique(values) {
|
|
97
|
+
return Array.from(new Set((values || []).filter(Boolean)));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function buildLaneOwnershipEntries(assignments) {
|
|
101
|
+
return (assignments || []).map((assignment) => {
|
|
102
|
+
const scopeLabels = unique((assignment.items || []).map(sanitizeScopeLabel));
|
|
103
|
+
const writePaths = unique(
|
|
104
|
+
(assignment.writePaths || [])
|
|
105
|
+
.map((item) => parseWritePathPattern(item))
|
|
106
|
+
.filter((item) => item && item.valid)
|
|
107
|
+
.map((item) => item.value)
|
|
108
|
+
);
|
|
109
|
+
const laneKey = buildLaneKey(assignment.lane);
|
|
110
|
+
return {
|
|
111
|
+
lane: assignment.lane,
|
|
112
|
+
lane_key: laneKey,
|
|
113
|
+
owner: String(assignment.owner || laneKey).trim() || laneKey,
|
|
114
|
+
scope_labels: scopeLabels,
|
|
115
|
+
scope_keys: unique(scopeLabels.map(buildScopeKey)),
|
|
116
|
+
write_paths: writePaths,
|
|
117
|
+
write_scope: scopeLabels.map((label) => ({
|
|
118
|
+
type: 'scope_label',
|
|
119
|
+
value: label
|
|
120
|
+
})).concat(
|
|
121
|
+
writePaths.map((value) => ({
|
|
122
|
+
type: 'path_pattern',
|
|
123
|
+
value
|
|
124
|
+
}))
|
|
125
|
+
),
|
|
126
|
+
depends_on: unique((assignment.dependsOn || []).map(normalizeDependencyRef)),
|
|
127
|
+
merge_rank: normalizeMergeRank(assignment.mergeRank, assignment.lane)
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function buildWorkspaceManifest({ projectName, classification, workers, generatedAt, lanes = [], sourceFile = null }) {
|
|
133
|
+
return {
|
|
134
|
+
version: 1,
|
|
135
|
+
generated_at: generatedAt,
|
|
136
|
+
project_name: projectName,
|
|
137
|
+
classification,
|
|
138
|
+
workers,
|
|
139
|
+
lane_strategy: 'isolated-lanes',
|
|
140
|
+
merge_strategy: 'lane-index-asc',
|
|
141
|
+
source_file: sourceFile,
|
|
142
|
+
lanes: lanes.map((lane) => ({
|
|
143
|
+
lane: lane.lane,
|
|
144
|
+
lane_key: lane.lane_key,
|
|
145
|
+
owner: lane.owner,
|
|
146
|
+
status_file: `${PARALLEL_RELATIVE_DIR}/${buildLaneKey(lane.lane)}.status.md`,
|
|
147
|
+
scope_keys: lane.scope_keys || [],
|
|
148
|
+
write_paths: lane.write_paths || [],
|
|
149
|
+
merge_rank: lane.merge_rank,
|
|
150
|
+
depends_on: lane.depends_on || []
|
|
151
|
+
}))
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function buildOwnershipMap({ generatedAt, lanes = [] }) {
|
|
156
|
+
return {
|
|
157
|
+
version: 1,
|
|
158
|
+
generated_at: generatedAt,
|
|
159
|
+
lanes: lanes.map((lane) => ({
|
|
160
|
+
lane: lane.lane,
|
|
161
|
+
lane_key: lane.lane_key,
|
|
162
|
+
owner: lane.owner,
|
|
163
|
+
scope_labels: lane.scope_labels || [],
|
|
164
|
+
scope_keys: lane.scope_keys || [],
|
|
165
|
+
write_paths: lane.write_paths || [],
|
|
166
|
+
write_scope: lane.write_scope || [],
|
|
167
|
+
depends_on: lane.depends_on || []
|
|
168
|
+
}))
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function buildMergePlan({ generatedAt, lanes = [], sourceFile = null }) {
|
|
173
|
+
return {
|
|
174
|
+
version: 1,
|
|
175
|
+
generated_at: generatedAt,
|
|
176
|
+
source_file: sourceFile,
|
|
177
|
+
strategy: 'lane-index-asc',
|
|
178
|
+
conflict_policy: 'shared-decisions-first',
|
|
179
|
+
order: lanes
|
|
180
|
+
.slice()
|
|
181
|
+
.sort((a, b) => Number(a.merge_rank || a.lane) - Number(b.merge_rank || b.lane))
|
|
182
|
+
.map((lane) => lane.lane),
|
|
183
|
+
lanes: lanes.map((lane) => ({
|
|
184
|
+
lane: lane.lane,
|
|
185
|
+
lane_key: lane.lane_key,
|
|
186
|
+
merge_rank: lane.merge_rank,
|
|
187
|
+
scope_keys: lane.scope_keys || [],
|
|
188
|
+
depends_on: lane.depends_on || []
|
|
189
|
+
}))
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function collectOwnershipConflicts(ownershipMap) {
|
|
194
|
+
if (!ownershipMap || !Array.isArray(ownershipMap.lanes)) return [];
|
|
195
|
+
|
|
196
|
+
const seen = new Map();
|
|
197
|
+
for (const lane of ownershipMap.lanes) {
|
|
198
|
+
for (const key of lane.scope_keys || []) {
|
|
199
|
+
if (!key) continue;
|
|
200
|
+
const current = seen.get(key) || [];
|
|
201
|
+
current.push(lane.lane);
|
|
202
|
+
seen.set(key, current);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return Array.from(seen.entries())
|
|
207
|
+
.filter(([, lanes]) => lanes.length > 1)
|
|
208
|
+
.map(([scope_key, lanes]) => ({ scope_key, lanes }));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function normalizeMergeRank(value, fallback) {
|
|
212
|
+
const num = Number(value);
|
|
213
|
+
if (Number.isFinite(num) && num > 0) return Math.floor(num);
|
|
214
|
+
const fallbackNum = Number(fallback);
|
|
215
|
+
if (Number.isFinite(fallbackNum) && fallbackNum > 0) return Math.floor(fallbackNum);
|
|
216
|
+
return 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function normalizeDependencyRef(value) {
|
|
220
|
+
const text = sanitizeScopeLabel(value)
|
|
221
|
+
.replace(/[\[\]]/g, '')
|
|
222
|
+
.toLowerCase();
|
|
223
|
+
if (!text) return null;
|
|
224
|
+
if (
|
|
225
|
+
text === 'list dependencies on other lanes or shared decisions' ||
|
|
226
|
+
text === 'list dependencies such as lane-1 or shared-decisions'
|
|
227
|
+
) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const laneMatch = text.match(/^(?:lane|agent)[\s-]+(\d+)$/);
|
|
232
|
+
if (laneMatch) {
|
|
233
|
+
return buildLaneKey(Number(laneMatch[1]));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (
|
|
237
|
+
text === 'shared decisions' ||
|
|
238
|
+
text === 'shared decision' ||
|
|
239
|
+
text === 'shared-decisions' ||
|
|
240
|
+
text === 'shared-decision'
|
|
241
|
+
) {
|
|
242
|
+
return 'shared-decisions';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return buildScopeKey(text) || null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function extractSectionBullets(content, title) {
|
|
249
|
+
const lines = String(content || '').split(/\r?\n/);
|
|
250
|
+
const start = lines.findIndex((line) => line.trim() === `## ${title}`);
|
|
251
|
+
if (start === -1) return [];
|
|
252
|
+
|
|
253
|
+
const items = [];
|
|
254
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
255
|
+
const line = lines[i];
|
|
256
|
+
if (line.startsWith('## ')) break;
|
|
257
|
+
const match = line.match(/^\s*-\s+(.*)$/);
|
|
258
|
+
if (!match) continue;
|
|
259
|
+
items.push(String(match[1] || '').trim());
|
|
260
|
+
}
|
|
261
|
+
return items;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function extractStatusScopeItems(content) {
|
|
265
|
+
return extractSectionBullets(content, 'Scope').filter((item) => {
|
|
266
|
+
const value = String(item || '').trim().toLowerCase();
|
|
267
|
+
return value && value !== '[define module or feature boundary]' && value !== '[unassigned]';
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function extractStatusDependencyItems(content) {
|
|
272
|
+
return unique(extractSectionBullets(content, 'Dependencies').map(normalizeDependencyRef));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function extractStatusWritePathItems(content) {
|
|
276
|
+
const ownershipItems = extractSectionBullets(content, 'Ownership');
|
|
277
|
+
const values = [];
|
|
278
|
+
for (const item of ownershipItems) {
|
|
279
|
+
const match = String(item || '').match(/^write_paths?:\s*(.*)$/i);
|
|
280
|
+
if (!match) continue;
|
|
281
|
+
const raw = String(match[1] || '').trim();
|
|
282
|
+
if (!raw) continue;
|
|
283
|
+
for (const part of raw.split(/\s*(?:,|\|)\s*/)) {
|
|
284
|
+
const parsed = parseWritePathPattern(part);
|
|
285
|
+
if (parsed && parsed.value) {
|
|
286
|
+
values.push(parsed.value);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return unique(values);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function extractStatusMergeRank(content, fallback = null) {
|
|
294
|
+
const items = extractSectionBullets(content, 'Merge');
|
|
295
|
+
for (const item of items) {
|
|
296
|
+
const match = String(item || '').match(/^merge_rank:\s*(\d+)$/i);
|
|
297
|
+
if (match) {
|
|
298
|
+
return normalizeMergeRank(match[1], fallback);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return normalizeMergeRank(fallback, 1);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function sortByLane(a, b) {
|
|
305
|
+
return Number(a.lane) - Number(b.lane);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function sortStrings(values) {
|
|
309
|
+
return (values || [])
|
|
310
|
+
.map((value) => String(value || '').trim())
|
|
311
|
+
.filter(Boolean)
|
|
312
|
+
.sort();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function normalizeComparableLaneEntry(lane) {
|
|
316
|
+
if (!lane || !Number.isFinite(Number(lane.lane))) return null;
|
|
317
|
+
const laneNumber = normalizeMergeRank(lane.lane, 1);
|
|
318
|
+
const laneKey = String(lane.lane_key || buildLaneKey(laneNumber)).trim() || buildLaneKey(laneNumber);
|
|
319
|
+
return {
|
|
320
|
+
lane: laneNumber,
|
|
321
|
+
lane_key: laneKey,
|
|
322
|
+
owner: String(lane.owner || laneKey).trim() || laneKey,
|
|
323
|
+
scope_keys: sortStrings(lane.scope_keys || []),
|
|
324
|
+
write_paths: sortStrings(lane.write_paths || []),
|
|
325
|
+
depends_on: sortStrings((lane.depends_on || []).map(normalizeDependencyRef)),
|
|
326
|
+
merge_rank: normalizeMergeRank(lane.merge_rank, laneNumber)
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function normalizeWorkspaceManifestForComparison(manifest) {
|
|
331
|
+
if (!manifest || !Array.isArray(manifest.lanes)) return null;
|
|
332
|
+
return {
|
|
333
|
+
workers: normalizeMergeRank(manifest.workers || manifest.lanes.length, manifest.lanes.length),
|
|
334
|
+
lane_strategy: String(manifest.lane_strategy || '').trim() || 'isolated-lanes',
|
|
335
|
+
merge_strategy: String(manifest.merge_strategy || '').trim() || 'lane-index-asc',
|
|
336
|
+
lanes: manifest.lanes
|
|
337
|
+
.map(normalizeComparableLaneEntry)
|
|
338
|
+
.filter(Boolean)
|
|
339
|
+
.sort(sortByLane)
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function normalizeOwnershipMapForComparison(ownershipMap) {
|
|
344
|
+
if (!ownershipMap || !Array.isArray(ownershipMap.lanes)) return null;
|
|
345
|
+
return {
|
|
346
|
+
lanes: ownershipMap.lanes
|
|
347
|
+
.map(normalizeComparableLaneEntry)
|
|
348
|
+
.filter(Boolean)
|
|
349
|
+
.sort(sortByLane)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function normalizeMergePlanForComparison(mergePlan) {
|
|
354
|
+
if (!mergePlan || !Array.isArray(mergePlan.lanes)) return null;
|
|
355
|
+
return {
|
|
356
|
+
strategy: String(mergePlan.strategy || '').trim() || 'lane-index-asc',
|
|
357
|
+
conflict_policy: String(mergePlan.conflict_policy || '').trim() || 'shared-decisions-first',
|
|
358
|
+
order: (mergePlan.order || []).map((value) => normalizeMergeRank(value, 1)),
|
|
359
|
+
lanes: mergePlan.lanes
|
|
360
|
+
.map(normalizeComparableLaneEntry)
|
|
361
|
+
.filter(Boolean)
|
|
362
|
+
.sort(sortByLane)
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function buildMachineSyncReport({ laneEntries = [], workspaceManifest = null, ownershipMap = null, mergePlan = null }) {
|
|
367
|
+
const expectedWorkspaceManifest = normalizeWorkspaceManifestForComparison(
|
|
368
|
+
buildWorkspaceManifest({
|
|
369
|
+
projectName: 'project',
|
|
370
|
+
classification: 'MEDIUM',
|
|
371
|
+
workers: laneEntries.length,
|
|
372
|
+
generatedAt: '1970-01-01T00:00:00.000Z',
|
|
373
|
+
lanes: laneEntries
|
|
374
|
+
})
|
|
375
|
+
);
|
|
376
|
+
const expectedOwnershipMap = normalizeOwnershipMapForComparison(
|
|
377
|
+
buildOwnershipMap({
|
|
378
|
+
generatedAt: '1970-01-01T00:00:00.000Z',
|
|
379
|
+
lanes: laneEntries
|
|
380
|
+
})
|
|
381
|
+
);
|
|
382
|
+
const expectedMergePlan = normalizeMergePlanForComparison(
|
|
383
|
+
buildMergePlan({
|
|
384
|
+
generatedAt: '1970-01-01T00:00:00.000Z',
|
|
385
|
+
lanes: laneEntries
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
const workspaceManifestInSync =
|
|
390
|
+
JSON.stringify(normalizeWorkspaceManifestForComparison(workspaceManifest)) ===
|
|
391
|
+
JSON.stringify(expectedWorkspaceManifest);
|
|
392
|
+
const ownershipMapInSync =
|
|
393
|
+
JSON.stringify(normalizeOwnershipMapForComparison(ownershipMap)) ===
|
|
394
|
+
JSON.stringify(expectedOwnershipMap);
|
|
395
|
+
const mergePlanInSync =
|
|
396
|
+
JSON.stringify(normalizeMergePlanForComparison(mergePlan)) ===
|
|
397
|
+
JSON.stringify(expectedMergePlan);
|
|
398
|
+
|
|
399
|
+
const staleFiles = [];
|
|
400
|
+
if (!workspaceManifestInSync) staleFiles.push('workspace.manifest.json');
|
|
401
|
+
if (!ownershipMapInSync) staleFiles.push('ownership-map.json');
|
|
402
|
+
if (!mergePlanInSync) staleFiles.push('merge-plan.json');
|
|
403
|
+
|
|
404
|
+
return {
|
|
405
|
+
workspaceManifestInSync,
|
|
406
|
+
ownershipMapInSync,
|
|
407
|
+
mergePlanInSync,
|
|
408
|
+
staleFiles
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function collectDependencyIssues({ lanes = [], mergeOrder = [] }) {
|
|
413
|
+
const laneMap = new Map();
|
|
414
|
+
const orderMap = new Map();
|
|
415
|
+
const invalid = [];
|
|
416
|
+
const blocked = [];
|
|
417
|
+
const orderViolations = [];
|
|
418
|
+
let declaredCount = 0;
|
|
419
|
+
|
|
420
|
+
for (const lane of lanes) {
|
|
421
|
+
laneMap.set(Number(lane.lane), lane);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
(mergeOrder || []).forEach((lane, index) => {
|
|
425
|
+
orderMap.set(Number(lane), index);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
for (const lane of lanes) {
|
|
429
|
+
const laneNumber = Number(lane.lane);
|
|
430
|
+
const status = String(lane.status || '').trim().toLowerCase();
|
|
431
|
+
const dependencies = unique((lane.dependencyItems || lane.depends_on || []).map(normalizeDependencyRef));
|
|
432
|
+
declaredCount += dependencies.length;
|
|
433
|
+
|
|
434
|
+
for (const dependency of dependencies) {
|
|
435
|
+
const match = String(dependency || '').match(/^lane-(\d+)$/);
|
|
436
|
+
if (!match) continue;
|
|
437
|
+
|
|
438
|
+
const dependencyLane = Number(match[1]);
|
|
439
|
+
const dependencyState = laneMap.get(dependencyLane);
|
|
440
|
+
if (!dependencyState) {
|
|
441
|
+
invalid.push({
|
|
442
|
+
lane: laneNumber,
|
|
443
|
+
dependency
|
|
444
|
+
});
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const dependencyStatus = String(dependencyState.status || '').trim().toLowerCase();
|
|
449
|
+
if (status && status !== 'pending' && dependencyStatus !== 'completed' && dependencyStatus !== 'merged') {
|
|
450
|
+
blocked.push({
|
|
451
|
+
lane: laneNumber,
|
|
452
|
+
dependency,
|
|
453
|
+
dependencyStatus: String(dependencyState.status || 'pending').trim() || 'pending'
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (orderMap.has(laneNumber) && orderMap.has(dependencyLane) && orderMap.get(dependencyLane) > orderMap.get(laneNumber)) {
|
|
458
|
+
orderViolations.push({
|
|
459
|
+
lane: laneNumber,
|
|
460
|
+
dependency
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return {
|
|
467
|
+
declaredCount,
|
|
468
|
+
invalidCount: invalid.length,
|
|
469
|
+
blockedCount: blocked.length,
|
|
470
|
+
orderViolationCount: orderViolations.length,
|
|
471
|
+
invalid,
|
|
472
|
+
blocked,
|
|
473
|
+
orderViolations
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function buildMergeExecutionReport({ lanes = [], mergeOrder = [] }) {
|
|
478
|
+
const laneMap = new Map();
|
|
479
|
+
const normalizedOrder = Array.isArray(mergeOrder) && mergeOrder.length > 0
|
|
480
|
+
? mergeOrder.map((value) => normalizeMergeRank(value, 1))
|
|
481
|
+
: lanes
|
|
482
|
+
.slice()
|
|
483
|
+
.sort((a, b) => normalizeMergeRank(a.mergeRank, a.lane) - normalizeMergeRank(b.mergeRank, b.lane))
|
|
484
|
+
.map((lane) => Number(lane.lane));
|
|
485
|
+
|
|
486
|
+
for (const lane of lanes) {
|
|
487
|
+
laneMap.set(Number(lane.lane), lane);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const mergedStatuses = new Set(['merged']);
|
|
491
|
+
const readyStatuses = new Set(['completed']);
|
|
492
|
+
const appliedOrExisting = new Set();
|
|
493
|
+
const plan = [];
|
|
494
|
+
const blocked = [];
|
|
495
|
+
let allReady = true;
|
|
496
|
+
|
|
497
|
+
for (let index = 0; index < normalizedOrder.length; index += 1) {
|
|
498
|
+
const laneNumber = Number(normalizedOrder[index]);
|
|
499
|
+
const lane = laneMap.get(laneNumber);
|
|
500
|
+
if (!lane) {
|
|
501
|
+
allReady = false;
|
|
502
|
+
blocked.push({
|
|
503
|
+
lane: laneNumber,
|
|
504
|
+
reason: 'missing_lane'
|
|
505
|
+
});
|
|
506
|
+
plan.push({
|
|
507
|
+
lane: laneNumber,
|
|
508
|
+
action: 'blocked',
|
|
509
|
+
reason: 'missing_lane'
|
|
510
|
+
});
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const status = String(lane.status || '').trim().toLowerCase();
|
|
515
|
+
const dependencies = unique((lane.dependencyItems || lane.depends_on || []).map(normalizeDependencyRef));
|
|
516
|
+
const unresolvedDependencies = [];
|
|
517
|
+
for (const dependency of dependencies) {
|
|
518
|
+
const match = String(dependency || '').match(/^lane-(\d+)$/);
|
|
519
|
+
if (!match) continue;
|
|
520
|
+
const dependencyLane = Number(match[1]);
|
|
521
|
+
const dependencyState = laneMap.get(dependencyLane);
|
|
522
|
+
const dependencyStatus = String(dependencyState && dependencyState.status ? dependencyState.status : '').trim().toLowerCase();
|
|
523
|
+
if (!dependencyState) {
|
|
524
|
+
unresolvedDependencies.push({
|
|
525
|
+
dependency,
|
|
526
|
+
reason: 'missing_lane'
|
|
527
|
+
});
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
if (!appliedOrExisting.has(dependencyLane) && !mergedStatuses.has(dependencyStatus)) {
|
|
531
|
+
unresolvedDependencies.push({
|
|
532
|
+
dependency,
|
|
533
|
+
reason: `dependency_status_${dependencyStatus || 'pending'}`
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (mergedStatuses.has(status)) {
|
|
539
|
+
appliedOrExisting.add(laneNumber);
|
|
540
|
+
plan.push({
|
|
541
|
+
lane: laneNumber,
|
|
542
|
+
status,
|
|
543
|
+
action: 'already_merged',
|
|
544
|
+
mergeRank: normalizeMergeRank(lane.mergeRank, laneNumber),
|
|
545
|
+
dependencies
|
|
546
|
+
});
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (!readyStatuses.has(status)) {
|
|
551
|
+
allReady = false;
|
|
552
|
+
blocked.push({
|
|
553
|
+
lane: laneNumber,
|
|
554
|
+
reason: `status_${status || 'unknown'}`
|
|
555
|
+
});
|
|
556
|
+
plan.push({
|
|
557
|
+
lane: laneNumber,
|
|
558
|
+
status,
|
|
559
|
+
action: 'blocked',
|
|
560
|
+
reason: `status_${status || 'unknown'}`,
|
|
561
|
+
mergeRank: normalizeMergeRank(lane.mergeRank, laneNumber),
|
|
562
|
+
dependencies
|
|
563
|
+
});
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (unresolvedDependencies.length > 0) {
|
|
568
|
+
allReady = false;
|
|
569
|
+
blocked.push({
|
|
570
|
+
lane: laneNumber,
|
|
571
|
+
reason: 'dependency_unresolved',
|
|
572
|
+
dependencies: unresolvedDependencies
|
|
573
|
+
});
|
|
574
|
+
plan.push({
|
|
575
|
+
lane: laneNumber,
|
|
576
|
+
status,
|
|
577
|
+
action: 'blocked',
|
|
578
|
+
reason: 'dependency_unresolved',
|
|
579
|
+
unresolvedDependencies,
|
|
580
|
+
mergeRank: normalizeMergeRank(lane.mergeRank, laneNumber),
|
|
581
|
+
dependencies
|
|
582
|
+
});
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
appliedOrExisting.add(laneNumber);
|
|
587
|
+
plan.push({
|
|
588
|
+
lane: laneNumber,
|
|
589
|
+
status,
|
|
590
|
+
action: 'merge',
|
|
591
|
+
mergeRank: normalizeMergeRank(lane.mergeRank, laneNumber),
|
|
592
|
+
dependencies
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return {
|
|
597
|
+
order: normalizedOrder,
|
|
598
|
+
plan,
|
|
599
|
+
blocked,
|
|
600
|
+
readyToApply: allReady,
|
|
601
|
+
readyLaneCount: plan.filter((item) => item.action === 'merge').length,
|
|
602
|
+
alreadyMergedCount: plan.filter((item) => item.action === 'already_merged').length,
|
|
603
|
+
blockedCount: plan.filter((item) => item.action === 'blocked').length
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function matchWritePathPattern(candidatePath, pattern) {
|
|
608
|
+
const candidate = normalizeProjectRelativePath(candidatePath);
|
|
609
|
+
const parsed = parseWritePathPattern(pattern);
|
|
610
|
+
if (!candidate || !parsed || !parsed.valid) return false;
|
|
611
|
+
if (parsed.type === 'exact') {
|
|
612
|
+
return candidate === parsed.base;
|
|
613
|
+
}
|
|
614
|
+
return candidate === parsed.base || candidate.startsWith(`${parsed.base}/`);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function patternsOverlap(left, right) {
|
|
618
|
+
const a = parseWritePathPattern(left);
|
|
619
|
+
const b = parseWritePathPattern(right);
|
|
620
|
+
if (!a || !b || !a.valid || !b.valid) return false;
|
|
621
|
+
if (a.type === 'exact' && b.type === 'exact') {
|
|
622
|
+
return a.base === b.base;
|
|
623
|
+
}
|
|
624
|
+
if (a.type === 'prefix' && b.type === 'prefix') {
|
|
625
|
+
return (
|
|
626
|
+
a.base === b.base ||
|
|
627
|
+
a.base.startsWith(`${b.base}/`) ||
|
|
628
|
+
b.base.startsWith(`${a.base}/`)
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
if (a.type === 'prefix') {
|
|
632
|
+
return b.base === a.base || b.base.startsWith(`${a.base}/`);
|
|
633
|
+
}
|
|
634
|
+
return a.base === b.base || a.base.startsWith(`${b.base}/`);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function collectWritePathConflicts(lanes = []) {
|
|
638
|
+
const normalizedLanes = (lanes || []).map((lane) => ({
|
|
639
|
+
lane: Number(lane.lane),
|
|
640
|
+
write_paths: unique(
|
|
641
|
+
(lane.write_paths || lane.writePathItems || [])
|
|
642
|
+
.map((item) => parseWritePathPattern(item))
|
|
643
|
+
.filter((item) => item && item.value)
|
|
644
|
+
.map((item) => item.value)
|
|
645
|
+
)
|
|
646
|
+
}));
|
|
647
|
+
|
|
648
|
+
const invalid = [];
|
|
649
|
+
for (const lane of lanes || []) {
|
|
650
|
+
for (const item of lane.write_paths || lane.writePathItems || []) {
|
|
651
|
+
const parsed = parseWritePathPattern(item);
|
|
652
|
+
if (parsed && !parsed.valid) {
|
|
653
|
+
invalid.push({
|
|
654
|
+
lane: Number(lane.lane),
|
|
655
|
+
value: parsed.value,
|
|
656
|
+
type: parsed.type
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const conflicts = [];
|
|
663
|
+
for (let i = 0; i < normalizedLanes.length; i += 1) {
|
|
664
|
+
const left = normalizedLanes[i];
|
|
665
|
+
for (let j = i + 1; j < normalizedLanes.length; j += 1) {
|
|
666
|
+
const right = normalizedLanes[j];
|
|
667
|
+
const overlaps = [];
|
|
668
|
+
for (const leftPattern of left.write_paths) {
|
|
669
|
+
for (const rightPattern of right.write_paths) {
|
|
670
|
+
if (patternsOverlap(leftPattern, rightPattern)) {
|
|
671
|
+
overlaps.push([leftPattern, rightPattern]);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (overlaps.length > 0) {
|
|
676
|
+
conflicts.push({
|
|
677
|
+
lanes: [left.lane, right.lane],
|
|
678
|
+
overlaps: unique(overlaps.map((item) => item.join(' :: ')))
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return {
|
|
685
|
+
invalid,
|
|
686
|
+
invalidPatterns: invalid,
|
|
687
|
+
invalidPatternCount: invalid.length,
|
|
688
|
+
invalidCount: invalid.length,
|
|
689
|
+
conflicts,
|
|
690
|
+
conflictCount: conflicts.length
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function replaceSection(content, title, items) {
|
|
695
|
+
const text = String(content || '');
|
|
696
|
+
const lines = text.split(/\r?\n/);
|
|
697
|
+
const start = lines.findIndex((line) => line.trim() === `## ${title}`);
|
|
698
|
+
const nextItems = Array.isArray(items) && items.length > 0 ? items : ['- [unassigned]'];
|
|
699
|
+
|
|
700
|
+
if (start === -1) {
|
|
701
|
+
const suffix = lines.length > 0 && lines[lines.length - 1] === '' ? '' : '\n';
|
|
702
|
+
return `${text}${suffix}\n## ${title}\n${nextItems.join('\n')}\n`;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
let end = lines.length;
|
|
706
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
707
|
+
if (lines[i].startsWith('## ')) {
|
|
708
|
+
end = i;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return `${[
|
|
714
|
+
...lines.slice(0, start + 1),
|
|
715
|
+
...nextItems,
|
|
716
|
+
...lines.slice(end)
|
|
717
|
+
].join('\n').replace(/\n*$/, '\n')}`;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function replaceMetadataLine(content, key, value) {
|
|
721
|
+
const text = String(content || '');
|
|
722
|
+
const pattern = new RegExp(`^-\\s*${key}:\\s*.*$`, 'm');
|
|
723
|
+
if (pattern.test(text)) {
|
|
724
|
+
return text.replace(pattern, `- ${key}: ${value}`);
|
|
725
|
+
}
|
|
726
|
+
return text;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
module.exports = {
|
|
730
|
+
PARALLEL_RELATIVE_DIR,
|
|
731
|
+
WORKSPACE_MANIFEST_RELATIVE_PATH,
|
|
732
|
+
OWNERSHIP_MAP_RELATIVE_PATH,
|
|
733
|
+
MERGE_PLAN_RELATIVE_PATH,
|
|
734
|
+
buildLaneKey,
|
|
735
|
+
sanitizeScopeLabel,
|
|
736
|
+
buildScopeKey,
|
|
737
|
+
normalizeProjectRelativePath,
|
|
738
|
+
parseWritePathPattern,
|
|
739
|
+
buildLaneOwnershipEntries,
|
|
740
|
+
buildWorkspaceManifest,
|
|
741
|
+
buildOwnershipMap,
|
|
742
|
+
buildMergePlan,
|
|
743
|
+
collectOwnershipConflicts,
|
|
744
|
+
collectWritePathConflicts,
|
|
745
|
+
normalizeDependencyRef,
|
|
746
|
+
extractStatusDependencyItems,
|
|
747
|
+
extractStatusWritePathItems,
|
|
748
|
+
extractStatusMergeRank,
|
|
749
|
+
buildMachineSyncReport,
|
|
750
|
+
collectDependencyIssues,
|
|
751
|
+
buildMergeExecutionReport,
|
|
752
|
+
matchWritePathPattern,
|
|
753
|
+
extractStatusScopeItems,
|
|
754
|
+
replaceSection,
|
|
755
|
+
replaceMetadataLine
|
|
756
|
+
};
|