@mmerterden/multi-agent-pipeline 20.37.0 → 20.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +123 -49
- package/README.md +12 -10
- package/README.tr.md +12 -10
- package/docs/adr/0006-skills-core-external-split.md +5 -5
- package/docs/adr/0010-own-code-graph.md +6 -7
- package/docs/adr/0013-lsp-code-intelligence.md +6 -8
- package/docs/adr/0017-change-impact-from-the-graph.md +4 -5
- package/docs/adr/0018-cross-repo-links-not-a-global-graph.md +1 -1
- package/docs/adr/README.md +1 -1
- package/docs/ecosystem.md +53 -41
- package/docs/facts.json +15 -13
- package/docs/features.md +2 -2
- package/docs/recovery-guide.md +1 -1
- package/install/_dev-only-files.mjs +3 -0
- package/install/_platform-filter.mjs +1 -23
- package/install/catalog-history.json +1 -1
- package/install/claude.mjs +8 -1
- package/install/codex.mjs +0 -2
- package/install/copilot.mjs +0 -2
- package/install/templates/claude-hooks.json +47 -1
- package/manifest.json +455 -332
- package/package.json +5 -2
- package/pipeline/agents/security-auditor.md +58 -6
- package/pipeline/commands/multi-agent/build-optimize/SKILL.md +1 -2
- package/pipeline/commands/multi-agent/complaint-analysis/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/design-check/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/graph/SKILL.md +12 -3
- package/pipeline/commands/multi-agent/manual-test/SKILL.md +12 -7
- package/pipeline/commands/multi-agent/research/SKILL.md +2 -2
- package/pipeline/commands/multi-agent/search/SKILL.md +10 -1
- package/pipeline/commands/multi-agent/security-review/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/setup/SKILL.md +1 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +8 -0
- package/pipeline/commands/multi-agent/store-ready/SKILL.md +1 -1
- package/pipeline/commands/sim-test.md +34 -1
- package/pipeline/lib/context-budget.mjs +103 -0
- package/pipeline/lib/credential-inventory.sh +2 -3
- package/pipeline/lib/identifier-scan.mjs +145 -0
- package/pipeline/lib/outbound-gate.mjs +28 -1
- package/pipeline/lib/unattended-profile-check.mjs +13 -4
- package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
- package/pipeline/multi-agent-refs/analysis/redesign.md +17 -3
- package/pipeline/multi-agent-refs/analysis-template-corporate.md +8 -4
- package/pipeline/multi-agent-refs/analysis-template.md +7 -5
- package/pipeline/multi-agent-refs/audit-guide.md +20 -0
- package/pipeline/multi-agent-refs/complaint-analysis/phases.md +1 -0
- package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +1 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +25 -0
- package/pipeline/multi-agent-refs/features/commit-multi-repo.md +63 -0
- package/pipeline/multi-agent-refs/features/design-conformance.md +20 -4
- package/pipeline/multi-agent-refs/features/dev-multi-repo.md +51 -0
- package/pipeline/multi-agent-refs/features/free-models.md +10 -3
- package/pipeline/multi-agent-refs/features/research.md +4 -3
- package/pipeline/multi-agent-refs/features/security-audit.md +25 -3
- package/pipeline/multi-agent-refs/features/test-gap.md +40 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +20 -0
- package/pipeline/multi-agent-refs/features/worktree-finalize.md +1 -1
- package/pipeline/multi-agent-refs/help/en.md +15 -9
- package/pipeline/multi-agent-refs/help/tr.md +15 -9
- package/pipeline/multi-agent-refs/knowledge.md +17 -0
- package/pipeline/multi-agent-refs/orchestrator/phase-3-user-test.md +12 -9
- package/pipeline/multi-agent-refs/outside-the-pipeline.md +9 -0
- package/pipeline/multi-agent-refs/phases/log-format.md +5 -0
- package/pipeline/multi-agent-refs/phases/operations.md +3 -5
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +8 -47
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +21 -65
- package/pipeline/multi-agent-refs/phases/phase-4-commit.md +9 -59
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +0 -31
- package/pipeline/multi-agent-refs/picker-contract.md +1 -1
- package/pipeline/multi-agent-refs/research/engine.md +2 -1
- package/pipeline/multi-agent-refs/rules.md +1 -1
- package/pipeline/multi-agent-refs/setup/free-models.md +10 -0
- package/pipeline/multi-agent-refs/store-ready/gate-3-policy.md +15 -0
- package/pipeline/multi-agent-refs/web-guide.md +2 -1
- package/pipeline/office/index.html +8 -9
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/rules/figma-pipeline.md +6 -3
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/learnings-ledger.schema.json +7 -2
- package/pipeline/schemas/prefs.schema.json +17 -4
- package/pipeline/schemas/reviewer-output.schema.json +113 -5
- package/pipeline/schemas/secret-patterns.json +49 -0
- package/pipeline/schemas/security-finding.schema.json +49 -5
- package/pipeline/scripts/_code-graph.mjs +3 -3
- package/pipeline/scripts/_graph-analysis.mjs +51 -0
- package/pipeline/scripts/_memory-policy.mjs +37 -7
- package/pipeline/scripts/_secret-scan.mjs +1 -1
- package/pipeline/scripts/_skill-practices.mjs +178 -0
- package/pipeline/scripts/_stack-routing.mjs +1 -0
- package/pipeline/scripts/autopilot-runner.mjs +8 -3
- package/pipeline/scripts/build-stack-plugins.mjs +8 -44
- package/pipeline/scripts/capture-resume.sh +19 -0
- package/pipeline/scripts/checkpoint-fold.sh +59 -0
- package/pipeline/scripts/file-context.mjs +306 -70
- package/pipeline/scripts/gate-ledger.mjs +1 -1
- package/pipeline/scripts/gen-skills-index.mjs +1 -1
- package/pipeline/scripts/graph-hint.mjs +197 -0
- package/pipeline/scripts/graph-hint.sh +20 -0
- package/pipeline/scripts/graph-query.mjs +306 -11
- package/pipeline/scripts/graph-report.mjs +29 -1
- package/pipeline/scripts/learnings-ledger.mjs +71 -15
- package/pipeline/scripts/note-agent-event.mjs +160 -0
- package/pipeline/scripts/note-agent-event.sh +19 -0
- package/pipeline/scripts/office-control.mjs +41 -15
- package/pipeline/scripts/offload-ref.sh +1 -1
- package/pipeline/scripts/parity-score.mjs +139 -0
- package/pipeline/scripts/pre-commit-check.sh +25 -4
- package/pipeline/scripts/pre-push-check.sh +3 -0
- package/pipeline/scripts/repo-recommend.mjs +321 -0
- package/pipeline/scripts/rework-rulings.mjs +5 -3
- package/pipeline/scripts/scan-agent-config.sh +1 -2
- package/pipeline/scripts/scope-check-gate.mjs +15 -2
- package/pipeline/scripts/security-evidence-gate.mjs +282 -0
- package/pipeline/scripts/unattended_policy.py +3 -2
- package/pipeline/scripts/user-test-handoff.sh +203 -0
- package/pipeline/scripts/validate-analysis-doc.mjs +17 -1
- package/pipeline/scripts/validate-planning.mjs +5 -3
- package/pipeline/scripts/validate-triage.mjs +2 -1
- package/pipeline/scripts/write-state.mjs +13 -4
- package/pipeline/skills/.skill-manifest.json +73 -69
- package/pipeline/skills/shared/README.md +41 -40
- package/pipeline/skills/shared/core/apple-archive-compliance/SKILL.md +6 -6
- package/pipeline/skills/shared/core/apple-archive-compliance/references/examples.md +1 -1
- package/pipeline/skills/shared/core/apple-archive-compliance/references/version-history.md +1 -1
- package/pipeline/skills/shared/core/google-play-compliance/SKILL.md +1 -1
- package/pipeline/skills/shared/core/google-play-compliance/references/notes.md +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-build-optimize/SKILL.md +0 -1
- package/pipeline/skills/shared/core/multi-agent-complaint-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +5 -5
- package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +10 -0
- package/pipeline/skills/shared/core/multi-agent-manual-test/SKILL.md +12 -7
- package/pipeline/skills/shared/core/multi-agent-research/SKILL.md +2 -2
- package/pipeline/skills/shared/core/multi-agent-search/SKILL.md +9 -0
- package/pipeline/skills/shared/core/multi-agent-security-review/SKILL.md +3 -2
- package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +1 -0
- package/pipeline/skills/shared/core/multi-agent-stack/SKILL.md +8 -0
- package/pipeline/skills/shared/core/multi-agent-store-ready/SKILL.md +4 -3
- package/pipeline/skills/shared/core/multi-agent-test/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-accessibility/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-dark-mode/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-dynamic-type/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-gen/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-test-screenshots/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-testflight-validation/SKILL.md +2 -2
- package/pipeline/skills/shared/external/accessibility-compliance-accessibility-audit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/agent-introspection-debugging/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/android-architecture/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-architecture/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-build-quality-gates/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-datastore/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-design-tokens-codegen/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/android-jetpack-compose-expert/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/android-mvi-viewmodel/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/android-performance/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/android-security/SKILL.md +1 -1
- package/pipeline/skills/shared/external/android-security/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/api-patterns/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/api-security-best-practices/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/app-store-changelog/SKILL.md +65 -49
- package/pipeline/skills/shared/external/app-store-changelog/evals/evals.json +40 -0
- package/pipeline/skills/shared/external/app-store-changelog/references/release-notes-guidelines.md +64 -34
- package/pipeline/skills/shared/external/app-store-changelog/scripts/collect_release_changes.sh +21 -23
- package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +4 -1
- package/pipeline/skills/shared/external/app-store-review/SKILL.md +6 -0
- package/pipeline/skills/shared/external/architecture/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/backlog/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/ci-cd-pipelines/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/clean-code/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/compose-components/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-components/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/compose-navigation/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-navigation/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/compose-testing/SKILL.md +1 -1
- package/pipeline/skills/shared/external/compose-testing/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/context-compression/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/core-data/SKILL.md +1 -1
- package/pipeline/skills/shared/external/council/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/css-modern/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/css-modern/references/code-examples.md +5 -0
- package/pipeline/skills/shared/external/database-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/database-patterns/references/orm-examples.md +5 -0
- package/pipeline/skills/shared/external/debugging-strategies/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/docker-expert/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/e2e-testing/SKILL.md +21 -21
- package/pipeline/skills/shared/external/e2e-testing/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/e2e-testing/references/document-fixtures.md +5 -5
- package/pipeline/skills/shared/external/evidence-github/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/evidence-registry/SKILL.md +1 -1
- package/pipeline/skills/shared/external/evidence-registry/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/fastapi-pro/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/firebase/SKILL.md +132 -54
- package/pipeline/skills/shared/external/firebase/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/firebase/references/functions-and-products.md +51 -0
- package/pipeline/skills/shared/external/firebase/references/security-rules.md +59 -0
- package/pipeline/skills/shared/external/fix-review-verdicts/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/free-llm-apis/SKILL.md +70 -0
- package/pipeline/skills/shared/external/free-llm-apis/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +33 -0
- package/pipeline/skills/shared/external/github-actions-templates/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/gradle-kotlin-dsl/SKILL.md +1 -1
- package/pipeline/skills/shared/external/gradle-kotlin-dsl/evals/evals.json +58 -0
- package/pipeline/skills/shared/external/handle-request/SKILL.md +2 -2
- package/pipeline/skills/shared/external/handle-request/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/hig-app-icons/SKILL.md +2 -2
- package/pipeline/skills/shared/external/hig-app-icons/references/icon-workflow.md +1 -1
- package/pipeline/skills/shared/external/hig-components-content/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-components-status/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-components-system/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/hig-inputs/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/hig-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/hig-platforms/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/hig-technologies/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/html-semantic/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/humanizer/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/ios-coding-standard/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/ios-debugger-agent/SKILL.md +91 -52
- package/pipeline/skills/shared/external/ios-debugger-agent/evals/evals.json +41 -0
- package/pipeline/skills/shared/external/ios-design-review/SKILL.md +12 -12
- package/pipeline/skills/shared/external/ios-design-review/references/appearance-matrix.md +16 -16
- package/pipeline/skills/shared/external/ios-design-review/references/checklist.md +1 -1
- package/pipeline/skills/shared/external/ios-iphone-duo/SKILL.md +0 -1
- package/pipeline/skills/shared/external/ios-module-structure/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/ios-security/SKILL.md +1 -1
- package/pipeline/skills/shared/external/ios-security/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/kotlin-coroutines-expert/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/localization-reuse-map/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/macos-menubar-tuist-app/SKILL.md +170 -74
- package/pipeline/skills/shared/external/macos-menubar-tuist-app/evals/evals.json +52 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/SKILL.md +119 -77
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Package.swift +5 -5
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/MyApp.swift +24 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/version.env +2 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/build_icon.sh +46 -39
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/compile_and_run.sh +70 -49
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/launch.sh +24 -17
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/make_appcast.sh +74 -59
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/package_app.sh +201 -170
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/setup_dev_signing.sh +50 -42
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/sign-and-notarize.sh +65 -35
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/version.env +2 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/packaging.md +49 -17
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/release.md +48 -23
- package/pipeline/skills/shared/external/macos-spm-app-packaging/references/scaffold.md +74 -44
- package/pipeline/skills/shared/external/monorepo-architect/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/nextjs-app-router/SKILL.md +14 -3
- package/pipeline/skills/shared/external/nextjs-app-router/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/nextjs-app-router/references/app-router-examples.md +3 -0
- package/pipeline/skills/shared/external/nodejs-backend-patterns/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/observability-engineer/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +10 -0
- package/pipeline/skills/shared/external/photos-camera-media/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/play-store-review/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/python-patterns/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/react-best-practices/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/rest-api-design/evals/evals.json +46 -0
- package/pipeline/skills/shared/external/retrofit-networking/SKILL.md +1 -1
- package/pipeline/skills/shared/external/retrofit-networking/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/room-database/SKILL.md +1 -1
- package/pipeline/skills/shared/external/room-database/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/scenario-gap-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/external/scenario-gap-analysis/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/search-first/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/security-review/SKILL.md +14 -3
- package/pipeline/skills/shared/external/security-review/evals/evals.json +48 -0
- package/pipeline/skills/shared/external/security-review/references/agentic-systems.md +93 -0
- package/pipeline/skills/shared/external/security-review/references/firebase-rules.md +100 -0
- package/pipeline/skills/shared/external/security-review/references/graphql.md +82 -0
- package/pipeline/skills/shared/external/security-review/references/llm-prompt-injection.md +93 -0
- package/pipeline/skills/shared/external/security-review/references/oauth-oidc.md +100 -0
- package/pipeline/skills/shared/external/security-review/references/owasp-mobile-top10-2024.md +1 -1
- package/pipeline/skills/shared/external/security-review/references/owasp-web-api-top10-2021.md +1 -1
- package/pipeline/skills/shared/external/security-review/references/supabase.md +73 -0
- package/pipeline/skills/shared/external/signal-community/SKILL.md +29 -10
- package/pipeline/skills/shared/external/signal-community/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/skill-creator/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/skill-creator/template.md +1 -3
- package/pipeline/skills/shared/external/spm-build-analysis/SKILL.md +80 -61
- package/pipeline/skills/shared/external/spm-build-analysis/evals/evals.json +56 -0
- package/pipeline/skills/shared/external/spm-build-analysis/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/spm-build-analysis/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/spm-build-analysis/references/spm-analysis-checks.md +89 -87
- package/pipeline/skills/shared/external/spm-build-analysis/scripts/check_spm_pins.py +90 -85
- package/pipeline/skills/shared/external/swift-concurrency-expert/SKILL.md +78 -69
- package/pipeline/skills/shared/external/swift-concurrency-expert/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/approachable-concurrency.md +52 -48
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/swift-6-2-concurrency.md +118 -184
- package/pipeline/skills/shared/external/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +68 -22
- package/pipeline/skills/shared/external/swift-concurrency-pro/SKILL.md +117 -94
- package/pipeline/skills/shared/external/swift-concurrency-pro/evals/evals.json +57 -0
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/actors.md +102 -97
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/async-streams.md +36 -37
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/bridging.md +82 -34
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/bug-patterns.md +90 -52
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/cancellation.md +55 -55
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/diagnostics.md +66 -43
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/hotspots.md +39 -23
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/interop.md +66 -68
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/new-features.md +152 -131
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/structured.md +60 -57
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/testing.md +131 -118
- package/pipeline/skills/shared/external/swift-concurrency-pro/references/unstructured.md +37 -29
- package/pipeline/skills/shared/external/swift-formatstyle/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swift-testing-pro/SKILL.md +77 -58
- package/pipeline/skills/shared/external/swift-testing-pro/evals/evals.json +59 -0
- package/pipeline/skills/shared/external/swift-testing-pro/references/async-tests.md +139 -144
- package/pipeline/skills/shared/external/swift-testing-pro/references/core-rules.md +90 -28
- package/pipeline/skills/shared/external/swift-testing-pro/references/migrating-from-xctest.md +38 -21
- package/pipeline/skills/shared/external/swift-testing-pro/references/new-features.md +139 -156
- package/pipeline/skills/shared/external/swift-testing-pro/references/writing-better-tests.md +173 -147
- package/pipeline/skills/shared/external/swiftdata-pro/SKILL.md +75 -59
- package/pipeline/skills/shared/external/swiftdata-pro/evals/evals.json +50 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/cloudkit.md +34 -7
- package/pipeline/skills/shared/external/swiftdata-pro/references/indexing.md +20 -14
- package/pipeline/skills/shared/external/swiftdata-pro/references/inheritance.md +127 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/model-rules.md +141 -0
- package/pipeline/skills/shared/external/swiftdata-pro/references/predicates.md +37 -44
- package/pipeline/skills/shared/external/swiftlint/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-expert-skill/SKILL.md +89 -88
- package/pipeline/skills/shared/external/swiftui-expert-skill/evals/evals.json +55 -0
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/accessibility-patterns.md +104 -122
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-advanced.md +73 -93
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-basics.md +144 -169
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-transitions.md +122 -133
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts-accessibility.md +141 -99
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts.md +273 -333
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/image-optimization.md +105 -128
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/latest-apis.md +199 -312
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/layout-best-practices.md +129 -169
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/liquid-glass.md +17 -30
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/list-patterns.md +198 -258
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-scenes.md +145 -218
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-views.md +150 -249
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-window-styling.md +109 -208
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/performance-patterns.md +225 -271
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/scroll-patterns.md +117 -210
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/sheet-navigation-patterns.md +171 -237
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/state-management.md +196 -260
- package/pipeline/skills/shared/external/swiftui-expert-skill/references/view-structure.md +167 -230
- package/pipeline/skills/shared/external/swiftui-gestures/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-layout-components/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-navigation/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +1 -2
- package/pipeline/skills/shared/external/swiftui-patterns/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/swiftui-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/SKILL.md +71 -79
- package/pipeline/skills/shared/external/swiftui-performance-audit/evals/evals.json +55 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/audit-layout.md +50 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/capture-checklist.md +51 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/hangs.md +34 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/instruments-guide.md +68 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/smell-catalog.md +191 -0
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/update-model.md +69 -0
- package/pipeline/skills/shared/external/swiftui-pro/SKILL.md +65 -63
- package/pipeline/skills/shared/external/swiftui-pro/evals/evals.json +45 -0
- package/pipeline/skills/shared/external/swiftui-pro/references/accessibility.md +40 -13
- package/pipeline/skills/shared/external/swiftui-pro/references/api.md +74 -29
- package/pipeline/skills/shared/external/swiftui-pro/references/data.md +44 -24
- package/pipeline/skills/shared/external/swiftui-pro/references/design.md +45 -31
- package/pipeline/skills/shared/external/swiftui-pro/references/hygiene.md +17 -8
- package/pipeline/skills/shared/external/swiftui-pro/references/navigation.md +19 -9
- package/pipeline/skills/shared/external/swiftui-pro/references/performance.md +50 -34
- package/pipeline/skills/shared/external/swiftui-pro/references/swift.md +73 -45
- package/pipeline/skills/shared/external/swiftui-pro/references/views.md +48 -23
- package/pipeline/skills/shared/external/swiftui-ui-patterns/SKILL.md +89 -83
- package/pipeline/skills/shared/external/swiftui-ui-patterns/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/app-wiring.md +119 -114
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/async-state.md +76 -61
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/components-index.md +63 -46
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/controls.md +32 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/deeplinks.md +49 -38
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/focus.md +77 -49
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/form.md +61 -44
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/grids.md +40 -42
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/input-toolbar.md +44 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/lightweight-clients.md +90 -64
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/list.md +48 -49
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/loading-placeholders.md +36 -25
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/macos-settings.md +30 -30
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/matched-transitions.md +49 -32
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/media.md +49 -41
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/menu-bar.md +52 -48
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/navigationstack.md +119 -104
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/overlay.md +30 -27
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/performance.md +33 -31
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/previews.md +27 -27
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scroll-reveal.md +79 -86
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scrollview.md +47 -40
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/searchable.md +55 -40
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/sheets.md +113 -84
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/split-views.md +37 -34
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/tabview.md +75 -75
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/theming.md +37 -32
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/title-menus.md +41 -51
- package/pipeline/skills/shared/external/swiftui-ui-patterns/references/top-bar.md +46 -30
- package/pipeline/skills/shared/external/swiftui-uikit-interop/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/swiftui-view-refactor/SKILL.md +152 -121
- package/pipeline/skills/shared/external/swiftui-view-refactor/evals/evals.json +56 -0
- package/pipeline/skills/shared/external/swiftui-view-refactor/references/mv-patterns.md +107 -98
- package/pipeline/skills/shared/external/swiftui-webkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/tailwind-css/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/test-result-triage/SKILL.md +2 -2
- package/pipeline/skills/shared/external/test-result-triage/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/testing-backend/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/tipkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/typescript-patterns/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/valven-rules/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/vision-framework/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/vue-composition/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/weatherkit/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/web-accessibility/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/web-performance/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/web-testing/SKILL.md +2 -2
- package/pipeline/skills/shared/external/web-testing/evals/evals.json +43 -0
- package/pipeline/skills/shared/external/web-testing/references/testing-examples.md +2 -2
- package/pipeline/skills/shared/external/widgetkit/evals/evals.json +44 -0
- package/pipeline/skills/shared/external/xcode-build-benchmark/SKILL.md +61 -55
- package/pipeline/skills/shared/external/xcode-build-benchmark/evals/evals.json +42 -0
- package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmark-artifacts.md +69 -67
- package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmarking-workflow.md +39 -47
- package/pipeline/skills/shared/external/xcode-build-benchmark/schemas/build-benchmark.schema.json +72 -154
- package/pipeline/skills/shared/external/xcode-build-benchmark/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-fixer/SKILL.md +145 -139
- package/pipeline/skills/shared/external/xcode-build-fixer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-build-fixer/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-build-fixer/references/fix-patterns.md +188 -143
- package/pipeline/skills/shared/external/xcode-build-fixer/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-build-fixer/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-orchestrator/SKILL.md +107 -98
- package/pipeline/skills/shared/external/xcode-build-orchestrator/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/benchmark-artifacts.md +69 -67
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/orchestration-report-template.md +81 -69
- package/pipeline/skills/shared/external/xcode-build-orchestrator/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/benchmark_builds.py +207 -245
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/diagnose_compilation.py +155 -210
- package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/generate_optimization_report.py +355 -480
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/SKILL.md +70 -69
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/code-compilation-checks.md +85 -73
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/recommendation-format.md +41 -40
- package/pipeline/skills/shared/external/xcode-compilation-analyzer/scripts/diagnose_compilation.py +155 -210
- package/pipeline/skills/shared/external/xcode-project-analyzer/SKILL.md +54 -52
- package/pipeline/skills/shared/external/xcode-project-analyzer/evals/evals.json +54 -0
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-optimization-sources.md +83 -133
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-settings-best-practices.md +81 -175
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/project-audit-checks.md +115 -83
- package/pipeline/skills/shared/external/xcode-project-analyzer/references/recommendation-format.md +41 -40
- package/pipeline/scripts/_notices.mjs +0 -171
- package/pipeline/skills/shared/external/NOTICE-avdlee-swiftui-agent-skill.md +0 -48
- package/pipeline/skills/shared/external/NOTICE-dimillian-skills.md +0 -63
- package/pipeline/skills/shared/external/NOTICE-paul-hudson-skills.md +0 -54
- package/pipeline/skills/shared/external/NOTICE-vibeship-spawner-skills.md +0 -203
- package/pipeline/skills/shared/external/NOTICE-xcode-build-skills.md +0 -60
- package/pipeline/skills/shared/external/ios-iphone-duo/NOTICE.md +0 -53
- package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/main.swift +0 -11
- package/pipeline/skills/shared/external/swiftdata-pro/references/class-inheritance.md +0 -104
- package/pipeline/skills/shared/external/swiftdata-pro/references/core-rules.md +0 -20
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/code-smells.md +0 -158
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +0 -46
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +0 -29
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/profiling-intake.md +0 -44
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/report-template.md +0 -47
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +0 -33
- package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +0 -52
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @file graph-hint.mjs - point a whole-repo identifier search at the code graph.
|
|
4
|
+
*
|
|
5
|
+
* PreToolUse on Grep and Glob. When the call is a bare identifier searched
|
|
6
|
+
* over the whole repository (a Grep pattern like `LoginView` or
|
|
7
|
+
* `\bauth_token\b` with no path or the repository root as path; a Glob for a
|
|
8
|
+
* file named after the identifier in any directory, wildcards around the name
|
|
9
|
+
* and an extension allowed, with no narrower path) and a current code graph
|
|
10
|
+
* exists for the repository, it adds one line of additionalContext naming
|
|
11
|
+
* `/multi-agent:graph ask` and the toolkit's graph query tool, which return
|
|
12
|
+
* ranked definitions and their neighbours within a token budget.
|
|
13
|
+
*
|
|
14
|
+
* "Current" is graphFreshness() from _diff-impact.mjs, the check
|
|
15
|
+
* graph-affected.mjs reports: the build commit is HEAD and no indexed file
|
|
16
|
+
* changed since. A stale graph says nothing, because pointing at an answer
|
|
17
|
+
* about an older tree is worse than no hint.
|
|
18
|
+
*
|
|
19
|
+
* Once per session: after the hint fires, the session never reads the graph
|
|
20
|
+
* again. A stale or unreadable graph is remembered per session under a key of
|
|
21
|
+
* the graph file's mtime and size and the repository HEAD, so a large graph is
|
|
22
|
+
* parsed at most once per (session, graph version, HEAD); once the graph is
|
|
23
|
+
* rebuilt or HEAD moves, the key changes and a now-current graph still hints
|
|
24
|
+
* later in the session. Off when prefs.global.codeGraph.enabled is false.
|
|
25
|
+
* Never blocks, never denies, and prints nothing on any failure.
|
|
26
|
+
*
|
|
27
|
+
* @module pipeline/scripts/graph-hint
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { spawnSync } from "node:child_process";
|
|
31
|
+
import {
|
|
32
|
+
existsSync,
|
|
33
|
+
lstatSync,
|
|
34
|
+
mkdirSync,
|
|
35
|
+
readFileSync,
|
|
36
|
+
realpathSync,
|
|
37
|
+
statSync,
|
|
38
|
+
writeFileSync,
|
|
39
|
+
} from "node:fs";
|
|
40
|
+
import { homedir, tmpdir } from "node:os";
|
|
41
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
42
|
+
|
|
43
|
+
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
44
|
+
import { graphFreshness } from "./_diff-impact.mjs";
|
|
45
|
+
|
|
46
|
+
const MAX_INPUT = 256 * 1024;
|
|
47
|
+
const IDENT = /^[A-Za-z_][A-Za-z0-9_]{2,63}$/;
|
|
48
|
+
const GLOB_IDENT = /^(?:\*\*\/)?\*?([A-Za-z_][A-Za-z0-9_]{2,63})\*?(?:\.[A-Za-z0-9*]+)?$/;
|
|
49
|
+
|
|
50
|
+
/** The identifier a Grep or Glob call searches for, or null. */
|
|
51
|
+
export function identifierOf(payload) {
|
|
52
|
+
const pattern = payload?.tool_input?.pattern;
|
|
53
|
+
if (typeof pattern !== "string") return null;
|
|
54
|
+
if (payload.tool_name === "Grep") {
|
|
55
|
+
const bare = pattern.replace(/^\\b/, "").replace(/\\b$/, "");
|
|
56
|
+
return IDENT.test(bare) ? bare : null;
|
|
57
|
+
}
|
|
58
|
+
if (payload.tool_name === "Glob") {
|
|
59
|
+
const m = GLOB_IDENT.exec(pattern);
|
|
60
|
+
return m ? m[1] : null;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function codeGraphEnabled(env) {
|
|
66
|
+
const p =
|
|
67
|
+
env.MULTI_AGENT_PREFS || join(env.HOME || homedir(), ".claude", "multi-agent-preferences.json");
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(readFileSync(p, "utf8"))?.global?.codeGraph?.enabled !== false;
|
|
70
|
+
} catch {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The repository's top level and the folder name its graph is stored under. */
|
|
76
|
+
function repoOf(cwd) {
|
|
77
|
+
const git = (args) =>
|
|
78
|
+
spawnSync("git", ["-C", cwd, ...args], { encoding: "utf8", timeout: 2000 }).stdout?.trim();
|
|
79
|
+
const top = git(["rev-parse", "--show-toplevel"]);
|
|
80
|
+
if (!top) return null;
|
|
81
|
+
const common = git(["rev-parse", "--path-format=absolute", "--git-common-dir"]) || "";
|
|
82
|
+
const root = basename(common) === ".git" ? dirname(common) : top;
|
|
83
|
+
const head = git(["rev-parse", "--verify", "-q", "HEAD"]) || "";
|
|
84
|
+
return { top: realpathSync(top), slug: basename(root), head };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The session's state file: `{ hinted, skip }`, where `skip` is the graph key
|
|
89
|
+
* last found stale or unreadable. A session without an id gets a state that
|
|
90
|
+
* is never saved; null when the state folder cannot be trusted.
|
|
91
|
+
*/
|
|
92
|
+
function sessionState(sessionId) {
|
|
93
|
+
if (!sessionId) return { file: null, state: {} };
|
|
94
|
+
const uid = process.getuid?.() ?? "user";
|
|
95
|
+
const dir = join(tmpdir(), `multi-agent-graph-hint-${uid}`);
|
|
96
|
+
try {
|
|
97
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
98
|
+
const st = lstatSync(dir);
|
|
99
|
+
if (!st.isDirectory() || (process.getuid && st.uid !== process.getuid())) return null;
|
|
100
|
+
const file = join(dir, String(sessionId).replace(/[^A-Za-z0-9_-]/g, ""));
|
|
101
|
+
if (!existsSync(file)) return { file, state: {} };
|
|
102
|
+
const raw = readFileSync(file, "utf8");
|
|
103
|
+
if (raw === "") return { file, state: { hinted: true } };
|
|
104
|
+
const state = JSON.parse(raw);
|
|
105
|
+
return { file, state: state && typeof state === "object" ? state : {} };
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function saveState(session, state) {
|
|
112
|
+
if (!session.file) return true;
|
|
113
|
+
try {
|
|
114
|
+
writeFileSync(session.file, JSON.stringify(state), { mode: 0o600 });
|
|
115
|
+
return true;
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The hook's answer for one payload, or null for silence. */
|
|
122
|
+
export function answer(
|
|
123
|
+
payload,
|
|
124
|
+
env = process.env,
|
|
125
|
+
{ readGraph = (p) => readFileSync(p, "utf8") } = {},
|
|
126
|
+
) {
|
|
127
|
+
const ident = identifierOf(payload);
|
|
128
|
+
if (!ident || !codeGraphEnabled(env)) return null;
|
|
129
|
+
const cwd = typeof payload.cwd === "string" && payload.cwd ? payload.cwd : process.cwd();
|
|
130
|
+
const repo = repoOf(cwd);
|
|
131
|
+
if (!repo) return null;
|
|
132
|
+
const path = payload.tool_input?.path;
|
|
133
|
+
if (typeof path === "string" && path) {
|
|
134
|
+
const abs = resolve(cwd, path);
|
|
135
|
+
if (!existsSync(abs) || realpathSync(abs) !== repo.top) return null;
|
|
136
|
+
}
|
|
137
|
+
const graphPath = join(
|
|
138
|
+
env.HOME || homedir(),
|
|
139
|
+
".claude",
|
|
140
|
+
"knowledge",
|
|
141
|
+
repo.slug,
|
|
142
|
+
"code-graph.json",
|
|
143
|
+
);
|
|
144
|
+
if (!existsSync(graphPath)) return null;
|
|
145
|
+
const session = sessionState(payload.session_id);
|
|
146
|
+
if (!session || session.state.hinted) return null;
|
|
147
|
+
let key;
|
|
148
|
+
try {
|
|
149
|
+
const st = statSync(graphPath);
|
|
150
|
+
key = `${st.mtimeMs}:${st.size}:${repo.head}`;
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (session.state.skip === key) return null;
|
|
155
|
+
let graph;
|
|
156
|
+
try {
|
|
157
|
+
graph = JSON.parse(readGraph(graphPath));
|
|
158
|
+
} catch {
|
|
159
|
+
saveState(session, { skip: key });
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (graphFreshness(graph, { root: graph.root || repo.top }).stale) {
|
|
163
|
+
saveState(session, { skip: key });
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (!saveState(session, { hinted: true })) return null;
|
|
167
|
+
const text =
|
|
168
|
+
`A current code graph exists for ${repo.slug}. For a symbol or concept search such as ` +
|
|
169
|
+
`\`${ident}\`, \`/multi-agent:graph ask "${ident}"\` or the toolkit tool ` +
|
|
170
|
+
`mcp__multi-agent-toolkit__graph_query returns ranked definitions and their neighbours ` +
|
|
171
|
+
`within a token budget. Grep stays the right tool for an exact text match.`;
|
|
172
|
+
return { hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: text } };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function main() {
|
|
176
|
+
let raw;
|
|
177
|
+
try {
|
|
178
|
+
raw = readFileSync(0, "utf8");
|
|
179
|
+
} catch {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!raw || raw.length > MAX_INPUT) return;
|
|
183
|
+
let payload;
|
|
184
|
+
try {
|
|
185
|
+
payload = JSON.parse(raw);
|
|
186
|
+
} catch {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const out = answer(payload);
|
|
190
|
+
if (out) process.stdout.write(JSON.stringify(out) + "\n");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
if (invokedDirectly(import.meta.url)) main();
|
|
195
|
+
} catch {
|
|
196
|
+
/* silent by contract */
|
|
197
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# graph-hint.sh - PreToolUse hook (Grep|Glob) for the pipeline.
|
|
3
|
+
#
|
|
4
|
+
# Before a whole-repo search for a bare identifier, and only when a current
|
|
5
|
+
# code graph exists for the repo, adds one line of context pointing at the
|
|
6
|
+
# graph query. Once per session. The logic is in graph-hint.mjs; this wrapper
|
|
7
|
+
# exists because every hook the pipeline registers is a
|
|
8
|
+
# `bash "$HOME/.<host>/scripts/<name>"` command.
|
|
9
|
+
#
|
|
10
|
+
# Exits 0 on every path and never blocks the search.
|
|
11
|
+
|
|
12
|
+
set -u
|
|
13
|
+
|
|
14
|
+
HERE="$(cd "$(dirname "$0")" 2>/dev/null && pwd || true)"
|
|
15
|
+
CORE="$HERE/graph-hint.mjs"
|
|
16
|
+
[ -f "$CORE" ] || exit 0
|
|
17
|
+
command -v node >/dev/null 2>&1 || exit 0
|
|
18
|
+
|
|
19
|
+
node "$CORE" 2>/dev/null || true
|
|
20
|
+
exit 0
|
|
@@ -16,8 +16,37 @@
|
|
|
16
16
|
* --budget N Output token cap. Default: 2000
|
|
17
17
|
* --depth N Max BFS depth from a seed. Default: 2
|
|
18
18
|
* --seeds N How many ranked seeds to expand. Default: 8
|
|
19
|
+
* --expand "<w..>" Up to 12 extra words merged into the ranking query. A word
|
|
20
|
+
* the graph's own vocabulary does not contain is dropped and
|
|
21
|
+
* reported, so an expansion can only point at names that
|
|
22
|
+
* exist; vocabulary words past the twelfth are reported as
|
|
23
|
+
* over the limit. `vocab --like` lists candidates.
|
|
24
|
+
* --no-log Do not append this query to the query log
|
|
19
25
|
* --json Emit JSON instead of text
|
|
20
26
|
*
|
|
27
|
+
* graph-query vocab --like <word> [--json]
|
|
28
|
+
* Up to 50 words of the graph's vocabulary that share a
|
|
29
|
+
* prefix with the word or are within edit distance 2 of it.
|
|
30
|
+
* The vocabulary is every node name split at camelCase,
|
|
31
|
+
* snake_case and kebab-case boundaries, lowercased, 3+ chars.
|
|
32
|
+
*
|
|
33
|
+
* graph-query feedback --id <Q:id> --outcome useful|dead_end|corrected
|
|
34
|
+
* Record how a logged query's answer fared. The outcome is
|
|
35
|
+
* stored against the query's top nodes; _memory-policy.mjs
|
|
36
|
+
* standing() turns each node's outcomes into corroborated
|
|
37
|
+
* (useful twice or more) or suppressed (corrected, or a dead
|
|
38
|
+
* end at least twice and more often than useful). In ranking
|
|
39
|
+
* a corroborated node's score is raised by STANDING_BOOST
|
|
40
|
+
* (2%) and a suppressed one lowered by it, so standing only
|
|
41
|
+
* reorders near-ties and never overturns a clear lead.
|
|
42
|
+
*
|
|
43
|
+
* Query log: each free-text query appends {id, ts, query, expand, top} to
|
|
44
|
+
* graph-queries.jsonl beside the graph (~/.claude/knowledge/<project>/), and
|
|
45
|
+
* feedback goes to graph-feedback.jsonl there. Each file is capped at
|
|
46
|
+
* LOG_MAX_BYTES (1 MiB): the row that would pass the cap first moves the file
|
|
47
|
+
* to <name>.1, replacing the previous generation, so at most two generations
|
|
48
|
+
* exist. MULTI_AGENT_GRAPH_LOG=0 turns the query log off.
|
|
49
|
+
*
|
|
21
50
|
* graph-query --path <from> <to> [--max-depth N] [--directed] [--kind K,...]
|
|
22
51
|
* Shortest path between two symbols or files, by node id or
|
|
23
52
|
* by name. A name that matches more than one node is refused
|
|
@@ -27,19 +56,28 @@
|
|
|
27
56
|
* Exit codes:
|
|
28
57
|
* 0 - answered (possibly empty, or no path within the depth)
|
|
29
58
|
* 1 - graph missing or unreadable
|
|
59
|
+
* 2 - feedback for a query id the log does not hold
|
|
30
60
|
* 3 - a --path endpoint is ambiguous or unknown
|
|
31
61
|
* 64 - usage error
|
|
32
62
|
*
|
|
33
63
|
* @module pipeline/scripts/graph-query
|
|
34
64
|
*/
|
|
35
65
|
|
|
36
|
-
import {
|
|
37
|
-
import { join, resolve, basename } from "node:path";
|
|
66
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync } from "node:fs";
|
|
67
|
+
import { join, resolve, basename, dirname } from "node:path";
|
|
38
68
|
import { homedir } from "node:os";
|
|
39
|
-
import { bm25 } from "./_retrieval.mjs";
|
|
69
|
+
import { bm25, shortId } from "./_retrieval.mjs";
|
|
70
|
+
import { standing } from "./_memory-policy.mjs";
|
|
40
71
|
import { parseFlags } from "./graph-build.mjs";
|
|
41
72
|
|
|
42
73
|
const CHARS_PER_TOKEN = 4;
|
|
74
|
+
const MAX_EXPAND = 12;
|
|
75
|
+
const MAX_LIKE = 50;
|
|
76
|
+
const LIKE_DISTANCE = 2;
|
|
77
|
+
const STANDING_BOOST = 0.02;
|
|
78
|
+
const LOG_MAX_BYTES = 1024 * 1024;
|
|
79
|
+
const LOG_TOP = 10;
|
|
80
|
+
const OUTCOMES = new Set(["useful", "dead_end", "corrected"]);
|
|
43
81
|
|
|
44
82
|
export function defaultGraphPath(cwd = process.cwd()) {
|
|
45
83
|
return join(homedir(), ".claude", "knowledge", basename(resolve(cwd)), "code-graph.json");
|
|
@@ -83,23 +121,182 @@ export function adjacency(graph) {
|
|
|
83
121
|
* directories, and `symbolKind` carries a little signal ("the FlightList view
|
|
84
122
|
* model") without letting the kind word alone win a match.
|
|
85
123
|
*
|
|
124
|
+
* `expand` words are appended to the question; `standing` (node id ->
|
|
125
|
+
* {corroborated, suppressed}) scales a node's score by STANDING_BOOST up or
|
|
126
|
+
* down. The sort is stable, so equal scores keep graph order.
|
|
127
|
+
*
|
|
86
128
|
* @param {object} graph
|
|
87
129
|
* @param {string} question
|
|
130
|
+
* @param {{expand?: string[], standing?: Map<string, {corroborated: boolean, suppressed: boolean}>}} [opts]
|
|
88
131
|
* @returns {Array<{node: object, score: number}>} descending, zero scores dropped
|
|
89
132
|
*/
|
|
90
|
-
export function rankNodes(graph, question) {
|
|
133
|
+
export function rankNodes(graph, question, { expand = [], standing: byNode = null } = {}) {
|
|
91
134
|
const docs = graph.nodes.map((n) => ({
|
|
92
135
|
name: n.name || "",
|
|
93
136
|
path: n.path || "",
|
|
94
137
|
symbolKind: n.symbolKind || "",
|
|
95
138
|
}));
|
|
96
|
-
const
|
|
139
|
+
const query = expand.length ? `${question} ${expand.join(" ")}` : question;
|
|
140
|
+
const scored = bm25(query, docs, { fieldWeights: { name: 3, path: 1, symbolKind: 1 } });
|
|
141
|
+
const factor = (id) => {
|
|
142
|
+
const s = byNode?.get(id);
|
|
143
|
+
if (!s) return 1;
|
|
144
|
+
if (s.suppressed) return 1 - STANDING_BOOST;
|
|
145
|
+
return s.corroborated ? 1 + STANDING_BOOST : 1;
|
|
146
|
+
};
|
|
97
147
|
return scored
|
|
98
148
|
.filter((s) => s.score > 0)
|
|
99
|
-
.
|
|
149
|
+
.map((s) => ({ index: s.index, score: s.score * factor(graph.nodes[s.index].id) }))
|
|
150
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
100
151
|
.map((s) => ({ node: graph.nodes[s.index], score: s.score }));
|
|
101
152
|
}
|
|
102
153
|
|
|
154
|
+
/** Words of an identifier: camelCase, snake_case, kebab-case and digits split. */
|
|
155
|
+
function nameWords(name) {
|
|
156
|
+
return String(name || "")
|
|
157
|
+
.split(/[^A-Za-z0-9]+/)
|
|
158
|
+
.flatMap((p) => p.split(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[A-Za-z])(?=\d)/))
|
|
159
|
+
.map((w) => w.toLowerCase())
|
|
160
|
+
.filter((w) => w.length >= 3 && /[a-z]/.test(w));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The graph's own vocabulary: every node name split into lowercase words,
|
|
165
|
+
* with how many names use each.
|
|
166
|
+
*
|
|
167
|
+
* @returns {Map<string, number>}
|
|
168
|
+
*/
|
|
169
|
+
export function vocabulary(graph) {
|
|
170
|
+
const v = new Map();
|
|
171
|
+
for (const n of graph.nodes) {
|
|
172
|
+
for (const w of new Set(nameWords(n.name))) v.set(w, (v.get(w) || 0) + 1);
|
|
173
|
+
}
|
|
174
|
+
return v;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Split expansion text into words and keep the first MAX_EXPAND distinct ones
|
|
179
|
+
* the vocabulary holds. A word the vocabulary lacks is dropped; a vocabulary
|
|
180
|
+
* word that arrives once the limit is full is reported as over the limit.
|
|
181
|
+
*
|
|
182
|
+
* @returns {{used: string[], dropped: string[], overLimit: string[]}}
|
|
183
|
+
*/
|
|
184
|
+
export function expandTerms(vocab, text) {
|
|
185
|
+
const words = [
|
|
186
|
+
...new Set(
|
|
187
|
+
String(text || "")
|
|
188
|
+
.toLowerCase()
|
|
189
|
+
.split(/[\s,]+/)
|
|
190
|
+
.filter(Boolean),
|
|
191
|
+
),
|
|
192
|
+
];
|
|
193
|
+
const used = [];
|
|
194
|
+
const dropped = [];
|
|
195
|
+
const overLimit = [];
|
|
196
|
+
for (const w of words) {
|
|
197
|
+
if (!vocab.has(w)) dropped.push(w);
|
|
198
|
+
else if (used.length < MAX_EXPAND) used.push(w);
|
|
199
|
+
else overLimit.push(w);
|
|
200
|
+
}
|
|
201
|
+
return { used, dropped, overLimit };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Levenshtein distance, stopping early once it exceeds `cap`. */
|
|
205
|
+
export function editDistance(a, b, cap = Infinity) {
|
|
206
|
+
if (Math.abs(a.length - b.length) > cap) return cap + 1;
|
|
207
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
208
|
+
for (let i = 1; i <= a.length; i++) {
|
|
209
|
+
const cur = [i];
|
|
210
|
+
let best = i;
|
|
211
|
+
for (let j = 1; j <= b.length; j++) {
|
|
212
|
+
cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
213
|
+
best = Math.min(best, cur[j]);
|
|
214
|
+
}
|
|
215
|
+
if (best > cap) return cap + 1;
|
|
216
|
+
prev = cur;
|
|
217
|
+
}
|
|
218
|
+
return prev[b.length];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Vocabulary words close to `word`: a shared prefix (one starts with the
|
|
223
|
+
* other, at least three letters) or edit distance <= 2. Ordered by distance,
|
|
224
|
+
* then by how many names use the word, then alphabetically; at most 50.
|
|
225
|
+
*
|
|
226
|
+
* @returns {string[]}
|
|
227
|
+
*/
|
|
228
|
+
export function vocabLike(vocab, word) {
|
|
229
|
+
const w = String(word || "").toLowerCase();
|
|
230
|
+
if (w.length < 2) return [];
|
|
231
|
+
const hits = [];
|
|
232
|
+
for (const [t, count] of vocab) {
|
|
233
|
+
const prefix = Math.min(t.length, w.length) >= 3 && (t.startsWith(w) || w.startsWith(t));
|
|
234
|
+
const d = editDistance(w, t, LIKE_DISTANCE);
|
|
235
|
+
if (!prefix && d > LIKE_DISTANCE) continue;
|
|
236
|
+
hits.push({ t, rank: prefix ? Math.min(d, 1) : d, count });
|
|
237
|
+
}
|
|
238
|
+
return hits
|
|
239
|
+
.sort((a, b) => a.rank - b.rank || b.count - a.count || (a.t < b.t ? -1 : a.t > b.t ? 1 : 0))
|
|
240
|
+
.slice(0, MAX_LIKE)
|
|
241
|
+
.map((h) => h.t);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Append one JSON row, moving the file to `<path>.1` first when the row would
|
|
246
|
+
* take it past `maxBytes`. Two generations at most.
|
|
247
|
+
*/
|
|
248
|
+
export function appendBounded(path, row, maxBytes = LOG_MAX_BYTES) {
|
|
249
|
+
const line = JSON.stringify(row) + "\n";
|
|
250
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
251
|
+
let size = 0;
|
|
252
|
+
try {
|
|
253
|
+
size = statSync(path).size;
|
|
254
|
+
} catch {
|
|
255
|
+
/* first row */
|
|
256
|
+
}
|
|
257
|
+
if (size > 0 && size + Buffer.byteLength(line) > maxBytes) renameSync(path, `${path}.1`);
|
|
258
|
+
appendFileSync(path, line, "utf8");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function readJsonl(path) {
|
|
262
|
+
const out = [];
|
|
263
|
+
for (const p of [`${path}.1`, path]) {
|
|
264
|
+
let text;
|
|
265
|
+
try {
|
|
266
|
+
text = readFileSync(p, "utf8");
|
|
267
|
+
} catch {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
for (const l of text.split("\n")) {
|
|
271
|
+
if (!l.trim()) continue;
|
|
272
|
+
try {
|
|
273
|
+
out.push(JSON.parse(l));
|
|
274
|
+
} catch {
|
|
275
|
+
/* skip a torn line */
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export const queryLogPath = (graphPath) => join(dirname(graphPath), "graph-queries.jsonl");
|
|
283
|
+
export const feedbackPath = (graphPath) => join(dirname(graphPath), "graph-feedback.jsonl");
|
|
284
|
+
|
|
285
|
+
/** node id -> standing, from the feedback recorded beside the graph. */
|
|
286
|
+
export function standingByNode(graphPath) {
|
|
287
|
+
const byNode = new Map();
|
|
288
|
+
for (const f of readJsonl(feedbackPath(graphPath))) {
|
|
289
|
+
if (!OUTCOMES.has(f.outcome) || !Array.isArray(f.nodes)) continue;
|
|
290
|
+
for (const id of f.nodes) {
|
|
291
|
+
if (!byNode.has(id)) byNode.set(id, []);
|
|
292
|
+
byNode.get(id).push({ ts: f.ts, outcome: f.outcome });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
const out = new Map();
|
|
296
|
+
for (const [id, rows] of byNode) out.set(id, standing(rows));
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
|
|
103
300
|
const CANDIDATES = 5;
|
|
104
301
|
|
|
105
302
|
/**
|
|
@@ -192,8 +389,16 @@ export function printedLine(dist, line, via) {
|
|
|
192
389
|
* @param {object} params
|
|
193
390
|
* @returns {{seeds: object[], hits: object[], truncated: boolean, tokens: number}}
|
|
194
391
|
*/
|
|
195
|
-
export function traverse({
|
|
196
|
-
|
|
392
|
+
export function traverse({
|
|
393
|
+
graph,
|
|
394
|
+
question,
|
|
395
|
+
budget,
|
|
396
|
+
depth,
|
|
397
|
+
seedCount,
|
|
398
|
+
expand = [],
|
|
399
|
+
standing: byNode = null,
|
|
400
|
+
}) {
|
|
401
|
+
const ranked = rankNodes(graph, question, { expand, standing: byNode });
|
|
197
402
|
const seeds = ranked.slice(0, seedCount).map((r) => r.node);
|
|
198
403
|
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
199
404
|
const adj = adjacency(graph);
|
|
@@ -291,13 +496,15 @@ function main() {
|
|
|
291
496
|
}
|
|
292
497
|
process.exit(pathMain(flags, ends, graph));
|
|
293
498
|
}
|
|
499
|
+
const path = flags.graph && flags.graph !== true ? resolve(flags.graph) : defaultGraphPath();
|
|
500
|
+
if (positional.length === 1 && positional[0] === "feedback")
|
|
501
|
+
process.exit(feedbackMain(flags, path));
|
|
294
502
|
const question = positional.join(" ").trim();
|
|
295
503
|
if (!question) {
|
|
296
504
|
process.stderr.write('graph-query: a question is required, e.g. graph-query "flight search"\n');
|
|
297
505
|
process.exit(64);
|
|
298
506
|
}
|
|
299
507
|
|
|
300
|
-
const path = flags.graph && flags.graph !== true ? resolve(flags.graph) : defaultGraphPath();
|
|
301
508
|
let graph;
|
|
302
509
|
try {
|
|
303
510
|
graph = loadGraph(path);
|
|
@@ -305,19 +512,64 @@ function main() {
|
|
|
305
512
|
process.stderr.write(`graph-query: ${e.message}\n`);
|
|
306
513
|
process.exit(1);
|
|
307
514
|
}
|
|
515
|
+
if (positional.length === 1 && positional[0] === "vocab" && flags.like !== undefined) {
|
|
516
|
+
process.exit(vocabMain(flags, graph));
|
|
517
|
+
}
|
|
308
518
|
|
|
309
519
|
const budget = Number(flags.budget) > 0 ? Number(flags.budget) : 2000;
|
|
310
520
|
const depth = Number(flags.depth) > 0 ? Number(flags.depth) : 2;
|
|
311
521
|
const seedCount = Number(flags.seeds) > 0 ? Number(flags.seeds) : 8;
|
|
522
|
+
const expansion =
|
|
523
|
+
typeof flags.expand === "string" ? expandTerms(vocabulary(graph), flags.expand) : null;
|
|
312
524
|
|
|
313
|
-
const result = traverse({
|
|
525
|
+
const result = traverse({
|
|
526
|
+
graph,
|
|
527
|
+
question,
|
|
528
|
+
budget,
|
|
529
|
+
depth,
|
|
530
|
+
seedCount,
|
|
531
|
+
expand: expansion?.used ?? [],
|
|
532
|
+
standing: standingByNode(path),
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
let logId = null;
|
|
536
|
+
if (flags["no-log"] !== true && process.env.MULTI_AGENT_GRAPH_LOG !== "0") {
|
|
537
|
+
const ts = new Date().toISOString();
|
|
538
|
+
logId = shortId("Q", ts, question, expansion?.used.join(" ") ?? "");
|
|
539
|
+
try {
|
|
540
|
+
appendBounded(queryLogPath(path), {
|
|
541
|
+
id: logId,
|
|
542
|
+
ts,
|
|
543
|
+
query: question,
|
|
544
|
+
expand: expansion?.used ?? [],
|
|
545
|
+
top: result.seeds.slice(0, LOG_TOP).map((n) => n.id),
|
|
546
|
+
});
|
|
547
|
+
} catch {
|
|
548
|
+
logId = null;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
314
551
|
|
|
315
552
|
if (flags.json === true) {
|
|
316
|
-
|
|
553
|
+
const doc = { question, budget, ...result };
|
|
554
|
+
if (expansion) doc.expansion = expansion;
|
|
555
|
+
if (logId) doc.logId = logId;
|
|
556
|
+
process.stdout.write(JSON.stringify(doc, null, 2) + "\n");
|
|
317
557
|
return;
|
|
318
558
|
}
|
|
319
559
|
|
|
320
560
|
process.stdout.write(`# ${question}\n\n`);
|
|
561
|
+
if (expansion) {
|
|
562
|
+
process.stdout.write(
|
|
563
|
+
`expanded with: ${expansion.used.join(" ") || "(none)"}` +
|
|
564
|
+
(expansion.overLimit.length
|
|
565
|
+
? `; over the limit of ${MAX_EXPAND}: ${expansion.overLimit.join(" ")}`
|
|
566
|
+
: "") +
|
|
567
|
+
(expansion.dropped.length
|
|
568
|
+
? `; dropped (not in the graph's vocabulary): ${expansion.dropped.join(" ")}`
|
|
569
|
+
: "") +
|
|
570
|
+
"\n\n",
|
|
571
|
+
);
|
|
572
|
+
}
|
|
321
573
|
if (result.hits.length === 0) {
|
|
322
574
|
process.stdout.write("no matching nodes\n");
|
|
323
575
|
return;
|
|
@@ -328,8 +580,51 @@ function main() {
|
|
|
328
580
|
process.stdout.write(
|
|
329
581
|
`\n${result.hits.length} nodes, ~${result.tokens} tokens` +
|
|
330
582
|
(result.truncated ? " (budget reached)" : "") +
|
|
583
|
+
(logId
|
|
584
|
+
? `; rate it: graph-query.mjs feedback --id ${logId} --outcome <useful|dead_end|corrected>`
|
|
585
|
+
: "") +
|
|
331
586
|
"\n",
|
|
332
587
|
);
|
|
333
588
|
}
|
|
334
589
|
|
|
590
|
+
function vocabMain(flags, graph) {
|
|
591
|
+
if (typeof flags.like !== "string" || !flags.like.trim()) {
|
|
592
|
+
process.stderr.write("graph-query: vocab needs --like <word>\n");
|
|
593
|
+
return 64;
|
|
594
|
+
}
|
|
595
|
+
const words = vocabLike(vocabulary(graph), flags.like.trim());
|
|
596
|
+
if (flags.json === true) {
|
|
597
|
+
process.stdout.write(JSON.stringify({ like: flags.like, words }, null, 2) + "\n");
|
|
598
|
+
} else {
|
|
599
|
+
process.stdout.write(words.length ? `${words.join("\n")}\n` : "no similar words\n");
|
|
600
|
+
}
|
|
601
|
+
return 0;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function feedbackMain(flags, graphPath) {
|
|
605
|
+
const id = typeof flags.id === "string" ? flags.id.trim() : "";
|
|
606
|
+
const outcome = typeof flags.outcome === "string" ? flags.outcome : "";
|
|
607
|
+
if (!id || !OUTCOMES.has(outcome)) {
|
|
608
|
+
process.stderr.write(
|
|
609
|
+
"graph-query: feedback needs --id <Q:id> --outcome <useful|dead_end|corrected>\n",
|
|
610
|
+
);
|
|
611
|
+
return 64;
|
|
612
|
+
}
|
|
613
|
+
const want = id.startsWith("Q:") ? id : `Q:${id}`;
|
|
614
|
+
const logged = readJsonl(queryLogPath(graphPath)).find((r) => r.id === want);
|
|
615
|
+
if (!logged) {
|
|
616
|
+
process.stderr.write(`graph-query: no logged query ${want}\n`);
|
|
617
|
+
return 2;
|
|
618
|
+
}
|
|
619
|
+
const nodes = Array.isArray(logged.top) ? logged.top : [];
|
|
620
|
+
appendBounded(feedbackPath(graphPath), {
|
|
621
|
+
ts: new Date().toISOString(),
|
|
622
|
+
id: want,
|
|
623
|
+
outcome,
|
|
624
|
+
nodes,
|
|
625
|
+
});
|
|
626
|
+
process.stdout.write(JSON.stringify({ ok: true, id: want, outcome, nodes: nodes.length }) + "\n");
|
|
627
|
+
return 0;
|
|
628
|
+
}
|
|
629
|
+
|
|
335
630
|
if (process.argv[1] && process.argv[1].endsWith("graph-query.mjs")) main();
|
|
@@ -37,7 +37,13 @@ import { join, dirname, resolve } from "node:path";
|
|
|
37
37
|
import { parseFlags } from "./graph-build.mjs";
|
|
38
38
|
import { loadGraph, defaultGraphPath } from "./graph-query.mjs";
|
|
39
39
|
import { loadRules } from "./_code-graph.mjs";
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
clusters,
|
|
42
|
+
graphDiff,
|
|
43
|
+
importCycles,
|
|
44
|
+
questions,
|
|
45
|
+
surprisingConnections,
|
|
46
|
+
} from "./_graph-analysis.mjs";
|
|
41
47
|
|
|
42
48
|
/**
|
|
43
49
|
* Top-level source directory of a path, used as the module bucket.
|
|
@@ -261,6 +267,28 @@ export function render(graph, top) {
|
|
|
261
267
|
}
|
|
262
268
|
L.push("");
|
|
263
269
|
|
|
270
|
+
const surprising = surprisingConnections(graph, { groups });
|
|
271
|
+
L.push(`## Surprising connections`);
|
|
272
|
+
L.push("");
|
|
273
|
+
if (!surprising.length) {
|
|
274
|
+
L.push(`None: no file edge crosses from one cluster into another.`);
|
|
275
|
+
} else {
|
|
276
|
+
L.push(
|
|
277
|
+
`Edges between two clusters, the rarest pair first. A pair joined by a single link is ` +
|
|
278
|
+
`a dependency the module structure does not otherwise show.`,
|
|
279
|
+
);
|
|
280
|
+
L.push("");
|
|
281
|
+
L.push(`| Edge | Kind | Clusters | Links between them |`);
|
|
282
|
+
L.push(`|---|---|---|---|`);
|
|
283
|
+
const short = (id) => id.replace(/^file:/, "");
|
|
284
|
+
for (const e of surprising) {
|
|
285
|
+
L.push(
|
|
286
|
+
`| \`${short(e.from)}\` -> \`${short(e.to)}\` | ${e.kind} | \`${e.a}\` / \`${e.b}\` | ${e.pairEdges} |`,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
L.push("");
|
|
291
|
+
|
|
264
292
|
const asks = questions(graph, { hubs: s.hubs, cycles, groups });
|
|
265
293
|
if (asks.length) {
|
|
266
294
|
L.push(`## Questions worth asking`);
|