aios-core 4.2.15 → 4.4.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/.aios-core/cli/commands/validate/index.js +1 -1
- package/.aios-core/core/code-intel/code-intel-client.js +19 -5
- package/.aios-core/core/code-intel/helpers/creation-helper.js +183 -0
- package/.aios-core/core/code-intel/helpers/devops-helper.js +166 -0
- package/.aios-core/core/code-intel/helpers/planning-helper.js +248 -0
- package/.aios-core/core/code-intel/helpers/qa-helper.js +187 -0
- package/.aios-core/core/code-intel/helpers/story-helper.js +146 -0
- package/.aios-core/core/code-intel/hook-runtime.js +186 -0
- package/.aios-core/core/code-intel/index.js +2 -0
- package/.aios-core/core/code-intel/providers/code-graph-provider.js +8 -0
- package/.aios-core/core/code-intel/providers/provider-interface.js +9 -0
- package/.aios-core/core/code-intel/providers/registry-provider.js +515 -0
- package/.aios-core/core/config/schemas/framework-config.schema.json +155 -7
- package/.aios-core/core/config/schemas/project-config.schema.json +329 -15
- package/.aios-core/core/config/template-overrides.js +84 -0
- package/.aios-core/core/docs/troubleshooting-guide.md +1 -1
- package/.aios-core/core/doctor/checks/agent-memory.js +63 -0
- package/.aios-core/core/doctor/checks/claude-md.js +56 -0
- package/.aios-core/core/doctor/checks/code-intel.js +131 -0
- package/.aios-core/core/doctor/checks/commands-count.js +81 -0
- package/.aios-core/core/doctor/checks/core-config.js +53 -0
- package/.aios-core/core/doctor/checks/entity-registry.js +53 -0
- package/.aios-core/core/doctor/checks/git-hooks.js +50 -0
- package/.aios-core/core/doctor/checks/graph-dashboard.js +48 -0
- package/.aios-core/core/doctor/checks/hooks-claude-count.js +118 -0
- package/.aios-core/core/doctor/checks/ide-sync.js +85 -0
- package/.aios-core/core/doctor/checks/index.js +46 -0
- package/.aios-core/core/doctor/checks/node-version.js +33 -0
- package/.aios-core/core/doctor/checks/npm-packages.js +35 -0
- package/.aios-core/core/doctor/checks/rules-files.js +61 -0
- package/.aios-core/core/doctor/checks/settings-json.js +121 -0
- package/.aios-core/core/doctor/checks/skills-count.js +72 -0
- package/.aios-core/core/doctor/fix-handler.js +165 -0
- package/.aios-core/core/doctor/formatters/json.js +14 -0
- package/.aios-core/core/doctor/formatters/text.js +59 -0
- package/.aios-core/core/doctor/index.js +94 -0
- package/.aios-core/core/graph-dashboard/cli.js +361 -0
- package/.aios-core/core/graph-dashboard/data-sources/code-intel-source.js +234 -0
- package/.aios-core/core/graph-dashboard/data-sources/metrics-source.js +95 -0
- package/.aios-core/core/graph-dashboard/data-sources/registry-source.js +106 -0
- package/.aios-core/core/graph-dashboard/formatters/dot-formatter.js +45 -0
- package/.aios-core/core/graph-dashboard/formatters/html-formatter.js +1437 -0
- package/.aios-core/core/graph-dashboard/formatters/json-formatter.js +13 -0
- package/.aios-core/core/graph-dashboard/formatters/mermaid-formatter.js +59 -0
- package/.aios-core/core/graph-dashboard/index.js +21 -0
- package/.aios-core/core/graph-dashboard/renderers/stats-renderer.js +217 -0
- package/.aios-core/core/graph-dashboard/renderers/status-renderer.js +125 -0
- package/.aios-core/core/graph-dashboard/renderers/tree-renderer.js +119 -0
- package/.aios-core/core/health-check/base-check.js +1 -1
- package/.aios-core/core/health-check/check-registry.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/build-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/ci-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/deployment-readiness.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/docker-config.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/env-file.js +1 -1
- package/.aios-core/core/health-check/checks/deployment/index.js +1 -1
- package/.aios-core/core/health-check/checks/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/disk-space.js +1 -1
- package/.aios-core/core/health-check/checks/local/environment-vars.js +1 -1
- package/.aios-core/core/health-check/checks/local/git-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/ide-detection.js +1 -1
- package/.aios-core/core/health-check/checks/local/index.js +1 -1
- package/.aios-core/core/health-check/checks/local/memory.js +1 -1
- package/.aios-core/core/health-check/checks/local/network.js +1 -1
- package/.aios-core/core/health-check/checks/local/npm-install.js +1 -1
- package/.aios-core/core/health-check/checks/local/shell-environment.js +1 -1
- package/.aios-core/core/health-check/checks/project/agent-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/aios-directory.js +1 -1
- package/.aios-core/core/health-check/checks/project/dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/project/framework-config.js +1 -1
- package/.aios-core/core/health-check/checks/project/index.js +1 -1
- package/.aios-core/core/health-check/checks/project/node-version.js +1 -1
- package/.aios-core/core/health-check/checks/project/package-json.js +1 -1
- package/.aios-core/core/health-check/checks/project/task-definitions.js +1 -1
- package/.aios-core/core/health-check/checks/project/workflow-dependencies.js +1 -1
- package/.aios-core/core/health-check/checks/repository/branch-protection.js +1 -1
- package/.aios-core/core/health-check/checks/repository/commit-history.js +1 -1
- package/.aios-core/core/health-check/checks/repository/conflicts.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-repo.js +1 -1
- package/.aios-core/core/health-check/checks/repository/git-status.js +1 -1
- package/.aios-core/core/health-check/checks/repository/gitignore.js +1 -1
- package/.aios-core/core/health-check/checks/repository/index.js +1 -1
- package/.aios-core/core/health-check/checks/repository/large-files.js +1 -1
- package/.aios-core/core/health-check/checks/repository/lockfile-integrity.js +1 -1
- package/.aios-core/core/health-check/checks/services/api-endpoints.js +1 -1
- package/.aios-core/core/health-check/checks/services/claude-code.js +1 -1
- package/.aios-core/core/health-check/checks/services/gemini-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/github-cli.js +1 -1
- package/.aios-core/core/health-check/checks/services/index.js +1 -1
- package/.aios-core/core/health-check/checks/services/mcp-integration.js +1 -1
- package/.aios-core/core/health-check/engine.js +1 -1
- package/.aios-core/core/health-check/healers/backup-manager.js +1 -1
- package/.aios-core/core/health-check/healers/index.js +1 -1
- package/.aios-core/core/health-check/index.js +9 -2
- package/.aios-core/core/health-check/reporters/console.js +1 -1
- package/.aios-core/core/health-check/reporters/index.js +1 -1
- package/.aios-core/core/health-check/reporters/json.js +1 -1
- package/.aios-core/core/health-check/reporters/markdown.js +1 -1
- package/.aios-core/core/ids/layer-classifier.js +65 -0
- package/.aios-core/core/ids/registry-updater.js +49 -0
- package/.aios-core/core/index.esm.js +1 -1
- package/.aios-core/core/index.js +1 -1
- package/.aios-core/core/session/context-detector.js +2 -7
- package/.aios-core/core/synapse/context/context-tracker.js +9 -1
- package/.aios-core/core/synapse/engine.js +33 -13
- package/.aios-core/core/synapse/memory/memory-bridge.js +17 -43
- package/.aios-core/core/synapse/memory/synapse-memory-provider.js +201 -0
- package/.aios-core/core/synapse/runtime/hook-runtime.js +40 -2
- package/.aios-core/core/synapse/session/session-manager.js +3 -2
- package/.aios-core/core/synapse/utils/atomic-write.js +79 -0
- package/.aios-core/core-config.yaml +34 -1
- package/.aios-core/data/aios-kb.md +2 -2
- package/.aios-core/data/capability-detection.js +290 -0
- package/.aios-core/data/entity-registry.yaml +10450 -2129
- package/.aios-core/data/mcp-discipline.js +166 -0
- package/.aios-core/data/mcp-tool-examples.yaml +215 -0
- package/.aios-core/data/tok2-validation.js +168 -0
- package/.aios-core/data/tok3-token-comparison.js +123 -0
- package/.aios-core/data/tool-registry.yaml +648 -0
- package/.aios-core/data/tool-search-validation.js +174 -0
- package/.aios-core/data/workflow-chains.yaml +156 -0
- package/.aios-core/development/agents/aios-master.md +17 -10
- package/.aios-core/development/agents/analyst/MEMORY.md +33 -0
- package/.aios-core/development/agents/analyst.md +17 -10
- package/.aios-core/development/agents/architect/MEMORY.md +39 -0
- package/.aios-core/development/agents/architect.md +17 -10
- package/.aios-core/development/agents/data-engineer/MEMORY.md +32 -0
- package/.aios-core/development/agents/data-engineer.md +17 -10
- package/.aios-core/development/agents/dev/MEMORY.md +46 -0
- package/.aios-core/development/agents/dev.md +18 -11
- package/.aios-core/development/agents/devops/MEMORY.md +39 -0
- package/.aios-core/development/agents/devops.md +44 -10
- package/.aios-core/development/agents/pm/MEMORY.md +38 -0
- package/.aios-core/development/agents/pm.md +17 -10
- package/.aios-core/development/agents/po/MEMORY.md +45 -0
- package/.aios-core/development/agents/po.md +17 -10
- package/.aios-core/development/agents/qa/MEMORY.md +42 -0
- package/.aios-core/development/agents/qa.md +18 -11
- package/.aios-core/development/agents/sm/MEMORY.md +31 -0
- package/.aios-core/development/agents/sm.md +17 -10
- package/.aios-core/development/agents/squad-creator.md +18 -9
- package/.aios-core/development/agents/ux/MEMORY.md +31 -0
- package/.aios-core/development/agents/ux-design-expert.md +16 -9
- package/.aios-core/development/checklists/issue-triage-checklist.md +35 -0
- package/.aios-core/development/checklists/memory-audit-checklist.md +53 -0
- package/.aios-core/development/scripts/issue-triage.js +171 -0
- package/.aios-core/development/scripts/populate-entity-registry.js +412 -19
- package/.aios-core/development/scripts/unified-activation-pipeline.js +31 -10
- package/.aios-core/development/tasks/analyze-project-structure.md +48 -0
- package/.aios-core/development/tasks/apply-qa-fixes.md +7 -0
- package/.aios-core/development/tasks/architect-analyze-impact.md +8 -1
- package/.aios-core/development/tasks/brownfield-create-epic.md +41 -0
- package/.aios-core/development/tasks/brownfield-create-story.md +7 -0
- package/.aios-core/development/tasks/build-autonomous.md +7 -0
- package/.aios-core/development/tasks/create-deep-research-prompt.md +7 -0
- package/.aios-core/development/tasks/create-doc.md +44 -0
- package/.aios-core/development/tasks/create-next-story.md +17 -0
- package/.aios-core/development/tasks/create-suite.md +7 -0
- package/.aios-core/development/tasks/dev-develop-story.md +9 -1
- package/.aios-core/development/tasks/execute-checklist.md +7 -0
- package/.aios-core/development/tasks/github-devops-github-pr-automation.md +56 -0
- package/.aios-core/development/tasks/github-devops-pre-push-quality-gate.md +70 -0
- package/.aios-core/development/tasks/github-issue-triage.md +118 -0
- package/.aios-core/development/tasks/health-check.yaml +206 -171
- package/.aios-core/development/tasks/kb-mode-interaction.md +3 -3
- package/.aios-core/development/tasks/plan-create-context.md +47 -1
- package/.aios-core/development/tasks/plan-create-implementation.md +55 -0
- package/.aios-core/development/tasks/po-close-story.md +7 -0
- package/.aios-core/development/tasks/pr-automation.md +5 -5
- package/.aios-core/development/tasks/qa-create-fix-request.md +7 -0
- package/.aios-core/development/tasks/qa-fix-issues.md +7 -0
- package/.aios-core/development/tasks/qa-gate.md +56 -0
- package/.aios-core/development/tasks/qa-review-story.md +32 -1
- package/.aios-core/development/tasks/release-management.md +7 -0
- package/.aios-core/development/tasks/resolve-github-issue.md +608 -0
- package/.aios-core/development/tasks/review-contributor-pr.md +152 -0
- package/.aios-core/development/tasks/setup-llm-routing.md +1 -1
- package/.aios-core/development/tasks/spec-critique.md +8 -0
- package/.aios-core/development/tasks/spec-gather-requirements.md +7 -0
- package/.aios-core/development/tasks/spec-research-dependencies.md +4 -0
- package/.aios-core/development/tasks/spec-write-spec.md +5 -0
- package/.aios-core/development/tasks/triage-github-issues.md +356 -0
- package/.aios-core/development/tasks/validate-agents.md +4 -0
- package/.aios-core/development/tasks/validate-next-story.md +17 -0
- package/.aios-core/development/templates/agent-handoff-tmpl.yaml +48 -0
- package/.aios-core/development/templates/code-intel-integration-pattern.md +199 -0
- package/.aios-core/development/templates/ptc-entity-validation.md +113 -0
- package/.aios-core/development/templates/ptc-qa-gate.md +100 -0
- package/.aios-core/development/templates/ptc-research-aggregation.md +94 -0
- package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
- package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
- package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
- package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
- package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
- package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
- package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
- package/.aios-core/development/templates/squad/agent-template.md +11 -0
- package/.aios-core/development/templates/squad/task-template.md +21 -0
- package/.aios-core/development/templates/squad-template/LICENSE +21 -21
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-COMPLETE.md +1 -1
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.2-SUMMARY.md +1 -1
- package/.aios-core/framework-config.yaml +8 -0
- package/.aios-core/index.esm.js +1 -1
- package/.aios-core/index.js +1 -1
- package/.aios-core/infrastructure/integrations/ai-providers/index.js +1 -1
- package/.aios-core/infrastructure/schemas/task-v3-schema.json +6 -0
- package/.aios-core/infrastructure/scripts/collect-tool-usage.js +311 -0
- package/.aios-core/infrastructure/scripts/generate-optimization-report.js +497 -0
- package/.aios-core/infrastructure/scripts/generate-settings-json.js +300 -0
- package/.aios-core/infrastructure/scripts/git-config-detector.js +65 -9
- package/.aios-core/infrastructure/scripts/ide-sync/index.js +3 -1
- package/.aios-core/infrastructure/scripts/ide-sync/transformers/github-copilot.js +184 -0
- package/.aios-core/infrastructure/scripts/repository-detector.js +3 -3
- package/.aios-core/infrastructure/templates/aios-sync.yaml.template +182 -182
- package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
- package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
- package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
- package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
- package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
- package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
- package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
- package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
- package/.aios-core/install-manifest.yaml +613 -305
- package/.aios-core/lib/build.json +1 -0
- package/.aios-core/local-config.yaml.template +71 -71
- package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
- package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
- package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
- package/.aios-core/monitor/hooks/notification.py +29 -29
- package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
- package/.aios-core/monitor/hooks/pre_compact.py +29 -29
- package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
- package/.aios-core/monitor/hooks/stop.py +29 -29
- package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
- package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
- package/.aios-core/product/templates/adr.hbs +125 -125
- package/.aios-core/product/templates/dbdr.hbs +241 -241
- package/.aios-core/product/templates/epic.hbs +212 -212
- package/.aios-core/product/templates/ide-rules/claude-rules.md +125 -0
- package/.aios-core/product/templates/pmdr.hbs +186 -186
- package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
- package/.aios-core/product/templates/prd.hbs +201 -201
- package/.aios-core/product/templates/story.hbs +263 -263
- package/.aios-core/product/templates/task.hbs +170 -170
- package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
- package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
- package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
- package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
- package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
- package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
- package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
- package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
- package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
- package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
- package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
- package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
- package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
- package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
- package/.aios-core/product/templates/tmpl-view.sql +177 -177
- package/.aios-core/scripts/pm.sh +0 -0
- package/.aios-core/user-guide.md +15 -15
- package/.aios-core/utils/filters/constants.js +10 -0
- package/.aios-core/utils/filters/content-filter.js +223 -0
- package/.aios-core/utils/filters/field-filter.js +126 -0
- package/.aios-core/utils/filters/index.js +180 -0
- package/.aios-core/utils/filters/schema-filter.js +157 -0
- package/.claude/CLAUDE.md +62 -0
- package/.claude/hooks/enforce-architecture-first.py +196 -196
- package/.claude/hooks/enforce-git-push-authority.sh +33 -0
- package/.claude/hooks/mind-clone-governance.py +192 -192
- package/.claude/hooks/read-protection.py +151 -151
- package/.claude/hooks/slug-validation.py +176 -176
- package/.claude/hooks/sql-governance.py +182 -182
- package/.claude/hooks/synapse-engine.cjs +28 -5
- package/.claude/hooks/write-path-validation.py +194 -194
- package/.claude/rules/agent-authority.md +105 -0
- package/.claude/rules/agent-handoff.md +97 -0
- package/.claude/rules/agent-memory-imports.md +15 -0
- package/.claude/rules/coderabbit-integration.md +101 -0
- package/.claude/rules/ids-principles.md +119 -0
- package/.claude/rules/story-lifecycle.md +145 -0
- package/.claude/rules/tool-examples.md +64 -0
- package/.claude/rules/tool-response-filtering.md +57 -0
- package/.claude/rules/workflow-execution.md +150 -0
- package/LICENSE +33 -33
- package/bin/aios-graph.js +9 -0
- package/bin/aios-init.js +2 -2
- package/bin/aios-minimal.js +0 -0
- package/bin/aios.js +17 -221
- package/bin/utils/detect-fsmonitor.js +70 -0
- package/bin/utils/framework-guard.js +238 -0
- package/bin/utils/validate-publish.js +108 -0
- package/package.json +6 -3
- package/packages/aios-install/bin/aios-install.js +0 -0
- package/packages/aios-install/bin/edmcp.js +0 -0
- package/packages/aios-pro-cli/bin/aios-pro.js +2 -0
- package/packages/installer/src/config/templates/core-config-template.js +25 -0
- package/packages/installer/src/installer/brownfield-upgrader.js +68 -5
- package/packages/installer/src/merger/index.js +3 -0
- package/packages/installer/src/merger/strategies/index.js +6 -0
- package/packages/installer/src/merger/strategies/yaml-merger.js +181 -0
- package/packages/installer/src/updater/index.js +4 -4
- package/packages/installer/src/wizard/i18n.js +321 -3
- package/packages/installer/src/wizard/ide-config-generator.js +173 -25
- package/packages/installer/src/wizard/index.js +119 -1
- package/packages/installer/src/wizard/pro-setup.js +137 -121
- package/packages/installer/tests/unit/artifact-copy-pipeline/artifact-copy-pipeline.test.js +271 -0
- package/packages/installer/tests/unit/claude-md-template-v5/claude-md-template-v5.test.js +192 -0
- package/packages/installer/tests/unit/doctor/doctor-checks.test.js +610 -0
- package/packages/installer/tests/unit/doctor/doctor-orchestrator.test.js +134 -0
- package/packages/installer/tests/unit/entity-registry-bootstrap.test.js +186 -0
- package/packages/installer/tests/unit/generate-settings-json/generate-settings-json.test.js +309 -0
- package/packages/installer/tests/unit/ide-sync-integration/ide-sync-integration.test.js +230 -0
- package/packages/installer/tests/unit/merger/strategies.test.js +2 -2
- package/packages/installer/tests/unit/merger/yaml-merger.test.js +327 -0
- package/scripts/check-markdown-links.py +352 -352
- package/scripts/dashboard-parallel-dev.sh +0 -0
- package/scripts/dashboard-parallel-phase3.sh +0 -0
- package/scripts/dashboard-parallel-phase4.sh +0 -0
- package/scripts/install-monitor-hooks.sh +0 -0
- package/scripts/package-synapse.js +2 -1
- package/pro/README.md +0 -66
- package/pro/license/degradation.js +0 -220
- package/pro/license/errors.js +0 -450
- package/pro/license/feature-gate.js +0 -354
- package/pro/license/index.js +0 -181
- package/pro/license/license-api.js +0 -651
- package/pro/license/license-cache.js +0 -523
- package/pro/license/license-crypto.js +0 -303
package/.aios-core/user-guide.md
CHANGED
|
@@ -34,7 +34,7 @@ O AIOS-FullStack oferece instalação simplificada através de um instalador int
|
|
|
34
34
|
cd /path/to/your/project
|
|
35
35
|
|
|
36
36
|
# Execute o instalador (versão RC atual)
|
|
37
|
-
npx
|
|
37
|
+
npx aios-core@latest install
|
|
38
38
|
|
|
39
39
|
# OU usando NPM direto (produção - quando disponível)
|
|
40
40
|
npx @aios/fullstack install
|
|
@@ -82,13 +82,13 @@ Se você está contribuindo para o AIOS-FullStack em si:
|
|
|
82
82
|
```bash
|
|
83
83
|
# Clone o repositório
|
|
84
84
|
git clone https://github.com/SynkraAI/aios-core
|
|
85
|
-
cd
|
|
85
|
+
cd aios-core
|
|
86
86
|
|
|
87
87
|
# Instale dependências
|
|
88
88
|
npm install
|
|
89
89
|
|
|
90
90
|
# Execute o instalador no modo desenvolvimento
|
|
91
|
-
npx
|
|
91
|
+
npx aios-core@latest install
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
### Estrutura Pós-Instalação
|
|
@@ -131,10 +131,10 @@ Se você já tem AIOS instalado e quer fazer upgrade:
|
|
|
131
131
|
|
|
132
132
|
```bash
|
|
133
133
|
# Upgrade automático (RC.9+)
|
|
134
|
-
npx
|
|
134
|
+
npx aios-core@latest install --force-upgrade
|
|
135
135
|
|
|
136
136
|
# OU interativo (todos os RCs)
|
|
137
|
-
npx
|
|
137
|
+
npx aios-core@latest install
|
|
138
138
|
# → Menu aparece:
|
|
139
139
|
# 1. Keep current version (v1.0.0-rc.8)
|
|
140
140
|
# 2. Upgrade AIOS core (v1.0.0-rc.8 → v1.0.0-rc.10)
|
|
@@ -146,18 +146,18 @@ npx @synkra/aios-core@latest install
|
|
|
146
146
|
|
|
147
147
|
```bash
|
|
148
148
|
# Ver versão disponível no NPM
|
|
149
|
-
npm view
|
|
149
|
+
npm view aios-core@latest version
|
|
150
150
|
# Output: 1.0.0-rc.10
|
|
151
151
|
|
|
152
152
|
# Ver opções de instalação e comandos disponíveis
|
|
153
|
-
npx
|
|
153
|
+
npx aios-core@latest --help
|
|
154
154
|
|
|
155
155
|
# Ver squads instalados
|
|
156
156
|
# Use o wizard de instalação para selecionar/visualizar squads disponíveis
|
|
157
|
-
npx
|
|
157
|
+
npx aios-core@latest install
|
|
158
158
|
|
|
159
159
|
# Ajuda do instalador
|
|
160
|
-
npx
|
|
160
|
+
npx aios-core@latest install --help
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
### 🚀 Futuro: Modo de Instalação Explícito (Story 3.14)
|
|
@@ -201,7 +201,7 @@ npx aios init
|
|
|
201
201
|
npm cache clean --force
|
|
202
202
|
|
|
203
203
|
# Usar versão específica
|
|
204
|
-
npx
|
|
204
|
+
npx aios-core@1.0.0-rc.10 install --force-upgrade
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
**Problema**: Agents/tasks não instalados
|
|
@@ -210,7 +210,7 @@ npx @synkra/aios-core@1.0.0-rc.10 install --force-upgrade
|
|
|
210
210
|
|
|
211
211
|
**Solução**: Usar RC.8 ou superior
|
|
212
212
|
```bash
|
|
213
|
-
npx
|
|
213
|
+
npx aios-core@latest install
|
|
214
214
|
```
|
|
215
215
|
|
|
216
216
|
**Problema**: Versão GitHub (4.31.1) detectada como mais nova que RC
|
|
@@ -219,7 +219,7 @@ npx @synkra/aios-core@latest install
|
|
|
219
219
|
|
|
220
220
|
**Solução**: Escolher "Upgrade" ou usar `--force-upgrade`
|
|
221
221
|
```bash
|
|
222
|
-
npx
|
|
222
|
+
npx aios-core@latest install --force-upgrade
|
|
223
223
|
# Migra de v4.31.1 para v1.0.0-rc.10 (novo scheme)
|
|
224
224
|
```
|
|
225
225
|
|
|
@@ -813,7 +813,7 @@ O agente @github-devops funciona com QUALQUER repositório git:
|
|
|
813
813
|
|
|
814
814
|
**Modo Framework Development** (futuro):
|
|
815
815
|
```bash
|
|
816
|
-
# No repositório
|
|
816
|
+
# No repositório aios-core
|
|
817
817
|
@github-devops
|
|
818
818
|
*detect-repo
|
|
819
819
|
# Output:
|
|
@@ -1289,7 +1289,7 @@ O Synkra AIOS suporta squads para domínios específicos:
|
|
|
1289
1289
|
**Configurar squads na instalação**:
|
|
1290
1290
|
```bash
|
|
1291
1291
|
# Durante a instalação, o wizard pergunta quais squads instalar
|
|
1292
|
-
npx
|
|
1292
|
+
npx aios-core@latest install
|
|
1293
1293
|
|
|
1294
1294
|
# O wizard mostra:
|
|
1295
1295
|
# 📦 Select Squads to Install:
|
|
@@ -1302,7 +1302,7 @@ npx @synkra/aios-core@latest install
|
|
|
1302
1302
|
**Adicionar squads depois**:
|
|
1303
1303
|
```bash
|
|
1304
1304
|
# Re-execute o instalador
|
|
1305
|
-
npx
|
|
1305
|
+
npx aios-core@latest install
|
|
1306
1306
|
|
|
1307
1307
|
# Escolha "Configure IDE settings" ou "Upgrade"
|
|
1308
1308
|
# Wizard permitirá adicionar squads não instalados
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// constants.js — Shared constants for filter modules
|
|
3
|
+
// =============================================================================
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
/** Approximate characters per token (~4 chars for English text) */
|
|
8
|
+
const CHARS_PER_TOKEN = 4;
|
|
9
|
+
|
|
10
|
+
module.exports = { CHARS_PER_TOKEN };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// content-filter.js — Content-type filter for MCP tool responses
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Extracts main content from HTML/text, strips noise (nav, ads, boilerplate),
|
|
5
|
+
// and truncates to max_tokens at a natural boundary.
|
|
6
|
+
//
|
|
7
|
+
// Usage (stdin):
|
|
8
|
+
// echo '{"content":"<html>...</html>"}' | node content-filter.js --max-tokens 2000
|
|
9
|
+
//
|
|
10
|
+
// Usage (file):
|
|
11
|
+
// node content-filter.js --input response.json --max-tokens 2000
|
|
12
|
+
//
|
|
13
|
+
// Usage (programmatic):
|
|
14
|
+
// const { filterContent } = require('./content-filter');
|
|
15
|
+
// const result = filterContent(inputData, { max_tokens: 2000, extract: ['title'] });
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const { CHARS_PER_TOKEN } = require('./constants');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Strip HTML tags and extract text content.
|
|
25
|
+
* Removes script, style, nav, footer, header, aside elements first.
|
|
26
|
+
* @param {string} html - Raw HTML string
|
|
27
|
+
* @returns {string} Clean text content
|
|
28
|
+
*/
|
|
29
|
+
function stripHtml(html) {
|
|
30
|
+
if (typeof html !== 'string') return String(html || '');
|
|
31
|
+
|
|
32
|
+
// Remove noise elements entirely (content + tags)
|
|
33
|
+
const noisePatterns = [
|
|
34
|
+
/<script[\s\S]*?<\/script>/gi,
|
|
35
|
+
/<style[\s\S]*?<\/style>/gi,
|
|
36
|
+
/<nav[\s\S]*?<\/nav>/gi,
|
|
37
|
+
/<footer[\s\S]*?<\/footer>/gi,
|
|
38
|
+
/<header[\s\S]*?<\/header>/gi,
|
|
39
|
+
/<aside[\s\S]*?<\/aside>/gi,
|
|
40
|
+
/<noscript[\s\S]*?<\/noscript>/gi,
|
|
41
|
+
/<!--[\s\S]*?-->/g,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
let clean = html;
|
|
45
|
+
for (const pattern of noisePatterns) {
|
|
46
|
+
clean = clean.replace(pattern, '');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Replace block elements with newlines
|
|
50
|
+
clean = clean.replace(/<\/?(div|p|br|h[1-6]|li|tr|td|th|blockquote|pre|section|article)[^>]*>/gi, '\n');
|
|
51
|
+
|
|
52
|
+
// Remove remaining HTML tags
|
|
53
|
+
clean = clean.replace(/<[^>]+>/g, '');
|
|
54
|
+
|
|
55
|
+
// Decode common HTML entities
|
|
56
|
+
clean = clean
|
|
57
|
+
.replace(/&/g, '&')
|
|
58
|
+
.replace(/</g, '<')
|
|
59
|
+
.replace(/>/g, '>')
|
|
60
|
+
.replace(/"/g, '"')
|
|
61
|
+
.replace(/'/g, "'")
|
|
62
|
+
.replace(/ /g, ' ');
|
|
63
|
+
|
|
64
|
+
// Normalize whitespace: collapse multiple blank lines
|
|
65
|
+
clean = clean.replace(/\n{3,}/g, '\n\n').trim();
|
|
66
|
+
|
|
67
|
+
return clean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Truncate text to approximately max_tokens at a natural boundary.
|
|
72
|
+
* @param {string} text - Text to truncate
|
|
73
|
+
* @param {number} maxTokens - Approximate token limit
|
|
74
|
+
* @returns {string} Truncated text
|
|
75
|
+
*/
|
|
76
|
+
function truncateAtBoundary(text, maxTokens) {
|
|
77
|
+
const maxChars = maxTokens * CHARS_PER_TOKEN;
|
|
78
|
+
|
|
79
|
+
if (text.length <= maxChars) return text;
|
|
80
|
+
|
|
81
|
+
// Find last paragraph break before limit
|
|
82
|
+
const slice = text.slice(0, maxChars);
|
|
83
|
+
const lastParagraph = slice.lastIndexOf('\n\n');
|
|
84
|
+
if (lastParagraph > maxChars * 0.5) {
|
|
85
|
+
return slice.slice(0, lastParagraph).trim() + '\n\n[...truncated]';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Fall back to last sentence
|
|
89
|
+
const lastSentence = slice.lastIndexOf('. ');
|
|
90
|
+
if (lastSentence > maxChars * 0.5) {
|
|
91
|
+
return slice.slice(0, lastSentence + 1).trim() + '\n\n[...truncated]';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Hard truncate
|
|
95
|
+
return slice.trim() + '\n\n[...truncated]';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Extract specified fields from an object.
|
|
100
|
+
* @param {Object} data - Source object
|
|
101
|
+
* @param {string[]} fields - Fields to extract
|
|
102
|
+
* @returns {Object} Object with only extracted fields
|
|
103
|
+
*/
|
|
104
|
+
function extractFields(data, fields) {
|
|
105
|
+
if (!data || typeof data !== 'object' || !Array.isArray(fields)) return data;
|
|
106
|
+
|
|
107
|
+
const result = {};
|
|
108
|
+
for (const field of fields) {
|
|
109
|
+
if (field in data) {
|
|
110
|
+
result[field] = data[field];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Apply content filter to input data.
|
|
118
|
+
* @param {string|Object} input - Raw input (string or parsed JSON)
|
|
119
|
+
* @param {Object} options - Filter options
|
|
120
|
+
* @param {number} [options.max_tokens=3000] - Token limit
|
|
121
|
+
* @param {string[]} [options.extract] - Fields to extract before content filtering
|
|
122
|
+
* @returns {{ filtered: string, original_length: number, filtered_length: number, reduction_pct: number }}
|
|
123
|
+
*/
|
|
124
|
+
function filterContent(input, options = {}) {
|
|
125
|
+
const maxTokens = options.max_tokens || 3000;
|
|
126
|
+
const extractList = options.extract || null;
|
|
127
|
+
|
|
128
|
+
let raw = input;
|
|
129
|
+
|
|
130
|
+
// If input is an object, extract fields first or stringify
|
|
131
|
+
if (typeof raw === 'object' && raw !== null) {
|
|
132
|
+
if (extractList) {
|
|
133
|
+
if (Array.isArray(raw)) {
|
|
134
|
+
raw = raw.map((item) => extractFields(item, extractList));
|
|
135
|
+
raw = JSON.stringify(raw, null, 2);
|
|
136
|
+
} else {
|
|
137
|
+
raw = extractFields(raw, extractList);
|
|
138
|
+
raw = JSON.stringify(raw, null, 2);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
raw = raw.content || raw.text || raw.body || JSON.stringify(raw, null, 2);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (typeof raw !== 'string') raw = String(raw || '');
|
|
146
|
+
|
|
147
|
+
const originalLength = raw.length;
|
|
148
|
+
|
|
149
|
+
// Strip HTML if it looks like HTML
|
|
150
|
+
let content = raw;
|
|
151
|
+
if (content.includes('<') && content.includes('>')) {
|
|
152
|
+
content = stripHtml(content);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Truncate to token limit
|
|
156
|
+
content = truncateAtBoundary(content, maxTokens);
|
|
157
|
+
|
|
158
|
+
const filteredLength = content.length;
|
|
159
|
+
const reductionPct = originalLength > 0
|
|
160
|
+
? Math.round((1 - filteredLength / originalLength) * 100)
|
|
161
|
+
: 0;
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
filtered: content,
|
|
165
|
+
original_length: originalLength,
|
|
166
|
+
filtered_length: filteredLength,
|
|
167
|
+
reduction_pct: reductionPct,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// CLI entrypoint
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
function parseArgs(argv) {
|
|
175
|
+
const args = {};
|
|
176
|
+
for (let i = 2; i < argv.length; i++) {
|
|
177
|
+
if (argv[i] === '--max-tokens' && argv[i + 1]) {
|
|
178
|
+
args.max_tokens = parseInt(argv[i + 1], 10);
|
|
179
|
+
i++;
|
|
180
|
+
} else if (argv[i] === '--input' && argv[i + 1]) {
|
|
181
|
+
args.input = argv[i + 1];
|
|
182
|
+
i++;
|
|
183
|
+
} else if (argv[i] === '--extract' && argv[i + 1]) {
|
|
184
|
+
args.extract = argv[i + 1].split(',');
|
|
185
|
+
i++;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return args;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function main() {
|
|
192
|
+
const args = parseArgs(process.argv);
|
|
193
|
+
|
|
194
|
+
let inputData;
|
|
195
|
+
if (args.input) {
|
|
196
|
+
inputData = fs.readFileSync(args.input, 'utf8');
|
|
197
|
+
} else if (!process.stdin.isTTY) {
|
|
198
|
+
inputData = fs.readFileSync(0, 'utf8');
|
|
199
|
+
} else {
|
|
200
|
+
console.error('Usage: echo \'data\' | node content-filter.js --max-tokens 2000');
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
inputData = JSON.parse(inputData);
|
|
206
|
+
} catch (_) {
|
|
207
|
+
// treat as raw text
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const result = filterContent(inputData, {
|
|
211
|
+
max_tokens: args.max_tokens,
|
|
212
|
+
extract: args.extract,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
console.log(JSON.stringify(result, null, 2));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Run CLI if executed directly
|
|
219
|
+
if (require.main === module) {
|
|
220
|
+
main();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
module.exports = { filterContent, stripHtml, truncateAtBoundary, extractFields, CHARS_PER_TOKEN };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// field-filter.js — Field-type filter for MCP tool responses (array data)
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Projects specified columns from arrays of objects and limits row count.
|
|
5
|
+
// Analogous to SQL: SELECT field1, field2 FROM data LIMIT max_rows
|
|
6
|
+
//
|
|
7
|
+
// Usage (stdin):
|
|
8
|
+
// echo '[{"a":1,"b":2,"c":3}]' | node field-filter.js --fields a,b --max-rows 10
|
|
9
|
+
//
|
|
10
|
+
// Usage (programmatic):
|
|
11
|
+
// const { filterFields } = require('./field-filter');
|
|
12
|
+
// const result = filterFields(data, { fields: ['a','b'], max_rows: 10 });
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Apply field filter to array data.
|
|
21
|
+
* @param {Object[]} input - Array of objects
|
|
22
|
+
* @param {Object} options - Filter options
|
|
23
|
+
* @param {string[]} options.fields - Columns to project
|
|
24
|
+
* @param {number} [options.max_rows] - Maximum rows to include
|
|
25
|
+
* @returns {{ filtered: Object[], original_length: number, filtered_length: number, reduction_pct: number, rows_original: number, rows_filtered: number }}
|
|
26
|
+
*/
|
|
27
|
+
function filterFields(input, options = {}) {
|
|
28
|
+
const fields = options.fields || [];
|
|
29
|
+
const maxRows = options.max_rows || Infinity;
|
|
30
|
+
|
|
31
|
+
// Ensure input is an array
|
|
32
|
+
const data = Array.isArray(input) ? input : [input];
|
|
33
|
+
|
|
34
|
+
const originalSerialized = JSON.stringify(data, null, 2);
|
|
35
|
+
const originalLength = originalSerialized.length;
|
|
36
|
+
const rowsOriginal = data.length;
|
|
37
|
+
|
|
38
|
+
// Limit rows
|
|
39
|
+
const sliced = data.slice(0, maxRows);
|
|
40
|
+
|
|
41
|
+
// Project fields
|
|
42
|
+
let filtered;
|
|
43
|
+
if (fields.length > 0) {
|
|
44
|
+
filtered = sliced.map((item) => {
|
|
45
|
+
if (!item || typeof item !== 'object') return item;
|
|
46
|
+
const projected = {};
|
|
47
|
+
for (const field of fields) {
|
|
48
|
+
if (field in item) {
|
|
49
|
+
projected[field] = item[field];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return projected;
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
filtered = sliced;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const filteredSerialized = JSON.stringify(filtered, null, 2);
|
|
59
|
+
const filteredLength = filteredSerialized.length;
|
|
60
|
+
const reductionPct = originalLength > 0
|
|
61
|
+
? Math.round((1 - filteredLength / originalLength) * 100)
|
|
62
|
+
: 0;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
filtered,
|
|
66
|
+
original_length: originalLength,
|
|
67
|
+
filtered_length: filteredLength,
|
|
68
|
+
reduction_pct: reductionPct,
|
|
69
|
+
rows_original: rowsOriginal,
|
|
70
|
+
rows_filtered: filtered.length,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// CLI entrypoint
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
function parseArgs(argv) {
|
|
78
|
+
const args = {};
|
|
79
|
+
for (let i = 2; i < argv.length; i++) {
|
|
80
|
+
if (argv[i] === '--fields' && argv[i + 1]) {
|
|
81
|
+
args.fields = argv[i + 1].split(',');
|
|
82
|
+
i++;
|
|
83
|
+
} else if (argv[i] === '--max-rows' && argv[i + 1]) {
|
|
84
|
+
args.max_rows = parseInt(argv[i + 1], 10);
|
|
85
|
+
i++;
|
|
86
|
+
} else if (argv[i] === '--input' && argv[i + 1]) {
|
|
87
|
+
args.input = argv[i + 1];
|
|
88
|
+
i++;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return args;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function main() {
|
|
95
|
+
const args = parseArgs(process.argv);
|
|
96
|
+
|
|
97
|
+
let inputData;
|
|
98
|
+
if (args.input) {
|
|
99
|
+
inputData = fs.readFileSync(args.input, 'utf8');
|
|
100
|
+
} else if (!process.stdin.isTTY) {
|
|
101
|
+
inputData = fs.readFileSync(0, 'utf8');
|
|
102
|
+
} else {
|
|
103
|
+
console.error('Usage: echo \'[{"a":1}]\' | node field-filter.js --fields a --max-rows 10');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
inputData = JSON.parse(inputData);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.error('Error: Input must be valid JSON.', err.message);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const result = filterFields(inputData, {
|
|
115
|
+
fields: args.fields,
|
|
116
|
+
max_rows: args.max_rows,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
console.log(JSON.stringify(result, null, 2));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (require.main === module) {
|
|
123
|
+
main();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { filterFields };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// index.js — Filter engine entry point
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Reads tool-registry.yaml, looks up filter config for a given tool,
|
|
5
|
+
// and dispatches to the appropriate filter (content, schema, field).
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// node .aios-core/utils/filters/index.js --tool exa --input response.json
|
|
9
|
+
// echo '{"data":"..."}' | node .aios-core/utils/filters/index.js --tool exa
|
|
10
|
+
//
|
|
11
|
+
// Programmatic:
|
|
12
|
+
// const { applyFilter, loadFilterConfig } = require('./index');
|
|
13
|
+
// const result = applyFilter('exa', inputData);
|
|
14
|
+
// =============================================================================
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const { filterContent } = require('./content-filter');
|
|
21
|
+
const { filterSchema } = require('./schema-filter');
|
|
22
|
+
const { filterFields } = require('./field-filter');
|
|
23
|
+
|
|
24
|
+
// Registry path relative to project root
|
|
25
|
+
const REGISTRY_PATH = path.join(__dirname, '..', '..', 'data', 'tool-registry.yaml');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Load filter configuration for a tool from tool-registry.yaml.
|
|
29
|
+
* @param {string} toolName - Tool name (case-sensitive, matches registry key)
|
|
30
|
+
* @param {string} [registryPath] - Override registry path (for testing)
|
|
31
|
+
* @returns {Object|null} Filter config or null if not found
|
|
32
|
+
*/
|
|
33
|
+
function loadFilterConfig(toolName, registryPath) {
|
|
34
|
+
const regPath = registryPath || REGISTRY_PATH;
|
|
35
|
+
|
|
36
|
+
let yaml;
|
|
37
|
+
try {
|
|
38
|
+
yaml = require('js-yaml');
|
|
39
|
+
} catch (_) {
|
|
40
|
+
// js-yaml not available — try yaml package
|
|
41
|
+
try {
|
|
42
|
+
yaml = require('yaml');
|
|
43
|
+
const content = fs.readFileSync(regPath, 'utf8');
|
|
44
|
+
const registry = yaml.parse(content);
|
|
45
|
+
const tool = registry.tools && registry.tools[toolName];
|
|
46
|
+
return (tool && tool.filter) || null;
|
|
47
|
+
} catch (__) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const content = fs.readFileSync(regPath, 'utf8');
|
|
54
|
+
const registry = yaml.load(content);
|
|
55
|
+
const tool = registry.tools && registry.tools[toolName];
|
|
56
|
+
return (tool && tool.filter) || null;
|
|
57
|
+
} catch (_) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Apply the appropriate filter to input data based on tool's registry config.
|
|
64
|
+
* @param {string} toolName - Tool name
|
|
65
|
+
* @param {*} input - Input data (string, object, or array)
|
|
66
|
+
* @param {Object} [overrideConfig] - Override filter config (skip registry lookup)
|
|
67
|
+
* @param {string} [registryPath] - Override registry path
|
|
68
|
+
* @returns {{ filtered: *, original_length: number, filtered_length: number, reduction_pct: number, filter_type: string }}
|
|
69
|
+
*/
|
|
70
|
+
function applyFilter(toolName, input, overrideConfig, registryPath) {
|
|
71
|
+
const config = overrideConfig || loadFilterConfig(toolName, registryPath);
|
|
72
|
+
|
|
73
|
+
if (!config) {
|
|
74
|
+
// No filter config — pass through
|
|
75
|
+
const serialized = typeof input === 'string' ? input : JSON.stringify(input, null, 2);
|
|
76
|
+
return {
|
|
77
|
+
filtered: input,
|
|
78
|
+
original_length: serialized.length,
|
|
79
|
+
filtered_length: serialized.length,
|
|
80
|
+
reduction_pct: 0,
|
|
81
|
+
filter_type: 'none',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const filterType = config.type;
|
|
86
|
+
|
|
87
|
+
switch (filterType) {
|
|
88
|
+
case 'content':
|
|
89
|
+
return {
|
|
90
|
+
...filterContent(input, {
|
|
91
|
+
max_tokens: config.max_tokens,
|
|
92
|
+
extract: config.extract,
|
|
93
|
+
}),
|
|
94
|
+
filter_type: 'content',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
case 'schema':
|
|
98
|
+
return {
|
|
99
|
+
...filterSchema(input, {
|
|
100
|
+
fields: config.fields,
|
|
101
|
+
max_tokens: config.max_tokens,
|
|
102
|
+
}),
|
|
103
|
+
filter_type: 'schema',
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
case 'field':
|
|
107
|
+
return {
|
|
108
|
+
...filterFields(input, {
|
|
109
|
+
fields: config.fields,
|
|
110
|
+
max_rows: config.max_rows,
|
|
111
|
+
}),
|
|
112
|
+
filter_type: 'field',
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
default:
|
|
116
|
+
// Unknown filter type — pass through
|
|
117
|
+
const serialized = typeof input === 'string' ? input : JSON.stringify(input, null, 2);
|
|
118
|
+
return {
|
|
119
|
+
filtered: input,
|
|
120
|
+
original_length: serialized.length,
|
|
121
|
+
filtered_length: serialized.length,
|
|
122
|
+
reduction_pct: 0,
|
|
123
|
+
filter_type: 'unknown',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
// CLI entrypoint
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
function parseArgs(argv) {
|
|
132
|
+
const args = {};
|
|
133
|
+
for (let i = 2; i < argv.length; i++) {
|
|
134
|
+
if (argv[i] === '--tool' && argv[i + 1]) {
|
|
135
|
+
args.tool = argv[i + 1];
|
|
136
|
+
i++;
|
|
137
|
+
} else if (argv[i] === '--input' && argv[i + 1]) {
|
|
138
|
+
args.input = argv[i + 1];
|
|
139
|
+
i++;
|
|
140
|
+
} else if (argv[i] === '--registry' && argv[i + 1]) {
|
|
141
|
+
args.registry = argv[i + 1];
|
|
142
|
+
i++;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return args;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function main() {
|
|
149
|
+
const args = parseArgs(process.argv);
|
|
150
|
+
|
|
151
|
+
if (!args.tool) {
|
|
152
|
+
console.error('Usage: node index.js --tool <tool-name> [--input <file>] [--registry <path>]');
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let inputData;
|
|
157
|
+
if (args.input) {
|
|
158
|
+
inputData = fs.readFileSync(args.input, 'utf8');
|
|
159
|
+
} else if (!process.stdin.isTTY) {
|
|
160
|
+
inputData = fs.readFileSync(0, 'utf8');
|
|
161
|
+
} else {
|
|
162
|
+
console.error('Error: Provide input via --input file or stdin pipe.');
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
inputData = JSON.parse(inputData);
|
|
168
|
+
} catch (_) {
|
|
169
|
+
// treat as raw text
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const result = applyFilter(args.tool, inputData, null, args.registry);
|
|
173
|
+
console.log(JSON.stringify(result, null, 2));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (require.main === module) {
|
|
177
|
+
main();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
module.exports = { applyFilter, loadFilterConfig };
|