pi-agent-ide 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
- package/dist/{chunk-2ZMYT6ZC.js → chunk-4U6KGABH.js} +1 -1
- package/dist/chunk-4ZTEPMJO.js +14 -0
- package/dist/{chunk-KNMWCDDK.js → chunk-6ACQQBUY.js} +1 -1
- package/dist/chunk-76WHES5H.js +7 -0
- package/dist/chunk-BHSO2MDK.js +6 -0
- package/dist/chunk-BMOJTJJJ.js +3 -0
- package/dist/chunk-GFWDXTOB.js +4 -0
- package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
- package/dist/chunk-JJVXUL5U.js +2 -0
- package/dist/chunk-KCEOTU5Z.js +3 -0
- package/dist/chunk-KVGQG43U.js +1 -0
- package/dist/{chunk-MTTKFJV6.js → chunk-LQYZG62K.js} +1 -1
- package/dist/{chunk-PETQCA7G.js → chunk-P6T3Q7LB.js} +1 -1
- package/dist/chunk-QIJMV2P2.js +2 -0
- package/dist/chunk-QJFRAMK7.js +2 -0
- package/dist/{chunk-2SKAED2I.js → chunk-RAZOACDD.js} +2 -2
- package/dist/chunk-RIGRP3FD.js +1 -0
- package/dist/chunk-S3ZPXWX7.js +2 -0
- package/dist/{chunk-266RH77Z.js → chunk-THSCUT2L.js} +1 -1
- package/dist/{chunk-EEH4WYI7.js → chunk-WNMGUALD.js} +1 -1
- package/dist/{chunk-ZIHEF6K3.js → chunk-X6MPU7UO.js} +1 -1
- package/dist/{chunk-SMSIT3CE.js → chunk-XF5PVZOS.js} +1 -1
- package/dist/{chunk-SJYDLHEF.js → chunk-ZXN3TWWW.js} +1 -1
- package/dist/entry-0.js +1 -1
- package/dist/entry-10.js +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-21.js +2 -1
- package/dist/entry-22.js +1 -1
- package/dist/entry-23.js +1 -1
- package/dist/entry-24.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +7 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-30.js +1 -1
- package/dist/entry-31.js +4 -1
- package/dist/entry-32.js +8 -1
- package/dist/entry-33.js +1 -1
- package/dist/entry-35.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-39.js +1 -1
- package/dist/entry-4.js +1 -1
- package/dist/entry-40.js +14 -1
- package/dist/entry-41.js +1 -1
- package/dist/entry-45.js +7 -1
- package/dist/entry-46.js +11 -1
- package/dist/entry-47.js +1 -1
- package/dist/entry-48.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +1 -1
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-61.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-69.js +59 -1
- package/dist/entry-70.js +4 -1
- package/dist/entry-71.js +1 -1
- package/dist/entry-72.js +29 -1
- package/dist/entry-73.js +2 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-76.js +1 -1
- package/dist/entry-77.js +3 -1
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/pi-agent-ide.js +2 -13
- package/docs/configuration.md +25 -0
- package/docs/extensions.md +4 -2
- package/docs/tools.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +2 -2
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +9 -9
- package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/node_modules/pi-agent-ide-ast/src/extension.ts +9 -14
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/node_modules/pi-agent-ide-changes/index.ts +1 -5
- package/node_modules/pi-agent-ide-changes/package.json +6 -6
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/index.ts +4 -1
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +1 -12
- package/node_modules/pi-agent-ide-lsp/package.json +8 -8
- package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
- package/node_modules/pi-agent-read/package.json +6 -6
- package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
- package/node_modules/pi-agent-read/src/core/read-core.ts +6 -26
- package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
- package/node_modules/pi-agent-search/package.json +3 -3
- package/node_modules/pi-agent-search/src/core/extension.ts +7 -5
- package/node_modules/pi-agent-search/src/core/search-core.ts +10 -0
- package/node_modules/pi-agent-search-text/index.ts +42 -33
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
- package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/node_modules/pi-agent-search-text/src/search-session.ts +48 -0
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +6 -6
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/node_modules/pi-agent-text-editor-argument-order/package.json +2 -2
- package/node_modules/pi-agent-text-editor-overwrite/package.json +3 -3
- package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +1 -6
- package/node_modules/pi-agent-web/package.json +6 -6
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/api/plugin-protocol.ts +2 -0
- package/src/api/text-editor.ts +7 -0
- package/src/api/tool-config.ts +4 -0
- package/src/composite/builtin-extensions.ts +148 -66
- package/src/composite/extensions-config.ts +18 -0
- package/src/core/diagnostic-entry.ts +94 -0
- package/src/core/diagnostic-store.ts +43 -21
- package/src/core/extension.ts +39 -17
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +6 -6
- package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
- package/src/extensions/pi-agent-read/src/core/read-core.ts +6 -26
- package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +28 -7
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +35 -30
- package/src/extensions/pi-agent-search/package.json +3 -3
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +42 -33
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +48 -0
- package/src/extensions/pi-agent-search/src/core/extension.ts +7 -5
- package/src/extensions/pi-agent-search/src/core/search-core.ts +10 -0
- package/src/extensions/pi-agent-text-editor/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +2 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +52 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +5 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +71 -1
- package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +7 -9
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +27 -2
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +38 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +23 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +5 -9
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +54 -14
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +9 -9
- package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +9 -14
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +60 -0
- package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +1 -5
- package/src/plugins/pi-agent-ide-changes/package.json +6 -6
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +1 -7
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +1 -16
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +12 -7
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/index.ts +4 -1
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +1 -12
- package/src/plugins/pi-agent-ide-lsp/package.json +8 -8
- package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +7 -4
- package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +8 -1
- package/src/post-edit/gate.ts +44 -15
- package/src/toolchain/types.ts +2 -0
- package/dist/chunk-2XYXV5HS.js +0 -4
- package/dist/chunk-34ZQTTU2.js +0 -2
- package/dist/chunk-4SQQKEVD.js +0 -16
- package/dist/chunk-5BWUVAR4.js +0 -1
- package/dist/chunk-6DN7NO7L.js +0 -1
- package/dist/chunk-6SMFVLTY.js +0 -1
- package/dist/chunk-6XQQBKPE.js +0 -58
- package/dist/chunk-BYWAG6X3.js +0 -6
- package/dist/chunk-EW2KVKCN.js +0 -2
- package/dist/chunk-F6SESI3P.js +0 -4
- package/dist/chunk-GTK5AREE.js +0 -2
- package/dist/chunk-HOBTFFQR.js +0 -1
- package/dist/chunk-IMVCVPMP.js +0 -3
- package/dist/chunk-IOCABSRL.js +0 -1
- package/dist/chunk-KH5KPBCR.js +0 -10
- package/dist/chunk-KYVOMBO5.js +0 -1
- package/dist/chunk-L4FA6OD4.js +0 -1
- package/dist/chunk-LFV6G5Z3.js +0 -1
- package/dist/chunk-LGN7EJYR.js +0 -13
- package/dist/chunk-MB6VVVAF.js +0 -2
- package/dist/chunk-MTQSGWZJ.js +0 -1
- package/dist/chunk-NI2NK4JU.js +0 -1
- package/dist/chunk-NXHPO7ER.js +0 -6
- package/dist/chunk-OFHVDY4Q.js +0 -2
- package/dist/chunk-OIL6BB2S.js +0 -33
- package/dist/chunk-ONWUJXUR.js +0 -1
- package/dist/chunk-PODWLGNO.js +0 -6
- package/dist/chunk-QZANC2IG.js +0 -1
- package/dist/chunk-SSZB66C3.js +0 -3
- package/dist/chunk-TG6H6EOI.js +0 -1
- package/dist/chunk-UTTW55S2.js +0 -1
- package/dist/chunk-VEJGSURY.js +0 -8
- package/dist/chunk-W3XYKJ5H.js +0 -1
- package/dist/chunk-XGUAL3CA.js +0 -1
- package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
- package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { AstScopeManager } from "./ast/manager.js";
|
|
22
22
|
import { astDoctorPlugin } from "./doctor-plugin.js";
|
|
23
23
|
import { createAstOutlineResolver } from "./outline-resolver.js";
|
|
24
|
+
import { createAstOverflowHandler } from "./overflow-handler.js";
|
|
24
25
|
import { createAstScopePostReadHandler, createAstScopePresenter } from "./scope-handler.js";
|
|
25
26
|
import { createAstScopeAnchorResolver } from "./scope-resolver.js";
|
|
26
27
|
import { createAstSearchResolver } from "./search-resolver.js";
|
|
@@ -43,19 +44,17 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
43
44
|
handler: createSourceMappedTextReadHandler(),
|
|
44
45
|
});
|
|
45
46
|
api.addView({ view: "ast", presenter });
|
|
47
|
+
const overflow = createAstOverflowHandler();
|
|
48
|
+
const scopes = createAstScopePostReadHandler();
|
|
46
49
|
api.addHandler({
|
|
47
50
|
stage: "post-read",
|
|
48
|
-
handler
|
|
51
|
+
async handler(context) {
|
|
52
|
+
const result = await overflow(context);
|
|
53
|
+
return result.kind === "return" ? result : scopes(result.context);
|
|
54
|
+
},
|
|
49
55
|
});
|
|
50
56
|
api.describe(
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
api.addPromptGuideline(
|
|
54
|
-
"You can use read with `ast:<path>` for a compact structural overview of a source file, including its classes, functions, signatures, and other declarations.",
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
api.addPromptGuideline(
|
|
58
|
-
'You can use read with `views: ["ast"]` to add scope boundaries alongside the file\'s source text.',
|
|
57
|
+
'ast:<path> — compact declaration outline. views: ["ast"] — scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.',
|
|
59
58
|
);
|
|
60
59
|
},
|
|
61
60
|
} satisfies ReadPlugin;
|
|
@@ -84,11 +83,7 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
84
83
|
setup(api): void {
|
|
85
84
|
api.addResolver({ resolver: createAstSearchResolver() });
|
|
86
85
|
api.describe(
|
|
87
|
-
"
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
api.addPromptGuideline(
|
|
91
|
-
"You can use search with `ast:<pattern>` for structural code search. You can limit it with `path`, `include`, and `exclude`.",
|
|
86
|
+
"Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search.",
|
|
92
87
|
);
|
|
93
88
|
},
|
|
94
89
|
}),
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { truncateHead } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ReadPostReadHandler } from "pi-agent-read/api/tools/read";
|
|
3
|
+
import type { SourceViewBlock } from "pi-agent-ide/api/code-view";
|
|
4
|
+
|
|
5
|
+
/** Replace an overflowing file window with a source-numbered whole-file outline.
|
|
6
|
+
* Small windows and files without a usable outline keep the normal read result.
|
|
7
|
+
*/
|
|
8
|
+
export function createAstOverflowHandler(): ReadPostReadHandler {
|
|
9
|
+
return async (context) => {
|
|
10
|
+
const { state, result } = context;
|
|
11
|
+
const block = result?.content.length === 1 ? result.content[0] : undefined;
|
|
12
|
+
if (
|
|
13
|
+
state?.contentKind !== "text" ||
|
|
14
|
+
state.resolvedBy !== "filesystem" ||
|
|
15
|
+
block?.type !== "text" ||
|
|
16
|
+
!truncateHead(block.text).truncated
|
|
17
|
+
) {
|
|
18
|
+
return { kind: "continue", context };
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const { AstOutlineManager, isSupportedOutlinePath } = await import("./ast/outline.js");
|
|
22
|
+
if (!isSupportedOutlinePath(state.source)) {
|
|
23
|
+
return { kind: "continue", context };
|
|
24
|
+
}
|
|
25
|
+
const format = (outline: SourceViewBlock): string =>
|
|
26
|
+
[
|
|
27
|
+
`AST overview of ${outline.path}, source lines 1-${outline.totalLines}: the requested text exceeded the read buffer.`,
|
|
28
|
+
"Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",
|
|
29
|
+
...outline.renderedLines.map(
|
|
30
|
+
(line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
|
|
31
|
+
),
|
|
32
|
+
].join("\n");
|
|
33
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
34
|
+
const outline = await new AstOutlineManager(12).readDocumentOutline(
|
|
35
|
+
state.source,
|
|
36
|
+
context.resolverContext.cwd,
|
|
37
|
+
state.text.lines.map((line) => line.content),
|
|
38
|
+
(candidate) => {
|
|
39
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
40
|
+
return !truncateHead(format(candidate)).truncated;
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
const text = format(outline);
|
|
44
|
+
// Even a pathological source label must respect the output budget.
|
|
45
|
+
if (truncateHead(text).truncated) {
|
|
46
|
+
return { kind: "continue", context };
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
kind: "return",
|
|
50
|
+
result: {
|
|
51
|
+
content: [{ type: "text", text }],
|
|
52
|
+
details: { source: state.source, resolvedBy: "ast-overflow" },
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
context.resolverContext.signal?.throwIfAborted();
|
|
57
|
+
return { kind: "continue", context };
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -7,7 +7,7 @@ export function createAstScopeAnchorResolver(manager: AstScopeManager): TextAnch
|
|
|
7
7
|
return {
|
|
8
8
|
id: "ast-scope",
|
|
9
9
|
description:
|
|
10
|
-
|
|
10
|
+
'`scope-begin-HASH` / `scope-end-HASH` from read views: ["ast"] — first/last lines of a scope. Any numeric suffix is part of the anchor.',
|
|
11
11
|
renderFull(value) {
|
|
12
12
|
return value;
|
|
13
13
|
},
|
|
@@ -39,11 +39,7 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
|
|
|
39
39
|
setup(api) {
|
|
40
40
|
api.addView({ view: "changes", presenter });
|
|
41
41
|
api.describe(
|
|
42
|
-
"
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
api.addPromptGuideline(
|
|
46
|
-
'You can use read with `views: ["changes"]` to add `CHANGE#...` anchors and Git index state for current file changes.',
|
|
42
|
+
'views: ["changes"] — uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.',
|
|
47
43
|
);
|
|
48
44
|
},
|
|
49
45
|
} satisfies ReadPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
|
-
"pi-agent-doctor": "0.2.
|
|
17
|
-
"pi-agent-invariant": "0.2.
|
|
18
|
-
"pi-agent-read": "0.2.
|
|
19
|
-
"pi-agent-text": "0.2.
|
|
20
|
-
"pi-agent-text-editor": "0.2.
|
|
16
|
+
"pi-agent-doctor": "0.2.2",
|
|
17
|
+
"pi-agent-invariant": "0.2.2",
|
|
18
|
+
"pi-agent-read": "0.2.2",
|
|
19
|
+
"pi-agent-text": "0.2.2",
|
|
20
|
+
"pi-agent-text-editor": "0.2.2"
|
|
21
21
|
},
|
|
22
22
|
"pi": {
|
|
23
23
|
"extensions": [
|
|
@@ -55,13 +55,7 @@ function createIndexChangeTool(
|
|
|
55
55
|
label: action,
|
|
56
56
|
|
|
57
57
|
promptSnippet: `${pastTense.slice(0, -1)} a selected Git change`,
|
|
58
|
-
description:
|
|
59
|
-
0,
|
|
60
|
-
-1,
|
|
61
|
-
)} one current Git change selected by a CHANGE# anchor without changing the worktree.`,
|
|
62
|
-
promptGuidelines: [
|
|
63
|
-
`You can use ${action} with a complete \`CHANGE#...\` anchor to ${action} only that current Git change without changing the worktree.`,
|
|
64
|
-
],
|
|
58
|
+
description: `Use ${action} to ${action === "stage" ? "add one current Git change to the index" : "remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,
|
|
65
59
|
parameters: indexChangeSchema,
|
|
66
60
|
async execute(_toolCallId, parameters, signal, _onUpdate, context) {
|
|
67
61
|
const file = resolveFile(parameters.file, context.cwd);
|
|
@@ -38,13 +38,9 @@ export function createUndoMutationTool(
|
|
|
38
38
|
return {
|
|
39
39
|
name: "undo",
|
|
40
40
|
description:
|
|
41
|
-
"
|
|
41
|
+
"Use undo to revert a selected uncommitted Git change or the latest text-editor transaction for one file. A CHANGE# anchor restores that change to HEAD in both worktree and index; last restores the file's state before its latest text-editor transaction.",
|
|
42
42
|
|
|
43
43
|
promptSnippet: "Restore a Git change or the latest text edit",
|
|
44
|
-
promptGuidelines: [
|
|
45
|
-
"You can use undo with a complete `CHANGE#...` anchor to restore that current Git change to HEAD in both the worktree and index.",
|
|
46
|
-
'You can use undo with `change: "last"` to restore a file to its state before its latest text-editor transaction.',
|
|
47
|
-
],
|
|
48
44
|
parameters: undoSchema,
|
|
49
45
|
intent: "restore",
|
|
50
46
|
source: { field: "file", inherited: true },
|
|
@@ -106,26 +106,11 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
|
|
|
106
106
|
},
|
|
107
107
|
});
|
|
108
108
|
api.describe(
|
|
109
|
-
|
|
109
|
+
'diagnostics:<path> — lint and language-server diagnostics. views: ["diagnostics"] — diagnostics alongside source text. Diagnostic sources name the actual reporting tools. Automatic notices include findings only and wake an idle agent as soon as results arrive; silence does not prove the file is clean. Use an explicit diagnostic read to check readiness. Pending results and snapshots are not completed checks; an empty snapshot does not prove the file is clean.',
|
|
110
110
|
);
|
|
111
111
|
api.addPromptGuideline(
|
|
112
112
|
"Use read with `diagnostics:<path>` or the `diagnostics` view for per-file diagnostics instead of running equivalent checks through Bash. Project builds and tests remain separate verification.",
|
|
113
113
|
);
|
|
114
|
-
api.addPromptGuideline(
|
|
115
|
-
'You can use read with `views: ["diagnostics"]` to add lint and LSP diagnostics alongside file content.',
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
api.addPromptGuideline(
|
|
119
|
-
"Treat diagnostic snapshots as incomplete observations, not completed checks; an empty snapshot is not evidence that the file is clean.",
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
api.addPromptGuideline(
|
|
123
|
-
"Explicit formatter, linter, and LSP overrides can match exact basenames with fileNames, such as Dockerfile or CMakeLists.txt. LSP requireRootMarker limits a server to files below one of its rootMarkers inside the project, keeping framework servers from claiming unrelated files. LSP initializationOptions can use {project} in string values for project-local plugin paths. Regex diagnostic parsers support multiline output and columnBase: 0 for zero-based tool columns.",
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
api.addPromptGuideline(
|
|
127
|
-
"For missing formatting or diagnostics, check native project configuration and installed executables before adding IDE overrides. Built-ins find tools in node_modules/.bin, Python virtualenv bin directories (Scripts on Windows), and vendor/bin; Windows executable suffixes follow PATHEXT. /pi-agent-ide-doctor reports detected tools and missing dependencies. A detected runtime does not prove its formatter modules or language server can run.",
|
|
128
|
-
);
|
|
129
114
|
},
|
|
130
115
|
} satisfies ReadPlugin;
|
|
131
116
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-formatter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.2.
|
|
6
|
+
"pi-agent-doctor": "0.2.2"
|
|
7
7
|
},
|
|
8
8
|
"pi": {
|
|
9
9
|
"extensions": [
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@earendil-works/pi-coding-agent": "*",
|
|
15
|
-
"pi-agent-ide": "0.2.
|
|
15
|
+
"pi-agent-ide": "0.2.2"
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { runConfiguredFormatter } from "pi-agent-ide/api/tool-config";
|
|
1
|
+
import { configuredExecutableName, runConfiguredFormatter } from "pi-agent-ide/api/tool-config";
|
|
2
2
|
|
|
3
3
|
import { FormatterCommandRegistry } from "./registry.js";
|
|
4
4
|
|
|
@@ -24,14 +24,19 @@ export function createFormatter(): Formatter {
|
|
|
24
24
|
const formatter = registry.resolve(filePath, context.cwd);
|
|
25
25
|
|
|
26
26
|
if (formatter === undefined) {
|
|
27
|
-
return { ok: true, edits: 0 };
|
|
27
|
+
return { ok: true, edits: 0, formatter: null };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const name = configuredExecutableName(formatter.run.command);
|
|
31
|
+
try {
|
|
32
|
+
const result = await runConfiguredFormatter(formatter, {
|
|
33
|
+
projectRoot: context.cwd,
|
|
34
|
+
filePath,
|
|
35
|
+
});
|
|
36
|
+
return { ok: result.ok, edits: result.changed ? 1 : 0, formatter: name };
|
|
37
|
+
} catch {
|
|
38
|
+
return { ok: false, edits: 0, formatter: name };
|
|
39
|
+
}
|
|
35
40
|
},
|
|
36
41
|
};
|
|
37
42
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configuredExecutableName } from "pi-agent-ide/api/tool-config";
|
|
1
2
|
import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
|
|
2
3
|
import { connectIdePlugin } from "pi-agent-ide/api/connect-plugin";
|
|
3
4
|
import { IDE_API_VERSION, IDE_PROTOCOL, type IdePlugin } from "pi-agent-ide/api/plugin-protocol";
|
|
@@ -52,6 +53,7 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
52
53
|
diagnostics: [],
|
|
53
54
|
reason: "No linter configured for this file",
|
|
54
55
|
};
|
|
56
|
+
const source = configuredExecutableName(config.check.command);
|
|
55
57
|
const result = await runConfiguredLinter(config, {
|
|
56
58
|
projectRoot: context.cwd,
|
|
57
59
|
filePath,
|
|
@@ -62,8 +64,9 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
|
|
|
62
64
|
status: "unavailable",
|
|
63
65
|
diagnostics: [],
|
|
64
66
|
reason: result.failure ?? "Lint check failed",
|
|
67
|
+
source,
|
|
65
68
|
}
|
|
66
|
-
: { status: "ready", diagnostics: result.diagnostics };
|
|
69
|
+
: { status: "ready", diagnostics: result.diagnostics, source };
|
|
67
70
|
},
|
|
68
71
|
});
|
|
69
72
|
},
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lint",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.2.
|
|
7
|
-
"pi-agent-invariant": "0.2.
|
|
8
|
-
"pi-agent-read": "0.2.
|
|
9
|
-
"pi-agent-resource": "0.2.
|
|
10
|
-
"pi-agent-text": "0.2.
|
|
6
|
+
"pi-agent-doctor": "0.2.2",
|
|
7
|
+
"pi-agent-invariant": "0.2.2",
|
|
8
|
+
"pi-agent-read": "0.2.2",
|
|
9
|
+
"pi-agent-resource": "0.2.2",
|
|
10
|
+
"pi-agent-text": "0.2.2"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
-
"pi-agent-ide": "0.2.
|
|
19
|
+
"pi-agent-ide": "0.2.2"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -90,14 +90,7 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
90
90
|
handler: createSourceMappedTextReadHandler(),
|
|
91
91
|
});
|
|
92
92
|
api.describe(
|
|
93
|
-
"
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
api.addPromptGuideline(
|
|
97
|
-
"You can use read with `symbol:<path>#<selector>` to inspect a known symbol's implementation without searching for it or reading the whole file.",
|
|
98
|
-
);
|
|
99
|
-
api.addPromptGuideline(
|
|
100
|
-
"You can use read with `graph:<path>` to inspect each top-level declaration's definition, referencing files, and incoming and outgoing calls. Members are listed with selectors; their relationships are not expanded. You can append `#<selector>` to inspect one symbol's references and calls, including a nested method.",
|
|
93
|
+
"symbol:<file>#<selector> — declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> — top-level declarations, references and calls; members include selectors. graph:<file>#<selector> — references and incoming/outgoing calls for that declaration or member.",
|
|
101
94
|
);
|
|
102
95
|
},
|
|
103
96
|
} satisfies ReadPlugin;
|
|
@@ -115,10 +108,6 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
115
108
|
api.describe(
|
|
116
109
|
"Use `symbols:<query>` to search workspace symbols and their references through configured language servers.",
|
|
117
110
|
);
|
|
118
|
-
|
|
119
|
-
api.addPromptGuideline(
|
|
120
|
-
"You can use search with `symbols:<query>` to find workspace symbols and their references through configured language servers.",
|
|
121
|
-
);
|
|
122
111
|
},
|
|
123
112
|
}),
|
|
124
113
|
]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cross-spawn": "^7.0.6",
|
|
7
|
-
"pi-agent-doctor": "0.2.
|
|
8
|
-
"pi-agent-invariant": "0.2.
|
|
9
|
-
"pi-agent-read": "0.2.
|
|
10
|
-
"pi-agent-resource": "0.2.
|
|
11
|
-
"pi-agent-search": "0.2.
|
|
12
|
-
"pi-agent-text": "0.2.
|
|
7
|
+
"pi-agent-doctor": "0.2.2",
|
|
8
|
+
"pi-agent-invariant": "0.2.2",
|
|
9
|
+
"pi-agent-read": "0.2.2",
|
|
10
|
+
"pi-agent-resource": "0.2.2",
|
|
11
|
+
"pi-agent-search": "0.2.2",
|
|
12
|
+
"pi-agent-text": "0.2.2",
|
|
13
13
|
"vscode-jsonrpc": "^9.0.0",
|
|
14
14
|
"vscode-uri": "^3.1.0"
|
|
15
15
|
},
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@earendil-works/pi-coding-agent": "*",
|
|
23
|
-
"pi-agent-ide": "0.2.
|
|
23
|
+
"pi-agent-ide": "0.2.2"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -41,7 +41,7 @@ export function createLspDiagnosticSource(
|
|
|
41
41
|
while (refreshState.queued && current()) {
|
|
42
42
|
refreshState.queued = false;
|
|
43
43
|
const result = await request();
|
|
44
|
-
if (current()) context.publish(toReport(result));
|
|
44
|
+
if (current()) context.publish(toReport(result, client.commandName));
|
|
45
45
|
}
|
|
46
46
|
} catch (error) {
|
|
47
47
|
if (current())
|
|
@@ -49,6 +49,7 @@ export function createLspDiagnosticSource(
|
|
|
49
49
|
status: "unavailable",
|
|
50
50
|
diagnostics: [],
|
|
51
51
|
reason: error instanceof Error ? error.message : String(error),
|
|
52
|
+
source: client.commandName,
|
|
52
53
|
});
|
|
53
54
|
} finally {
|
|
54
55
|
refreshState.active = false;
|
|
@@ -70,6 +71,7 @@ export function createLspDiagnosticSource(
|
|
|
70
71
|
context.publish({
|
|
71
72
|
status: "snapshot",
|
|
72
73
|
diagnostics: event.diagnostics,
|
|
74
|
+
source: client.commandName,
|
|
73
75
|
reason: snapshotReason(event.version === undefined),
|
|
74
76
|
});
|
|
75
77
|
}
|
|
@@ -78,7 +80,7 @@ export function createLspDiagnosticSource(
|
|
|
78
80
|
try {
|
|
79
81
|
const result = await request();
|
|
80
82
|
version = client.documentVersion(uri);
|
|
81
|
-
return toReport(result);
|
|
83
|
+
return toReport(result, client.commandName);
|
|
82
84
|
} catch (error) {
|
|
83
85
|
refreshState.queued = false;
|
|
84
86
|
unsubscribe();
|
|
@@ -99,12 +101,13 @@ function snapshotReason(unversioned: boolean): string {
|
|
|
99
101
|
return `Latest push snapshot; completion is unknown${unversioned ? "; language server omitted the document version" : ""}`;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
function toReport(result: LspDiagnosticResult): IdeDiagnosticReport {
|
|
104
|
+
function toReport(result: LspDiagnosticResult, source: string): IdeDiagnosticReport {
|
|
103
105
|
return result.complete
|
|
104
|
-
? { status: "ready", diagnostics: result.diagnostics }
|
|
106
|
+
? { status: "ready", diagnostics: result.diagnostics, source }
|
|
105
107
|
: {
|
|
106
108
|
status: "snapshot",
|
|
107
109
|
diagnostics: result.diagnostics,
|
|
108
110
|
reason: snapshotReason(result.unversioned),
|
|
111
|
+
source,
|
|
109
112
|
};
|
|
110
113
|
}
|
|
@@ -4,7 +4,10 @@ import { type ChildProcess } from "node:child_process";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
import spawnProcess from "cross-spawn";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
configuredExecutableName,
|
|
9
|
+
createConfiguredProcessEnvironment,
|
|
10
|
+
} from "pi-agent-ide/api/tool-config";
|
|
8
11
|
import {
|
|
9
12
|
createMessageConnection,
|
|
10
13
|
CancellationTokenSource,
|
|
@@ -94,6 +97,10 @@ export class LspClient {
|
|
|
94
97
|
return this._process?.pid ?? null;
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
/** Executable used to start this server, independent of its configured ID. */
|
|
101
|
+
get commandName(): string {
|
|
102
|
+
return configuredExecutableName(this._command);
|
|
103
|
+
}
|
|
97
104
|
get diagnosticMode(): "unknown" | "pull" | "push" {
|
|
98
105
|
return this._diagnosticMode;
|
|
99
106
|
}
|
package/src/post-edit/gate.ts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
3
|
import { warmupFormatting } from "#src/toolchain/registry.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { MutationFormatting } from "pi-agent-text-editor/api/mutation-result";
|
|
5
|
+
import type {
|
|
6
|
+
TextPostEditTransaction,
|
|
7
|
+
TextPostEditStatusContribution,
|
|
8
|
+
} from "pi-agent-text-editor/api/post-edit";
|
|
5
9
|
|
|
6
|
-
/** Finish
|
|
7
|
-
export async function runIdePostEditGate(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
10
|
+
/** Finish file-writing work and report the formatter outcome, separately from diagnostics. */
|
|
11
|
+
export async function runIdePostEditGate(
|
|
12
|
+
transaction: TextPostEditTransaction,
|
|
13
|
+
): Promise<{ formatting: MutationFormatting } & Partial<TextPostEditStatusContribution>> {
|
|
14
|
+
if (!path.isAbsolute(transaction.resourceSource))
|
|
15
|
+
return { formatting: { status: "unavailable" } };
|
|
16
|
+
let formatterName: string | undefined;
|
|
17
|
+
try {
|
|
18
|
+
const toolchain = await warmupFormatting({ cwd: transaction.cwd });
|
|
19
|
+
const extension = path.extname(transaction.resourceSource).toLowerCase();
|
|
20
|
+
const matches = (tool: { extensions: readonly string[] }) =>
|
|
21
|
+
tool.extensions.includes(extension) || tool.extensions.includes("*");
|
|
22
|
+
const syntax = toolchain.compilers.find(matches);
|
|
23
|
+
if (syntax) {
|
|
24
|
+
const result = await syntax.compile({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
25
|
+
if (result.syntaxErrors.length > 0) return { formatting: { status: "skipped-syntax" } };
|
|
26
|
+
}
|
|
27
|
+
const formatter = toolchain.formatters.find(matches);
|
|
28
|
+
if (!formatter) return { formatting: { status: "unavailable" } };
|
|
29
|
+
formatterName = formatter.name;
|
|
30
|
+
const result = await formatter.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
31
|
+
if (result.formatter === null) return { formatting: { status: "unavailable" } };
|
|
32
|
+
formatterName = result.formatter ?? formatter.name;
|
|
33
|
+
return {
|
|
34
|
+
formatting: {
|
|
35
|
+
status: !result.ok ? "failed" : result.edits > 0 ? "changed" : "unchanged",
|
|
36
|
+
formatter: formatterName,
|
|
37
|
+
},
|
|
38
|
+
...(result.ok
|
|
39
|
+
? { diffStatuses: [{ text: `Formatted (${formatterName})`, tone: "success" as const }] }
|
|
40
|
+
: {}),
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
formatting: {
|
|
45
|
+
status: "failed",
|
|
46
|
+
...(formatterName === undefined ? {} : { formatter: formatterName }),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
17
49
|
}
|
|
18
|
-
// Configured formatters may use their own parser to reject invalid syntax safely.
|
|
19
|
-
const formatter = toolchain.formatters.find(matches);
|
|
20
|
-
await formatter?.format({ filePath: transaction.resourceSource }, toolchain.ctx);
|
|
21
50
|
}
|
package/src/toolchain/types.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface FormatInput {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface FormatResult {
|
|
32
|
+
/** Actual formatter executable. Omit for a named formatter plugin; null means no formatter was selected. */
|
|
33
|
+
formatter?: string | null;
|
|
32
34
|
ok: boolean;
|
|
33
35
|
/**
|
|
34
36
|
Number of edits applied. 0 = no change.
|
package/dist/chunk-2XYXV5HS.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as A}from"./chunk-WZI4YC2O.js";import{a as I}from"./chunk-ERVMDQGX.js";import{a as D,b as $}from"./chunk-VFBLX4TG.js";import{a as j}from"./chunk-OBWZ5RYN.js";import{a as b,b as L}from"./chunk-KZBAJFCV.js";import{e as P,g as R,h as k,i as E,l as S}from"./chunk-L4FA6OD4.js";import{a as u}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import v from"node:path";import{fileURLToPath as X}from"node:url";function z(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return q(t);case"eslint-json":return F(t);case"sarif":return J(t);case"checkstyle":return V(t);case"gcc":case"clang":return W(t);case"regex":return G(t,u(e.pattern),e.columnBase??1)}}s(z,"parseDiagnostics");function q(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(p):[]}s(q,"parsePiJson");function F(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(i=>p(i).map(r=>({...r,...n.filePath&&{file:n.filePath}}))):[])}s(F,"parseEslintJson");function J(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(i=>{let r=i.locations?.[0]?.physicalLocation,c=r?.region??{},o=i.message;return p({file:r?.artifactLocation?.uri,line:c.startLine,column:c.startColumn,message:o?.text,code:i.ruleId,severity:H(i.level)})}))}s(J,"parseSarif");function V(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let i=T(u(n[1])).name;for(let r of u(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let c=T(u(r[1]));e.push(...p({file:i,line:Number(c.line),column:Number(c.column??1),message:c.message,code:c.source,severity:c.severity}))}}return e}s(V,"parseCheckstyle");function T(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[u(e[1]),U(u(e[2]))]))}s(T,"xmlAttributes");function W(t){return Z(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}s(W,"parseCompilerLines");function G(t,e,n){return[...t.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).matchAll(new RegExp(e,"gmu"))].flatMap(i=>i.groups===void 0?[]:p({...i.groups,...i.groups.column!==void 0&&{column:Number(i.groups.column)+(1-n)}}))}s(G,"parseRegexLines");function Z(t,e){return t.split(/\r?\n/u).flatMap(n=>{let i=n.match(e)?.groups;return i===void 0?[]:p(i)})}s(Z,"parseMatchingLines");function p(t){if(typeof t!="object"||t===null)return[];let e=t,n=N(e.line??e.startLine),i=N(e.column??e.startColumn,1),r=typeof e.message=="string"?e.message:void 0;return n===void 0||r===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:O(e.code??e.ruleId,"lint"),message:r,line:n,column:i??1,severity:B(e.severity)}]}s(p,"normalizeDiagnostic");function N(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}s(N,"numberValue");function O(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}s(O,"stringValue");function B(t){if(t===2)return"error";if(t===1)return"warning";let e=O(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}s(B,"severityValue");function H(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}s(H,"sarifSeverity");function U(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let i=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return i<=1114111?String.fromCodePoint(i):e}).replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}s(U,"decodeXml");var w=[a("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),a("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),a("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),a("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),a("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),a("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),a("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),a("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),a("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),a("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),a("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),a("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),a("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),a("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),a("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),a("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),a("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),a("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),a("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),a("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),a("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),a("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),a("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),a("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),a("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),a("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),a("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),a("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),a("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),a("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),a("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function a(t,e,n,i,r,c,o,d,l,f,h=[0,1],g,x){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:i,documentation:d,...f&&{dependencies:f},linter:{extensions:r,...x&&{fileNames:x},check:{command:c,successExitCodes:h},diagnostics:{format:o,...l&&{pattern:l},...g!==void 0&&{columnBase:g}}}}}s(a,"recipe");var m=class t{constructor(e,n,i=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=i}static{s(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let i=await P(e,"linters",l=>S(l).linters,n),r=n.environment??process.env,c=await Promise.all(i.entries.filter(l=>l.layer==="built-in").map(async l=>({id:l.id,available:await k(l.config.check,e,r)}))),o=await A(e,w),d=[...i.entries].sort((l,f)=>l.layer==="built-in"&&f.layer==="built-in"?(o.get(f.id)?.score??0)-(o.get(l.id)?.score??0):0);return new t(d,new Set(c.filter(l=>l.available).map(l=>l.id)),o)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,i])=>({id:n,config:i,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return R(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function y(t,e){let n;try{n=await E(t.check,e)}catch(d){return{ok:!1,diagnostics:[],failure:`command could not start: ${d instanceof Error?d.message:String(d)}`}}let i=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(d=>d.trim().length>0).join(`
|
|
4
|
-
`):n.stdout.trim().length>0?n.stdout:n.stderr,r;try{r=z(i,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${i.trim().slice(0,200)||"empty command output"}`}}let c=n.ok&&(n.exitCode===0||r.length>0),o=t.check.cwd==="file"?v.dirname(e.filePath):e.projectRoot;return r=r.filter(d=>{if(d.file===void 0)return!0;let l=d.file.startsWith("file:")?X(d.file):d.file;return v.resolve(o,l)===v.resolve(e.filePath)}).map(({file:d,...l})=>l),{ok:c,diagnostics:r,...!c&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}s(y,"runConfiguredLinter");function _(t){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:s(()=>Promise.resolve(!0),"detect"),async lint({filePath:e,fix:n},i){let r=t.resolve(e,i.cwd);if(r===void 0)return{ok:!0,diagnostics:[]};let c=n===!0&&r.fix!==void 0?r.fix:r.check,o=await y({...r,check:c},{projectRoot:i.cwd,filePath:e});return{ok:o.ok,diagnostics:o.diagnostics}}}}s(_,"createCommandLinter");import{copyFile as K,mkdtemp as Q,rm as Y}from"node:fs/promises";import C from"node:path";var M={protocol:D,apiVersion:1,id:"lint",setup(t){for(let e of w)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:ee}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await m.fromDirectory(e.cwd,{environment:e.env}),i=te(n,e.files,e.cwd);return i.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(i.map(async({entry:r,source:c})=>{let o=`${r.id} [${r.layer}] command ${JSON.stringify(r.config.check.command)}`,d=await Q(C.join(C.dirname(c),".pi-agent-ide-doctor-")),l=C.join(d,C.basename(c));try{await K(c,l);let f=await y(r.config,{projectRoot:e.cwd,filePath:l,env:e.env});return f.ok?{status:"pass",message:`${o}: probe passed`,detail:r.sourcePath}:{status:"fail",message:`${o}: probe failed`,detail:f.failure??r.sourcePath}}catch(f){return{status:"fail",message:`${o}: ${f instanceof Error?f.message:String(f)}`,detail:r.sourcePath}}finally{await Y(d,{recursive:!0,force:!0})}}))}catch(n){return[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function ee(t){try{let e=await m.fromDirectory(t.cwd,{environment:t.env}),n=[],i=new Map;for(let[r,c]of t.detectedLanguages){let o=c.map(d=>e.resolveEntry(d,t.cwd)).find(d=>d!==void 0);o!==void 0&&(n.push({kind:"linter",languageId:r,toolId:o.id}),await k(o.config.check,t.cwd,t.env)||i.set(o.id,{id:`linter-${o.id}-unavailable`,message:`Configured linter ${o.id} cannot run ${JSON.stringify(o.config.check.command)}`}))}return{selections:n,actions:[...i.values()]}}catch(e){return{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}s(ee,"inspectLinterSetup");function te(t,e,n){let i=new Map;for(let r of e){let c=t.resolveEntry(r,n);c!==void 0&&!i.has(c.id)&&i.set(c.id,{entry:c,source:r})}return[...i.values()]}s(te,"applicableLinters");async function ne(t){let e,n,i=s(o=>((n===void 0||e!==o)&&(e=o,n=ie(o)),n),"registryFor"),r={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:s(async o=>(await i(o.cwd),!0),"detect"),async lint(o,d){let l=await i(d.cwd);return _(l).lint(o,d)}},c={protocol:b,apiVersion:3,id:"lint",setup(o){o.addTool(r),o.addDiagnosticSource({id:"lint",async diagnose(d,l){let f=await i(l.cwd);l.signal.throwIfAborted();let h=f.resolve(d,l.cwd);if(!h)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let g=await y(h,{projectRoot:l.cwd,filePath:d,signal:l.signal});return!g.ok&&g.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:g.failure??"Lint check failed"}:{status:"ready",diagnostics:g.diagnostics}}})}};await Promise.all([j(t,c),I(t,M)])}s(ne,"registerLint");async function ie(t){let e=process.env.PI_AGENT_IDE_CONFIG_DIR??t;return m.fromDirectory(e)}s(ie,"loadRegistry");export{ne as a};
|