@namewta/skills-hub 0.1.49 → 0.1.51
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 +6 -6
- 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 +60 -0
- package/skills/home/home-project-changelog/references/tools.md +27 -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 +34 -37
- package/skills/home/home-project-changelog/scripts/contract.mjs +39 -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 +136 -128
- package/skills/home/home-website/assets/website/scripts/render.mjs +3 -3
- 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 +69 -23
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +74 -42
- package/skills/home/home-website/assets/website/site/templates/layout.mjs +2 -6
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +33 -24
- package/skills/home/home-website/assets/website/site/templates/model.mjs +28 -5
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +48 -19
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +2 -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 +105 -0
- package/skills/home/home-website/scripts/init.mjs +79 -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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { byText, sortUnique } from "../ir.mjs";
|
|
2
|
+
function checkAcyclic(lemmas, start) {
|
|
3
|
+
const state = new Map();
|
|
4
|
+
const stack = [];
|
|
5
|
+
const visit = (name) => {
|
|
6
|
+
state.set(name, 1);
|
|
7
|
+
stack.push(name);
|
|
8
|
+
const lemma = lemmas.get(name);
|
|
9
|
+
if (lemma) {
|
|
10
|
+
for (const edge of lemma.to) {
|
|
11
|
+
const mark = state.get(edge.name);
|
|
12
|
+
if (mark === 1) {
|
|
13
|
+
const at = stack.indexOf(edge.name);
|
|
14
|
+
const cycle = [...stack.slice(at), edge.name].join(" -> ");
|
|
15
|
+
throw new Error(`可见引理图存在环:${cycle}。`);
|
|
16
|
+
}
|
|
17
|
+
if (mark === undefined) visit(edge.name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
stack.pop();
|
|
21
|
+
state.set(name, 2);
|
|
22
|
+
};
|
|
23
|
+
visit(start);
|
|
24
|
+
}
|
|
25
|
+
export function contract(facts) {
|
|
26
|
+
const decls = new Map();
|
|
27
|
+
for (const d of facts.decls) decls.set(d.name, d);
|
|
28
|
+
const outside = new Map();
|
|
29
|
+
for (const o of facts.outside) outside.set(o.name, o);
|
|
30
|
+
const rootDecl = decls.get(facts.target);
|
|
31
|
+
if (!rootDecl)
|
|
32
|
+
throw new Error(
|
|
33
|
+
`decls 缺少目标声明 ${facts.target}。`,
|
|
34
|
+
);
|
|
35
|
+
if (!rootDecl.visible)
|
|
36
|
+
throw new Error(
|
|
37
|
+
`目标声明 ${facts.target} 必须在 decls 中可见。`,
|
|
38
|
+
);
|
|
39
|
+
const lemmas = new Map();
|
|
40
|
+
const queue = [facts.target];
|
|
41
|
+
const queued = new Set([facts.target]);
|
|
42
|
+
while (queue.length > 0) {
|
|
43
|
+
const name = queue.shift();
|
|
44
|
+
const decl = decls.get(name);
|
|
45
|
+
if (!decl) continue;
|
|
46
|
+
const to = new Map();
|
|
47
|
+
const library = new Set();
|
|
48
|
+
const axioms = new Set();
|
|
49
|
+
const sorries = [];
|
|
50
|
+
const seenSorries = new Set();
|
|
51
|
+
const pushSorry = (entry, mod) => {
|
|
52
|
+
const key = entry.at
|
|
53
|
+
? `${mod}\0${entry.in}\0${entry.synthetic}\0${entry.at.line}:${entry.at.column}`
|
|
54
|
+
: `${mod}\0${entry.in}\0${entry.synthetic}\0`;
|
|
55
|
+
if (seenSorries.has(key)) return;
|
|
56
|
+
seenSorries.add(key);
|
|
57
|
+
sorries.push(entry);
|
|
58
|
+
};
|
|
59
|
+
for (const s of decl.sorries) {
|
|
60
|
+
pushSorry(
|
|
61
|
+
{
|
|
62
|
+
in: s.in ?? decl.userName,
|
|
63
|
+
synthetic: s.synthetic,
|
|
64
|
+
at: s.at,
|
|
65
|
+
},
|
|
66
|
+
decl.module,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (decl.kind === "axiom") axioms.add(decl.name);
|
|
70
|
+
const hiddenThrough = new Map();
|
|
71
|
+
const hiddenSorriesSeen = new Set();
|
|
72
|
+
const outsideSorriesSeen = new Set();
|
|
73
|
+
const work = decl.uses.map((ref) => ({
|
|
74
|
+
ref,
|
|
75
|
+
through: "proof",
|
|
76
|
+
}));
|
|
77
|
+
while (work.length > 0) {
|
|
78
|
+
const item = work.shift();
|
|
79
|
+
const sub = decls.get(item.ref);
|
|
80
|
+
if (sub) {
|
|
81
|
+
if (sub.visible) {
|
|
82
|
+
if (sub.name === decl.name) continue;
|
|
83
|
+
const prev = to.get(sub.name);
|
|
84
|
+
if (prev === undefined || item.through === "proof")
|
|
85
|
+
to.set(sub.name, item.through);
|
|
86
|
+
if (!queued.has(sub.name)) {
|
|
87
|
+
queued.add(sub.name);
|
|
88
|
+
queue.push(sub.name);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
const nextThrough =
|
|
92
|
+
item.through === "definition" || sub.isUserDef
|
|
93
|
+
? "definition"
|
|
94
|
+
: "proof";
|
|
95
|
+
if (!hiddenSorriesSeen.has(sub.name)) {
|
|
96
|
+
hiddenSorriesSeen.add(sub.name);
|
|
97
|
+
for (const s of sub.sorries) {
|
|
98
|
+
pushSorry(
|
|
99
|
+
{
|
|
100
|
+
in: s.in ?? (sub.isUserDef ? sub.userName : decl.userName),
|
|
101
|
+
synthetic: s.synthetic,
|
|
102
|
+
at: s.at,
|
|
103
|
+
},
|
|
104
|
+
sub.module,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const prev = hiddenThrough.get(sub.name);
|
|
109
|
+
if (prev === "proof" || prev === nextThrough) continue;
|
|
110
|
+
hiddenThrough.set(sub.name, nextThrough);
|
|
111
|
+
for (const nextRef of sub.uses)
|
|
112
|
+
work.push({
|
|
113
|
+
ref: nextRef,
|
|
114
|
+
through: nextThrough,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const ext = outside.get(item.ref);
|
|
120
|
+
if (ext) {
|
|
121
|
+
if (ext.kind === "theorem") library.add(ext.name);
|
|
122
|
+
for (const ax of ext.axioms) axioms.add(ax);
|
|
123
|
+
if (
|
|
124
|
+
ext.name !== "sorryAx" &&
|
|
125
|
+
ext.axioms.includes("sorryAx") &&
|
|
126
|
+
!outsideSorriesSeen.has(ext.name)
|
|
127
|
+
) {
|
|
128
|
+
outsideSorriesSeen.add(ext.name);
|
|
129
|
+
pushSorry(
|
|
130
|
+
{
|
|
131
|
+
in: `${ext.name} (${ext.home})`,
|
|
132
|
+
synthetic: false,
|
|
133
|
+
at: undefined,
|
|
134
|
+
},
|
|
135
|
+
ext.home,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const edges = [...to.entries()]
|
|
141
|
+
.sort(([a], [b]) => byText(a, b))
|
|
142
|
+
.map(([edgeName, through]) => ({
|
|
143
|
+
name: edgeName,
|
|
144
|
+
through,
|
|
145
|
+
}));
|
|
146
|
+
lemmas.set(name, {
|
|
147
|
+
decl,
|
|
148
|
+
to: edges,
|
|
149
|
+
library: sortUnique(library),
|
|
150
|
+
axioms: sortUnique(axioms),
|
|
151
|
+
sorries,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
checkAcyclic(lemmas, facts.target);
|
|
155
|
+
return {
|
|
156
|
+
target: facts.target,
|
|
157
|
+
lemmas,
|
|
158
|
+
reducedEdges: 0,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { hasSubtreeMark } from "../ir.mjs";
|
|
2
|
+
const hypSig = (h) =>
|
|
3
|
+
h.value !== undefined ? `${h.type} := ${h.value}` : h.type;
|
|
4
|
+
const isTypeBinder = (h) =>
|
|
5
|
+
h.type === "Type" ||
|
|
6
|
+
h.type.startsWith("Type ") ||
|
|
7
|
+
h.type === "Sort" ||
|
|
8
|
+
h.type.startsWith("Sort ");
|
|
9
|
+
function branchGoalSig(input) {
|
|
10
|
+
const { entryGoal, lastGoal, parentLastGoal, hyps } = input;
|
|
11
|
+
if (!entryGoal) return "";
|
|
12
|
+
const added = [];
|
|
13
|
+
if (parentLastGoal) {
|
|
14
|
+
const parentMap = new Map();
|
|
15
|
+
for (const hid of parentLastGoal.hyps) {
|
|
16
|
+
const h = hyps[hid];
|
|
17
|
+
if (h) parentMap.set(h.name, hypSig(h));
|
|
18
|
+
}
|
|
19
|
+
for (const hid of entryGoal.hyps) {
|
|
20
|
+
const h = hyps[hid];
|
|
21
|
+
if (!h || isTypeBinder(h)) continue;
|
|
22
|
+
const sig = hypSig(h);
|
|
23
|
+
if (parentMap.get(h.name) !== sig) added.push(`e:${h.name}:${sig}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (lastGoal && lastGoal.id !== entryGoal.id) {
|
|
27
|
+
const entryMap = new Map();
|
|
28
|
+
for (const hid of entryGoal.hyps) {
|
|
29
|
+
const h = hyps[hid];
|
|
30
|
+
if (h) entryMap.set(h.name, hypSig(h));
|
|
31
|
+
}
|
|
32
|
+
for (const hid of lastGoal.hyps) {
|
|
33
|
+
const h = hyps[hid];
|
|
34
|
+
if (!h || isTypeBinder(h)) continue;
|
|
35
|
+
const sig = hypSig(h);
|
|
36
|
+
if (entryMap.get(h.name) !== sig) added.push(`m:${h.name}:${sig}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return `${entryGoal.target}\0${added.join("\n")}`;
|
|
40
|
+
}
|
|
41
|
+
export function foldSiblings(input) {
|
|
42
|
+
const { roots, script } = input;
|
|
43
|
+
const goalById = new Map();
|
|
44
|
+
for (const g of script.goals) goalById.set(g.id, g);
|
|
45
|
+
const stepById = new Map();
|
|
46
|
+
for (const s of script.steps) stepById.set(s.id, s);
|
|
47
|
+
const stepSignature = (block) =>
|
|
48
|
+
block.steps
|
|
49
|
+
.map((sid) => {
|
|
50
|
+
const text = stepById.get(sid)?.text ?? `#${sid}`;
|
|
51
|
+
const inl = block.inlined.get(sid);
|
|
52
|
+
return inl && inl.length > 0 ? `${text}[${inl.join(";")}]` : text;
|
|
53
|
+
})
|
|
54
|
+
.join("\n");
|
|
55
|
+
const subtreeSignature = (block) => {
|
|
56
|
+
const childSigs = block.into
|
|
57
|
+
.map((c) => `${c.times}:${subtreeSignature(c)}`)
|
|
58
|
+
.join(",");
|
|
59
|
+
return `${stepSignature(block)}|${block.errorLabel ?? ""}|(${childSigs})`;
|
|
60
|
+
};
|
|
61
|
+
const subtreeGoalSig = (block, parentLastGoal) => {
|
|
62
|
+
const own = branchGoalSig({
|
|
63
|
+
entryGoal: goalById.get(block.entry),
|
|
64
|
+
lastGoal: goalById.get(block.last),
|
|
65
|
+
parentLastGoal,
|
|
66
|
+
hyps: script.hyps,
|
|
67
|
+
});
|
|
68
|
+
const ownLast = goalById.get(block.last) ?? goalById.get(block.entry);
|
|
69
|
+
const childSigs = block.into
|
|
70
|
+
.map((c) => subtreeGoalSig(c, ownLast))
|
|
71
|
+
.join(",");
|
|
72
|
+
return `${own}|(${childSigs})`;
|
|
73
|
+
};
|
|
74
|
+
const hasErrorInSubtree = (block) =>
|
|
75
|
+
block.errorLabel !== undefined || block.into.some(hasErrorInSubtree);
|
|
76
|
+
const mergeChildSubtree = (
|
|
77
|
+
target,
|
|
78
|
+
extra,
|
|
79
|
+
targetParentLast,
|
|
80
|
+
extraParentLast,
|
|
81
|
+
) => {
|
|
82
|
+
const targetSig = branchGoalSig({
|
|
83
|
+
entryGoal: goalById.get(target.entry),
|
|
84
|
+
lastGoal: goalById.get(target.last),
|
|
85
|
+
parentLastGoal: targetParentLast,
|
|
86
|
+
hyps: script.hyps,
|
|
87
|
+
});
|
|
88
|
+
const extraSig = branchGoalSig({
|
|
89
|
+
entryGoal: goalById.get(extra.entry),
|
|
90
|
+
lastGoal: goalById.get(extra.last),
|
|
91
|
+
parentLastGoal: extraParentLast,
|
|
92
|
+
hyps: script.hyps,
|
|
93
|
+
});
|
|
94
|
+
if (extra.differentGoals || targetSig !== extraSig)
|
|
95
|
+
target.differentGoals = true;
|
|
96
|
+
for (const tag of extra.tags) {
|
|
97
|
+
if (!target.tags.includes(tag)) target.tags.push(tag);
|
|
98
|
+
}
|
|
99
|
+
for (const entry of extra.foldedEntries) target.foldedEntries.push(entry);
|
|
100
|
+
const nextTargetLast =
|
|
101
|
+
goalById.get(target.last) ?? goalById.get(target.entry);
|
|
102
|
+
const nextExtraLast = goalById.get(extra.last) ?? goalById.get(extra.entry);
|
|
103
|
+
for (let i = 0; i < target.into.length && i < extra.into.length; i++) {
|
|
104
|
+
mergeChildSubtree(
|
|
105
|
+
target.into[i],
|
|
106
|
+
extra.into[i],
|
|
107
|
+
nextTargetLast,
|
|
108
|
+
nextExtraLast,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const mergeInto = (target, extra, differentGoals) => {
|
|
113
|
+
target.times += extra.times;
|
|
114
|
+
if (differentGoals || extra.differentGoals) target.differentGoals = true;
|
|
115
|
+
for (const tag of extra.tags) {
|
|
116
|
+
if (!target.tags.includes(tag)) target.tags.push(tag);
|
|
117
|
+
}
|
|
118
|
+
for (const entry of extra.foldedEntries) target.foldedEntries.push(entry);
|
|
119
|
+
const nextTargetLast =
|
|
120
|
+
goalById.get(target.last) ?? goalById.get(target.entry);
|
|
121
|
+
const nextExtraLast = goalById.get(extra.last) ?? goalById.get(extra.entry);
|
|
122
|
+
for (let i = 0; i < target.into.length && i < extra.into.length; i++) {
|
|
123
|
+
mergeChildSubtree(
|
|
124
|
+
target.into[i],
|
|
125
|
+
extra.into[i],
|
|
126
|
+
nextTargetLast,
|
|
127
|
+
nextExtraLast,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const convert = (block) => {
|
|
132
|
+
const parentLastGoal =
|
|
133
|
+
goalById.get(block.last) ?? goalById.get(block.entry);
|
|
134
|
+
const rawChildren = block.into.map(convert);
|
|
135
|
+
const items = rawChildren.map((drawn) => {
|
|
136
|
+
const foldable = !hasSubtreeMark(drawn) && !hasErrorInSubtree(drawn);
|
|
137
|
+
return {
|
|
138
|
+
drawn,
|
|
139
|
+
foldable,
|
|
140
|
+
tacticSig: foldable ? subtreeSignature(drawn) : "",
|
|
141
|
+
goalSig: foldable ? subtreeGoalSig(drawn, parentLastGoal) : "",
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
const exactMerged = [];
|
|
145
|
+
const byExact = new Map();
|
|
146
|
+
for (const item of items) {
|
|
147
|
+
if (!item.foldable) {
|
|
148
|
+
exactMerged.push(item);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const key = `${item.tacticSig}\u0001${item.goalSig}`;
|
|
152
|
+
const existing = byExact.get(key);
|
|
153
|
+
if (existing) {
|
|
154
|
+
mergeInto(existing.drawn, item.drawn, false);
|
|
155
|
+
} else {
|
|
156
|
+
byExact.set(key, item);
|
|
157
|
+
exactMerged.push(item);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const tacticGroupCounts = new Map();
|
|
161
|
+
for (const item of exactMerged) {
|
|
162
|
+
if (!item.foldable) continue;
|
|
163
|
+
tacticGroupCounts.set(
|
|
164
|
+
item.tacticSig,
|
|
165
|
+
(tacticGroupCounts.get(item.tacticSig) ?? 0) + item.drawn.times,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const merged = [];
|
|
169
|
+
const byTactic = new Map();
|
|
170
|
+
for (const item of exactMerged) {
|
|
171
|
+
if (!item.foldable || (tacticGroupCounts.get(item.tacticSig) ?? 0) < 3) {
|
|
172
|
+
merged.push(item.drawn);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const existing = byTactic.get(item.tacticSig);
|
|
176
|
+
if (existing) {
|
|
177
|
+
mergeInto(existing, item.drawn, true);
|
|
178
|
+
} else {
|
|
179
|
+
byTactic.set(item.tacticSig, item.drawn);
|
|
180
|
+
merged.push(item.drawn);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const tag = goalById.get(block.entry)?.tag;
|
|
184
|
+
const ownEntry = {
|
|
185
|
+
entry: block.entry,
|
|
186
|
+
last: block.last,
|
|
187
|
+
tag,
|
|
188
|
+
steps: [...block.steps],
|
|
189
|
+
inlined: new Map(block.inlined),
|
|
190
|
+
errorLabel: block.errorLabel,
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
...block,
|
|
194
|
+
into: merged,
|
|
195
|
+
times: 1,
|
|
196
|
+
tags: tag ? [tag] : [],
|
|
197
|
+
differentGoals: false,
|
|
198
|
+
foldedEntries: [ownEntry],
|
|
199
|
+
hidden: undefined,
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
return roots.map(({ root, block }) => ({
|
|
203
|
+
root,
|
|
204
|
+
block: convert(block),
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { spanStrictlyInside } from "../ir.mjs";
|
|
2
|
+
export function inlineBlocks(input) {
|
|
3
|
+
const { roots, script } = input;
|
|
4
|
+
const goalById = new Map();
|
|
5
|
+
for (const g of script.goals) goalById.set(g.id, g);
|
|
6
|
+
const stepById = new Map();
|
|
7
|
+
for (const s of script.steps) stepById.set(s.id, s);
|
|
8
|
+
const isSpawnedOneStep = (parentStep, child) => {
|
|
9
|
+
if (child.into.length !== 0) return undefined;
|
|
10
|
+
if (child.steps.length !== 1) return undefined;
|
|
11
|
+
if (child.marks.size !== 0 || child.errorLabel !== undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
const goal = goalById.get(child.last);
|
|
14
|
+
if (goal && goal.closedBy !== "proof") return undefined;
|
|
15
|
+
const childStep = stepById.get(child.steps[0]);
|
|
16
|
+
if (!childStep) return undefined;
|
|
17
|
+
if (!spanStrictlyInside(parentStep.span, childStep.span)) return undefined;
|
|
18
|
+
return childStep.text;
|
|
19
|
+
};
|
|
20
|
+
const isInsideParent = (parentStep, child) => {
|
|
21
|
+
if (child.steps.length === 0) return false;
|
|
22
|
+
const first = stepById.get(child.steps[0]);
|
|
23
|
+
return (
|
|
24
|
+
first !== undefined && spanStrictlyInside(parentStep.span, first.span)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const transform = (raw) => {
|
|
28
|
+
const block = {
|
|
29
|
+
...raw,
|
|
30
|
+
steps: [...raw.steps],
|
|
31
|
+
inlined: new Map(raw.inlined),
|
|
32
|
+
marks: new Set(raw.marks),
|
|
33
|
+
restsOnKinds: new Set(raw.restsOnKinds),
|
|
34
|
+
into: raw.into.map(transform),
|
|
35
|
+
};
|
|
36
|
+
while (block.steps.length > 0 && block.into.length > 1) {
|
|
37
|
+
const lastStepId = block.steps[block.steps.length - 1];
|
|
38
|
+
const parentStep = stepById.get(lastStepId);
|
|
39
|
+
if (!parentStep) break;
|
|
40
|
+
const hasExternalContinuation = block.into.some(
|
|
41
|
+
(child) => !isInsideParent(parentStep, child),
|
|
42
|
+
);
|
|
43
|
+
if (!hasExternalContinuation) break;
|
|
44
|
+
const remaining = [];
|
|
45
|
+
const foldedTexts = [...(block.inlined.get(lastStepId) ?? [])];
|
|
46
|
+
let didInline = false;
|
|
47
|
+
for (const child of block.into) {
|
|
48
|
+
const text = isSpawnedOneStep(parentStep, child);
|
|
49
|
+
if (text !== undefined) {
|
|
50
|
+
foldedTexts.push(text);
|
|
51
|
+
didInline = true;
|
|
52
|
+
} else {
|
|
53
|
+
remaining.push(child);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!didInline) break;
|
|
57
|
+
block.inlined.set(lastStepId, foldedTexts);
|
|
58
|
+
if (remaining.length === 1) {
|
|
59
|
+
const cont = remaining[0];
|
|
60
|
+
for (const s of cont.steps) block.steps.push(s);
|
|
61
|
+
for (const [k, v] of cont.inlined) {
|
|
62
|
+
const prev = block.inlined.get(k);
|
|
63
|
+
block.inlined.set(k, prev ? [...prev, ...v] : [...v]);
|
|
64
|
+
}
|
|
65
|
+
for (const m of cont.marks) block.marks.add(m);
|
|
66
|
+
if (cont.restsOnKinds) {
|
|
67
|
+
block.restsOnKinds ??= new Set();
|
|
68
|
+
for (const k of cont.restsOnKinds) block.restsOnKinds.add(k);
|
|
69
|
+
}
|
|
70
|
+
block.errorLabel = cont.errorLabel ?? block.errorLabel;
|
|
71
|
+
block.last = cont.last;
|
|
72
|
+
block.into = cont.into;
|
|
73
|
+
} else {
|
|
74
|
+
block.into = remaining;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return block;
|
|
79
|
+
};
|
|
80
|
+
return roots.map(({ root, block }) => ({
|
|
81
|
+
root,
|
|
82
|
+
block: transform(block),
|
|
83
|
+
}));
|
|
84
|
+
}
|