@jaimevalasek/aioson 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/LICENSE +661 -21
- package/README.md +9 -1
- package/docs/design-previews/aurora-command-ui-website.html +884 -0
- package/docs/design-previews/aurora-command-ui.html +682 -0
- package/docs/design-previews/bold-editorial-ui-website.html +658 -0
- package/docs/design-previews/bold-editorial-ui.html +717 -0
- package/docs/design-previews/clean-saas-ui-website.html +1202 -0
- package/docs/design-previews/clean-saas-ui.html +549 -0
- package/docs/design-previews/cognitive-core-ui-website.html +1009 -0
- package/docs/design-previews/cognitive-core-ui.html +463 -0
- package/docs/design-previews/glassmorphism-ui-website.html +572 -0
- package/docs/design-previews/glassmorphism-ui.html +886 -0
- package/docs/design-previews/index.html +699 -0
- package/docs/design-previews/interface-design-website.html +1187 -0
- package/docs/design-previews/interface-design.html +513 -0
- package/docs/design-previews/neo-brutalist-ui-website.html +621 -0
- package/docs/design-previews/neo-brutalist-ui.html +797 -0
- package/docs/design-previews/premium-command-center-ui-website.html +1217 -0
- package/docs/design-previews/premium-command-center-ui.html +552 -0
- package/docs/design-previews/warm-craft-ui-website.html +684 -0
- package/docs/design-previews/warm-craft-ui.html +739 -0
- package/docs/en/cli-reference.md +20 -9
- package/docs/en/squad-dashboard.md +372 -0
- package/docs/openclaw-bridge.md +308 -0
- package/docs/pt/README.md +7 -0
- package/docs/pt/agent-sharding.md +132 -0
- package/docs/pt/agentes.md +131 -11
- package/docs/pt/busca-de-contexto.md +129 -0
- package/docs/pt/cache-de-contexto.md +156 -0
- package/docs/pt/cenarios.md +46 -2
- package/docs/pt/comandos-cli.md +88 -1
- package/docs/pt/design-hybrid-forge.md +107 -0
- package/docs/pt/inicio-rapido.md +72 -5
- package/docs/pt/inteligencia-adaptativa.md +324 -0
- package/docs/pt/monitor-de-contexto.md +104 -0
- package/docs/pt/recuperacao-de-sessao.md +125 -0
- package/docs/pt/sandbox.md +125 -0
- package/docs/pt/skills.md +98 -6
- package/docs/pt/squad-dashboard.md +373 -0
- package/docs/testing/genome-2.0-matrix.md +5 -5
- package/docs/testing/genome-2.0-rollout.md +9 -9
- package/package.json +2 -2
- package/src/agent-loader.js +280 -0
- package/src/backup-local.js +74 -0
- package/src/cli.js +192 -0
- package/src/commands/agent-loader.js +85 -0
- package/src/commands/backup-local-cmd.js +25 -0
- package/src/commands/context-cache.js +90 -0
- package/src/commands/context-monitor.js +92 -0
- package/src/commands/context-search.js +66 -0
- package/src/commands/design-hybrid-options.js +385 -0
- package/src/commands/health.js +214 -0
- package/src/commands/init.js +54 -13
- package/src/commands/install.js +52 -13
- package/src/commands/learning-evolve.js +355 -0
- package/src/commands/live.js +34 -0
- package/src/commands/recovery.js +43 -0
- package/src/commands/runtime.js +242 -0
- package/src/commands/sandbox.js +37 -0
- package/src/commands/setup-context.js +29 -4
- package/src/commands/setup.js +178 -0
- package/src/commands/skill.js +79 -32
- package/src/commands/squad-daemon.js +209 -0
- package/src/commands/squad-dashboard.js +39 -0
- package/src/commands/squad-deploy.js +64 -0
- package/src/commands/squad-doctor.js +52 -0
- package/src/commands/squad-mcp.js +270 -0
- package/src/commands/squad-processes.js +56 -0
- package/src/commands/squad-recovery.js +42 -0
- package/src/commands/squad-roi.js +291 -0
- package/src/commands/squad-score.js +250 -0
- package/src/commands/squad-status.js +37 -1
- package/src/commands/squad-validate.js +62 -1
- package/src/commands/squad-webhook.js +160 -0
- package/src/commands/squad-worker.js +191 -0
- package/src/commands/squad-worktrees.js +75 -0
- package/src/commands/tool-registry-cmd.js +232 -0
- package/src/commands/update.js +7 -0
- package/src/commands/web-map.js +70 -0
- package/src/commands/web-scrape.js +71 -0
- package/src/constants.js +17 -0
- package/src/context-cache.js +159 -0
- package/src/context-search.js +326 -0
- package/src/context-writer.js +45 -1
- package/src/design-variation-catalog.js +503 -0
- package/src/i18n/messages/en.js +159 -3
- package/src/i18n/messages/es.js +147 -2
- package/src/i18n/messages/fr.js +147 -2
- package/src/i18n/messages/pt-BR.js +158 -3
- package/src/install-animation.js +260 -0
- package/src/install-profile.js +143 -0
- package/src/install-wizard.js +474 -0
- package/src/installer.js +38 -10
- package/src/lib/webhook-server.js +328 -0
- package/src/mcp-connectors/registry.js +602 -0
- package/src/parser.js +7 -1
- package/src/recovery-context-session.js +154 -0
- package/src/runtime-store.js +355 -2
- package/src/sandbox.js +177 -0
- package/src/squad/external-session.js +180 -0
- package/src/squad/inter-squad.js +74 -0
- package/src/squad/recovery-context.js +201 -0
- package/src/squad/worktree-manager.js +114 -0
- package/src/squad-daemon.js +490 -0
- package/src/squad-dashboard/api.js +223 -0
- package/src/squad-dashboard/attachment-handler.js +93 -0
- package/src/squad-dashboard/context-monitor.js +157 -0
- package/src/squad-dashboard/execution-logs.js +115 -0
- package/src/squad-dashboard/hunk-review.js +209 -0
- package/src/squad-dashboard/metrics.js +133 -0
- package/src/squad-dashboard/process-monitor.js +125 -0
- package/src/squad-dashboard/renderer.js +858 -0
- package/src/squad-dashboard/server.js +232 -0
- package/src/squad-dashboard/styles.js +525 -0
- package/src/squad-dashboard/token-tracker.js +99 -0
- package/src/tool-executor.js +94 -0
- package/src/updater.js +11 -3
- package/src/web.js +284 -0
- package/src/worker-runner.js +339 -0
- package/template/.aioson/agents/analyst.md +62 -3
- package/template/.aioson/agents/architect.md +42 -0
- package/template/.aioson/agents/design-hybrid-forge.md +127 -0
- package/template/.aioson/agents/dev.md +223 -11
- package/template/.aioson/agents/deyvin.md +65 -0
- package/template/.aioson/agents/neo.md +152 -0
- package/template/.aioson/agents/orache.md +17 -0
- package/template/.aioson/agents/orchestrator.md +26 -0
- package/template/.aioson/agents/pm.md +58 -0
- package/template/.aioson/agents/product.md +88 -12
- package/template/.aioson/agents/qa.md +80 -0
- package/template/.aioson/agents/setup.md +128 -22
- package/template/.aioson/agents/sheldon.md +704 -0
- package/template/.aioson/agents/squad.md +191 -0
- package/template/.aioson/agents/tester.md +410 -0
- package/template/.aioson/agents/ux-ui.md +12 -0
- package/template/.aioson/config.md +21 -0
- package/template/.aioson/context/forensics/.gitkeep +0 -0
- package/template/.aioson/context/seeds/seed-example.md +27 -0
- package/template/.aioson/context/user-profile.md +42 -0
- package/template/.aioson/locales/en/agents/analyst.md +8 -0
- package/template/.aioson/locales/en/agents/architect.md +8 -0
- package/template/.aioson/locales/en/agents/dev.md +66 -7
- package/template/.aioson/locales/en/agents/deyvin.md +8 -0
- package/template/.aioson/locales/en/agents/neo.md +8 -0
- package/template/.aioson/locales/en/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/en/agents/qa.md +49 -0
- package/template/.aioson/locales/en/agents/setup.md +35 -2
- package/template/.aioson/locales/en/agents/sheldon.md +340 -0
- package/template/.aioson/locales/en/agents/ux-ui.md +8 -0
- package/template/.aioson/locales/es/agents/analyst.md +8 -0
- package/template/.aioson/locales/es/agents/architect.md +8 -0
- package/template/.aioson/locales/es/agents/dev.md +66 -7
- package/template/.aioson/locales/es/agents/deyvin.md +8 -0
- package/template/.aioson/locales/es/agents/neo.md +48 -0
- package/template/.aioson/locales/es/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/es/agents/qa.md +26 -0
- package/template/.aioson/locales/es/agents/setup.md +35 -2
- package/template/.aioson/locales/es/agents/sheldon.md +192 -0
- package/template/.aioson/locales/es/agents/squad.md +63 -0
- package/template/.aioson/locales/es/agents/ux-ui.md +8 -0
- package/template/.aioson/locales/fr/agents/analyst.md +8 -0
- package/template/.aioson/locales/fr/agents/architect.md +8 -0
- package/template/.aioson/locales/fr/agents/dev.md +66 -7
- package/template/.aioson/locales/fr/agents/deyvin.md +8 -0
- package/template/.aioson/locales/fr/agents/neo.md +48 -0
- package/template/.aioson/locales/fr/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/fr/agents/qa.md +26 -0
- package/template/.aioson/locales/fr/agents/setup.md +35 -2
- package/template/.aioson/locales/fr/agents/sheldon.md +192 -0
- package/template/.aioson/locales/fr/agents/squad.md +63 -0
- package/template/.aioson/locales/fr/agents/ux-ui.md +8 -0
- package/template/.aioson/locales/pt-BR/agents/analyst.md +19 -0
- package/template/.aioson/locales/pt-BR/agents/architect.md +19 -0
- package/template/.aioson/locales/pt-BR/agents/dev.md +75 -12
- package/template/.aioson/locales/pt-BR/agents/deyvin.md +8 -0
- package/template/.aioson/locales/pt-BR/agents/neo.md +147 -0
- package/template/.aioson/locales/pt-BR/agents/orchestrator.md +26 -0
- package/template/.aioson/locales/pt-BR/agents/product.md +8 -3
- package/template/.aioson/locales/pt-BR/agents/qa.md +60 -0
- package/template/.aioson/locales/pt-BR/agents/setup.md +35 -2
- package/template/.aioson/locales/pt-BR/agents/sheldon.md +192 -0
- package/template/.aioson/locales/pt-BR/agents/squad.md +105 -0
- package/template/.aioson/locales/pt-BR/agents/ux-ui.md +8 -0
- package/template/.aioson/schemas/squad-blueprint.schema.json +21 -0
- package/template/.aioson/schemas/squad-manifest.schema.json +178 -1
- package/template/.aioson/skills/design/aurora-command-ui/SKILL.md +243 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/art-direction.md +293 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/components.md +827 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/dashboards.md +250 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/design-tokens.md +585 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/motion.md +365 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/patterns.md +482 -0
- package/template/.aioson/skills/design/aurora-command-ui/references/websites.md +387 -0
- package/template/.aioson/skills/design/bold-editorial-ui/SKILL.md +205 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/art-direction.md +338 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/components.md +977 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/dashboards.md +218 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/design-tokens.md +326 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/motion.md +461 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/patterns.md +293 -0
- package/template/.aioson/skills/design/bold-editorial-ui/references/websites.md +352 -0
- package/template/.aioson/skills/design/clean-saas-ui/SKILL.md +210 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/art-direction.md +319 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/components.md +365 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/dashboards.md +196 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/design-tokens.md +244 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/motion.md +235 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/patterns.md +215 -0
- package/template/.aioson/skills/design/clean-saas-ui/references/websites.md +295 -0
- package/template/.aioson/skills/design/cognitive-core-ui/SKILL.md +55 -9
- package/template/.aioson/skills/design/cognitive-core-ui/references/art-direction.md +339 -0
- package/template/.aioson/skills/design/cognitive-core-ui/references/components.md +1 -1
- package/template/.aioson/skills/design/cognitive-core-ui/references/dashboards.md +100 -0
- package/template/.aioson/skills/design/cognitive-core-ui/references/design-tokens.md +43 -9
- package/template/.aioson/skills/design/cognitive-core-ui/references/motion.md +40 -0
- package/template/.aioson/skills/design/cognitive-core-ui/references/patterns.md +1 -1
- package/template/.aioson/skills/design/cognitive-core-ui/references/websites.md +99 -12
- package/template/.aioson/skills/design/glassmorphism-ui/SKILL.md +222 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/art-direction.md +159 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/components.md +498 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/dashboards.md +236 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/design-tokens.md +274 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/motion.md +355 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/patterns.md +198 -0
- package/template/.aioson/skills/design/glassmorphism-ui/references/websites.md +307 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/SKILL.md +213 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/art-direction.md +228 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/components.md +855 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/dashboards.md +334 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/design-tokens.md +342 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/motion.md +286 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/patterns.md +458 -0
- package/template/.aioson/skills/design/neo-brutalist-ui/references/websites.md +723 -0
- package/template/.aioson/skills/design/warm-craft-ui/SKILL.md +209 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/art-direction.md +324 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/components.md +508 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/dashboards.md +223 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/design-tokens.md +374 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/motion.md +356 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/patterns.md +288 -0
- package/template/.aioson/skills/design/warm-craft-ui/references/websites.md +289 -0
- package/template/.aioson/skills/premium-visual-design/SKILL.md +83 -0
- package/template/.aioson/skills/premium-visual-design/components/agent-badge.md +92 -0
- package/template/.aioson/skills/premium-visual-design/components/dependency-node.md +102 -0
- package/template/.aioson/skills/premium-visual-design/components/mention-autocomplete.md +136 -0
- package/template/.aioson/skills/premium-visual-design/components/notification-center.md +136 -0
- package/template/.aioson/skills/premium-visual-design/components/review-action-bar.md +188 -0
- package/template/.aioson/skills/premium-visual-design/components/team-switcher.md +131 -0
- package/template/.aioson/skills/premium-visual-design/patterns/agent-message-thread.md +198 -0
- package/template/.aioson/skills/premium-visual-design/patterns/notification-panel.md +275 -0
- package/template/.aioson/skills/premium-visual-design/patterns/review-workflow-ui.md +234 -0
- package/template/.aioson/skills/premium-visual-design/patterns/task-dependency-graph.md +147 -0
- package/template/.aioson/skills/premium-visual-design/tokens/status-extended.md +142 -0
- package/template/.aioson/skills/process/aioson-spec-driven/SKILL.md +45 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/approval-gates.md +109 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/artifact-map.md +44 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/classification-map.md +37 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/hardening-lane.md +49 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/maintenance-and-state.md +66 -0
- package/template/.aioson/skills/process/aioson-spec-driven/references/ui-language.md +75 -0
- package/template/.aioson/skills/process/design-hybrid-forge/SKILL.md +144 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/crossover-protocol.md +221 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/naming-registry.md +88 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/output-contract.md +291 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/pair-compatibility.md +117 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/quality-gates.md +188 -0
- package/template/.aioson/skills/process/design-hybrid-forge/references/variation-library.md +125 -0
- package/template/.aioson/skills/squad/formats/catalog.json +15 -0
- package/template/.aioson/skills/squad/formats/content/blog-post.md +47 -0
- package/template/.aioson/skills/squad/formats/content/newsletter.md +47 -0
- package/template/.aioson/skills/squad/formats/creative/podcast-script.md +43 -0
- package/template/.aioson/skills/squad/formats/creative/video-script.md +41 -0
- package/template/.aioson/skills/squad/formats/social/instagram-feed.md +42 -0
- package/template/.aioson/skills/squad/formats/social/linkedin-post.md +42 -0
- package/template/.aioson/skills/squad/formats/social/tiktok.md +39 -0
- package/template/.aioson/skills/squad/formats/social/twitter-thread.md +39 -0
- package/template/.aioson/skills/squad/formats/social/youtube-long.md +47 -0
- package/template/.aioson/skills/squad/formats/social/youtube-shorts.md +39 -0
- package/template/.aioson/skills/squad/patterns/multi-platform-pattern.md +108 -0
- package/template/.aioson/skills/squad/patterns/persona-based-pattern.md +98 -0
- package/template/.aioson/skills/squad/patterns/pipeline-pattern.md +106 -0
- package/template/.aioson/skills/squad/patterns/review-loop-pattern.md +81 -0
- package/template/.aioson/skills/squad/references/checklist-templates.md +122 -0
- package/template/.aioson/skills/squad/references/executor-archetypes.md +123 -0
- package/template/.aioson/skills/squad/references/workflow-templates.md +169 -0
- package/template/.aioson/skills/static/debugging-protocol.md +42 -0
- package/template/.aioson/skills/static/git-worktrees.md +36 -0
- package/template/.aioson/tasks/implementation-plan.md +19 -0
- package/template/.aioson/tasks/squad-design.md +28 -0
- package/template/.aioson/tasks/squad-profile.md +48 -0
- package/template/.aioson/tasks/squad-review.md +61 -0
- package/template/.aioson/tasks/squad-task-decompose.md +66 -0
- package/template/.claude/commands/aioson/agent/neo.md +5 -0
- package/template/.claude/commands/aioson/agent/tester.md +5 -0
- package/template/.gemini/GEMINI.md +1 -0
- package/template/.gemini/commands/aios-neo.toml +4 -0
- package/template/.gemini/commands/aios-tester.toml +6 -0
- package/template/AGENTS.md +26 -1
- package/template/CLAUDE.md +6 -2
- package/template/OPENCODE.md +2 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require('node:child_process');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const SAFE_ENV_KEYS = new Set(['PATH', 'HOME', 'LANG', 'TERM', 'USER', 'SHELL', 'TMPDIR', 'TMP', 'TEMP']);
|
|
7
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
8
|
+
|
|
9
|
+
function buildSafeEnv(inputJson) {
|
|
10
|
+
const safe = {};
|
|
11
|
+
for (const key of SAFE_ENV_KEYS) {
|
|
12
|
+
if (process.env[key] !== undefined) {
|
|
13
|
+
safe[key] = process.env[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
safe.TOOL_INPUT = typeof inputJson === 'string' ? inputJson : JSON.stringify(inputJson ?? {});
|
|
17
|
+
return safe;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Executa uma dynamic tool de forma segura via subprocess.
|
|
22
|
+
* @param {object} toolDef - Registro da tool (da tabela dynamic_tools)
|
|
23
|
+
* @param {object|string} inputJson - Input para a tool
|
|
24
|
+
* @param {object} opts
|
|
25
|
+
* @param {string} [opts.projectDir] - Diretório do projeto (para resolver caminhos relativos)
|
|
26
|
+
* @param {number} [opts.timeoutMs] - Timeout em ms (default: 30s)
|
|
27
|
+
* @returns {{ ok: boolean, stdout: string, stderr: string, exitCode: number, error?: string }}
|
|
28
|
+
*/
|
|
29
|
+
function executeTool(toolDef, inputJson, opts = {}) {
|
|
30
|
+
const timeoutMs = opts.timeoutMs || DEFAULT_TIMEOUT_MS;
|
|
31
|
+
const projectDir = opts.projectDir || process.cwd();
|
|
32
|
+
const safeEnv = buildSafeEnv(inputJson);
|
|
33
|
+
|
|
34
|
+
let result;
|
|
35
|
+
|
|
36
|
+
if (toolDef.handler_type === 'shell') {
|
|
37
|
+
if (!toolDef.handler_code) {
|
|
38
|
+
return { ok: false, stdout: '', stderr: '', exitCode: 1, error: 'handler_code is required for shell tools' };
|
|
39
|
+
}
|
|
40
|
+
result = spawnSync('bash', ['-c', toolDef.handler_code], {
|
|
41
|
+
env: safeEnv,
|
|
42
|
+
encoding: 'utf8',
|
|
43
|
+
timeout: timeoutMs,
|
|
44
|
+
maxBuffer: 1024 * 1024
|
|
45
|
+
});
|
|
46
|
+
} else if (toolDef.handler_type === 'script') {
|
|
47
|
+
if (!toolDef.handler_path) {
|
|
48
|
+
return { ok: false, stdout: '', stderr: '', exitCode: 1, error: 'handler_path is required for script tools' };
|
|
49
|
+
}
|
|
50
|
+
const scriptPath = path.isAbsolute(toolDef.handler_path)
|
|
51
|
+
? toolDef.handler_path
|
|
52
|
+
: path.resolve(projectDir, toolDef.handler_path);
|
|
53
|
+
|
|
54
|
+
result = spawnSync('node', ['--env-file=', scriptPath], {
|
|
55
|
+
env: safeEnv,
|
|
56
|
+
encoding: 'utf8',
|
|
57
|
+
timeout: timeoutMs,
|
|
58
|
+
maxBuffer: 1024 * 1024,
|
|
59
|
+
input: safeEnv.TOOL_INPUT
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Fallback: node sem --env-file= (versões antigas do Node não suportam)
|
|
63
|
+
if (result.error && result.error.code === 'ERR_INVALID_ARG_VALUE') {
|
|
64
|
+
result = spawnSync('node', [scriptPath], {
|
|
65
|
+
env: safeEnv,
|
|
66
|
+
encoding: 'utf8',
|
|
67
|
+
timeout: timeoutMs,
|
|
68
|
+
maxBuffer: 1024 * 1024,
|
|
69
|
+
input: safeEnv.TOOL_INPUT
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return { ok: false, stdout: '', stderr: '', exitCode: 1, error: `Unknown handler_type: ${toolDef.handler_type}` };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const stdout = String(result.stdout || '').trim();
|
|
77
|
+
const stderr = String(result.stderr || '').trim();
|
|
78
|
+
const exitCode = result.status ?? 1;
|
|
79
|
+
|
|
80
|
+
if (result.error) {
|
|
81
|
+
const isTimeout = result.error.code === 'ETIMEDOUT' || result.error.killed;
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
stdout,
|
|
85
|
+
stderr,
|
|
86
|
+
exitCode,
|
|
87
|
+
error: isTimeout ? `Tool timed out after ${timeoutMs}ms` : result.error.message
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { ok: exitCode === 0, stdout, stderr, exitCode };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = { executeTool, buildSafeEnv };
|
package/src/updater.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('node:path');
|
|
4
|
-
const { detectExistingInstall, installTemplate } = require('./installer');
|
|
4
|
+
const { detectExistingInstall, installTemplate, readInstallProfile } = require('./installer');
|
|
5
5
|
|
|
6
6
|
async function updateInstallation(targetDir, options = {}) {
|
|
7
7
|
const installed = await detectExistingInstall(targetDir);
|
|
@@ -13,17 +13,25 @@ async function updateInstallation(targetDir, options = {}) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const savedProfile = await readInstallProfile(targetDir);
|
|
17
|
+
|
|
18
|
+
// During update, pass null profile so ALL framework files are installed
|
|
19
|
+
// (not just those matching the saved profile).
|
|
20
|
+
// This ensures new framework files from the new version are always installed.
|
|
21
|
+
// Profile-based filtering only applies to init/install.
|
|
16
22
|
const result = await installTemplate(targetDir, {
|
|
17
23
|
overwrite: true,
|
|
18
24
|
dryRun: Boolean(options.dryRun),
|
|
19
25
|
mode: 'update',
|
|
20
26
|
backupOnOverwrite: true,
|
|
21
|
-
frameworkDetection: options.frameworkDetection || null
|
|
27
|
+
frameworkDetection: options.frameworkDetection || null,
|
|
28
|
+
installProfile: null
|
|
22
29
|
});
|
|
23
30
|
|
|
24
31
|
return {
|
|
25
32
|
ok: true,
|
|
26
|
-
...result
|
|
33
|
+
...result,
|
|
34
|
+
savedProfile
|
|
27
35
|
};
|
|
28
36
|
}
|
|
29
37
|
|
package/src/web.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 10000;
|
|
4
|
+
const DEFAULT_MAX_HTML_CHARS = 500000;
|
|
5
|
+
const DEFAULT_USER_AGENT = 'AIOSON-Web/1.0 (+https://aioson.dev)';
|
|
6
|
+
|
|
7
|
+
function ensureValidUrl(input) {
|
|
8
|
+
try {
|
|
9
|
+
return new URL(String(input || '').trim());
|
|
10
|
+
} catch {
|
|
11
|
+
throw new Error(`Invalid URL: ${input || ''}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function normalizeUrl(input) {
|
|
16
|
+
const url = input instanceof URL ? new URL(input.toString()) : ensureValidUrl(input);
|
|
17
|
+
url.hash = '';
|
|
18
|
+
if ((url.protocol === 'http:' && url.port === '80') || (url.protocol === 'https:' && url.port === '443')) {
|
|
19
|
+
url.port = '';
|
|
20
|
+
}
|
|
21
|
+
const normalized = url.toString();
|
|
22
|
+
return normalized.endsWith('/') ? normalized.slice(0, -1) : normalized;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function decodeHtmlEntities(text) {
|
|
26
|
+
return String(text || '')
|
|
27
|
+
.replace(/&#(\d+);/g, (_, code) => String.fromCodePoint(Number(code)))
|
|
28
|
+
.replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCodePoint(parseInt(code, 16)))
|
|
29
|
+
.replace(/ /gi, ' ')
|
|
30
|
+
.replace(/&/gi, '&')
|
|
31
|
+
.replace(/"/gi, '"')
|
|
32
|
+
.replace(/'/gi, "'")
|
|
33
|
+
.replace(/</gi, '<')
|
|
34
|
+
.replace(/>/gi, '>');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stripTags(html) {
|
|
38
|
+
return decodeHtmlEntities(String(html || '').replace(/<[^>]+>/g, ' '));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function cleanWhitespace(text) {
|
|
42
|
+
return String(text || '')
|
|
43
|
+
.replace(/\r/g, '')
|
|
44
|
+
.replace(/\t/g, ' ')
|
|
45
|
+
.replace(/[ \u00A0]+\n/g, '\n')
|
|
46
|
+
.replace(/\n[ \u00A0]+/g, '\n')
|
|
47
|
+
.replace(/[ \u00A0]{2,}/g, ' ')
|
|
48
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
49
|
+
.trim();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function extractTagContent(html, tagName) {
|
|
53
|
+
const match = String(html || '').match(new RegExp(`<${tagName}[^>]*>([\\s\\S]*?)<\\/${tagName}>`, 'i'));
|
|
54
|
+
return match ? match[1] : '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function extractTitle(html) {
|
|
58
|
+
return cleanWhitespace(stripTags(extractTagContent(html, 'title')));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function extractMetaContent(html, name) {
|
|
62
|
+
const match = String(html || '').match(new RegExp(`<meta[^>]+(?:name|property)=['\"]${name}['\"][^>]+content=['\"]([^'\"]+)['\"][^>]*>`, 'i'));
|
|
63
|
+
return match ? decodeHtmlEntities(match[1]).trim() : '';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function extractCanonical(html) {
|
|
67
|
+
const match = String(html || '').match(/<link[^>]+rel=['\"]canonical['\"][^>]+href=['\"]([^'\"]+)['\"][^>]*>/i);
|
|
68
|
+
return match ? match[1].trim() : '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function extractMainHtml(html) {
|
|
72
|
+
const source = String(html || '');
|
|
73
|
+
const patterns = [
|
|
74
|
+
/<main\b[^>]*>([\s\S]*?)<\/main>/i,
|
|
75
|
+
/<article\b[^>]*>([\s\S]*?)<\/article>/i,
|
|
76
|
+
/<div\b[^>]*role=['\"]main['\"][^>]*>([\s\S]*?)<\/div>/i,
|
|
77
|
+
/<body\b[^>]*>([\s\S]*?)<\/body>/i
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
for (const pattern of patterns) {
|
|
81
|
+
const match = source.match(pattern);
|
|
82
|
+
if (match && match[1]) return match[1];
|
|
83
|
+
}
|
|
84
|
+
return source;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function htmlToMarkdown(html) {
|
|
88
|
+
let output = String(html || '');
|
|
89
|
+
output = output.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, ' ');
|
|
90
|
+
output = output.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, ' ');
|
|
91
|
+
output = output.replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ' ');
|
|
92
|
+
output = output.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gi, ' ');
|
|
93
|
+
output = output.replace(/<h1\b[^>]*>([\s\S]*?)<\/h1>/gi, '\n# $1\n\n');
|
|
94
|
+
output = output.replace(/<h2\b[^>]*>([\s\S]*?)<\/h2>/gi, '\n## $1\n\n');
|
|
95
|
+
output = output.replace(/<h3\b[^>]*>([\s\S]*?)<\/h3>/gi, '\n### $1\n\n');
|
|
96
|
+
output = output.replace(/<h4\b[^>]*>([\s\S]*?)<\/h4>/gi, '\n#### $1\n\n');
|
|
97
|
+
output = output.replace(/<h5\b[^>]*>([\s\S]*?)<\/h5>/gi, '\n##### $1\n\n');
|
|
98
|
+
output = output.replace(/<h6\b[^>]*>([\s\S]*?)<\/h6>/gi, '\n###### $1\n\n');
|
|
99
|
+
output = output.replace(/<li\b[^>]*>([\s\S]*?)<\/li>/gi, '\n- $1');
|
|
100
|
+
output = output.replace(/<(p|div|section|article|main|header|footer|aside|blockquote)\b[^>]*>/gi, '\n');
|
|
101
|
+
output = output.replace(/<\/(p|div|section|article|main|header|footer|aside|blockquote)>/gi, '\n');
|
|
102
|
+
output = output.replace(/<br\s*\/?>/gi, '\n');
|
|
103
|
+
output = output.replace(/<a\b[^>]*href=['\"]([^'\"]+)['\"][^>]*>([\s\S]*?)<\/a>/gi, '$2 ($1)');
|
|
104
|
+
output = stripTags(output);
|
|
105
|
+
return cleanWhitespace(output);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function htmlToText(html) {
|
|
109
|
+
return cleanWhitespace(stripTags(String(html || '')
|
|
110
|
+
.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, ' ')
|
|
111
|
+
.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, ' ')
|
|
112
|
+
.replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, ' ')
|
|
113
|
+
.replace(/<br\s*\/?>/gi, '\n')
|
|
114
|
+
.replace(/<\/(p|div|section|article|main|header|footer|aside|li|ul|ol|h1|h2|h3|h4|h5|h6)>/gi, '\n')));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function resolveHref(href, pageUrl) {
|
|
118
|
+
const value = String(href || '').trim();
|
|
119
|
+
if (!value || value.startsWith('#') || value.startsWith('mailto:') || value.startsWith('tel:') || value.startsWith('javascript:')) {
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
return normalizeUrl(new URL(value, pageUrl));
|
|
125
|
+
} catch {
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function extractLinks(html, pageUrl, options = {}) {
|
|
131
|
+
const sameOriginOnly = options.sameOriginOnly !== false;
|
|
132
|
+
const base = ensureValidUrl(pageUrl);
|
|
133
|
+
const links = new Set();
|
|
134
|
+
const pattern = /<a\b[^>]*href=['\"]([^'\"]+)['\"][^>]*>/gi;
|
|
135
|
+
let match;
|
|
136
|
+
|
|
137
|
+
while ((match = pattern.exec(String(html || ''))) !== null) {
|
|
138
|
+
const normalized = resolveHref(match[1], base);
|
|
139
|
+
if (!normalized) continue;
|
|
140
|
+
if (sameOriginOnly) {
|
|
141
|
+
try {
|
|
142
|
+
if (new URL(normalized).origin !== base.origin) continue;
|
|
143
|
+
} catch {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
links.add(normalized);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return Array.from(links).sort();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function fetchPage(url, options = {}) {
|
|
154
|
+
const timeoutMs = Number(options.timeoutMs) > 0 ? Number(options.timeoutMs) : DEFAULT_TIMEOUT_MS;
|
|
155
|
+
const maxHtmlChars = Number(options.maxHtmlChars) > 0 ? Number(options.maxHtmlChars) : DEFAULT_MAX_HTML_CHARS;
|
|
156
|
+
const headers = {
|
|
157
|
+
'user-agent': options.userAgent || DEFAULT_USER_AGENT,
|
|
158
|
+
'accept': 'text/html,application/xhtml+xml,text/plain;q=0.9,*/*;q=0.8',
|
|
159
|
+
...(options.headers || {})
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const response = await fetch(String(url), {
|
|
163
|
+
method: 'GET',
|
|
164
|
+
headers,
|
|
165
|
+
redirect: 'follow',
|
|
166
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const finalUrl = normalizeUrl(response.url || url);
|
|
170
|
+
const contentType = response.headers.get('content-type') || '';
|
|
171
|
+
const rawText = await response.text();
|
|
172
|
+
const html = rawText.length > maxHtmlChars ? rawText.slice(0, maxHtmlChars) : rawText;
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
ok: response.ok,
|
|
176
|
+
url: finalUrl,
|
|
177
|
+
statusCode: response.status,
|
|
178
|
+
contentType,
|
|
179
|
+
html,
|
|
180
|
+
truncated: rawText.length > html.length
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function scrapePage(url, options = {}) {
|
|
185
|
+
const page = await fetchPage(url, options);
|
|
186
|
+
const mainHtml = extractMainHtml(page.html);
|
|
187
|
+
const title = extractTitle(page.html);
|
|
188
|
+
const description = extractMetaContent(page.html, 'description') || extractMetaContent(page.html, 'og:description');
|
|
189
|
+
const canonical = extractCanonical(page.html);
|
|
190
|
+
const links = extractLinks(page.html, page.url, { sameOriginOnly: options.sameOriginOnly !== false });
|
|
191
|
+
const text = htmlToText(mainHtml);
|
|
192
|
+
const markdown = htmlToMarkdown(mainHtml);
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
ok: page.ok,
|
|
196
|
+
url: page.url,
|
|
197
|
+
statusCode: page.statusCode,
|
|
198
|
+
contentType: page.contentType,
|
|
199
|
+
title,
|
|
200
|
+
description,
|
|
201
|
+
canonical,
|
|
202
|
+
html: mainHtml,
|
|
203
|
+
text,
|
|
204
|
+
markdown,
|
|
205
|
+
links,
|
|
206
|
+
truncated: page.truncated
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function mapWebsite(url, options = {}) {
|
|
211
|
+
const startUrl = normalizeUrl(url);
|
|
212
|
+
const start = ensureValidUrl(startUrl);
|
|
213
|
+
const maxDepth = Number(options.maxDepth) >= 0 ? Number(options.maxDepth) : 2;
|
|
214
|
+
const maxPages = Number(options.maxPages) > 0 ? Number(options.maxPages) : 25;
|
|
215
|
+
const sameOriginOnly = options.sameOriginOnly !== false;
|
|
216
|
+
|
|
217
|
+
const queue = [{ url: startUrl, depth: 0 }];
|
|
218
|
+
const visited = new Set();
|
|
219
|
+
const pages = [];
|
|
220
|
+
|
|
221
|
+
while (queue.length > 0 && visited.size < maxPages) {
|
|
222
|
+
const current = queue.shift();
|
|
223
|
+
if (!current || visited.has(current.url)) continue;
|
|
224
|
+
visited.add(current.url);
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
const page = await scrapePage(current.url, options);
|
|
228
|
+
const sameOriginLinks = extractLinks(page.html || '', page.url, { sameOriginOnly });
|
|
229
|
+
pages.push({
|
|
230
|
+
url: page.url,
|
|
231
|
+
depth: current.depth,
|
|
232
|
+
statusCode: page.statusCode,
|
|
233
|
+
title: page.title,
|
|
234
|
+
description: page.description,
|
|
235
|
+
linkCount: sameOriginLinks.length
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
if (current.depth >= maxDepth) continue;
|
|
239
|
+
for (const link of sameOriginLinks) {
|
|
240
|
+
if (visited.has(link)) continue;
|
|
241
|
+
if (sameOriginOnly) {
|
|
242
|
+
try {
|
|
243
|
+
if (new URL(link).origin != start.origin) continue;
|
|
244
|
+
} catch {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
queue.push({ url: link, depth: current.depth + 1 });
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
pages.push({
|
|
252
|
+
url: current.url,
|
|
253
|
+
depth: current.depth,
|
|
254
|
+
statusCode: 0,
|
|
255
|
+
title: '',
|
|
256
|
+
description: '',
|
|
257
|
+
linkCount: 0,
|
|
258
|
+
error: error.message
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
startUrl,
|
|
265
|
+
maxDepth,
|
|
266
|
+
maxPages,
|
|
267
|
+
pageCount: pages.length,
|
|
268
|
+
urls: pages.map((item) => item.url),
|
|
269
|
+
pages
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
module.exports = {
|
|
274
|
+
DEFAULT_TIMEOUT_MS,
|
|
275
|
+
DEFAULT_MAX_HTML_CHARS,
|
|
276
|
+
DEFAULT_USER_AGENT,
|
|
277
|
+
normalizeUrl,
|
|
278
|
+
extractLinks,
|
|
279
|
+
htmlToMarkdown,
|
|
280
|
+
htmlToText,
|
|
281
|
+
fetchPage,
|
|
282
|
+
scrapePage,
|
|
283
|
+
mapWebsite
|
|
284
|
+
};
|