ultimate-pi 0.18.0 → 0.19.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/.agents/skills/harness-debate-plan/SKILL.md +1 -1
- package/.agents/skills/harness-decisions/SKILL.md +2 -3
- package/.agents/skills/harness-governor/SKILL.md +6 -5
- package/.agents/skills/harness-orchestration/SKILL.md +4 -4
- package/.agents/skills/harness-review/SKILL.md +7 -7
- package/.agents/skills/harness-sentrux-setup/SKILL.md +4 -3
- package/.agents/skills/harness-steer/SKILL.md +1 -1
- package/.agents/skills/sentrux/SKILL.md +9 -9
- package/.pi/PACKAGING.md +4 -4
- package/.pi/SYSTEM.md +54 -120
- package/.pi/agents/harness/incident-recorder.md +0 -1
- package/.pi/agents/harness/planning/decompose.md +1 -3
- package/.pi/agents/harness/planning/execution-plan-author.md +0 -2
- package/.pi/agents/harness/planning/hypothesis-validator.md +0 -2
- package/.pi/agents/harness/planning/hypothesis.md +0 -2
- package/.pi/agents/harness/planning/implementation-researcher.md +0 -2
- package/.pi/agents/harness/planning/plan-adversary.md +0 -2
- package/.pi/agents/harness/planning/plan-evaluator.md +1 -3
- package/.pi/agents/harness/planning/planning-context.md +0 -2
- package/.pi/agents/harness/planning/review-integrator.md +0 -2
- package/.pi/agents/harness/planning/sprint-contract-auditor.md +0 -2
- package/.pi/agents/harness/planning/stack-researcher.md +0 -2
- package/.pi/agents/harness/{adversary.md → reviewing/adversary.md} +0 -2
- package/.pi/agents/harness/{evaluator.md → reviewing/evaluator.md} +0 -2
- package/.pi/agents/harness/{tie-breaker.md → reviewing/tie-breaker.md} +0 -2
- package/.pi/agents/harness/{executor.md → running/executor.md} +0 -2
- package/.pi/agents/harness/sentrux-bootstrap.md +0 -1
- package/.pi/agents/harness/sentrux-steward.md +0 -2
- package/.pi/agents/harness/trace-librarian.md +0 -1
- package/.pi/extensions/00-harness-project-control.ts +133 -0
- package/.pi/extensions/00-posthog-network-bootstrap.ts +1 -1
- package/.pi/extensions/agt-kill-switch.ts +57 -0
- package/.pi/extensions/agt-prompt-guard.ts +32 -0
- package/.pi/extensions/budget-guard.ts +2 -0
- package/.pi/extensions/custom-footer.ts +46 -145
- package/.pi/extensions/custom-header.ts +1 -1
- package/.pi/extensions/custom-system-prompt.ts +1 -1
- package/.pi/extensions/debate-orchestrator.ts +7 -5
- package/.pi/extensions/harness-ask-user.ts +8 -8
- package/.pi/extensions/harness-debate-tools.ts +27 -43
- package/.pi/extensions/harness-lens.ts +94 -0
- package/.pi/extensions/harness-live-widget.ts +33 -2
- package/.pi/extensions/harness-plan-approval.ts +12 -12
- package/.pi/extensions/harness-run-context.ts +1214 -852
- package/.pi/extensions/harness-subagent-governance.ts +8 -0
- package/.pi/extensions/harness-subagent-submit.ts +36 -164
- package/.pi/extensions/harness-subagents.ts +4 -4
- package/.pi/extensions/harness-telemetry.ts +3 -1
- package/.pi/extensions/harness-web-tools.ts +3 -3
- package/.pi/extensions/observation-bus.ts +2 -0
- package/.pi/extensions/policy-gate.ts +27 -5
- package/.pi/extensions/review-integrity.ts +91 -10
- package/.pi/extensions/sentrux-rules-sync.ts +3 -1
- package/.pi/extensions/subagent-governance.ts +92 -0
- package/.pi/extensions/test-diff-integrity.ts +1 -0
- package/.pi/extensions/trace-recorder.ts +3 -1
- package/.pi/extensions/{ultimate-pi-vcc.ts → vcc-compaction.ts} +1 -1
- package/.pi/harness/README.md +6 -2
- package/.pi/harness/agents.manifest.json +38 -49
- package/.pi/harness/agents.policy.yaml +275 -0
- package/.pi/harness/corpus/graphify-kb-updater.config.json +55 -0
- package/.pi/harness/docs/adrs/0006-sentrux-dual-layer.md +2 -1
- package/.pi/harness/docs/adrs/0030-inhouse-vcc-compaction.md +1 -1
- package/.pi/harness/docs/adrs/0035-plan-phase-review-gate.md +1 -1
- package/.pi/harness/docs/adrs/0044-harness-steer-loop.md +3 -2
- package/.pi/harness/docs/adrs/0045-harness-lens-minimal-contract.md +49 -0
- package/.pi/harness/docs/adrs/0045-phase-scoped-agent-directories.md +33 -0
- package/.pi/harness/docs/adrs/0046-agt-policy-engine.md +51 -0
- package/.pi/harness/docs/adrs/0047-agt-layered-security.md +39 -0
- package/.pi/harness/docs/adrs/0048-tool-call-hook-order.md +25 -0
- package/.pi/harness/docs/adrs/0049-agents-policy-manifest.md +36 -0
- package/.pi/harness/docs/adrs/README.md +6 -0
- package/.pi/harness/docs/graphify-kb-updater-runbook.md +11 -5
- package/.pi/harness/docs/practice-map.md +2 -2
- package/.pi/harness/evolution/README.md +1 -2
- package/.pi/harness/examples/agents.policy.project.yaml +19 -0
- package/.pi/harness/examples/policies/custom-deny-bash.yaml +9 -0
- package/.pi/harness/policies/bash-denylists.yaml +5 -0
- package/.pi/harness/policies/defaults.yaml +51 -0
- package/.pi/harness/policies/orchestrator.yaml +18 -0
- package/.pi/harness/policies/phases.yaml +10 -0
- package/.pi/harness/policies/roles.yaml +5 -0
- package/.pi/harness/policies/web-guard.yaml +5 -0
- package/.pi/harness/policies/workflow-sequences.yaml +9 -0
- package/.pi/harness/sentrux/architecture.manifest.json +26 -4
- package/.pi/harness/specs/harness-spawn-context.schema.json +1 -1
- package/.pi/harness/specs/observation.schema.json +2 -1
- package/.pi/lib/agents-policy.d.mts +70 -0
- package/.pi/lib/agents-policy.mjs +325 -0
- package/.pi/lib/agents-policy.ts +19 -0
- package/.pi/lib/agt/audit-run-sink.ts +52 -0
- package/.pi/lib/agt/build-evaluation-context.ts +285 -0
- package/.pi/lib/agt/config.ts +28 -0
- package/.pi/lib/agt/delegation.ts +69 -0
- package/.pi/lib/agt/evaluate-policy.ts +56 -0
- package/.pi/lib/agt/identity-registry.ts +41 -0
- package/.pi/lib/agt/index.ts +55 -0
- package/.pi/lib/agt/kill-switch-state.ts +11 -0
- package/.pi/lib/agt/legacy-evaluate.ts +101 -0
- package/.pi/lib/agt/policy-engine.ts +154 -0
- package/.pi/lib/agt/rings.ts +21 -0
- package/.pi/lib/agt/sre-hooks.ts +45 -0
- package/.pi/lib/agt/trust-run-store.ts +26 -0
- package/.pi/lib/agt/workflow-history.ts +29 -0
- package/.pi/lib/agt-governance-active.ts +14 -0
- package/.pi/lib/agt-tool-guard.ts +78 -0
- package/.pi/lib/ask-user/dialog.ts +314 -0
- package/.pi/{extensions/lib → lib}/debate-bus-core.ts +10 -10
- package/.pi/{extensions/lib → lib}/debate-bus-state.ts +1 -1
- package/.pi/{extensions/lib → lib}/extension-load-guard.ts +21 -0
- package/.pi/lib/harness-agt-tool-guard.ts +5 -0
- package/.pi/{extensions/lib → lib}/harness-artifact-gate.ts +6 -16
- package/.pi/lib/harness-debate-core-deps.ts +14 -0
- package/.pi/lib/harness-debate-workflow-deps.ts +43 -0
- package/.pi/lib/harness-lens/.gitattributes +1 -0
- package/.pi/lib/harness-lens/clients/edit-autopatch.ts +88 -0
- package/.pi/lib/harness-lens/clients/file-kinds.ts +380 -0
- package/.pi/lib/harness-lens/clients/file-time.ts +215 -0
- package/.pi/lib/harness-lens/clients/file-utils.ts +484 -0
- package/.pi/lib/harness-lens/clients/format-service.ts +276 -0
- package/.pi/lib/harness-lens/clients/formatters.ts +1000 -0
- package/.pi/lib/harness-lens/clients/git-guard.ts +31 -0
- package/.pi/lib/harness-lens/clients/indent-retarget.ts +90 -0
- package/.pi/lib/harness-lens/clients/installer/index.ts +2368 -0
- package/.pi/lib/harness-lens/clients/latency-logger.ts +80 -0
- package/.pi/lib/harness-lens/clients/lens-config.ts +43 -0
- package/.pi/lib/harness-lens/clients/lens-events.ts +164 -0
- package/.pi/lib/harness-lens/clients/lsp/aggregation.ts +91 -0
- package/.pi/lib/harness-lens/clients/lsp/client.ts +1466 -0
- package/.pi/lib/harness-lens/clients/lsp/config.ts +216 -0
- package/.pi/lib/harness-lens/clients/lsp/edits.ts +297 -0
- package/.pi/lib/harness-lens/clients/lsp/index.ts +1355 -0
- package/.pi/lib/harness-lens/clients/lsp/interactive-install.ts +424 -0
- package/.pi/lib/harness-lens/clients/lsp/language.ts +223 -0
- package/.pi/lib/harness-lens/clients/lsp/launch.ts +939 -0
- package/.pi/lib/harness-lens/clients/lsp/lsp-index.ts +11 -0
- package/.pi/lib/harness-lens/clients/lsp/path-utils.ts +12 -0
- package/.pi/lib/harness-lens/clients/lsp/server-strategies.ts +81 -0
- package/.pi/lib/harness-lens/clients/lsp/server.ts +1971 -0
- package/.pi/lib/harness-lens/clients/path-utils.ts +182 -0
- package/.pi/lib/harness-lens/clients/pipeline.ts +360 -0
- package/.pi/lib/harness-lens/clients/project-profile.ts +117 -0
- package/.pi/lib/harness-lens/clients/runtime-agent-end.ts +112 -0
- package/.pi/lib/harness-lens/clients/runtime-config.ts +33 -0
- package/.pi/lib/harness-lens/clients/runtime-coordinator.ts +186 -0
- package/.pi/lib/harness-lens/clients/runtime-tool-result.ts +171 -0
- package/.pi/lib/harness-lens/clients/safe-spawn.ts +339 -0
- package/.pi/lib/harness-lens/clients/secrets-scanner.ts +214 -0
- package/.pi/lib/harness-lens/clients/tool-policy.ts +2072 -0
- package/.pi/lib/harness-lens/clients/types.ts +59 -0
- package/.pi/lib/harness-lens/clients/widget-state.ts +283 -0
- package/.pi/lib/harness-lens/index.ts +532 -0
- package/.pi/lib/harness-lens/tools/lsp-diagnostics.ts +706 -0
- package/.pi/lib/harness-lens/tools/lsp-navigation.ts +1246 -0
- package/.pi/{extensions/lib → lib}/harness-posthog.ts +3 -0
- package/.pi/lib/harness-project-config.ts +91 -0
- package/.pi/lib/harness-run-context-responses.ts +9 -0
- package/.pi/lib/harness-run-context.ts +1 -3
- package/.pi/{extensions/lib/spawn-policy.ts → lib/harness-spawn-policy.ts} +4 -3
- package/.pi/{extensions/lib → lib}/harness-spawn-topology.ts +5 -28
- package/.pi/lib/harness-subagent-auth.ts +51 -0
- package/.pi/{extensions/lib → lib}/harness-subagent-precheck.ts +13 -10
- package/.pi/{extensions/lib → lib}/harness-subagent-submit-pipeline.ts +3 -3
- package/.pi/lib/harness-subagent-submit-register.ts +163 -0
- package/.pi/{extensions/lib → lib}/harness-subagent-submit-registry.ts +1 -55
- package/.pi/{extensions/lib → lib}/harness-subagents-bridge.ts +53 -14
- package/.pi/{extensions/lib → lib}/harness-subprocess-bootstrap.ts +1 -1
- package/.pi/lib/harness-ui-state.ts +27 -12
- package/.pi/{extensions/lib → lib}/plan-approval/create-plan.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/format-plan.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/plan-review.ts +162 -201
- package/.pi/{extensions/lib → lib}/plan-approval/render.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-approval/resolve-disk.ts +2 -2
- package/.pi/{extensions/lib → lib}/plan-approval/types.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-approval/validate.ts +3 -3
- package/.pi/{extensions/lib → lib}/plan-approval-readiness.ts +3 -52
- package/.pi/{extensions/lib → lib}/plan-debate-envelope.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-debate-gate.ts +1 -1
- package/.pi/{extensions/lib → lib}/plan-debate-lane.ts +1 -4
- package/.pi/{extensions/lib → lib}/plan-messenger.ts +1 -1
- package/.pi/prompts/harness-auto.md +2 -2
- package/.pi/prompts/harness-plan.md +4 -6
- package/.pi/prompts/harness-review.md +9 -9
- package/.pi/prompts/harness-run.md +7 -7
- package/.pi/prompts/harness-setup.md +42 -68
- package/.pi/prompts/harness-steer.md +2 -2
- package/.pi/scripts/README.md +3 -5
- package/.pi/scripts/generate-agents-policy-yaml.mjs +148 -0
- package/.pi/scripts/graphify-kb-updater.mjs +48 -8
- package/.pi/scripts/harness-agents-manifest.mjs +61 -4
- package/.pi/scripts/harness-agt-doctor.ts +36 -0
- package/.pi/scripts/harness-cli-verify.sh +9 -2
- package/.pi/scripts/harness-project-toggle.mjs +129 -0
- package/.pi/scripts/harness-sentrux-cli.mjs +142 -0
- package/.pi/scripts/harness-verify.mjs +113 -39
- package/.pi/scripts/harness-web-policy-guard.mjs +2 -2
- package/.pi/scripts/validate-plan-dag.mjs +65 -74
- package/.pi/scripts/vendor-pi-vcc-settings.stub.ts +2 -2
- package/.pi/scripts/vendor-sync-pi-vcc.sh +1 -1
- package/.pi/skills/architecture/broker-domain/SKILL.md +65 -0
- package/.pi/skills/architecture/cqrs/SKILL.md +63 -0
- package/.pi/skills/architecture/event-driven/SKILL.md +60 -0
- package/.pi/skills/architecture/hexagonal-ports-adapters/SKILL.md +66 -0
- package/.pi/skills/architecture/layered/SKILL.md +68 -0
- package/.pi/skills/architecture/microkernel/SKILL.md +62 -0
- package/.pi/skills/architecture/microservices/SKILL.md +64 -0
- package/.pi/skills/architecture/modular-monolith/SKILL.md +65 -0
- package/.pi/skills/architecture/orchestration-driven-soa/SKILL.md +61 -0
- package/.pi/skills/architecture/pipeline/SKILL.md +63 -0
- package/.pi/skills/architecture/service-based/SKILL.md +64 -0
- package/.pi/skills/architecture/service-mesh/SKILL.md +60 -0
- package/.pi/skills/architecture/space-based/SKILL.md +60 -0
- package/.pi/skills/ast-grep/SKILL.md +40 -321
- package/.pi/skills/delivery/debugging-discipline/SKILL.md +36 -0
- package/.pi/skills/delivery/documentation-update/SKILL.md +33 -0
- package/.pi/skills/delivery/requirements-to-implementation/SKILL.md +34 -0
- package/.pi/skills/delivery/risk-based-verification/SKILL.md +43 -0
- package/.pi/skills/delivery/tradeoff-analysis/SKILL.md +34 -0
- package/.pi/skills/engineering/api-contract-design/SKILL.md +38 -0
- package/.pi/skills/engineering/cohesion-coupling/SKILL.md +43 -0
- package/.pi/skills/engineering/complexity-control/SKILL.md +31 -0
- package/.pi/skills/engineering/defensive-programming/SKILL.md +38 -0
- package/.pi/skills/engineering/dependency-management/SKILL.md +29 -0
- package/.pi/skills/engineering/domain-modeling/SKILL.md +32 -0
- package/.pi/skills/engineering/error-handling/SKILL.md +37 -0
- package/.pi/skills/engineering/legacy-code-seams/SKILL.md +35 -0
- package/.pi/skills/engineering/naming-and-intent/SKILL.md +29 -0
- package/.pi/skills/engineering/refactoring-safe-evolution/SKILL.md +35 -0
- package/.pi/skills/engineering/routine-function-design/SKILL.md +34 -0
- package/.pi/skills/engineering/small-change-discipline/SKILL.md +35 -0
- package/.pi/skills/lsp-navigation/SKILL.md +89 -0
- package/.pi/skills/quality/code-review-self-check/SKILL.md +35 -0
- package/.pi/skills/quality/privacy-data-handling/SKILL.md +26 -0
- package/.pi/skills/quality/security-review/SKILL.md +34 -0
- package/.pi/skills/quality/test-strategy/SKILL.md +33 -0
- package/.pi/skills/quality/testability-design/SKILL.md +33 -0
- package/.pi/skills/systems/concurrency-safety/SKILL.md +32 -0
- package/.pi/skills/systems/data-modeling-migrations/SKILL.md +31 -0
- package/.pi/skills/systems/observability-instrumentation/SKILL.md +32 -0
- package/.pi/skills/systems/performance-measurement/SKILL.md +35 -0
- package/.pi/skills/systems/reliability-design/SKILL.md +32 -0
- package/.sentrux/rules.toml +20 -4
- package/AGENTS.md +5 -0
- package/CHANGELOG.md +26 -0
- package/README.md +85 -58
- package/THIRD_PARTY_NOTICES.md +12 -21
- package/package.json +15 -7
- package/vendor/pi-subagents/src/agents.ts +45 -1
- package/vendor/pi-subagents/src/subagents.ts +866 -811
- package/vendor/pi-vcc/src/core/brief.ts +68 -99
- package/vendor/pi-vcc/src/core/settings.ts +2 -2
- package/.agents/skills/caveman/SKILL.md +0 -67
- package/.pi/agents/harness/meta-optimizer.md +0 -36
- package/.pi/agents/harness/planning/scout-graphify.md +0 -39
- package/.pi/agents/harness/planning/scout-semantic.md +0 -41
- package/.pi/agents/harness/planning/scout-structure.md +0 -37
- package/.pi/extensions/lib/ask-user/dialog.ts +0 -260
- package/.pi/extensions/lib/harness-subagent-auth.ts +0 -209
- package/.pi/extensions/lib/harness-subagent-policy.ts +0 -236
- package/.pi/extensions/pi-model-router-harness.ts +0 -42
- package/.pi/harness/evolution/meta-optimizer.mjs +0 -99
- package/.pi/harness/specs/router-tuning-proposal.schema.json +0 -114
- package/.pi/model-router.example.json +0 -36
- package/.pi/prompts/harness-critic.md +0 -10
- package/.pi/prompts/harness-eval.md +0 -10
- package/.pi/prompts/harness-router-tune.md +0 -52
- package/.pi/scripts/harness-generate-model-router.mjs +0 -327
- package/.pi/scripts/harness-model-router-routing.test.mjs +0 -97
- package/.pi/scripts/harness-sync-model-router.mjs +0 -97
- package/.pi/scripts/vendor-sync-pi-model-router.sh +0 -47
- package/vendor/pi-model-router/.prettierignore +0 -4
- package/vendor/pi-model-router/.prettierrc +0 -5
- package/vendor/pi-model-router/AGENTS.md +0 -39
- package/vendor/pi-model-router/LICENSE +0 -21
- package/vendor/pi-model-router/README.md +0 -99
- package/vendor/pi-model-router/UPSTREAM_PIN.md +0 -10
- package/vendor/pi-model-router/docs/ARCHITECTURE.md +0 -54
- package/vendor/pi-model-router/extensions/commands.ts +0 -720
- package/vendor/pi-model-router/extensions/config.ts +0 -348
- package/vendor/pi-model-router/extensions/constants.ts +0 -1
- package/vendor/pi-model-router/extensions/index.ts +0 -478
- package/vendor/pi-model-router/extensions/provider.ts +0 -580
- package/vendor/pi-model-router/extensions/routing.ts +0 -564
- package/vendor/pi-model-router/extensions/state.ts +0 -52
- package/vendor/pi-model-router/extensions/types.ts +0 -95
- package/vendor/pi-model-router/extensions/ui.ts +0 -144
- package/vendor/pi-model-router/model-router.example.json +0 -48
- package/vendor/pi-model-router/package.json +0 -48
- package/vendor/pi-model-router/tsconfig.json +0 -16
- /package/.pi/{prompts → harness/docs}/planning-rubrics.md +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/fallback.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/render.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/schema.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/types.ts +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/validate-core.mjs +0 -0
- /package/.pi/{extensions/lib → lib}/ask-user/validate.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-cocoindex-refresh.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-paths.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-spawn-budget.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-vcc-settings.ts +0 -0
- /package/.pi/{extensions/lib → lib}/harness-web/run-cli.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-approval/dialog.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-approval/schema.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-eligibility.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-focus.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-id.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-lanes.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-round-status.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-debate-write-guard.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-review-gate.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-review-integrator-rules.ts +0 -0
- /package/.pi/{extensions/lib → lib}/plan-scope-guard.ts +0 -0
- /package/.pi/{extensions/lib → lib}/posthog-client.ts +0 -0
- /package/.pi/{extensions/lib → lib}/posthog-node.d.ts +0 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive LSP Installer
|
|
3
|
+
*
|
|
4
|
+
* Provides lazy auto-install with user prompt for common languages.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - 30-second timeout with auto-accept
|
|
8
|
+
* - --auto-install flag for non-interactive mode
|
|
9
|
+
* - User choice caching per project
|
|
10
|
+
* - Only prompts for "common" languages (Go, Rust, YAML, JSON, Bash)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import * as fs from "node:fs/promises";
|
|
15
|
+
import * as path from "node:path";
|
|
16
|
+
import { getProjectDataDir } from "../file-utils.js";
|
|
17
|
+
|
|
18
|
+
function canUseInteractivePrompt(): boolean {
|
|
19
|
+
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function isToolOnPath(toolId: string): Promise<boolean> {
|
|
23
|
+
const locator = process.platform === "win32" ? "where" : "which";
|
|
24
|
+
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const proc = spawn(locator, [toolId], { stdio: "ignore", shell: false });
|
|
27
|
+
proc.on("close", (code) => resolve(code === 0));
|
|
28
|
+
proc.on("error", () => resolve(false));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Install strategy:
|
|
34
|
+
* - "npm": npm install -g <packageName> (managed by harness lens, goes into .pi/harness/.lens/tools)
|
|
35
|
+
* - "shell": run installCommand verbatim in a shell (gem, dotnet, brew, etc.)
|
|
36
|
+
* - "manual": can't auto-install — show installCommand and tell the user to run it
|
|
37
|
+
*/
|
|
38
|
+
type InstallStrategy = "npm" | "shell" | "manual";
|
|
39
|
+
|
|
40
|
+
interface LanguageConfig {
|
|
41
|
+
toolId: string;
|
|
42
|
+
toolName: string;
|
|
43
|
+
/** Shown to user and used as the shell command for "shell" strategy */
|
|
44
|
+
installCommand: string;
|
|
45
|
+
/** npm package name — required for "npm" strategy */
|
|
46
|
+
packageName?: string;
|
|
47
|
+
installStrategy: InstallStrategy;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Languages that support interactive auto-install prompt
|
|
51
|
+
const COMMON_LANGUAGES: Record<string, LanguageConfig> = {
|
|
52
|
+
// --- Originally supported ---
|
|
53
|
+
go: {
|
|
54
|
+
toolId: "gopls",
|
|
55
|
+
toolName: "Go Language Server (gopls)",
|
|
56
|
+
installCommand: "go install golang.org/x/tools/gopls@latest",
|
|
57
|
+
installStrategy: "shell",
|
|
58
|
+
},
|
|
59
|
+
rust: {
|
|
60
|
+
toolId: "rust-analyzer",
|
|
61
|
+
toolName: "Rust Language Server (rust-analyzer)",
|
|
62
|
+
installCommand: "rustup component add rust-analyzer",
|
|
63
|
+
installStrategy: "shell",
|
|
64
|
+
},
|
|
65
|
+
yaml: {
|
|
66
|
+
toolId: "yaml-language-server",
|
|
67
|
+
toolName: "YAML Language Server",
|
|
68
|
+
installCommand: "npm install -g yaml-language-server",
|
|
69
|
+
packageName: "yaml-language-server",
|
|
70
|
+
installStrategy: "npm",
|
|
71
|
+
},
|
|
72
|
+
json: {
|
|
73
|
+
toolId: "vscode-json-language-server",
|
|
74
|
+
toolName: "JSON Language Server",
|
|
75
|
+
installCommand: "npm install -g vscode-langservers-extracted",
|
|
76
|
+
packageName: "vscode-langservers-extracted",
|
|
77
|
+
installStrategy: "npm",
|
|
78
|
+
},
|
|
79
|
+
bash: {
|
|
80
|
+
toolId: "bash-language-server",
|
|
81
|
+
toolName: "Bash Language Server",
|
|
82
|
+
installCommand: "npm install -g bash-language-server",
|
|
83
|
+
packageName: "bash-language-server",
|
|
84
|
+
installStrategy: "npm",
|
|
85
|
+
},
|
|
86
|
+
// --- Tier-4: previously silent on ENOENT ---
|
|
87
|
+
ruby: {
|
|
88
|
+
toolId: "ruby-lsp",
|
|
89
|
+
toolName: "Ruby LSP",
|
|
90
|
+
installCommand: "gem install ruby-lsp",
|
|
91
|
+
installStrategy: "shell",
|
|
92
|
+
},
|
|
93
|
+
php: {
|
|
94
|
+
toolId: "intelephense",
|
|
95
|
+
toolName: "PHP Language Server (Intelephense)",
|
|
96
|
+
installCommand: "npm install -g intelephense",
|
|
97
|
+
packageName: "intelephense",
|
|
98
|
+
installStrategy: "npm",
|
|
99
|
+
},
|
|
100
|
+
csharp: {
|
|
101
|
+
toolId: "csharp-ls",
|
|
102
|
+
toolName: "C# Language Server (csharp-ls)",
|
|
103
|
+
installCommand: "dotnet tool install -g csharp-ls",
|
|
104
|
+
installStrategy: "shell",
|
|
105
|
+
},
|
|
106
|
+
fsharp: {
|
|
107
|
+
toolId: "fsautocomplete",
|
|
108
|
+
toolName: "F# Language Server (FSAutocomplete)",
|
|
109
|
+
installCommand: "dotnet tool install -g fsautocomplete",
|
|
110
|
+
installStrategy: "shell",
|
|
111
|
+
},
|
|
112
|
+
java: {
|
|
113
|
+
toolId: "jdtls",
|
|
114
|
+
toolName: "Java Language Server (Eclipse JDT LS)",
|
|
115
|
+
installCommand:
|
|
116
|
+
"brew install jdtls # or: https://github.com/eclipse-jdtls/eclipse.jdt.ls",
|
|
117
|
+
installStrategy: "manual",
|
|
118
|
+
},
|
|
119
|
+
kotlin: {
|
|
120
|
+
toolId: "kotlin-language-server",
|
|
121
|
+
toolName: "Kotlin Language Server",
|
|
122
|
+
installCommand:
|
|
123
|
+
"brew install kotlin-language-server # or: https://github.com/fwcd/kotlin-language-server",
|
|
124
|
+
installStrategy: "manual",
|
|
125
|
+
},
|
|
126
|
+
swift: {
|
|
127
|
+
toolId: "sourcekit-lsp",
|
|
128
|
+
toolName: "Swift Language Server (SourceKit-LSP)",
|
|
129
|
+
installCommand:
|
|
130
|
+
"xcode-select --install # bundled with Xcode / Swift toolchain",
|
|
131
|
+
installStrategy: "manual",
|
|
132
|
+
},
|
|
133
|
+
dart: {
|
|
134
|
+
toolId: "dart",
|
|
135
|
+
toolName: "Dart Language Server",
|
|
136
|
+
installCommand: "# Install Dart SDK: https://dart.dev/get-dart",
|
|
137
|
+
installStrategy: "manual",
|
|
138
|
+
},
|
|
139
|
+
lua: {
|
|
140
|
+
toolId: "lua-language-server",
|
|
141
|
+
toolName: "Lua Language Server",
|
|
142
|
+
installCommand: "brew install lua-language-server",
|
|
143
|
+
installStrategy: "shell",
|
|
144
|
+
},
|
|
145
|
+
cpp: {
|
|
146
|
+
toolId: "clangd",
|
|
147
|
+
toolName: "C/C++ Language Server (clangd)",
|
|
148
|
+
installCommand: "brew install llvm # or: apt install clangd",
|
|
149
|
+
installStrategy: "manual",
|
|
150
|
+
},
|
|
151
|
+
zig: {
|
|
152
|
+
toolId: "zls",
|
|
153
|
+
toolName: "Zig Language Server (ZLS)",
|
|
154
|
+
installCommand: "brew install zls",
|
|
155
|
+
installStrategy: "shell",
|
|
156
|
+
},
|
|
157
|
+
haskell: {
|
|
158
|
+
toolId: "haskell-language-server-wrapper",
|
|
159
|
+
toolName: "Haskell Language Server",
|
|
160
|
+
installCommand: "ghcup install hls",
|
|
161
|
+
installStrategy: "shell",
|
|
162
|
+
},
|
|
163
|
+
elixir: {
|
|
164
|
+
toolId: "elixir-ls",
|
|
165
|
+
toolName: "Elixir Language Server (ElixirLS)",
|
|
166
|
+
installCommand:
|
|
167
|
+
"# Download from: https://github.com/elixir-lsp/elixir-ls/releases",
|
|
168
|
+
installStrategy: "manual",
|
|
169
|
+
},
|
|
170
|
+
gleam: {
|
|
171
|
+
toolId: "gleam",
|
|
172
|
+
toolName: "Gleam Language Server",
|
|
173
|
+
installCommand: "brew install gleam",
|
|
174
|
+
installStrategy: "shell",
|
|
175
|
+
},
|
|
176
|
+
ocaml: {
|
|
177
|
+
toolId: "ocamllsp",
|
|
178
|
+
toolName: "OCaml Language Server (ocamllsp)",
|
|
179
|
+
installCommand: "opam install ocaml-lsp-server",
|
|
180
|
+
installStrategy: "shell",
|
|
181
|
+
},
|
|
182
|
+
clojure: {
|
|
183
|
+
toolId: "clojure-lsp",
|
|
184
|
+
toolName: "Clojure Language Server",
|
|
185
|
+
installCommand: "brew install clojure-lsp/brew/clojure-lsp",
|
|
186
|
+
installStrategy: "shell",
|
|
187
|
+
},
|
|
188
|
+
terraform: {
|
|
189
|
+
toolId: "terraform-ls",
|
|
190
|
+
toolName: "Terraform Language Server",
|
|
191
|
+
installCommand: "brew install hashicorp/tap/terraform-ls",
|
|
192
|
+
installStrategy: "shell",
|
|
193
|
+
},
|
|
194
|
+
nix: {
|
|
195
|
+
toolId: "nixd",
|
|
196
|
+
toolName: "Nix Language Server (nixd)",
|
|
197
|
+
installCommand: "nix profile install nixpkgs#nixd",
|
|
198
|
+
installStrategy: "shell",
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
interface InstallChoice {
|
|
203
|
+
choice: "yes" | "no" | "auto";
|
|
204
|
+
timestamp: number;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get the cache file path for install choices
|
|
209
|
+
*/
|
|
210
|
+
function getCachePath(cwd: string): string {
|
|
211
|
+
return path.join(getProjectDataDir(cwd), "install-choices.json");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Read cached install choices
|
|
216
|
+
*/
|
|
217
|
+
async function readChoices(
|
|
218
|
+
cwd: string,
|
|
219
|
+
): Promise<Record<string, InstallChoice>> {
|
|
220
|
+
try {
|
|
221
|
+
const cachePath = getCachePath(cwd);
|
|
222
|
+
const content = await fs.readFile(cachePath, "utf-8");
|
|
223
|
+
return JSON.parse(content);
|
|
224
|
+
} catch {
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Save install choice to cache
|
|
231
|
+
*/
|
|
232
|
+
async function saveChoice(
|
|
233
|
+
cwd: string,
|
|
234
|
+
toolId: string,
|
|
235
|
+
choice: "yes" | "no" | "auto",
|
|
236
|
+
): Promise<void> {
|
|
237
|
+
const choices = await readChoices(cwd);
|
|
238
|
+
choices[toolId] = { choice, timestamp: Date.now() };
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
const cachePath = getCachePath(cwd);
|
|
242
|
+
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
243
|
+
await fs.writeFile(cachePath, JSON.stringify(choices, null, 2));
|
|
244
|
+
} catch {
|
|
245
|
+
// Ignore cache write errors
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Prompt user with timeout
|
|
251
|
+
*/
|
|
252
|
+
function promptUser(timeoutMs: number): Promise<"yes" | "no"> {
|
|
253
|
+
return new Promise((resolve) => {
|
|
254
|
+
// Set up stdin for single char input
|
|
255
|
+
process.stdin.setRawMode?.(true);
|
|
256
|
+
process.stdin.resume();
|
|
257
|
+
process.stdin.setEncoding("utf8");
|
|
258
|
+
|
|
259
|
+
const onData = (data: Buffer | string) => {
|
|
260
|
+
const char = data.toString().trim().toLowerCase();
|
|
261
|
+
cleanup();
|
|
262
|
+
|
|
263
|
+
if (char === "y" || char === "\n" || char === "\r") {
|
|
264
|
+
resolve("yes");
|
|
265
|
+
} else if (char === "n") {
|
|
266
|
+
resolve("no");
|
|
267
|
+
}
|
|
268
|
+
// For any other input, auto-accept after timeout
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
process.stdin.on("data", onData);
|
|
272
|
+
|
|
273
|
+
// Auto-decline after timeout
|
|
274
|
+
const timeout = setTimeout(() => {
|
|
275
|
+
cleanup();
|
|
276
|
+
resolve("no");
|
|
277
|
+
}, timeoutMs);
|
|
278
|
+
|
|
279
|
+
// Handle stdin closing
|
|
280
|
+
process.stdin.on("end", () => {
|
|
281
|
+
cleanup();
|
|
282
|
+
resolve("no");
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
function cleanup() {
|
|
286
|
+
clearTimeout(timeout);
|
|
287
|
+
process.stdin.removeListener("data", onData);
|
|
288
|
+
process.stdin.setRawMode?.(false);
|
|
289
|
+
process.stdin.pause();
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Check if --auto-install flag is set
|
|
296
|
+
*/
|
|
297
|
+
function isAutoInstallEnabled(): boolean {
|
|
298
|
+
// Check environment variable or process arguments
|
|
299
|
+
return (
|
|
300
|
+
process.env.PI_LENS_AUTO_INSTALL === "1" ||
|
|
301
|
+
process.argv.includes("--auto-install")
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Attempt to install a tool using the configured strategy.
|
|
307
|
+
*
|
|
308
|
+
* - "npm": npm install -g <packageName>
|
|
309
|
+
* - "shell": run installCommand verbatim via shell (gem, dotnet, brew, etc.)
|
|
310
|
+
* - "manual": can't auto-install — print the command and return false
|
|
311
|
+
*/
|
|
312
|
+
async function installTool(config: LanguageConfig): Promise<boolean> {
|
|
313
|
+
const { installCommand, packageName, installStrategy } = config;
|
|
314
|
+
|
|
315
|
+
if (installStrategy === "manual") {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const [cmd, ...args] =
|
|
320
|
+
installStrategy === "npm" && packageName
|
|
321
|
+
? ["npm", "install", "-g", packageName]
|
|
322
|
+
: process.platform === "win32"
|
|
323
|
+
? ["powershell", "-NoProfile", "-Command", installCommand]
|
|
324
|
+
: ["sh", "-c", installCommand];
|
|
325
|
+
|
|
326
|
+
return new Promise((resolve) => {
|
|
327
|
+
const proc = spawn(cmd, args, { stdio: "inherit", shell: false });
|
|
328
|
+
|
|
329
|
+
proc.on("close", (code) => {
|
|
330
|
+
if (code === 0) {
|
|
331
|
+
resolve(true);
|
|
332
|
+
} else {
|
|
333
|
+
resolve(false);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
proc.on("error", () => {
|
|
338
|
+
resolve(false);
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Prompt user for installation with timeout, or auto-install if flag set
|
|
345
|
+
*
|
|
346
|
+
* @param language - Language identifier (go, rust, yaml, json, bash)
|
|
347
|
+
* @param cwd - Project root
|
|
348
|
+
* @returns true if tool is/should be installed, false to skip
|
|
349
|
+
*/
|
|
350
|
+
export async function promptForInstall(
|
|
351
|
+
language: string,
|
|
352
|
+
cwd: string,
|
|
353
|
+
): Promise<boolean> {
|
|
354
|
+
const config = COMMON_LANGUAGES[language];
|
|
355
|
+
if (!config) {
|
|
356
|
+
// Not a common language, don't prompt
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Check cache first
|
|
361
|
+
const choices = await readChoices(cwd);
|
|
362
|
+
const cached = choices[config.toolId];
|
|
363
|
+
|
|
364
|
+
if (cached) {
|
|
365
|
+
// Cache valid for 30 days
|
|
366
|
+
const thirtyDays = 30 * 24 * 60 * 60 * 1000;
|
|
367
|
+
if (Date.now() - cached.timestamp < thirtyDays) {
|
|
368
|
+
if (cached.choice === "yes" || cached.choice === "auto") {
|
|
369
|
+
const toolAvailable = await isToolOnPath(config.toolId);
|
|
370
|
+
if (toolAvailable) {
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
return false; // User previously declined
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Check auto-install flag
|
|
380
|
+
if (isAutoInstallEnabled()) {
|
|
381
|
+
await saveChoice(cwd, config.toolId, "auto");
|
|
382
|
+
return installTool(config);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (!canUseInteractivePrompt()) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// For manual-only tools, skip the Y/n prompt because user must install manually.
|
|
390
|
+
if (config.installStrategy === "manual") {
|
|
391
|
+
await saveChoice(cwd, config.toolId, "no");
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
const answer = await promptUser(10000);
|
|
395
|
+
await saveChoice(cwd, config.toolId, answer);
|
|
396
|
+
|
|
397
|
+
if (answer === "yes") {
|
|
398
|
+
return installTool(config);
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Get install command for display purposes
|
|
405
|
+
*/
|
|
406
|
+
export function getInstallCommand(language: string): string | undefined {
|
|
407
|
+
return COMMON_LANGUAGES[language]?.installCommand;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Get install strategy for a language (exposed for testing)
|
|
412
|
+
*/
|
|
413
|
+
export function getInstallStrategy(
|
|
414
|
+
language: string,
|
|
415
|
+
): InstallStrategy | undefined {
|
|
416
|
+
return COMMON_LANGUAGES[language]?.installStrategy;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Check if a language supports interactive install
|
|
421
|
+
*/
|
|
422
|
+
export function supportsInteractiveInstall(language: string): boolean {
|
|
423
|
+
return language in COMMON_LANGUAGES;
|
|
424
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Language ID Mappings for LSP
|
|
5
|
+
*
|
|
6
|
+
* Maps file extensions to LSP language identifiers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const LANGUAGE_EXTENSIONS: Record<string, string> = {
|
|
10
|
+
// JavaScript/TypeScript
|
|
11
|
+
".ts": "typescript",
|
|
12
|
+
".tsx": "typescriptreact",
|
|
13
|
+
".mts": "typescript",
|
|
14
|
+
".cts": "typescript",
|
|
15
|
+
".js": "javascript",
|
|
16
|
+
".jsx": "javascriptreact",
|
|
17
|
+
".mjs": "javascript",
|
|
18
|
+
".cjs": "javascript",
|
|
19
|
+
".svelte": "svelte",
|
|
20
|
+
".vue": "vue",
|
|
21
|
+
".astro": "astro",
|
|
22
|
+
|
|
23
|
+
// Python
|
|
24
|
+
".py": "python",
|
|
25
|
+
".pyi": "python",
|
|
26
|
+
|
|
27
|
+
// Go
|
|
28
|
+
".go": "go",
|
|
29
|
+
".mod": "go",
|
|
30
|
+
".sum": "go",
|
|
31
|
+
|
|
32
|
+
// Rust
|
|
33
|
+
".rs": "rust",
|
|
34
|
+
".ron": "rust",
|
|
35
|
+
|
|
36
|
+
// C/C++
|
|
37
|
+
".c": "c",
|
|
38
|
+
".cpp": "cpp",
|
|
39
|
+
".cc": "cpp",
|
|
40
|
+
".cxx": "cpp",
|
|
41
|
+
".h": "c",
|
|
42
|
+
".hpp": "cpp",
|
|
43
|
+
".hh": "cpp",
|
|
44
|
+
|
|
45
|
+
// Java
|
|
46
|
+
".java": "java",
|
|
47
|
+
|
|
48
|
+
// Kotlin
|
|
49
|
+
".kt": "kotlin",
|
|
50
|
+
".kts": "kotlin",
|
|
51
|
+
|
|
52
|
+
// Ruby
|
|
53
|
+
".rb": "ruby",
|
|
54
|
+
".rake": "ruby",
|
|
55
|
+
".gemspec": "ruby",
|
|
56
|
+
".ru": "ruby",
|
|
57
|
+
|
|
58
|
+
// PHP
|
|
59
|
+
".php": "php",
|
|
60
|
+
|
|
61
|
+
// C#
|
|
62
|
+
".cs": "csharp",
|
|
63
|
+
|
|
64
|
+
// F#
|
|
65
|
+
".fs": "fsharp",
|
|
66
|
+
".fsi": "fsharp",
|
|
67
|
+
".fsx": "fsharp",
|
|
68
|
+
|
|
69
|
+
// Swift
|
|
70
|
+
".swift": "swift",
|
|
71
|
+
|
|
72
|
+
// Dart
|
|
73
|
+
".dart": "dart",
|
|
74
|
+
|
|
75
|
+
// Lua
|
|
76
|
+
".lua": "lua",
|
|
77
|
+
|
|
78
|
+
// Shell
|
|
79
|
+
".sh": "shellscript",
|
|
80
|
+
".bash": "shellscript",
|
|
81
|
+
".zsh": "shellscript",
|
|
82
|
+
".fish": "shellscript",
|
|
83
|
+
|
|
84
|
+
// JSON/YAML
|
|
85
|
+
".json": "json",
|
|
86
|
+
".jsonc": "jsonc",
|
|
87
|
+
".yaml": "yaml",
|
|
88
|
+
".yml": "yaml",
|
|
89
|
+
|
|
90
|
+
// Markdown
|
|
91
|
+
".md": "markdown",
|
|
92
|
+
".mdx": "markdown",
|
|
93
|
+
|
|
94
|
+
// CSS
|
|
95
|
+
".css": "css",
|
|
96
|
+
".scss": "scss",
|
|
97
|
+
".sass": "sass",
|
|
98
|
+
".less": "less",
|
|
99
|
+
|
|
100
|
+
// HTML
|
|
101
|
+
".html": "html",
|
|
102
|
+
".htm": "html",
|
|
103
|
+
|
|
104
|
+
// SQL
|
|
105
|
+
".sql": "sql",
|
|
106
|
+
|
|
107
|
+
// Docker
|
|
108
|
+
".dockerfile": "dockerfile",
|
|
109
|
+
Dockerfile: "dockerfile",
|
|
110
|
+
|
|
111
|
+
// Terraform
|
|
112
|
+
".tf": "terraform",
|
|
113
|
+
".tfvars": "terraform",
|
|
114
|
+
|
|
115
|
+
// Nix
|
|
116
|
+
".nix": "nix",
|
|
117
|
+
|
|
118
|
+
// Elixir
|
|
119
|
+
".ex": "elixir",
|
|
120
|
+
".exs": "elixir",
|
|
121
|
+
|
|
122
|
+
// Haskell
|
|
123
|
+
".hs": "haskell",
|
|
124
|
+
".lhs": "haskell",
|
|
125
|
+
|
|
126
|
+
// OCaml
|
|
127
|
+
".ml": "ocaml",
|
|
128
|
+
".mli": "ocaml",
|
|
129
|
+
|
|
130
|
+
// Zig
|
|
131
|
+
".zig": "zig",
|
|
132
|
+
".zon": "zig",
|
|
133
|
+
|
|
134
|
+
// Gleam
|
|
135
|
+
".gleam": "gleam",
|
|
136
|
+
|
|
137
|
+
// Clojure
|
|
138
|
+
".clj": "clojure",
|
|
139
|
+
".cljs": "clojure",
|
|
140
|
+
".cljc": "clojure",
|
|
141
|
+
".edn": "clojure",
|
|
142
|
+
|
|
143
|
+
// Scala
|
|
144
|
+
".scala": "scala",
|
|
145
|
+
".sc": "scala",
|
|
146
|
+
|
|
147
|
+
// R
|
|
148
|
+
".r": "r",
|
|
149
|
+
".R": "r",
|
|
150
|
+
|
|
151
|
+
// Julia
|
|
152
|
+
".jl": "julia",
|
|
153
|
+
|
|
154
|
+
// Perl
|
|
155
|
+
".pl": "perl",
|
|
156
|
+
".pm": "perl",
|
|
157
|
+
|
|
158
|
+
// Erlang
|
|
159
|
+
".erl": "erlang",
|
|
160
|
+
".hrl": "erlang",
|
|
161
|
+
|
|
162
|
+
// Fortran
|
|
163
|
+
".f": "fortran",
|
|
164
|
+
".f90": "fortran",
|
|
165
|
+
".f95": "fortran",
|
|
166
|
+
|
|
167
|
+
// COBOL
|
|
168
|
+
".cob": "cobol",
|
|
169
|
+
".cbl": "cobol",
|
|
170
|
+
|
|
171
|
+
// Pascal
|
|
172
|
+
".pas": "pascal",
|
|
173
|
+
".pp": "pascal",
|
|
174
|
+
|
|
175
|
+
// Ada
|
|
176
|
+
".adb": "ada",
|
|
177
|
+
".ads": "ada",
|
|
178
|
+
|
|
179
|
+
// VHDL/Verilog
|
|
180
|
+
".vhd": "vhdl",
|
|
181
|
+
".vhdl": "vhdl",
|
|
182
|
+
".v": "verilog",
|
|
183
|
+
".sv": "systemverilog",
|
|
184
|
+
|
|
185
|
+
// GraphQL
|
|
186
|
+
".graphql": "graphql",
|
|
187
|
+
".gql": "graphql",
|
|
188
|
+
|
|
189
|
+
// Protocol Buffers
|
|
190
|
+
".proto": "proto",
|
|
191
|
+
|
|
192
|
+
// TOML
|
|
193
|
+
".toml": "toml",
|
|
194
|
+
|
|
195
|
+
// Prisma
|
|
196
|
+
".prisma": "prisma",
|
|
197
|
+
|
|
198
|
+
// Typst
|
|
199
|
+
".typ": "typst",
|
|
200
|
+
".typc": "typst",
|
|
201
|
+
} as const;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get language ID for a file path
|
|
205
|
+
*/
|
|
206
|
+
export function getLanguageId(filePath: string): string | undefined {
|
|
207
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
208
|
+
if (ext && LANGUAGE_EXTENSIONS[ext]) {
|
|
209
|
+
return LANGUAGE_EXTENSIONS[ext];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const base = path.basename(filePath);
|
|
213
|
+
return LANGUAGE_EXTENSIONS[base] ?? LANGUAGE_EXTENSIONS[base.toLowerCase()];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Get all extensions for a language ID
|
|
218
|
+
*/
|
|
219
|
+
export function getExtensionsForLanguage(languageId: string): string[] {
|
|
220
|
+
return Object.entries(LANGUAGE_EXTENSIONS)
|
|
221
|
+
.filter(([, id]) => id === languageId)
|
|
222
|
+
.map(([ext]) => ext);
|
|
223
|
+
}
|