mcp-efficiency-engine 0.1.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/.github/CODEOWNERS +40 -0
- package/.github/GITHUB_MCP_INTEGRATION.md +366 -0
- package/.github/ISSUE_TEMPLATE/bug.md +51 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +45 -0
- package/.github/ISSUE_TEMPLATE/question.md +18 -0
- package/.github/agents/backend.agent.md +18 -0
- package/.github/agents/community-manager.agent.md +18 -0
- package/.github/agents/dba.agent.md +18 -0
- package/.github/agents/frontend-agent.agent.md +18 -0
- package/.github/agents/github-repository-manager.agent.md +338 -0
- package/.github/agents/iot.agent.md +20 -0
- package/.github/agents/legacy.agent.md +18 -0
- package/.github/agents/rag-azure.agent.md +18 -0
- package/.github/agents/rag-local.agent.md +18 -0
- package/.github/agents/snapshot.agent.md +18 -0
- package/.github/agents/ux-ui.agent.md +18 -0
- package/.github/agents/wiki-agent.agent.md +23 -0
- package/.github/copilot-instructions.md +44 -0
- package/.github/instructions/always-on-optimization.instructions.md +54 -0
- package/.github/prompts/auto-route.prompt.md +33 -0
- package/.github/prompts/azure-rag.query.prompt.md +19 -0
- package/.github/prompts/backend.fix-bug.prompt.md +13 -0
- package/.github/prompts/cavecrew.prompt.md +16 -0
- package/.github/prompts/caveman-commit.prompt.md +14 -0
- package/.github/prompts/caveman-compress.prompt.md +15 -0
- package/.github/prompts/caveman-debug.prompt.md +13 -0
- package/.github/prompts/caveman-help.prompt.md +11 -0
- package/.github/prompts/caveman-review.prompt.md +15 -0
- package/.github/prompts/caveman-stats.prompt.md +11 -0
- package/.github/prompts/caveman.prompt.md +11 -0
- package/.github/prompts/community.post.prompt.md +14 -0
- package/.github/prompts/dba.query-review.prompt.md +15 -0
- package/.github/prompts/dev.fix-bug.prompt.md +13 -0
- package/.github/prompts/frontend.code.prompt.md +13 -0
- package/.github/prompts/legacy.impact-analysis.prompt.md +14 -0
- package/.github/prompts/project.kickoff-analysis.prompt.md +51 -0
- package/.github/prompts/rag.knowledge-answer.prompt.md +13 -0
- package/.github/prompts/token-saver-review.prompt.md +14 -0
- package/.github/prompts/ux-ui.review.prompt.md +14 -0
- package/.github/pull_request_template.md +71 -0
- package/.github/skills/ahorro-tokens/SKILL.md +36 -0
- package/.github/skills/azure-rag-enterprise/SKILL.md +24 -0
- package/.github/skills/backend-coding/SKILL.md +24 -0
- package/.github/skills/cavecrew/SKILL.md +17 -0
- package/.github/skills/caveman/SKILL.md +25 -0
- package/.github/skills/caveman-commit/SKILL.md +15 -0
- package/.github/skills/caveman-compress/SKILL.md +14 -0
- package/.github/skills/caveman-help/SKILL.md +19 -0
- package/.github/skills/caveman-mode/SKILL.md +43 -0
- package/.github/skills/caveman-review/SKILL.md +16 -0
- package/.github/skills/caveman-stats/SKILL.md +13 -0
- package/.github/skills/community-content/SKILL.md +22 -0
- package/.github/skills/database-analysis/SKILL.md +23 -0
- package/.github/skills/dev-coding/SKILL.md +24 -0
- package/.github/skills/frontend-coding/SKILL.md +24 -0
- package/.github/skills/human-in-the-loop/SKILL.md +47 -0
- package/.github/skills/iot-architecture/SKILL.md +22 -0
- package/.github/skills/legacy-migration/SKILL.md +22 -0
- package/.github/skills/rag-knowledge/SKILL.md +21 -0
- package/.github/skills/token-saver/SKILL.md +36 -0
- package/.github/skills/ux-ui-governance/SKILL.md +24 -0
- package/.github/skills/wiki-tools.json +24 -0
- package/.github/workflows/auto-devlog.yml +56 -0
- package/.github/workflows/auto-manage-issues.yml +64 -0
- package/.github/workflows/auto-sync.yml +54 -0
- package/.github/workflows/autodocs-sync.yml +114 -0
- package/.github/workflows/ci.yml +68 -0
- package/.github/workflows/pages.yml +59 -0
- package/.github/workflows/routing-evals.yml +59 -0
- package/.github/workflows/techriders-coverage-effective.yml +91 -0
- package/.vscode/mcp.json +44 -0
- package/AGENTS.md +160 -0
- package/ARCHITECTURE.md +57 -0
- package/FINAL_USAGE_GUIDE.md +106 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/README_WIKI.md +130 -0
- package/autodocs/README.md +22 -0
- package/autodocs/schema/wiki-node.schema.json +56 -0
- package/autolearning/feedback-loop.md +90 -0
- package/bin/install-host.js +326 -0
- package/bin/mcpee.js +116 -0
- package/context/repomix/repomix.config.json +20 -0
- package/memory/cross-memory-reasoning.md +17 -0
- package/memory/mempry-registry.yml +16 -0
- package/observability/evals/chat-token-usage-report.json +64 -0
- package/observability/evals/chat-token-usage-report.md +33 -0
- package/observability/evals/iteration-value-report.json +76 -0
- package/observability/evals/iteration-value-report.md +39 -0
- package/observability/evals/learning-loop-report.json +268 -0
- package/observability/evals/learning-loop-report.md +37 -0
- package/observability/evals/repo-intake-eval-cases.md +23 -0
- package/observability/evals/routing-eval-cases.json +68 -0
- package/observability/evals/routing-eval-cases.md +25 -0
- package/observability/evals/routing-eval-report.json +72 -0
- package/observability/evaluation.md +34 -0
- package/observability/logs/copilot-usage-ingest-report.json +13 -0
- package/observability/logs/iteration-metrics.jsonl +75 -0
- package/observability/logs/learning-feedback.jsonl +152 -0
- package/observability/logs/routing-decisions.jsonl +333 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-004146.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-005554.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260701-010351.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-145829.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-150021.log +8 -0
- package/observability/logs/session/agent-pipeline-preflight-20260704-154328.log +8 -0
- package/observability/logs/session/bye-20260629-221513.json +39 -0
- package/observability/logs/session/bye-20260629-221545.json +59 -0
- package/observability/logs/session/bye-20260629-222007.json +52 -0
- package/observability/logs/session/bye-20260629-222133.json +59 -0
- package/observability/logs/session/bye-20260629-222412.json +45 -0
- package/observability/logs/session/bye-20260629-223224.json +52 -0
- package/observability/logs/session/bye-20260629-224050.json +59 -0
- package/observability/logs/session/bye-20260630-105732.json +24 -0
- package/observability/logs/session/bye-20260630-211536.json +87 -0
- package/observability/logs/session/bye-20260630-223423.json +87 -0
- package/observability/logs/session/bye-20260630-232534.json +87 -0
- package/observability/logs/session/bye-20260701-003638.json +126 -0
- package/observability/logs/session/bye-20260701-003849.json +126 -0
- package/observability/logs/session/bye-20260701-004315.json +138 -0
- package/observability/logs/session/bye-20260701-004559.json +76 -0
- package/observability/logs/session/bye-20260701-005913.json +138 -0
- package/observability/logs/session/bye-20260701-010753.json +138 -0
- package/observability/logs/session/bye-20260703-194106.json +24 -0
- package/observability/logs/session/bye-20260703-233443.json +76 -0
- package/observability/logs/session/bye-20260703-233653.json +76 -0
- package/observability/logs/session/bye-20260704-150317.json +152 -0
- package/observability/logs/session/bye-20260704-150929.json +75 -0
- package/observability/logs/session/bye-20260704-151050.json +75 -0
- package/observability/logs/session/bye-20260705-115458.json +165 -0
- package/observability/logs/session/codegraph-status-20260701-004228.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-004310.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005637.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-005908.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010444.log +39 -0
- package/observability/logs/session/codegraph-status-20260701-010747.log +39 -0
- package/observability/logs/session/codegraph-status-20260704-150137.log +26 -0
- package/observability/logs/session/codegraph-status-20260704-150313.log +28 -0
- package/observability/logs/session/codegraph-status-20260704-154445.log +26 -0
- package/observability/logs/session/codegraph-status-20260705-115454.log +27 -0
- package/observability/logs/session/codegraph-sync-20260701-004211.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-004241.log +82 -0
- package/observability/logs/session/codegraph-sync-20260701-005620.log +89 -0
- package/observability/logs/session/codegraph-sync-20260701-005840.log +88 -0
- package/observability/logs/session/codegraph-sync-20260701-010419.log +93 -0
- package/observability/logs/session/codegraph-sync-20260701-010609.log +90 -0
- package/observability/logs/session/codegraph-sync-20260704-145856.log +70 -0
- package/observability/logs/session/codegraph-sync-20260704-150047.log +53 -0
- package/observability/logs/session/codegraph-sync-20260704-150204.log +44 -0
- package/observability/logs/session/codegraph-sync-20260704-154353.log +26 -0
- package/observability/logs/session/codegraph-sync-20260705-115337.log +32 -0
- package/observability/logs/session/hi-20260629-221459.json +38 -0
- package/observability/logs/session/hi-20260629-221945.json +59 -0
- package/observability/logs/session/hi-20260629-222108.json +66 -0
- package/observability/logs/session/hi-20260629-222352.json +45 -0
- package/observability/logs/session/hi-20260629-225719.json +59 -0
- package/observability/logs/session/hi-20260629-233722.json +52 -0
- package/observability/logs/session/hi-20260629-233913.json +198 -0
- package/observability/logs/session/hi-20260630-110156.json +177 -0
- package/observability/logs/session/hi-20260630-191243.json +184 -0
- package/observability/logs/session/hi-20260630-230050.json +234 -0
- package/observability/logs/session/hi-20260630-230523.json +227 -0
- package/observability/logs/session/hi-20260630-230855.json +227 -0
- package/observability/logs/session/hi-20260630-231638.json +227 -0
- package/observability/logs/session/hi-20260630-231756.json +219 -0
- package/observability/logs/session/hi-20260701-002842.json +234 -0
- package/observability/logs/session/hi-20260701-003458.json +282 -0
- package/observability/logs/session/hi-20260701-004233.json +290 -0
- package/observability/logs/session/hi-20260701-004554.json +236 -0
- package/observability/logs/session/hi-20260701-005641.json +290 -0
- package/observability/logs/session/hi-20260701-010450.json +290 -0
- package/observability/logs/session/hi-20260703-233854.json +312 -0
- package/observability/logs/session/hi-20260703-234448.json +318 -0
- package/observability/logs/session/hi-20260704-145907.json +353 -0
- package/observability/logs/session/hi-20260704-150141.json +392 -0
- package/observability/logs/session/hi-20260704-154448.json +392 -0
- package/observability/logs/session/iteration-value-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-005907.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260701-010747.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260704-150312.log +3 -0
- package/observability/logs/session/iteration-value-refresh-20260705-115453.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-004309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-005906.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260701-010745.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260704-150309.log +3 -0
- package/observability/logs/session/learning-loop-refresh-20260705-115450.log +3 -0
- package/observability/logs/session/project-notes-refresh-20260701-004227.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-004308.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005636.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-005906.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010443.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260701-010744.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150133.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-150309.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260704-154442.log +1 -0
- package/observability/logs/session/project-notes-refresh-20260705-115449.log +1 -0
- package/observability/logs/session/repo-intake-20260701-004218.log +6 -0
- package/observability/logs/session/repo-intake-20260701-005626.log +6 -0
- package/observability/logs/session/repo-intake-20260701-010433.log +6 -0
- package/observability/logs/session/repo-intake-20260704-150053.log +6 -0
- package/observability/logs/session/repo-intake-20260704-154404.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-004247.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-005847.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260701-010615.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260704-150209.log +6 -0
- package/observability/logs/session/repo-intake-refresh-20260705-115342.log +6 -0
- package/observability/logs/session/repo-registry-validation-20260701-004234.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-004556.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-005833.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260701-010601.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260704-150155.log +2 -0
- package/observability/logs/session/repo-registry-validation-20260705-115323.log +2 -0
- package/observability/logs/session/repomix-refresh-20260701-003823.log +4236 -0
- package/observability/logs/session/repomix-refresh-20260701-004251.log +4275 -0
- package/observability/logs/session/repomix-refresh-20260701-005850.log +4248 -0
- package/observability/logs/session/repomix-refresh-20260701-010619.log +6531 -0
- package/observability/logs/session/repomix-refresh-20260704-150239.log +652 -0
- package/observability/logs/session/repomix-refresh-20260705-115419.log +178 -0
- package/observability/logs/session/routing-evals-20260701-004221.log +2 -0
- package/observability/logs/session/routing-evals-20260701-004235.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005629.log +2 -0
- package/observability/logs/session/routing-evals-20260701-005834.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010437.log +2 -0
- package/observability/logs/session/routing-evals-20260701-010603.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150125.log +2 -0
- package/observability/logs/session/routing-evals-20260704-150157.log +2 -0
- package/observability/logs/session/routing-evals-20260704-154434.log +2 -0
- package/observability/logs/session/routing-evals-20260705-115327.log +2 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-004250.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-005850.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260701-010618.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260704-150238.log +3 -0
- package/observability/logs/session/sibling-discovery-refresh-20260705-115418.log +3 -0
- package/observability/logs.schema.json +95 -0
- package/observability/logs.schema.md +26 -0
- package/observability/metrics.md +35 -0
- package/observability/routing-evaluator.md +37 -0
- package/observability/scoring-rubric.md +38 -0
- package/optimization/ALWAYS_ON_OPTIMIZATION.md +98 -0
- package/optimization/caveman-mode.md +62 -0
- package/optimization/examples/login-bug.md +25 -0
- package/optimization/examples/sla-query.md +25 -0
- package/optimization/optimization-routing.md +30 -0
- package/optimization/policies/response-style.policy.md +45 -0
- package/optimization/policies/token-budget.policy.md +28 -0
- package/optimization/profiles/always-on.profile.md +19 -0
- package/optimization/profiles/architecture.profile.md +20 -0
- package/optimization/profiles/debug.profile.md +20 -0
- package/optimization/profiles/enterprise-rag.profile.md +20 -0
- package/optimization/profiles/training.profile.md +20 -0
- package/optimization/token-saver.md +58 -0
- package/orchestrator/corporate-routing.md +51 -0
- package/orchestrator/decision-matrix.md +33 -0
- package/orchestrator/fallback.md +29 -0
- package/orchestrator/repo-routing.md +58 -0
- package/orchestrator/router.md +75 -0
- package/orchestrator/wiki/__init__.py +5 -0
- package/orchestrator/wiki/graph_consolidator.py +506 -0
- package/orchestrator/wiki/incremental_engine.py +57 -0
- package/orchestrator/wiki/plugin_manager.py +40 -0
- package/package.json +70 -0
- package/policies/context-policy.md +25 -0
- package/policies/cost-policy.md +25 -0
- package/policies/repo-intake-policy.md +36 -0
- package/policies/security-policy.md +25 -0
- package/repo-intake/README.md +81 -0
- package/repo-intake/templates/agent.template.md +4 -0
- package/repo-intake/templates/context-manifest.template.md +4 -0
- package/repo-intake/templates/skill.template.md +3 -0
- package/repo-registry/repos.schema.json +102 -0
- package/repo-registry/repos.template.json +26 -0
- package/requirements.txt +1 -0
- package/scripts/README.md +109 -0
- package/scripts/__init__.py +0 -0
- package/scripts/bootstrap-portable.cmd +4 -0
- package/scripts/bootstrap-portable.ps1 +90 -0
- package/scripts/context/azure-rag-mcp-adapter.py +1 -0
- package/scripts/context/build-graphify.ps1 +1 -0
- package/scripts/context/build-repomix.ps1 +1 -0
- package/scripts/discovery/discover-boost-repos.cmd +4 -0
- package/scripts/discovery/discover-boost-repos.py +186 -0
- package/scripts/discovery/refresh-project-notes.py +179 -0
- package/scripts/github/INSTALL.md +295 -0
- package/scripts/github/README.md +455 -0
- package/scripts/github/apply-boost-templates.ps1 +163 -0
- package/scripts/github/apply-single-repo.ps1 +85 -0
- package/scripts/github/create-devlog.ps1 +380 -0
- package/scripts/github/manage-issues.ps1 +332 -0
- package/scripts/github/sync-repo.ps1 +267 -0
- package/scripts/intake/agent-pipeline-preflight.py +151 -0
- package/scripts/intake/init-template-registry.cmd +4 -0
- package/scripts/intake/init-template-registry.ps1 +258 -0
- package/scripts/intake/repo-intake.py +354 -0
- package/scripts/intake/resolve-routing.py +620 -0
- package/scripts/intake/run-repo-intake.cmd +4 -0
- package/scripts/intake/run-repo-intake.ps1 +46 -0
- package/scripts/intake/run-routing-evals.py +147 -0
- package/scripts/intake/validate-database-routing.py +91 -0
- package/scripts/intake/validate-rag-routing.py +85 -0
- package/scripts/intake/validate-repo-registry.ps1 +20 -0
- package/scripts/intake/validate-repo-registry.py +286 -0
- package/scripts/intake/validate-security.py +170 -0
- package/scripts/learning/autolearning-gate.py +71 -0
- package/scripts/learning/chat-token-usage-report.py +326 -0
- package/scripts/learning/ingest-copilot-session-usage.py +421 -0
- package/scripts/learning/iteration-value-report.py +275 -0
- package/scripts/learning/learning-loop-report.py +272 -0
- package/scripts/learning/record-iteration-metrics.py +116 -0
- package/scripts/learning/record-learning-feedback.py +91 -0
- package/scripts/ops/bye.ps1 +620 -0
- package/scripts/ops/compare-demo-results.ps1 +826 -0
- package/scripts/ops/demo1.ps1 +11 -0
- package/scripts/ops/demo2.ps1 +11 -0
- package/scripts/ops/demo3.ps1 +11 -0
- package/scripts/ops/demo4.ps1 +11 -0
- package/scripts/ops/hi.ps1 +1045 -0
- package/scripts/ops/llm-token-probe.py +164 -0
- package/scripts/ops/run-all-demos.ps1 +39 -0
- package/scripts/ops/run-demo-block.ps1 +85 -0
- package/scripts/ops/run-demo-session.ps1 +532 -0
- package/scripts/setup/optimize-engines.ps1 +183 -0
- package/scripts/setup/setup-codegraph.ps1 +3 -0
- package/scripts/setup/setup-gitnexus.ps1 +3 -0
- package/scripts/setup/setup-graphify.ps1 +2 -0
- package/scripts/setup/setup-prerequisites.ps1 +205 -0
- package/scripts/setup/start-gitnexus.ps1 +71 -0
- package/scripts/setup/validate-context.ps1 +361 -0
- package/scripts/wiki/__init__.py +0 -0
- package/scripts/wiki/compiler_main.py +189 -0
- package/scripts/wiki/normalizer.py +206 -0
- package/scripts/wiki/providers/base_provider.py +25 -0
- package/scripts/wiki/providers/codegraph_provider.py +49 -0
- package/scripts/wiki/providers/graphify_provider.py +49 -0
- package/scripts/wiki/providers/repo_content_provider.py +408 -0
- package/scripts/wiki/query_autodocs.py +60 -0
- package/scripts/wiki/validator.py +183 -0
- package/scripts/wiki/wiki_compiler.py +5 -0
- package/specs/architecture.spec.md +32 -0
- package/specs/azure-rag.spec.md +28 -0
- package/specs/coding-standards.spec.md +24 -0
- package/specs/database.spec.md +29 -0
- package/specs/migration.spec.md +26 -0
- package/specs/observability.spec.md +24 -0
- package/specs/optimization.spec.md +31 -0
- package/specs/rag.spec.md +30 -0
- package/specs/repo-intake.spec.md +25 -0
- package/specs/routing.spec.md +24 -0
- package/specs/security.spec.md +30 -0
- package/specs/wiki/provider-contract.json +33 -0
- package/specs/wiki/unified-knowledge-graph.json +25 -0
- package/templates/BOOST_README_TEMPLATE.md +96 -0
- package/templates/CODEOWNERS_TEMPLATE.txt +29 -0
- package/templates/LICENSE_MIT_TEMPLATE.txt +21 -0
- package/templates/PERSONAL_README_TEMPLATE.md +90 -0
- package/templates/README_boost_RAG_Azure.md +46 -0
- package/templates/README_boost_azure_iot_edge.md +48 -0
- package/templates/README_boost_backend.md +47 -0
- package/templates/README_boost_dba.md +57 -0
- package/templates/ci.yml.template +73 -0
- package/tooling/tooling.manifest.json +72 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[string]$ConfigPath = ".\projects\TSS2026\analysis_mcpee\demo-session.config.json",
|
|
3
|
+
[switch]$StopOnError,
|
|
4
|
+
[switch]$DryRun,
|
|
5
|
+
[switch]$ShowConsoleSummary = $true
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
Set-StrictMode -Version Latest
|
|
9
|
+
$ErrorActionPreference = 'Stop'
|
|
10
|
+
|
|
11
|
+
function Resolve-AbsolutePath {
|
|
12
|
+
param(
|
|
13
|
+
[string]$Path,
|
|
14
|
+
[string]$BasePath
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
if ([System.IO.Path]::IsPathRooted($Path)) {
|
|
18
|
+
return [System.IO.Path]::GetFullPath($Path)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [System.IO.Path]::GetFullPath((Join-Path $BasePath $Path))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function New-RunFolder {
|
|
25
|
+
param(
|
|
26
|
+
[string]$OutputRoot,
|
|
27
|
+
[string]$SessionName
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
|
31
|
+
$safeSession = ($SessionName.ToLowerInvariant() -replace '[^a-z0-9_-]+', '-') -replace '(^-|-$)', ''
|
|
32
|
+
$runFolder = Join-Path $OutputRoot ("{0}-{1}" -f $stamp, $safeSession)
|
|
33
|
+
New-Item -ItemType Directory -Path $runFolder -Force | Out-Null
|
|
34
|
+
return $runFolder
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Convert-ToNullableDouble {
|
|
38
|
+
param([string]$Value)
|
|
39
|
+
|
|
40
|
+
if ([string]::IsNullOrWhiteSpace($Value)) {
|
|
41
|
+
return $null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$normalized = $Value.Trim().Replace(',', '.')
|
|
45
|
+
$parsed = 0.0
|
|
46
|
+
if ([double]::TryParse($normalized, [System.Globalization.NumberStyles]::Float, [System.Globalization.CultureInfo]::InvariantCulture, [ref]$parsed)) {
|
|
47
|
+
return [double]$parsed
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return $null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function Get-PatternSum {
|
|
54
|
+
param(
|
|
55
|
+
[string]$Text,
|
|
56
|
+
[string]$Pattern
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
if ([string]::IsNullOrWhiteSpace($Text)) {
|
|
60
|
+
return $null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
$matches = [regex]::Matches($Text, $Pattern, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
|
64
|
+
if ($matches.Count -eq 0) {
|
|
65
|
+
return $null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
$sum = 0.0
|
|
69
|
+
$found = $false
|
|
70
|
+
foreach ($m in $matches) {
|
|
71
|
+
if ($m.Groups.Count -lt 2) {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
$n = Convert-ToNullableDouble -Value $m.Groups[1].Value
|
|
75
|
+
if ($null -ne $n) {
|
|
76
|
+
$sum += $n
|
|
77
|
+
$found = $true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (-not $found) {
|
|
82
|
+
return $null
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return [math]::Round($sum, 6)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function Get-TokenMetricsFromText {
|
|
89
|
+
param([string]$Text)
|
|
90
|
+
|
|
91
|
+
$prompt = Get-PatternSum -Text $Text -Pattern '(?:prompt_tokens|input_tokens)\s*[:=]\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
92
|
+
$context = Get-PatternSum -Text $Text -Pattern '(?:context_tokens)\s*[:=]\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
93
|
+
$response = Get-PatternSum -Text $Text -Pattern '(?:completion_tokens|output_tokens|response_tokens)\s*[:=]\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
94
|
+
$total = Get-PatternSum -Text $Text -Pattern '(?:total_tokens|tokens_total)\s*[:=]\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
95
|
+
$cost = Get-PatternSum -Text $Text -Pattern '(?:total_cost_usd|cost_estimated_usd|cost_usd|total_cost)\s*[:=]\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
96
|
+
|
|
97
|
+
$source = 'logs'
|
|
98
|
+
$probeStatusMatch = [regex]::Match(($Text ?? ''), '(?:probe_status)\s*[:=]\s*([^\r\n]+)', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
|
99
|
+
if ($probeStatusMatch.Success -and $probeStatusMatch.Groups.Count -gt 1) {
|
|
100
|
+
$source = ('probe-' + $probeStatusMatch.Groups[1].Value.Trim())
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Compatibility with RAG CLI output format: "Tokens: 1234"
|
|
104
|
+
if ($null -eq $total) {
|
|
105
|
+
$tokensAlt = Get-PatternSum -Text $Text -Pattern '(?:Tokens)\s*:\s*([0-9]+(?:[\.,][0-9]+)?)'
|
|
106
|
+
if ($null -ne $tokensAlt) {
|
|
107
|
+
$total = $tokensAlt
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if ($null -eq $prompt -and $null -eq $context -and $null -eq $response -and $null -eq $total -and $null -eq $cost) {
|
|
111
|
+
$source = 'logs-no-token-pattern'
|
|
112
|
+
$total = 0
|
|
113
|
+
$cost = 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return [ordered]@{
|
|
117
|
+
tokens_prompt = $prompt
|
|
118
|
+
tokens_context = $context
|
|
119
|
+
tokens_response = $response
|
|
120
|
+
tokens_total = $total
|
|
121
|
+
cost_estimated_usd = $cost
|
|
122
|
+
source = $source
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function Get-SumOrZero {
|
|
127
|
+
param([array]$Values)
|
|
128
|
+
|
|
129
|
+
if ($null -eq $Values -or $Values.Count -eq 0) {
|
|
130
|
+
return 0
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
$sum = (@($Values) | Measure-Object -Sum).Sum
|
|
134
|
+
if ($null -eq $sum) {
|
|
135
|
+
return 0
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return [double]$sum
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function Invoke-Step {
|
|
142
|
+
param(
|
|
143
|
+
[int]$Index,
|
|
144
|
+
[int]$Total,
|
|
145
|
+
[pscustomobject]$Step,
|
|
146
|
+
[string]$RunFolder,
|
|
147
|
+
[switch]$DryRun
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
$stepName = [string]$Step.name
|
|
151
|
+
$question = [string]$Step.question
|
|
152
|
+
$flow = @($Step.flow)
|
|
153
|
+
$workingDir = [string]$Step.working_dir
|
|
154
|
+
$command = [string]$Step.command
|
|
155
|
+
$timeoutSec = if ($null -ne $Step.timeout_sec) { [int]$Step.timeout_sec } else { 1800 }
|
|
156
|
+
$required = if ($null -ne $Step.required) { [bool]$Step.required } else { $true }
|
|
157
|
+
|
|
158
|
+
$safeStep = ($stepName.ToLowerInvariant() -replace '[^a-z0-9_-]+', '-') -replace '(^-|-$)', ''
|
|
159
|
+
$stdoutPath = Join-Path $RunFolder ("{0:D2}-{1}.stdout.log" -f $Index, $safeStep)
|
|
160
|
+
$stderrPath = Join-Path $RunFolder ("{0:D2}-{1}.stderr.log" -f $Index, $safeStep)
|
|
161
|
+
$combinedPath = Join-Path $RunFolder ("{0:D2}-{1}.log" -f $Index, $safeStep)
|
|
162
|
+
|
|
163
|
+
Write-Host ("[{0}/{1}] {2}" -f $Index, $Total, $stepName) -ForegroundColor Cyan
|
|
164
|
+
if (-not [string]::IsNullOrWhiteSpace($question)) {
|
|
165
|
+
Write-Host (" question: {0}" -f $question)
|
|
166
|
+
}
|
|
167
|
+
if ($flow.Count -gt 0) {
|
|
168
|
+
Write-Host (" flow: {0}" -f (($flow | ForEach-Object { [string]$_ }) -join ' -> '))
|
|
169
|
+
}
|
|
170
|
+
Write-Host (" dir: {0}" -f $workingDir)
|
|
171
|
+
Write-Host (" cmd: {0}" -f $command)
|
|
172
|
+
|
|
173
|
+
if ($DryRun) {
|
|
174
|
+
return [ordered]@{
|
|
175
|
+
name = $stepName
|
|
176
|
+
required = $required
|
|
177
|
+
status = 'dry-run'
|
|
178
|
+
exit_code = 0
|
|
179
|
+
started_at = (Get-Date).ToString('o')
|
|
180
|
+
ended_at = (Get-Date).ToString('o')
|
|
181
|
+
duration_sec = 0
|
|
182
|
+
question = $question
|
|
183
|
+
flow = @($flow)
|
|
184
|
+
working_dir = $workingDir
|
|
185
|
+
command = $command
|
|
186
|
+
stdout_log = $stdoutPath
|
|
187
|
+
stderr_log = $stderrPath
|
|
188
|
+
combined_log = $combinedPath
|
|
189
|
+
timeout_sec = $timeoutSec
|
|
190
|
+
expected_patterns = @($Step.expected_patterns)
|
|
191
|
+
missing_patterns = @()
|
|
192
|
+
token_metrics = [ordered]@{
|
|
193
|
+
tokens_prompt = $null
|
|
194
|
+
tokens_context = $null
|
|
195
|
+
tokens_response = $null
|
|
196
|
+
tokens_total = $null
|
|
197
|
+
cost_estimated_usd = $null
|
|
198
|
+
source = 'dry-run'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (-not (Test-Path $workingDir)) {
|
|
204
|
+
return [ordered]@{
|
|
205
|
+
name = $stepName
|
|
206
|
+
required = $required
|
|
207
|
+
status = 'failed'
|
|
208
|
+
exit_code = -1
|
|
209
|
+
started_at = (Get-Date).ToString('o')
|
|
210
|
+
ended_at = (Get-Date).ToString('o')
|
|
211
|
+
duration_sec = 0
|
|
212
|
+
question = $question
|
|
213
|
+
flow = @($flow)
|
|
214
|
+
working_dir = $workingDir
|
|
215
|
+
command = $command
|
|
216
|
+
stdout_log = $stdoutPath
|
|
217
|
+
stderr_log = $stderrPath
|
|
218
|
+
combined_log = $combinedPath
|
|
219
|
+
timeout_sec = $timeoutSec
|
|
220
|
+
expected_patterns = @($Step.expected_patterns)
|
|
221
|
+
missing_patterns = @("working_dir_not_found")
|
|
222
|
+
message = "Working directory does not exist"
|
|
223
|
+
token_metrics = [ordered]@{
|
|
224
|
+
tokens_prompt = $null
|
|
225
|
+
tokens_context = $null
|
|
226
|
+
tokens_response = $null
|
|
227
|
+
tokens_total = $null
|
|
228
|
+
cost_estimated_usd = $null
|
|
229
|
+
source = 'working-dir-missing'
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
$started = Get-Date
|
|
235
|
+
$proc = Start-Process -FilePath 'pwsh' -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', $command) -WorkingDirectory $workingDir -RedirectStandardOutput $stdoutPath -RedirectStandardError $stderrPath -PassThru
|
|
236
|
+
|
|
237
|
+
$timedOut = $false
|
|
238
|
+
try {
|
|
239
|
+
$null = $proc.WaitForExit($timeoutSec * 1000)
|
|
240
|
+
if (-not $proc.HasExited) {
|
|
241
|
+
$timedOut = $true
|
|
242
|
+
Stop-Process -Id $proc.Id -Force
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
if (-not $proc.HasExited) {
|
|
247
|
+
Stop-Process -Id $proc.Id -Force
|
|
248
|
+
}
|
|
249
|
+
throw
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
$ended = Get-Date
|
|
253
|
+
$durationSec = [math]::Round((($ended - $started).TotalSeconds), 2)
|
|
254
|
+
|
|
255
|
+
$stdoutText = if (Test-Path $stdoutPath) { Get-Content $stdoutPath -Raw } else { '' }
|
|
256
|
+
$stderrText = if (Test-Path $stderrPath) { Get-Content $stderrPath -Raw } else { '' }
|
|
257
|
+
|
|
258
|
+
Set-Content -Path $combinedPath -Value ($stdoutText + [Environment]::NewLine + $stderrText) -Encoding UTF8
|
|
259
|
+
$tokenMetrics = Get-TokenMetricsFromText -Text ($stdoutText + [Environment]::NewLine + $stderrText)
|
|
260
|
+
|
|
261
|
+
$exitCode = if ($timedOut) { -2 } else { $proc.ExitCode }
|
|
262
|
+
$status = if ($timedOut) { 'timeout' } elseif ($exitCode -eq 0) { 'ok' } else { 'failed' }
|
|
263
|
+
|
|
264
|
+
$expectedPatterns = @($Step.expected_patterns)
|
|
265
|
+
$missingPatterns = @()
|
|
266
|
+
if ($expectedPatterns.Count -gt 0) {
|
|
267
|
+
foreach ($pattern in $expectedPatterns) {
|
|
268
|
+
$found = Select-String -Path $combinedPath -Pattern [string]$pattern -SimpleMatch -Quiet
|
|
269
|
+
if (-not $found) {
|
|
270
|
+
$missingPatterns += [string]$pattern
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if ($missingPatterns.Count -gt 0 -and $status -eq 'ok') {
|
|
275
|
+
$status = 'failed'
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
Write-Host (" status: {0} (exit={1}, {2}s)" -f $status, $exitCode, $durationSec) -ForegroundColor $(if ($status -eq 'ok') { 'Green' } else { 'Red' })
|
|
280
|
+
|
|
281
|
+
return [ordered]@{
|
|
282
|
+
name = $stepName
|
|
283
|
+
required = $required
|
|
284
|
+
status = $status
|
|
285
|
+
exit_code = $exitCode
|
|
286
|
+
started_at = $started.ToString('o')
|
|
287
|
+
ended_at = $ended.ToString('o')
|
|
288
|
+
duration_sec = $durationSec
|
|
289
|
+
question = $question
|
|
290
|
+
flow = @($flow)
|
|
291
|
+
working_dir = $workingDir
|
|
292
|
+
command = $command
|
|
293
|
+
stdout_log = $stdoutPath
|
|
294
|
+
stderr_log = $stderrPath
|
|
295
|
+
combined_log = $combinedPath
|
|
296
|
+
timeout_sec = $timeoutSec
|
|
297
|
+
expected_patterns = $expectedPatterns
|
|
298
|
+
missing_patterns = $missingPatterns
|
|
299
|
+
timed_out = $timedOut
|
|
300
|
+
token_metrics = $tokenMetrics
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function Write-MarkdownReport {
|
|
305
|
+
param(
|
|
306
|
+
[string]$Path,
|
|
307
|
+
[pscustomobject]$Config,
|
|
308
|
+
[array]$Results,
|
|
309
|
+
[datetime]$Started,
|
|
310
|
+
[datetime]$Ended
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
$okCount = @($Results | Where-Object { $_.status -eq 'ok' }).Count
|
|
314
|
+
$failedCount = @($Results | Where-Object { $_.status -eq 'failed' -or $_.status -eq 'timeout' }).Count
|
|
315
|
+
$durationSec = [math]::Round((($Ended - $Started).TotalSeconds), 2)
|
|
316
|
+
|
|
317
|
+
$lines = @()
|
|
318
|
+
$lines += "# Demo Session Report"
|
|
319
|
+
$lines += ""
|
|
320
|
+
$lines += ("Session: {0}" -f $Config.session_name)
|
|
321
|
+
$lines += ("Started: {0}" -f $Started.ToString('o'))
|
|
322
|
+
$lines += ("Ended: {0}" -f $Ended.ToString('o'))
|
|
323
|
+
$lines += ("Duration (sec): {0}" -f $durationSec)
|
|
324
|
+
$lines += ("Steps OK: {0}" -f $okCount)
|
|
325
|
+
$lines += ("Steps Failed/Timeout: {0}" -f $failedCount)
|
|
326
|
+
$lines += ""
|
|
327
|
+
$lines += "## Step Summary"
|
|
328
|
+
$lines += ""
|
|
329
|
+
$lines += "| # | Step | Status | Exit | Seconds | Required |"
|
|
330
|
+
$lines += "|---|---|---|---:|---:|---|"
|
|
331
|
+
|
|
332
|
+
$index = 1
|
|
333
|
+
foreach ($result in $Results) {
|
|
334
|
+
$lines += ("| {0} | {1} | {2} | {3} | {4} | {5} |" -f $index, $result.name, $result.status, $result.exit_code, $result.duration_sec, $result.required)
|
|
335
|
+
$index++
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
$lines += ""
|
|
339
|
+
$lines += "## Guion Hablado (listo para demo en directo)"
|
|
340
|
+
$lines += ""
|
|
341
|
+
|
|
342
|
+
foreach ($result in $Results) {
|
|
343
|
+
$lines += ("### {0}" -f $result.name)
|
|
344
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$result.question)) {
|
|
345
|
+
$lines += ("- Pregunta: {0}" -f $result.question)
|
|
346
|
+
}
|
|
347
|
+
if (@($result.flow).Count -gt 0) {
|
|
348
|
+
$lines += ("- Flujo: {0}" -f ((@($result.flow) | ForEach-Object { [string]$_ }) -join ' -> '))
|
|
349
|
+
}
|
|
350
|
+
$lines += ("- Voy a hacer: {0}" -f $result.name)
|
|
351
|
+
$lines += ("- Vamos a lanzarlo: {0}" -f $result.command)
|
|
352
|
+
$lines += ("- Se ejecuta en: {0}" -f $result.working_dir)
|
|
353
|
+
|
|
354
|
+
if ($result.status -eq 'ok') {
|
|
355
|
+
$lines += "- Ha hecho: ejecucion correcta sin errores operativos."
|
|
356
|
+
$lines += "- Obtenemos este resultado: OK, bloque validado para continuar la historia."
|
|
357
|
+
}
|
|
358
|
+
elseif ($result.status -eq 'timeout') {
|
|
359
|
+
$lines += "- Ha hecho: se alcanzo el tiempo maximo definido para este bloque."
|
|
360
|
+
$lines += "- Obtenemos este resultado: TIMEOUT controlado; usamos logs para explicar causa y mitigacion."
|
|
361
|
+
}
|
|
362
|
+
elseif ($result.status -eq 'dry-run') {
|
|
363
|
+
$lines += "- Ha hecho: simulacion sin ejecucion real de comandos."
|
|
364
|
+
$lines += "- Obtenemos este resultado: checklist validado para correr la demo real."
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
$lines += "- Ha hecho: ejecucion con error controlado."
|
|
368
|
+
$lines += "- Obtenemos este resultado: FAIL con evidencia para comentar el aprendizaje y el plan de accion."
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
$lines += ("- Estado tecnico: {0} (exit={1}, {2}s)" -f $result.status, $result.exit_code, $result.duration_sec)
|
|
372
|
+
|
|
373
|
+
if ($result.missing_patterns.Count -gt 0) {
|
|
374
|
+
$lines += ("- Patrones esperados no encontrados: {0}" -f (($result.missing_patterns) -join ', '))
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
$lines += ("- Log combinado: {0}" -f $result.combined_log)
|
|
378
|
+
$lines += ""
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
Set-Content -Path $Path -Value $lines -Encoding UTF8
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
|
385
|
+
$configAbsPath = Resolve-AbsolutePath -Path $ConfigPath -BasePath $repoRoot
|
|
386
|
+
|
|
387
|
+
if (-not (Test-Path $configAbsPath)) {
|
|
388
|
+
throw "Config file not found: $configAbsPath"
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
$config = Get-Content $configAbsPath -Raw | ConvertFrom-Json -Depth 20
|
|
392
|
+
if ($null -eq $config.steps -or @($config.steps).Count -eq 0) {
|
|
393
|
+
throw "Config has no steps: $configAbsPath"
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
$outputRootRaw = if ([string]::IsNullOrWhiteSpace([string]$config.output_root)) {
|
|
397
|
+
'.\projects\TSS2026\analysis_mcpee\demo_runs'
|
|
398
|
+
} else {
|
|
399
|
+
[string]$config.output_root
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
$outputRoot = Resolve-AbsolutePath -Path $outputRootRaw -BasePath $repoRoot
|
|
403
|
+
New-Item -ItemType Directory -Path $outputRoot -Force | Out-Null
|
|
404
|
+
|
|
405
|
+
$sessionName = if ([string]::IsNullOrWhiteSpace([string]$config.session_name)) {
|
|
406
|
+
'demo-session'
|
|
407
|
+
} else {
|
|
408
|
+
[string]$config.session_name
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
$runFolder = New-RunFolder -OutputRoot $outputRoot -SessionName $sessionName
|
|
412
|
+
Write-Host ("Run folder: {0}" -f $runFolder) -ForegroundColor Yellow
|
|
413
|
+
|
|
414
|
+
$results = @()
|
|
415
|
+
$startedAt = Get-Date
|
|
416
|
+
$total = @($config.steps).Count
|
|
417
|
+
|
|
418
|
+
$index = 1
|
|
419
|
+
foreach ($step in $config.steps) {
|
|
420
|
+
$questionValue = ''
|
|
421
|
+
if ($step.PSObject.Properties.Name -contains 'question' -and $null -ne $step.question) {
|
|
422
|
+
$questionValue = [string]$step.question
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
$flowValue = @()
|
|
426
|
+
if ($step.PSObject.Properties.Name -contains 'flow' -and $null -ne $step.flow) {
|
|
427
|
+
$flowValue = @($step.flow)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
$stepObj = [pscustomobject]@{
|
|
431
|
+
name = [string]$step.name
|
|
432
|
+
question = $questionValue
|
|
433
|
+
flow = $flowValue
|
|
434
|
+
working_dir = Resolve-AbsolutePath -Path ([string]$step.working_dir) -BasePath $repoRoot
|
|
435
|
+
command = [string]$step.command
|
|
436
|
+
timeout_sec = if ($null -ne $step.timeout_sec) { [int]$step.timeout_sec } else { 1800 }
|
|
437
|
+
required = if ($null -ne $step.required) { [bool]$step.required } else { $true }
|
|
438
|
+
expected_patterns = @($step.expected_patterns)
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
$result = Invoke-Step -Index $index -Total $total -Step $stepObj -RunFolder $runFolder -DryRun:$DryRun
|
|
442
|
+
$results += [pscustomobject]$result
|
|
443
|
+
|
|
444
|
+
$shouldStop = $false
|
|
445
|
+
if ($result.status -ne 'ok' -and $result.required) {
|
|
446
|
+
if ($StopOnError -or ($config.stop_on_error -eq $true)) {
|
|
447
|
+
$shouldStop = $true
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if ($shouldStop) {
|
|
452
|
+
Write-Host "Stopping due to required step failure." -ForegroundColor Red
|
|
453
|
+
break
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
$index++
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
$endedAt = Get-Date
|
|
460
|
+
|
|
461
|
+
$summaryObj = [ordered]@{
|
|
462
|
+
session_name = $sessionName
|
|
463
|
+
config_path = $configAbsPath
|
|
464
|
+
run_folder = $runFolder
|
|
465
|
+
started_at = $startedAt.ToString('o')
|
|
466
|
+
ended_at = $endedAt.ToString('o')
|
|
467
|
+
duration_sec = [math]::Round((($endedAt - $startedAt).TotalSeconds), 2)
|
|
468
|
+
stop_on_error = [bool]($StopOnError -or ($config.stop_on_error -eq $true))
|
|
469
|
+
dry_run = [bool]$DryRun
|
|
470
|
+
steps_total = $total
|
|
471
|
+
steps_executed = @($results).Count
|
|
472
|
+
steps_ok = @($results | Where-Object { $_.status -eq 'ok' }).Count
|
|
473
|
+
steps_failed = @($results | Where-Object { $_.status -eq 'failed' }).Count
|
|
474
|
+
steps_timeout = @($results | Where-Object { $_.status -eq 'timeout' }).Count
|
|
475
|
+
steps_required_failed = @($results | Where-Object { $_.status -eq 'failed' -and $_.required -eq $true }).Count
|
|
476
|
+
steps_required_timeout = @($results | Where-Object { $_.status -eq 'timeout' -and $_.required -eq $true }).Count
|
|
477
|
+
token_metrics = [ordered]@{
|
|
478
|
+
tokens_prompt = [math]::Round((Get-SumOrZero -Values @($results | Where-Object { $null -ne $_.token_metrics -and $null -ne $_.token_metrics.tokens_prompt } | ForEach-Object { [double]$_.token_metrics.tokens_prompt })), 6)
|
|
479
|
+
tokens_context = [math]::Round((Get-SumOrZero -Values @($results | Where-Object { $null -ne $_.token_metrics -and $null -ne $_.token_metrics.tokens_context } | ForEach-Object { [double]$_.token_metrics.tokens_context })), 6)
|
|
480
|
+
tokens_response = [math]::Round((Get-SumOrZero -Values @($results | Where-Object { $null -ne $_.token_metrics -and $null -ne $_.token_metrics.tokens_response } | ForEach-Object { [double]$_.token_metrics.tokens_response })), 6)
|
|
481
|
+
tokens_total = [math]::Round((Get-SumOrZero -Values @($results | Where-Object { $null -ne $_.token_metrics -and $null -ne $_.token_metrics.tokens_total } | ForEach-Object { [double]$_.token_metrics.tokens_total })), 6)
|
|
482
|
+
cost_estimated_usd = [math]::Round((Get-SumOrZero -Values @($results | Where-Object { $null -ne $_.token_metrics -and $null -ne $_.token_metrics.cost_estimated_usd } | ForEach-Object { [double]$_.token_metrics.cost_estimated_usd })), 6)
|
|
483
|
+
source = if ($DryRun) { 'dry-run' } else { 'summary-from-step-logs' }
|
|
484
|
+
}
|
|
485
|
+
results = @($results)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
$jsonPath = Join-Path $runFolder 'summary.json'
|
|
489
|
+
$mdPath = Join-Path $runFolder 'summary.md'
|
|
490
|
+
|
|
491
|
+
$summaryObj | ConvertTo-Json -Depth 10 | Set-Content -Path $jsonPath -Encoding UTF8
|
|
492
|
+
Write-MarkdownReport -Path $mdPath -Config $config -Results $results -Started $startedAt -Ended $endedAt
|
|
493
|
+
|
|
494
|
+
Write-Host ''
|
|
495
|
+
Write-Host '=== DEMO SESSION SUMMARY ===' -ForegroundColor Cyan
|
|
496
|
+
Write-Host ("Session: {0}" -f $sessionName)
|
|
497
|
+
Write-Host ("Steps executed: {0}/{1}" -f $summaryObj.steps_executed, $summaryObj.steps_total)
|
|
498
|
+
Write-Host ("OK={0}, Failed={1}, Timeout={2}" -f $summaryObj.steps_ok, $summaryObj.steps_failed, $summaryObj.steps_timeout)
|
|
499
|
+
Write-Host ("JSON: {0}" -f $jsonPath)
|
|
500
|
+
Write-Host ("MD: {0}" -f $mdPath)
|
|
501
|
+
|
|
502
|
+
if ($ShowConsoleSummary) {
|
|
503
|
+
Write-Host ''
|
|
504
|
+
Write-Host '=== SPEAKER SUMMARY ===' -ForegroundColor Yellow
|
|
505
|
+
foreach ($result in $results) {
|
|
506
|
+
$line = "- {0}: {1} (exit={2}, {3}s)" -f $result.name, $result.status, $result.exit_code, $result.duration_sec
|
|
507
|
+
Write-Host $line
|
|
508
|
+
if (-not [string]::IsNullOrWhiteSpace([string]$result.question)) {
|
|
509
|
+
Write-Host (" pregunta: {0}" -f $result.question)
|
|
510
|
+
}
|
|
511
|
+
if (@($result.flow).Count -gt 0) {
|
|
512
|
+
Write-Host (" flujo: {0}" -f ((@($result.flow) | ForEach-Object { [string]$_ }) -join ' -> '))
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
Write-Host ''
|
|
516
|
+
Write-Host 'Summary file content:' -ForegroundColor Yellow
|
|
517
|
+
if (Test-Path $mdPath) {
|
|
518
|
+
Get-Content -Path $mdPath
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if ($summaryObj.steps_required_failed -gt 0 -or $summaryObj.steps_required_timeout -gt 0) {
|
|
523
|
+
Write-Host ''
|
|
524
|
+
Write-Host '=== FIN EJECUCION: TERMINADO CON INCIDENCIAS ===' -ForegroundColor Red
|
|
525
|
+
Write-Host ('Resultado final (pasos requeridos): FAILED={0}, TIMEOUT={1}. Revisa summary.md y logs.' -f $summaryObj.steps_required_failed, $summaryObj.steps_required_timeout)
|
|
526
|
+
exit 1
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
Write-Host ''
|
|
530
|
+
Write-Host '=== FIN EJECUCION: TERMINADO OK ===' -ForegroundColor Green
|
|
531
|
+
Write-Host 'Resultado final: todos los pasos completados correctamente.'
|
|
532
|
+
exit 0
|