@namewta/skills-hub 0.1.49 → 0.1.52
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/README.md +4 -1
- package/THIRD_PARTY_NOTICES.md +19 -7
- package/cli.mjs +2 -2
- package/install.mjs +11 -4
- package/package.json +1 -1
- package/scripts/persistence/home.md +1 -1
- package/skills/dev/dev-build/SKILL.md +2 -0
- package/skills/dev/dev-build/references/implement-request.md +7 -2
- package/skills/dev/dev-formal-verify/SKILL.md +2 -1
- package/skills/dev/dev-formal-verify/references/create-check.md +3 -1
- package/skills/dev/dev-formal-verify/references/example.md +1 -1
- package/skills/dev/dev-formal-verify/references/tool-choice.md +1 -1
- package/skills/dev/dev-help/references/capabilities.md +6 -6
- package/skills/dev/dev-help/references/guide-verification.md +7 -1
- package/skills/dev/dev-help/references/help-method.md +7 -1
- package/skills/dev/dev-issue/SKILL.md +1 -0
- package/skills/dev/dev-issue/references/github-operations.md +8 -0
- package/skills/dev/dev-plan/references/plan-template.md +1 -0
- package/skills/dev/dev-plan/references/vertical-slicing.md +2 -0
- package/skills/dev/dev-pr/references/pull-request-evidence.md +2 -0
- package/skills/dev/dev-review/references/host-parity.md +12 -0
- package/skills/dev/dev-review/references/review-baseline.md +2 -0
- package/skills/dev/dev-setup/references/formal-options.md +1 -1
- package/skills/dev/dev-statechart/SKILL.md +17 -19
- package/skills/dev/dev-statechart/agents/openai.yaml +3 -3
- package/skills/dev/dev-statechart/assets/theme.css +135 -0
- package/skills/dev/dev-statechart/references/lean-proof.md +47 -0
- package/skills/dev/dev-statechart/references/render.md +15 -83
- package/skills/dev/dev-statechart/references/runtime.md +21 -1
- package/skills/dev/dev-statechart/scripts/lean/backends/lemma-chart.mjs +285 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/mermaid.mjs +174 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/proof-chart.mjs +540 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/report.mjs +242 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/facts.mjs +234 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/view.mjs +217 -0
- package/skills/dev/dev-statechart/scripts/lean/ir.mjs +226 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/attribute.mjs +148 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/blocks.mjs +32 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/budget.mjs +167 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/check.mjs +70 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/contract.mjs +160 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/fold.mjs +206 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/inline.mjs +84 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/mark.mjs +432 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/reduce.mjs +73 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/trust.mjs +111 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/view-lemmas.mjs +155 -0
- package/skills/dev/dev-statechart/scripts/lean/pipeline.mjs +164 -0
- package/skills/dev/dev-statechart/scripts/lean/run.mjs +168 -0
- package/skills/dev/dev-statechart/scripts/statechart.mjs +42 -23
- package/skills/dev/dev-statechart/scripts/worker.mjs +33 -7
- package/skills/dev/dev-ui-design/SKILL.md +2 -2
- package/skills/dev/dev-ui-design/references/interaction-review.md +9 -0
- package/skills/dev/dev-verify/SKILL.md +1 -1
- package/skills/dev/dev-verify/references/evidence-storage.md +12 -0
- package/skills/dev/dev-workflow/SKILL.md +6 -6
- package/skills/dev/dev-workflow/references/method-handoffs.md +7 -1
- package/skills/dev/dev-writing/SKILL.md +2 -0
- package/skills/dev/dev-writing/references/library-docs.md +37 -0
- package/skills/home/home-doctor/references/diagnosis.md +2 -2
- package/skills/home/home-doctor/scripts/doctor.mjs +68 -38
- package/skills/home/home-project-changelog/SKILL.md +7 -7
- package/skills/home/home-project-changelog/assets/project-changelog.example.json +188 -0
- package/skills/home/home-project-changelog/assets/project-changelog.schema.json +156 -0
- package/skills/home/home-project-changelog/assets/worker-brief.md +1 -1
- package/skills/home/home-project-changelog/references/git-ranges.md +2 -2
- package/skills/home/home-project-changelog/references/schema.md +61 -0
- package/skills/home/home-project-changelog/references/tools.md +28 -22
- package/skills/home/home-project-changelog/references/workflow.md +12 -9
- package/skills/home/home-project-changelog/references/writing.md +5 -3
- package/skills/home/home-project-changelog/scripts/changelog.mjs +42 -38
- package/skills/home/home-project-changelog/scripts/contract.mjs +40 -3
- package/skills/home/home-project-changelog/scripts/legacy-markdown.mjs +116 -0
- package/skills/home/home-project-changelog/scripts/migrate.mjs +122 -0
- package/skills/home/home-project-changelog/scripts/revision.mjs +2 -196
- package/skills/home/home-project-changelog/scripts/storage.mjs +120 -125
- package/skills/home/home-project-changelog/scripts/summary.mjs +0 -60
- package/skills/home/home-route/SKILL.md +2 -2
- package/skills/home/home-route/references/routing.md +3 -1
- package/skills/home/home-route/scripts/route.mjs +79 -11
- package/skills/home/home-setup/SKILL.md +2 -1
- package/skills/home/home-setup/assets/repos.schema.json +10 -0
- package/skills/home/home-setup/references/registry.md +18 -1
- package/skills/home/home-setup/scripts/registry.mjs +67 -7
- package/skills/home/home-website/SKILL.md +13 -9
- package/skills/home/home-website/assets/website/scripts/inputs.mjs +143 -128
- package/skills/home/home-website/assets/website/scripts/render.mjs +8 -6
- package/skills/home/home-website/assets/website/scripts/site.mjs +21 -10
- package/skills/home/home-website/assets/website/site/public/home-assets/app.js +81 -34
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +92 -70
- package/skills/home/home-website/assets/website/site/templates/favicon.png +0 -0
- package/skills/home/home-website/assets/website/site/templates/layout.mjs +13 -10
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +51 -46
- package/skills/home/home-website/assets/website/site/templates/model.mjs +58 -14
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +28 -30
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +3 -107
- package/skills/home/home-website/assets/website/site.config.json +1 -1
- package/skills/home/home-website/references/website.md +64 -46
- package/skills/home/home-website/scripts/activate.mjs +106 -0
- package/skills/home/home-website/scripts/init.mjs +98 -11
- package/skills/home/home-workflow/SKILL.md +6 -4
- package/skills/system/system-clash-proxy-config/SKILL.md +21 -0
- package/skills/system/system-clash-proxy-config/agents/openai.yaml +4 -0
- package/skills/system/system-clash-proxy-config/assets/clash-override.js +328 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/browser-privacy.md +2 -2
- package/skills/system/{system-config → system-clash-proxy-config}/references/changes.md +2 -2
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/clash-verge.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/diagnosis.md +1 -1
- package/skills/system/system-clash-proxy-config/references/dns-workflow.md +42 -0
- package/skills/system/system-clash-proxy-config/references/egress-macos.md +31 -0
- package/skills/system/system-clash-proxy-config/references/egress-windows.md +37 -0
- package/skills/system/system-clash-proxy-config/references/egress.md +12 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/flclash.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/index.md +1 -1
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/linux-cutover.md +29 -0
- package/skills/system/system-clash-proxy-config/references/locale-workflow.md +9 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/mihomo.md +1 -25
- package/skills/system/system-clash-proxy-config/references/session.md +34 -0
- package/skills/system/system-clash-proxy-config/references/subscription.md +29 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/troubleshooting.md +7 -7
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/verification.md +2 -0
- package/skills/system/system-clash-proxy-config/scripts/prepare-session.mjs +155 -0
- package/skills/system/system-clash-proxy-config/scripts/run-session.mjs +138 -0
- package/skills/system/system-inspect/SKILL.md +1 -1
- package/skills/system/system-inspect/references/health-audit.md +1 -1
- package/upstream-skills/zh-archify/SKILL.md +11 -11
- package/upstream-skills/zh-archify/assets/template.html +6 -3
- package/upstream-skills/zh-archify/bin/archify.mjs +67 -4
- package/upstream-skills/zh-archify/modules/code-analysis/ARCHITECTURE.md +7 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/analyze-run.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/check.mjs +29 -15
- package/upstream-skills/zh-archify/modules/code-analysis/bin/drift.mjs +3 -3
- package/upstream-skills/zh-archify/modules/code-analysis/bin/prepare.mjs +5 -6
- package/upstream-skills/zh-archify/modules/code-analysis/bin/serve.mjs +66 -36
- package/upstream-skills/zh-archify/modules/code-analysis/bin/verify-change.mjs +43 -13
- package/upstream-skills/zh-archify/modules/code-analysis/docs/TECH-GUIDE.md +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/docs/USAGE.md +37 -4
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/functions.mjs +7 -5
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/index.mjs +4 -1
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/snapshot-host.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/architecture-drift.mjs +28 -7
- package/upstream-skills/zh-archify/modules/code-analysis/lib/drift-capture.mjs +4 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/git-sources.mjs +5 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/output.mjs +272 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/pull-request.mjs +34 -4
- package/upstream-skills/zh-archify/modules/code-analysis/lib/task.mjs +4 -2
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-context.mjs +13 -1
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-history.mjs +112 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification.mjs +6 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/atlas.mjs +71 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.css +16 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.js +121 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas3d.js +38 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.css +14 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.js +187 -27
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/verification.js +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/i18n.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/inject.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/page.mjs +11 -6
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/pull-request.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/schemas/ai-task.schema.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/atlas.test.mjs +88 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/duplicates.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/external-workflow.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.missing.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.valid.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.changed.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/module-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/function-source-range.test.mjs +10 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/output-recovery.test.mjs +626 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/pull-request.test.mjs +98 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/review.test.mjs +37 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/source-panel.test.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/task.test.mjs +3 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification-history.test.mjs +216 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification.test.mjs +122 -0
- package/upstream-skills/zh-archify/package-lock.json +2 -2
- package/upstream-skills/zh-archify/package.json +1 -1
- package/upstream-skills/zh-archify/references/authoring-contract.md +2 -0
- package/upstream-skills/zh-archify/references/explainer-authoring.md +1 -1
- package/upstream-skills/zh-archify/renderers/architecture/render-architecture.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/class/render-class.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/dataflow/render-dataflow.mjs +2 -1
- package/upstream-skills/zh-archify/renderers/erd/render-erd.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/lifecycle/render-lifecycle.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/sequence/render-sequence.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/shared/cli.mjs +7 -1
- package/upstream-skills/zh-archify/renderers/timeline/render-timeline.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/tree/render-tree.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/waterfall/render-waterfall.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/workflow/render-workflow.mjs +3 -2
- package/upstream-skills/zh-archify/renderers/workflow/workflow-compiler.mjs +68 -7
- package/upstream-skills/zh-archify/skill-release.json +1 -1
- package/upstream-skills/zh-modern-web-guidance/SKILL.md +4 -11
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-detection.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-model.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/prompt-api.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/summarizer.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/translator.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/custom-ml-model-inference.md +342 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/data-parallel-computation.md +337 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/improve-next-page-load-performance.md +4 -1
- package/upstream-skills/zh-modern-web-guidance/guides/performance/large-scene-rendering.md +350 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/viewport-aware-dropdowns.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/declarative-dialog-popover-control.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md +29 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/sortable-table.md +1 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/app-menus.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/context-menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/copy-button.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/dialog.md +10 -1
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/hovercard.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/navbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-app-tours.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-toast-notifications.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/toolbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/content-first-noise-reduction.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/natural-interactions.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/webmcp/agentic-javascript-tools.md +27 -0
- package/skills/home/home-project-changelog/assets/project-changelog.md +0 -35
- package/skills/system/system-clash-tun-egress/SKILL.md +0 -22
- package/skills/system/system-clash-tun-egress/agents/openai.yaml +0 -4
- package/skills/system/system-config/SKILL.md +0 -37
- package/skills/system/system-config/agents/openai.yaml +0 -4
- package/skills/system/system-config/references/ai-cli-config.md +0 -75
- package/skills/system/system-config/references/ai-cli-optimization.md +0 -37
- package/skills/system/system-config/references/index.md +0 -12
- package/skills/system/system-config/references/locale-workflow.md +0 -33
- package/skills/system/system-config/references/locale.md +0 -50
- package/skills/system/system-proxy/SKILL.md +0 -40
- package/skills/system/system-proxy/agents/openai.yaml +0 -4
- package/skills/system/system-proxy/assets/protected-rules.yaml +0 -7
- package/skills/system/system-proxy/references/dns-workflow.md +0 -152
- /package/skills/system/{system-config → system-clash-proxy-config}/assets/configuration.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/assets/network.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/acceptance.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-fields.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-misconceptions.md +0 -0
- /package/skills/system/{system-clash-tun-egress/references/troubleshooting.md → system-clash-proxy-config/references/egress-troubleshooting.md} +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-linux.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-macos.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-windows.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/network-performance.md +0 -0
- /package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/nodes-and-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platform-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platforms.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/tun-dns.md +0 -0
|
@@ -2218,7 +2218,7 @@ const COMMAND_USAGE = {
|
|
|
2218
2218
|
patch: 'explainer <artifact.html> <panel-id> <replacement-file> <output.html> [--json] [--quality standard|showcase] [--repo-root path]',
|
|
2219
2219
|
finalize: '<type> <input.json> <output.html> [--json] [--browser-check] [--no-update-notice] [--receipt path] [--out-dir <dir>] [--quality standard|showcase] [--repo-root path] [--candidate-sha256 hex]',
|
|
2220
2220
|
preview: '<type> <input.json> [output.html] [--no-open] [--quality standard|showcase] [--repo-root path]',
|
|
2221
|
-
validate: '<type> <input.json> [--json] [--layout-json] [--quality standard|showcase] [--repo-root path]',
|
|
2221
|
+
validate: '<type> <input.json> [--json [--with-layout]] [--layout-json] [--quality standard|showcase] [--repo-root path]',
|
|
2222
2222
|
'export-svg': '<type> <input.json> <output.svg|stem> [--theme both|light|dark] [--preset name] [--animate-flow] [--json] [--quality standard|showcase] [--repo-root path]',
|
|
2223
2223
|
pr: ['preflight [--repo-root path] [--base ref] [--head ref] [--init dir] [--mode ask|on-demand|proactive] [--target body|comment] [--global-rules path] [--json]', 'validate <manifest.json> [--repo-root path] [--json]', 'build <manifest.json> --out-dir <dir> [--repo-root path] [--platform github|gitlab|generic] [--no-html] [--animate-flow] [--quality standard|showcase] [--json]', 'attach <pr-number-or-url|gitlab-mr-url> --manifest <build-receipt.json> [--target body|comment] [--repo owner/name] [--allow-stale] [--dry-run] [--json]'],
|
|
2224
2224
|
migrate: 'workflow <old.json> <new.json> --to-schema 2 [--output portable.html] [--json] [--repo-root path]',
|
|
@@ -7138,6 +7138,7 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7138
7138
|
const quality = qualityArgs.quality;
|
|
7139
7139
|
const repoRoot = repoArgs.repoRoot;
|
|
7140
7140
|
const knownOptions = new Set(['--json', '--layout-json']);
|
|
7141
|
+
if (invokingCommand === 'validate') knownOptions.add('--with-layout');
|
|
7141
7142
|
const unknown = args.filter((arg) => arg.startsWith('--') && !knownOptions.has(arg));
|
|
7142
7143
|
if (unknown.length) rejectCliArgument(`Unknown ${invokingCommand} option "${unknown[0]}".`, {
|
|
7143
7144
|
code: 'cli/unknown-option',
|
|
@@ -7146,6 +7147,7 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7146
7147
|
});
|
|
7147
7148
|
const json = args.includes('--json');
|
|
7148
7149
|
const layoutJson = args.includes('--layout-json');
|
|
7150
|
+
const withLayout = args.includes('--with-layout');
|
|
7149
7151
|
const rest = args.filter((arg) => !knownOptions.has(arg));
|
|
7150
7152
|
const [type, input] = rest;
|
|
7151
7153
|
if (!type || !input || rest.length !== 2) rejectCliArgument(usage(), {
|
|
@@ -7153,6 +7155,25 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7153
7155
|
supportedFixes: [`use: archify ${invokingCommand} <type> <input.json> [options]`],
|
|
7154
7156
|
});
|
|
7155
7157
|
const renderer = rendererPath(type);
|
|
7158
|
+
// --with-layout adds the --layout-json report to a passing --json verdict,
|
|
7159
|
+
// so a caller that needs both pays for one render (#1420).
|
|
7160
|
+
if (withLayout && (layoutJson || !json)) rejectCliArgument(
|
|
7161
|
+
layoutJson
|
|
7162
|
+
? `--with-layout adds the layout to the --json verdict; it cannot be combined with --layout-json.`
|
|
7163
|
+
: `--with-layout requires --json.`,
|
|
7164
|
+
{
|
|
7165
|
+
code: 'cli/unsupported-option',
|
|
7166
|
+
subject: { command: invokingCommand, option: '--with-layout' },
|
|
7167
|
+
supportedFixes: layoutJson
|
|
7168
|
+
? ['use --json --with-layout for the verdict and layout together', 'use --layout-json alone for the layout only']
|
|
7169
|
+
: ['add --json'],
|
|
7170
|
+
},
|
|
7171
|
+
);
|
|
7172
|
+
if (withLayout && type === 'explainer') rejectCliArgument('--with-layout is supported for native diagram types; explainer has no layout report.', {
|
|
7173
|
+
code: 'cli/unsupported-option',
|
|
7174
|
+
subject: { command: invokingCommand, option: '--with-layout', type },
|
|
7175
|
+
supportedFixes: ['remove --with-layout for explainer documents'],
|
|
7176
|
+
});
|
|
7156
7177
|
|
|
7157
7178
|
const inputPath = path.resolve(input);
|
|
7158
7179
|
let specification;
|
|
@@ -7222,6 +7243,7 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7222
7243
|
const temporary = createOwnedTempDirectory('archify-validate-');
|
|
7223
7244
|
const tmp = temporary.path;
|
|
7224
7245
|
const out = path.join(tmp, `${type}.html`);
|
|
7246
|
+
const layoutReportPath = withLayout ? path.join(tmp, 'layout.json') : null;
|
|
7225
7247
|
let exitCode = 0;
|
|
7226
7248
|
let report = () => {};
|
|
7227
7249
|
|
|
@@ -7235,7 +7257,11 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7235
7257
|
}
|
|
7236
7258
|
const render = runNode([renderer, snapshot, out], {
|
|
7237
7259
|
stdio: 'pipe',
|
|
7238
|
-
env: {
|
|
7260
|
+
env: {
|
|
7261
|
+
...rendererEnv(quality, repoRoot, true),
|
|
7262
|
+
...(preparedBundlePath ? { ARCHIFY_EXPLAINER_PREPARED: preparedBundlePath, ARCHIFY_EXPLAINER_SNAPSHOT_INPUT: inputPath } : {}),
|
|
7263
|
+
...(layoutReportPath ? { ARCHIFY_LAYOUT_REPORT_PATH: layoutReportPath } : {}),
|
|
7264
|
+
},
|
|
7239
7265
|
});
|
|
7240
7266
|
if (render.status !== 0) {
|
|
7241
7267
|
const failure = rendererFailure(render);
|
|
@@ -7293,7 +7319,37 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7293
7319
|
} else {
|
|
7294
7320
|
const result = JSON.parse(check.stdout);
|
|
7295
7321
|
const engineeringProfile = engineeringProfileFromArtifact(fs.readFileSync(out));
|
|
7296
|
-
|
|
7322
|
+
let layout;
|
|
7323
|
+
if (layoutReportPath) {
|
|
7324
|
+
try {
|
|
7325
|
+
const recorded = JSON.parse(fs.readFileSync(layoutReportPath, 'utf8'));
|
|
7326
|
+
if (recorded?.ok !== true || recorded.diagram_type !== type
|
|
7327
|
+
|| !Array.isArray(recorded.viewBox) || recorded.viewBox.length !== 2) {
|
|
7328
|
+
throw new Error(`Expected a successful ${type} layout report with a viewBox.`);
|
|
7329
|
+
}
|
|
7330
|
+
layout = recorded;
|
|
7331
|
+
} catch (error) {
|
|
7332
|
+
exitCode = 1;
|
|
7333
|
+
const message = `The renderer did not record a readable layout report: ${error.message}`;
|
|
7334
|
+
report = () => reportFailure({
|
|
7335
|
+
json,
|
|
7336
|
+
stage: 'render',
|
|
7337
|
+
type,
|
|
7338
|
+
input: path.resolve(input),
|
|
7339
|
+
error: message,
|
|
7340
|
+
diagnostics: [{
|
|
7341
|
+
code: 'validate/layout-report-unavailable',
|
|
7342
|
+
severity: 'error',
|
|
7343
|
+
message,
|
|
7344
|
+
subject: { type },
|
|
7345
|
+
evidence: { reason: error.code || error.name },
|
|
7346
|
+
supportedFixes: ['run validate <type> <input.json> --layout-json for the layout alone', 'report the renderer failure'],
|
|
7347
|
+
}],
|
|
7348
|
+
status: 1,
|
|
7349
|
+
});
|
|
7350
|
+
}
|
|
7351
|
+
}
|
|
7352
|
+
if (exitCode === 0 && json) {
|
|
7297
7353
|
const candidate = {
|
|
7298
7354
|
path: path.resolve(input),
|
|
7299
7355
|
...artifactIdentity(specification),
|
|
@@ -7325,9 +7381,10 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7325
7381
|
composition: result.composition,
|
|
7326
7382
|
...(engineeringProfile ? { engineeringProfile } : {}),
|
|
7327
7383
|
...(localeWarnings.length ? { diagnostics: localeWarnings } : {}),
|
|
7384
|
+
...(withLayout ? { layout } : {}),
|
|
7328
7385
|
};
|
|
7329
7386
|
report = () => console.log(JSON.stringify(receipt, null, 2));
|
|
7330
|
-
} else {
|
|
7387
|
+
} else if (exitCode === 0) {
|
|
7331
7388
|
const engineering = engineeringProfile
|
|
7332
7389
|
? `; engineering ${engineeringProfile}: pass`
|
|
7333
7390
|
: '';
|
|
@@ -7363,6 +7420,12 @@ async function commandValidate(args, invocation = {}) {
|
|
|
7363
7420
|
if (exitCode !== 0) process.exitCode = exitCode;
|
|
7364
7421
|
}
|
|
7365
7422
|
|
|
7423
|
+
// Only validate --with-layout may supply this internal path to a renderer.
|
|
7424
|
+
// Strip inherited spellings before dispatch, including Windows case aliases.
|
|
7425
|
+
for (const name of Object.keys(process.env)) {
|
|
7426
|
+
if (name.toUpperCase() === 'ARCHIFY_LAYOUT_REPORT_PATH') delete process.env[name];
|
|
7427
|
+
}
|
|
7428
|
+
|
|
7366
7429
|
const [command, ...args] = process.argv.slice(2);
|
|
7367
7430
|
// Reuse the canonical help metadata rather than a separate help registry.
|
|
7368
7431
|
// Only the sole --help form bypasses command argument parsing and operations.
|
|
@@ -124,7 +124,13 @@ AI 任务预览使用共用任务生成器的 Markdown。在线页面从经过
|
|
|
124
124
|
- `overview.json`
|
|
125
125
|
- `repo.analysis.html`
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
每次运行都先在输出锁保护下写入一个新的暂存目录。返回数据可读后,当前结果移到 `<out>/analysis.previous/`,候选结果移入 `<out>/analysis/`。如果发布失败且回滚成功,两份已完成的报告都会恢复。
|
|
128
|
+
|
|
129
|
+
`check` 也会在发布前将完整输出写入暂存目录。报告发布与工作台的审阅保存共用同一个输出目录锁,锁覆盖从选择自动比较对象到发布的全过程。工作进程写入由锁持有者准备的目录。重试只有在确认写入进程已退出时,才会清除尚未发布的暂存目录。
|
|
130
|
+
|
|
131
|
+
在 Linux 上,锁的标记将写入进程绑定到本次系统启动和 PID 命名空间。若仍能看到该 PID,比较启动时间要求时间命名空间一致,且 procfs 视图属于同一 PID 命名空间。身份不同或无法核实(包括旧格式锁标记)时,保留锁。在其他平台上,仅在同一机器和进程视图内共享可写输出目录。
|
|
132
|
+
|
|
133
|
+
发布中断或回滚失败时,会保留移动计划和备份供恢复。回滚失败会记录终止状态,即使工作台进程仍在运行,重试也能报告需恢复。
|
|
128
134
|
|
|
129
135
|
分析 HTML 嵌入已映射文件及证据文件的源码上下文,可以离线显示已有结果。没有本地服务器就不能重新扫描项目。
|
|
130
136
|
|
|
@@ -11,7 +11,8 @@ process.stdin.setEncoding('utf8');
|
|
|
11
11
|
process.stdin.on('data', (chunk) => { input += chunk; });
|
|
12
12
|
process.stdin.on('end', () => {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
// The lock owner creates the stage, so a late worker cannot recreate it.
|
|
15
|
+
const result = analyzeRepository(JSON.parse(input), { createOutput: false });
|
|
15
16
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
16
17
|
} catch (error) {
|
|
17
18
|
const diagnostics = error instanceof DiagnosticError ? error.diagnostics
|
|
@@ -6,6 +6,7 @@ import fs from 'node:fs';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { DiagnosticError, fail, receipt } from '../core/index.mjs';
|
|
9
|
+
import { outputEntry, withAnalysisOutput, writeCheckOutputs } from '../lib/output.mjs';
|
|
9
10
|
import { baselineCommand, taskCommand } from '../lib/task-command.mjs';
|
|
10
11
|
|
|
11
12
|
export const USAGE = `Usage:
|
|
@@ -59,10 +60,9 @@ export function parseCheckArgs(argv) {
|
|
|
59
60
|
|
|
60
61
|
export async function runCheck(argv) {
|
|
61
62
|
const { repo, options } = parseCheckArgs(argv);
|
|
62
|
-
const
|
|
63
|
-
const {
|
|
64
|
-
const {
|
|
65
|
-
const { alignDiagram, findingModules } = await import('../overlay/inject.mjs');
|
|
63
|
+
const out = options['--out'] ? path.resolve(options['--out']) : null;
|
|
64
|
+
const { extractFacts, buildGraph, evaluateGraph, loadBaseline, saveBaseline, loadPrevious, readJsonInput } = await import('../lib/analysis.mjs');
|
|
65
|
+
const { baselineFrom, acceptFinding, revokeFinding } = await import('../lib/review.mjs');
|
|
66
66
|
|
|
67
67
|
const root = path.resolve(repo);
|
|
68
68
|
const baselineFile = options['--baseline'] ? path.resolve(options['--baseline']) : null;
|
|
@@ -96,11 +96,9 @@ export async function runCheck(argv) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// An explicit --compare must be readable; the automatic one in --out is optional.
|
|
103
|
-
const previous = loadPrevious(previousFile, { strict: Boolean(options['--compare']) });
|
|
99
|
+
const compare = options['--compare'] ? path.resolve(options['--compare']) : null;
|
|
100
|
+
if (compare && !fs.existsSync(compare)) fail('cli/input-invalid', `Not a file: ${options['--compare']}`, { subject: { option: '--compare' }, supportedFixes: ['pass the findings.json of an earlier run'] });
|
|
101
|
+
const explicitPrevious = compare ? loadPrevious(compare, { strict: true }) : null;
|
|
104
102
|
|
|
105
103
|
const { facts, config, otherLanguages } = extractFacts(root, { language: options['--language'] || null, config: options['--config'] || null });
|
|
106
104
|
const graph = buildGraph(facts, config);
|
|
@@ -121,6 +119,20 @@ export async function runCheck(argv) {
|
|
|
121
119
|
return { exitCode: 0, receipt: receipt('ok', { command: 'check', action: 'update-baseline', baseline: baselineFile, entries: doc.accepted.length, kept, added: doc.accepted.length - kept, dropped: existing ? existing.accepted.length - kept : 0 }) };
|
|
122
120
|
}
|
|
123
121
|
|
|
122
|
+
const finish = lock => finishCheck({ root, out, options, irDoc, mapDoc, baselineFile, explicitPrevious, facts, config, otherLanguages, graph, findings, lock });
|
|
123
|
+
return out ? withAnalysisOutput(out, finish) : finish(null);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function finishCheck({ root, out, options, irDoc, mapDoc, baselineFile, explicitPrevious, facts, config, otherLanguages, graph, findings, lock }) {
|
|
127
|
+
const { loadBaseline, loadPrevious, stableJson, reviewSummary } = await import('../lib/analysis.mjs');
|
|
128
|
+
const { reviewFindings, isOpen } = await import('../lib/review.mjs');
|
|
129
|
+
const { buildOverview, findingWhere } = await import('../overlay/overview.mjs');
|
|
130
|
+
const { alignDiagram, findingModules } = await import('../overlay/inject.mjs');
|
|
131
|
+
let previous = explicitPrevious;
|
|
132
|
+
if (!previous && out) {
|
|
133
|
+
const file = path.join(out, 'findings.json');
|
|
134
|
+
if (outputEntry(file)) previous = loadPrevious(file);
|
|
135
|
+
}
|
|
124
136
|
const review = reviewFindings(findings.diagnostics, { baseline: loadBaseline(baselineFile), previous, analysis: findings.analysis, files: [...facts.files, ...(findings.externalEvidence || [])].map((f) => f.path) });
|
|
125
137
|
if (options['--new-only'] && review.comparison && (findings.analysis.external?.length || previous?.analysis?.external?.length) && review.comparison.comparable !== true) {
|
|
126
138
|
fail('external/comparison-unverified', 'New-only gating requires comparable external reports.', { evidence: { reasons: review.comparison.reasons }, supportedFixes: ['provide matching tool versions, rule configuration, complete scan scope and source-bound reports', 'run a full check without --new-only to inspect the available diagnostics'] });
|
|
@@ -133,11 +145,6 @@ export async function runCheck(argv) {
|
|
|
133
145
|
: findings.diagnostics.map((d) => ({ ...d, ...(review.findings[d.id] ? { review: review.findings[d.id] } : {}), moduleIds: findingModules(d, fileModule), componentIds: [] }));
|
|
134
146
|
const overview = buildOverview({ findings: listed, graph, facts, unmapped: alignment ? alignment.unmapped : [], ambiguousModules: alignment ? alignment.ambiguousModules : [], run, diagram: Boolean(alignment) });
|
|
135
147
|
|
|
136
|
-
if (out) {
|
|
137
|
-
fs.mkdirSync(out, { recursive: true });
|
|
138
|
-
for (const [name, doc] of [['raw-facts', facts], ['module-graph', graph], ['findings', findings], ['review', review], ['overview', overview]]) fs.writeFileSync(path.join(out, `${name}.json`), stableJson(doc));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
148
|
const failOn = options['--fail-on'];
|
|
142
149
|
const newOnly = Boolean(options['--new-only']);
|
|
143
150
|
const failing = failOn === 'never' ? [] : findings.diagnostics.filter((d) => SEVERITY[d.severity] <= SEVERITY[failOn]
|
|
@@ -146,7 +153,7 @@ export async function runCheck(argv) {
|
|
|
146
153
|
// finding counts as new: a missing artifact must not pass the gate.
|
|
147
154
|
&& (!newOnly || !review.comparison || review.findings[d.id]?.since === 'new'));
|
|
148
155
|
const status = failing.length ? 'failed' : 'ok';
|
|
149
|
-
|
|
156
|
+
const result = {
|
|
150
157
|
exitCode: failing.length ? 1 : 0,
|
|
151
158
|
receipt: receipt(status, {
|
|
152
159
|
command: 'check', root, out,
|
|
@@ -211,6 +218,13 @@ export async function runCheck(argv) {
|
|
|
211
218
|
},
|
|
212
219
|
}),
|
|
213
220
|
};
|
|
221
|
+
if (lock) {
|
|
222
|
+
// The implicit comparison reads findings.json. Publish it last, after
|
|
223
|
+
// every other artifact and the CLI receipt are ready.
|
|
224
|
+
const documents = [['raw-facts', facts], ['module-graph', graph], ['review', review], ['overview', overview], ['findings', findings]];
|
|
225
|
+
writeCheckOutputs(out, lock, documents.map(([name, doc]) => [`${name}.json`, stableJson(doc)]));
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
214
228
|
}
|
|
215
229
|
|
|
216
230
|
export { findingWhere as where } from '../overlay/overview.mjs';
|
|
@@ -5,7 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { DiagnosticError, fail, receipt } from '../core/index.mjs';
|
|
8
|
-
import { assertDriftPin, captureDriftTree, driftRepository } from '../lib/drift-capture.mjs';
|
|
8
|
+
import { assertDriftPin, captureDriftTree, driftRepository, skippedDriftDirectory } from '../lib/drift-capture.mjs';
|
|
9
9
|
import { driftReportMaxBytes, readDriftInput } from '../lib/drift-input.mjs';
|
|
10
10
|
import { validateDriftFollowup } from '../lib/drift-verification.mjs';
|
|
11
11
|
import { driftDigest } from '../lib/architecture-drift.mjs';
|
|
@@ -117,10 +117,10 @@ async function run([repoArg, ...args]) {
|
|
|
117
117
|
const resolutionInputs = new Map();
|
|
118
118
|
const { facts } = extractFacts(root, { language: 'ts', config, capturedOnly: true, onCapture({ reads }) {
|
|
119
119
|
for (const [file, content] of reads) {
|
|
120
|
-
if (content === undefined) continue;
|
|
121
120
|
const relative = path.relative(root, file).split(path.sep).join('/');
|
|
122
121
|
if (relative !== '..' && !relative.startsWith('../') && !path.isAbsolute(relative)) {
|
|
123
|
-
resolutionInputs.set(relative, driftDigest(content));
|
|
122
|
+
if (content !== undefined) resolutionInputs.set(relative, driftDigest(content));
|
|
123
|
+
else if (skippedDriftDirectory(relative.split('/'))) resolutionInputs.set(relative, null);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
} });
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// One-shot companion to serve: a portable analysis view with captured AI tasks.
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import fs from 'node:fs';
|
|
5
4
|
import { fileURLToPath } from 'node:url';
|
|
6
5
|
import { DiagnosticError, receipt } from '../core/index.mjs';
|
|
7
6
|
import { prepareAnalysisSession, runSessionAnalysis } from './serve.mjs';
|
|
8
7
|
|
|
9
8
|
export async function prepareAnalysisView(argv, dependencies = {}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
return prepareAnalysisSession(argv, async (session, lock) => {
|
|
10
|
+
const { summary } = await runSessionAnalysis({ ...session, openAnalysis: true }, lock, dependencies);
|
|
11
|
+
return receipt('ok', { command: 'prepare', summary, diagram: session.delivered,
|
|
12
|
+
html: path.join(session.out, 'analysis', 'repo.analysis.html'), resume: session.resume });
|
|
13
|
+
});
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
@@ -22,6 +22,7 @@ import { execFile, spawn } from 'node:child_process';
|
|
|
22
22
|
import { promisify } from 'node:util';
|
|
23
23
|
import { fileURLToPath } from 'node:url';
|
|
24
24
|
import { DiagnosticError, fail } from '../core/index.mjs';
|
|
25
|
+
import { needsOutputRecovery, outputEntry, OUTPUT_BUSY, publishAnalysisMoves, withAnalysisOutput } from '../lib/output.mjs';
|
|
25
26
|
import { analysisStartCommand } from '../lib/task-command.mjs';
|
|
26
27
|
import { standaloneShell } from '../overlay/standalone.mjs';
|
|
27
28
|
import { clientAsset } from '../overlay/client-assets.mjs';
|
|
@@ -38,6 +39,7 @@ const TASK_BODY_LIMIT = 16 * 1024;
|
|
|
38
39
|
// Failures come back as the worker's structured diagnostics.
|
|
39
40
|
export function runWorker(options, { offline = false } = {}) {
|
|
40
41
|
return new Promise((resolve, reject) => {
|
|
42
|
+
fs.mkdirSync(options.out, { recursive: true });
|
|
41
43
|
const child = spawn(process.execPath, [worker], {
|
|
42
44
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
43
45
|
...(offline ? { env: { ...process.env, GIT_NO_LAZY_FETCH: '1', GIT_ALLOW_PROTOCOL: '', CARGO_NET_OFFLINE: 'true', RUSTUP_AUTO_INSTALL: '0' } } : {}),
|
|
@@ -100,7 +102,7 @@ export function parseArgs(argv) {
|
|
|
100
102
|
return { repo, options };
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
export async function prepareAnalysisSession(argv) {
|
|
105
|
+
export async function prepareAnalysisSession(argv, run = session => session) {
|
|
104
106
|
const { repo, options } = parseArgs(argv);
|
|
105
107
|
const root = path.resolve(repo), ir = options['--ir'] ? path.resolve(options['--ir']) : null, out = path.resolve(options['--out']);
|
|
106
108
|
const irBytes = ir ? fs.readFileSync(ir) : null;
|
|
@@ -110,8 +112,13 @@ export async function prepareAnalysisSession(argv) {
|
|
|
110
112
|
const pullRequest = options['--base']
|
|
111
113
|
? await resolveLocalPullRequest(root, options['--base'], options['--head'], options['--scope'])
|
|
112
114
|
: options['--pr'] ? await resolvePullRequest(root, options['--pr'], options['--repository'], options['--scope']) : null;
|
|
113
|
-
|
|
115
|
+
return withAnalysisOutput(out, async lock => {
|
|
116
|
+
const session = await createAnalysisSession({ root, ir, out, options, irBytes, doc, locale, pullRequest });
|
|
117
|
+
return run(session, lock);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
114
120
|
|
|
121
|
+
async function createAnalysisSession({ root, ir, out, options, irBytes, doc, locale, pullRequest }) {
|
|
115
122
|
// 1. Archify delivers the diagram. Repository evidence is checked when the IR pins a repository.
|
|
116
123
|
const delivered = ir ? path.join(out, 'architecture.html') : null;
|
|
117
124
|
let evidenceArgs = [];
|
|
@@ -125,7 +132,7 @@ export async function prepareAnalysisSession(argv) {
|
|
|
125
132
|
const deliveryInput = path.join(out, `.analysis-input-${randomBytes(12).toString('hex')}.json`);
|
|
126
133
|
fs.writeFileSync(deliveryInput, options['--locale'] ? JSON.stringify(doc) : irBytes, { flag: 'wx' });
|
|
127
134
|
try {
|
|
128
|
-
await execute(process.execPath, [archify, 'deliver', 'architecture', deliveryInput, delivered, '--quality', quality, ...evidenceArgs, '--json'], { maxBuffer: 16 * 1024 * 1024 });
|
|
135
|
+
await execute(process.execPath, [archify, 'deliver', 'architecture', deliveryInput, delivered, '--quality', quality, ...evidenceArgs, '--json'], { maxBuffer: 16 * 1024 * 1024, ...(pullRequest?.local ? { env: { ...process.env, ARCHIFY_UPDATE_CHECK_DISABLED: '1' } } : {}) });
|
|
129
136
|
} catch (error) {
|
|
130
137
|
// Archify refused the diagram. Show its receipt, not a bare "command failed": the IR needs
|
|
131
138
|
// repair (validate → fix what the diagnostics point at → validate again) before it can be served.
|
|
@@ -157,9 +164,13 @@ export async function prepareAnalysisSession(argv) {
|
|
|
157
164
|
return { root, ir, out, options, irBytes, doc, locale, delivered, baselineFile, resume, pullRequest };
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
// Callers hold the output lock for the lifetime of the comparison and publish.
|
|
168
|
+
export async function runSessionAnalysis({ root, ir, doc, locale, delivered, out, options, baselineFile, resume, pullRequest = null, openAnalysis = false }, lock, { preparePRSources = preparePullRequest } = {}) {
|
|
161
169
|
const analysisDir = path.join(out, 'analysis');
|
|
162
|
-
const
|
|
170
|
+
const previousDir = path.join(out, 'analysis.previous');
|
|
171
|
+
const next = path.join(lock, 'next');
|
|
172
|
+
const current = outputEntry(analysisDir, { directory: true });
|
|
173
|
+
const previous = outputEntry(previousDir, { directory: true });
|
|
163
174
|
let capture = null;
|
|
164
175
|
const offline = Boolean(pullRequest?.local);
|
|
165
176
|
try {
|
|
@@ -168,7 +179,7 @@ export async function runSessionAnalysis({ root, ir, doc, locale, delivered, out
|
|
|
168
179
|
const { loadConfig, stableJson } = await import('../lib/analysis.mjs');
|
|
169
180
|
const { selectAdapter } = await import('../extract/index.mjs');
|
|
170
181
|
capture = await preparePRSources({ ...pullRequest, out });
|
|
171
|
-
fs.mkdirSync(next
|
|
182
|
+
fs.mkdirSync(next);
|
|
172
183
|
const cfg = loadConfig(config);
|
|
173
184
|
config = path.join(next, 'captured-config.json');
|
|
174
185
|
fs.writeFileSync(config, stableJson(cfg));
|
|
@@ -187,18 +198,26 @@ export async function runSessionAnalysis({ root, ir, doc, locale, delivered, out
|
|
|
187
198
|
language, config, source: capture?.source('head') || null,
|
|
188
199
|
pullRequest: capture ? { pr: capture.pr, scope: capture.scope, changedFiles: capture.changedFiles, manifests: capture.manifests, sourceRoot: capture.roots.head, baseSourceRoot: capture.roots.base, sourceGitRoot: capture.sourceGitRoot } : null,
|
|
189
200
|
map: options['--map'] ? path.resolve(options['--map']) : null, baseline: fs.existsSync(baselineFile) ? baselineFile : null,
|
|
190
|
-
previous: capture ? path.join(next, 'base/findings.json') : path.join(analysisDir, 'findings.json'),
|
|
201
|
+
previous: capture ? path.join(next, 'base/findings.json') : path.join(current ? analysisDir : previousDir, 'findings.json'),
|
|
202
|
+
previousHeadDir: capture ? (current ? analysisDir : previousDir) : null,
|
|
203
|
+
retainBaselines: !capture,
|
|
191
204
|
}, { offline });
|
|
205
|
+
// Read what the caller will return while the old pair is still in place.
|
|
206
|
+
const html = fs.readFileSync(path.join(next, 'repo.analysis.html'), 'utf8');
|
|
207
|
+
const overview = JSON.parse(fs.readFileSync(path.join(next, 'overview.json'), 'utf8'));
|
|
208
|
+
const summary = { counts: overview.counts, coverage: overview.coverage, leads: overview.investigation.leads };
|
|
209
|
+
const moves = [];
|
|
210
|
+
if (current) {
|
|
211
|
+
if (previous) moves.push([previousDir, path.join(lock, 'previous')]);
|
|
212
|
+
moves.push([analysisDir, previousDir]);
|
|
213
|
+
}
|
|
214
|
+
moves.push([next, analysisDir]);
|
|
215
|
+
publishAnalysisMoves(moves, lock);
|
|
216
|
+
return { html, summary };
|
|
192
217
|
} catch (error) {
|
|
193
|
-
fs.rmSync(
|
|
194
|
-
if (capture) fs.rmSync(capture.directory, { recursive: true, force: true });
|
|
218
|
+
if (capture && !needsOutputRecovery(error)) fs.rmSync(capture.directory, { recursive: true, force: true });
|
|
195
219
|
throw error;
|
|
196
220
|
}
|
|
197
|
-
const previousDir = path.join(out, 'analysis.previous');
|
|
198
|
-
fs.rmSync(previousDir, { recursive: true, force: true });
|
|
199
|
-
if (fs.existsSync(analysisDir)) fs.renameSync(analysisDir, previousDir);
|
|
200
|
-
fs.renameSync(next, analysisDir);
|
|
201
|
-
return fs.readFileSync(path.join(analysisDir, 'repo.analysis.html'), 'utf8');
|
|
202
221
|
}
|
|
203
222
|
|
|
204
223
|
export async function startAnalysisView(argv, dependencies = {}) {
|
|
@@ -208,7 +227,7 @@ export async function startAnalysisView(argv, dependencies = {}) {
|
|
|
208
227
|
const page = (delivered ? fs.readFileSync(delivered, 'utf8') : standaloneShell({ locale, title: path.basename(root) })).replace('</body>', `<script>(${client.toString()})(${JSON.stringify(token)}, ${JSON.stringify(messagesFor(locale))}, ${createTranslator.toString()}, ${!ir}, ${JSON.stringify(clientAsset('entry.css'))})</script></body>`);
|
|
209
228
|
let pending = null, result = null, origin, reviewing = false;
|
|
210
229
|
const analysisDir = path.join(out, 'analysis');
|
|
211
|
-
const runAnalysis = () => runSessionAnalysis(session, dependencies);
|
|
230
|
+
const runAnalysis = () => withAnalysisOutput(out, lock => runSessionAnalysis(session, lock, dependencies));
|
|
212
231
|
const currentRoot = () => {
|
|
213
232
|
if (!session.pullRequest) return root;
|
|
214
233
|
const file = path.join(analysisDir, 'view-context.json');
|
|
@@ -237,11 +256,11 @@ export async function startAnalysisView(argv, dependencies = {}) {
|
|
|
237
256
|
// 3. The click returns the latest result; 4. a refresh request runs a new one.
|
|
238
257
|
// Concurrent requests share the run in progress.
|
|
239
258
|
try {
|
|
240
|
-
if (!pending && (!result || req.headers['x-analysis-refresh'] === '1')) pending = runAnalysis().then((html) => { result = html; return html; }).finally(() => { pending = null; });
|
|
259
|
+
if (!pending && (!result || req.headers['x-analysis-refresh'] === '1')) pending = runAnalysis().then(({ html }) => { result = html; return html; }).finally(() => { pending = null; });
|
|
241
260
|
send(200, pending ? await pending : result, 'text/html; charset=utf-8');
|
|
242
261
|
} catch (error) {
|
|
243
262
|
const diagnostics = error instanceof DiagnosticError ? error.diagnostics : [{ code: 'internal/unclassified', severity: 'error', message: error.message, subject: {}, evidence: {}, supportedFixes: [] }];
|
|
244
|
-
send(500, JSON.stringify({ error: diagnostics.map((d) => d.message).join('\n'), diagnostics }));
|
|
263
|
+
send(diagnostics.some(d => d.code === OUTPUT_BUSY) ? 409 : 500, JSON.stringify({ error: diagnostics.map((d) => d.message).join('\n'), diagnostics }));
|
|
245
264
|
}
|
|
246
265
|
});
|
|
247
266
|
// 5. A task for findings of the result on disk, checked against the working tree now.
|
|
@@ -259,21 +278,24 @@ export async function startAnalysisView(argv, dependencies = {}) {
|
|
|
259
278
|
if (!Array.isArray(ids) || !ids.length || ids.length > 20 || !ids.every((id) => typeof id === 'string' && /^[A-Z]{2,4}-(?:[0-9a-f]{12}|[0-9]{4,})$/.test(id))) return send(400, JSON.stringify({ error: 'ids must list 1–20 finding ids' }));
|
|
260
279
|
if (expected !== undefined && (!expected || typeof expected !== 'object' || Array.isArray(expected) || ids.some((id) => typeof expected[id] !== 'string' || !/^[0-9a-f]{64}$/.test(expected[id])))) return send(400, JSON.stringify({ error: 'expected must map every selected finding id to its displayed reviewTarget digest' }));
|
|
261
280
|
if (pending || reviewing) return fail409('task/analysis-running', 'An analysis or review update is running; build the task when it has finished.', ['retry after the analysis completes']);
|
|
262
|
-
if (!fs.existsSync(path.join(analysisDir, 'findings.json'))) return fail409('task/no-analysis', 'Run the analysis before building a task.', ['click Code Analysis first']);
|
|
263
281
|
try {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
282
|
+
await withAnalysisOutput(out, async () => {
|
|
283
|
+
if (!fs.existsSync(path.join(analysisDir, 'findings.json'))) return fail409('task/no-analysis', 'Run the analysis before building a task.', ['click Code Analysis first']);
|
|
284
|
+
const { buildTask, renderTaskMarkdown } = await import('../lib/task.mjs');
|
|
285
|
+
const { verifyTask } = await import('../lib/evidence.mjs');
|
|
286
|
+
const { loadBaseline, loadPrevious } = await import('../lib/analysis.mjs');
|
|
287
|
+
const { reviewFindings, reviewTargetDigest } = await import('../lib/review.mjs');
|
|
288
|
+
const read = (name) => JSON.parse(fs.readFileSync(path.join(analysisDir, name), 'utf8'));
|
|
289
|
+
const findings = read('findings.json'), facts = read('raw-facts.json');
|
|
290
|
+
if (expected && findings.diagnostics.some((finding) => ids.includes(finding.id) && reviewTargetDigest(finding) !== expected[finding.id])) return fail409('task/finding-changed', 'The finding changed since this page was loaded. Re-analyze to refresh the displayed claim before exporting its task.', ['refresh the analysis page and review the current finding']);
|
|
291
|
+
const review = reviewFindings(findings.diagnostics, { baseline: fs.existsSync(baselineFile) ? loadBaseline(baselineFile) : null, previous: loadPrevious(comparisonFile()), analysis: findings.analysis, files: [...facts.files, ...(findings.externalEvidence || [])].map((f) => f.path) });
|
|
292
|
+
const task = verifyTask(buildTask({ findings, facts, ids, review }), currentRoot());
|
|
293
|
+
send(200, JSON.stringify({ task, markdown: renderTaskMarkdown(task) }));
|
|
294
|
+
});
|
|
274
295
|
} catch (error) {
|
|
275
296
|
const diagnostics = error instanceof DiagnosticError ? error.diagnostics : [{ code: 'internal/unclassified', severity: 'error', message: error.message, subject: {}, evidence: {}, supportedFixes: [] }];
|
|
276
|
-
|
|
297
|
+
const status = diagnostics.some(d => d.code === OUTPUT_BUSY) ? 409 : error instanceof DiagnosticError && !needsOutputRecovery(error) ? 422 : 500;
|
|
298
|
+
send(status, JSON.stringify({ error: diagnostics.map((d) => d.message).join('\n'), diagnostics }));
|
|
277
299
|
}
|
|
278
300
|
};
|
|
279
301
|
// A fixed baseline destination and one id per decision. Paths are never supplied
|
|
@@ -288,10 +310,10 @@ export async function startAnalysisView(argv, dependencies = {}) {
|
|
|
288
310
|
if (!input || !['accept', 'revoke'].includes(input.action) || typeof input.id !== 'string' || !/^[A-Z]{2,4}-[0-9a-f]{12}$/.test(input.id)) return send(400, JSON.stringify({ error: 'review requires action accept/revoke and a stable finding id' }));
|
|
289
311
|
if (input.action === 'accept' && (typeof input.expected !== 'string' || !/^[0-9a-f]{64}$/.test(input.expected))) return send(400, JSON.stringify({ error: 'accept requires the reviewTarget digest shown with the finding' }));
|
|
290
312
|
if (pending || reviewing) return send(409, JSON.stringify({ error: 'An analysis or review update is running; retry after it finishes.' }));
|
|
291
|
-
if (!fs.existsSync(path.join(analysisDir, 'findings.json'))) return send(409, JSON.stringify({ error: 'Run an analysis before reviewing a finding.' }));
|
|
292
313
|
reviewing = true;
|
|
293
314
|
let phase = 'prepare';
|
|
294
|
-
|
|
315
|
+
const save = async () => {
|
|
316
|
+
if (!fs.existsSync(path.join(analysisDir, 'findings.json'))) return send(409, JSON.stringify({ error: 'Run an analysis before reviewing a finding.' }));
|
|
295
317
|
const { loadBaseline, saveBaseline, loadPrevious } = await import('../lib/analysis.mjs');
|
|
296
318
|
const { acceptFinding, revokeFinding, reviewFindings, reviewTargetDigest } = await import('../lib/review.mjs');
|
|
297
319
|
const { buildTask } = await import('../lib/task.mjs');
|
|
@@ -321,9 +343,13 @@ export async function startAnalysisView(argv, dependencies = {}) {
|
|
|
321
343
|
response.warnings = [{ code: 'review/artifacts-not-updated', message: `The baseline was saved and this server has the updated view, but disk view artifacts could not all be updated (${error.message}). Re-analyze when the output directory is writable to refresh the saved files.` }];
|
|
322
344
|
}
|
|
323
345
|
send(200, JSON.stringify(response));
|
|
346
|
+
};
|
|
347
|
+
try {
|
|
348
|
+
await withAnalysisOutput(out, save);
|
|
324
349
|
} catch (error) {
|
|
325
350
|
const diagnostics = error instanceof DiagnosticError ? error.diagnostics : [{ code: phase === 'save' ? 'baseline/write-failed' : 'review/preparation-failed', severity: 'error', message: error.message, subject: {}, evidence: {}, supportedFixes: [phase === 'save' ? 'check that the configured baseline can be written, then retry' : 're-analyze the repository to rebuild its captured view, then retry'] }];
|
|
326
|
-
|
|
351
|
+
const status = diagnostics.some(d => d.code === OUTPUT_BUSY) ? 409 : error instanceof DiagnosticError ? 422 : 500;
|
|
352
|
+
send(status, JSON.stringify({ error: diagnostics.map((d) => d.message).join('\n'), diagnostics }));
|
|
327
353
|
} finally { reviewing = false; }
|
|
328
354
|
};
|
|
329
355
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
@@ -412,14 +438,15 @@ function client(token, messages, makeTranslator, standalone, entryCss) {
|
|
|
412
438
|
};
|
|
413
439
|
// Re-analysis: the server runs a new analysis; the page then reloads and opens it,
|
|
414
440
|
// which re-mounts the layer cleanly instead of patching a live one.
|
|
415
|
-
window.__archifyReanalyze = async function () {
|
|
441
|
+
window.__archifyReanalyze = async function (reading) {
|
|
416
442
|
var response = await fetch('/analyze', { method: 'POST', headers: { 'X-Analysis-Token': token, 'X-Analysis-Refresh': '1' } });
|
|
417
443
|
if (!response.ok) {
|
|
418
444
|
var body = {};
|
|
419
445
|
try { body = await response.json(); } catch (e) { /* not JSON */ }
|
|
420
446
|
throw new Error(body.error || tr("analysis failed"));
|
|
421
447
|
}
|
|
422
|
-
|
|
448
|
+
history.replaceState({ analysisRefresh: { token: token, reading: reading } }, '', location.pathname);
|
|
449
|
+
location.reload();
|
|
423
450
|
};
|
|
424
451
|
button.addEventListener('click', async function () {
|
|
425
452
|
button.disabled = true; button.setAttribute('aria-busy', 'true'); setLabel(tr("Analyzing…")); say(tr("Reading the repository — imports, modules, rules."));
|
|
@@ -456,13 +483,16 @@ function client(token, messages, makeTranslator, standalone, entryCss) {
|
|
|
456
483
|
if (toggle && document.documentElement.getAttribute('data-bauify') !== 'on') toggle.click();
|
|
457
484
|
var params = new URLSearchParams(location.search), selectedFinding = params.get('finding');
|
|
458
485
|
if (selectedFinding && window.__archifyShowFinding) window.__archifyShowFinding(selectedFinding, params.get('from') === 'findings' ? 'findings' : 'summary');
|
|
459
|
-
if (
|
|
486
|
+
if (refreshReading) window.__archifyRestoreReading?.(refreshReading);
|
|
487
|
+
if (location.search || refreshReading) history.replaceState(null, '', location.pathname);
|
|
460
488
|
} catch (error) {
|
|
461
489
|
button.disabled = false; button.removeAttribute('aria-busy'); setLabel(tr("Code Analysis"));
|
|
462
490
|
say(tr("Analysis failed: ") + error.message + tr(" — click Code Analysis to retry."));
|
|
463
491
|
}
|
|
464
492
|
});
|
|
465
|
-
|
|
493
|
+
var savedRefresh = history.state?.analysisRefresh;
|
|
494
|
+
var refreshReading = savedRefresh?.token === token && savedRefresh.reading;
|
|
495
|
+
if (standalone || refreshReading || new URLSearchParams(location.search).get('analysis') === 'open') button.click();
|
|
466
496
|
}
|
|
467
497
|
|
|
468
498
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|