@oh-my-pi/pi-coding-agent 8.0.20 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +125 -0
- package/docs/session.md +111 -46
- package/examples/custom-tools/hello/index.ts +1 -1
- package/examples/custom-tools/todo/index.ts +3 -4
- package/examples/extensions/api-demo.ts +0 -1
- package/examples/extensions/chalk-logger.ts +2 -3
- package/examples/extensions/hello.ts +0 -1
- package/examples/extensions/pirate.ts +0 -1
- package/examples/extensions/plan-mode.ts +15 -16
- package/examples/extensions/todo.ts +3 -4
- package/examples/extensions/tools.ts +1 -2
- package/examples/extensions/with-deps/index.ts +0 -1
- package/examples/hooks/auto-commit-on-exit.ts +1 -2
- package/examples/hooks/confirm-destructive.ts +0 -1
- package/examples/hooks/custom-compaction.ts +1 -2
- package/examples/hooks/dirty-repo-guard.ts +0 -1
- package/examples/hooks/file-trigger.ts +3 -4
- package/examples/hooks/git-checkpoint.ts +0 -1
- package/examples/hooks/handoff.ts +3 -4
- package/examples/hooks/permission-gate.ts +1 -2
- package/examples/hooks/protected-paths.ts +1 -2
- package/examples/hooks/qna.ts +2 -3
- package/examples/hooks/snake.ts +4 -5
- package/examples/hooks/status-line.ts +0 -1
- package/examples/sdk/01-minimal.ts +2 -3
- package/examples/sdk/02-custom-model.ts +2 -3
- package/examples/sdk/03-custom-prompt.ts +3 -4
- package/examples/sdk/04-skills.ts +2 -3
- package/examples/sdk/06-extensions.ts +1 -2
- package/examples/sdk/06-hooks.ts +6 -7
- package/examples/sdk/07-context-files.ts +0 -1
- package/examples/sdk/08-prompt-templates.ts +0 -1
- package/examples/sdk/08-slash-commands.ts +0 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +0 -1
- package/examples/sdk/10-settings.ts +0 -1
- package/examples/sdk/11-sessions.ts +0 -1
- package/package.json +54 -23
- package/scripts/format-prompts.ts +0 -1
- package/src/capability/context-file.ts +3 -4
- package/src/capability/extension-module.ts +3 -4
- package/src/capability/extension.ts +3 -4
- package/src/capability/fs.ts +20 -21
- package/src/capability/hook.ts +3 -4
- package/src/capability/index.ts +15 -16
- package/src/capability/instruction.ts +3 -4
- package/src/capability/mcp.ts +3 -4
- package/src/capability/prompt.ts +3 -4
- package/src/capability/rule.ts +3 -4
- package/src/capability/settings.ts +2 -3
- package/src/capability/skill.ts +3 -4
- package/src/capability/slash-command.ts +3 -4
- package/src/capability/ssh.ts +3 -4
- package/src/capability/system-prompt.ts +3 -4
- package/src/capability/tool.ts +3 -4
- package/src/cli/args.ts +5 -6
- package/src/cli/config-cli.ts +6 -7
- package/src/cli/file-processor.ts +19 -17
- package/src/cli/jupyter-cli.ts +105 -0
- package/src/cli/list-models.ts +10 -11
- package/src/cli/plugin-cli.ts +20 -25
- package/src/cli/session-picker.ts +2 -3
- package/src/cli/setup-cli.ts +2 -3
- package/src/cli/stats-cli.ts +2 -3
- package/src/cli/update-cli.ts +25 -22
- package/src/commit/agentic/agent.ts +307 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +351 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +26 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +40 -0
- package/src/commit/agentic/state.ts +69 -0
- package/src/commit/agentic/tools/analyze-file.ts +131 -0
- package/src/commit/agentic/tools/git-file-diff.ts +194 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +84 -0
- package/src/commit/agentic/tools/index.ts +56 -0
- package/src/commit/agentic/tools/propose-changelog.ts +128 -0
- package/src/commit/agentic/tools/propose-commit.ts +154 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/split-commit.ts +280 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +200 -0
- package/src/commit/analysis/conventional.ts +165 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +112 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +36 -0
- package/src/commit/changelog/generate.ts +110 -0
- package/src/commit/changelog/index.ts +233 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +93 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/git/errors.ts +11 -0
- package/src/commit/git/index.ts +212 -0
- package/src/commit/git/operations.ts +53 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +63 -0
- package/src/commit/map-reduce/map-phase.ts +178 -0
- package/src/commit/map-reduce/reduce-phase.ts +145 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +80 -0
- package/src/commit/pipeline.ts +240 -0
- package/src/commit/prompts/analysis-system.md +155 -0
- package/src/commit/prompts/analysis-user.md +41 -0
- package/src/commit/prompts/changelog-system.md +56 -0
- package/src/commit/prompts/changelog-user.md +19 -0
- package/src/commit/prompts/file-observer-system.md +26 -0
- package/src/commit/prompts/file-observer-user.md +9 -0
- package/src/commit/prompts/reduce-system.md +60 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +4 -0
- package/src/commit/prompts/summary-system.md +52 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/types.ts +109 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +6 -8
- package/src/config/model-registry.ts +65 -38
- package/src/config/model-resolver.ts +18 -19
- package/src/config/prompt-templates.ts +11 -11
- package/src/config/settings-manager.ts +141 -50
- package/src/config.ts +64 -66
- package/src/cursor.ts +11 -9
- package/src/discovery/agents-md.ts +11 -12
- package/src/discovery/builtin.ts +68 -73
- package/src/discovery/claude.ts +41 -42
- package/src/discovery/cline.ts +11 -12
- package/src/discovery/codex.ts +52 -53
- package/src/discovery/cursor.ts +9 -10
- package/src/discovery/gemini.ts +17 -22
- package/src/discovery/github.ts +13 -14
- package/src/discovery/helpers.ts +35 -34
- package/src/discovery/index.ts +22 -24
- package/src/discovery/mcp-json.ts +8 -9
- package/src/discovery/ssh.ts +8 -9
- package/src/discovery/vscode.ts +4 -5
- package/src/discovery/windsurf.ts +6 -7
- package/src/exa/company.ts +1 -2
- package/src/exa/index.ts +2 -3
- package/src/exa/linkedin.ts +1 -2
- package/src/exa/mcp-client.ts +14 -16
- package/src/exa/render.ts +10 -11
- package/src/exa/researcher.ts +1 -2
- package/src/exa/search.ts +1 -2
- package/src/exa/types.ts +0 -1
- package/src/exa/websets.ts +1 -2
- package/src/exec/bash-executor.ts +3 -4
- package/src/exec/exec.ts +0 -1
- package/src/export/custom-share.ts +5 -6
- package/src/export/html/index.ts +24 -21
- package/src/export/ttsr.ts +2 -3
- package/src/extensibility/custom-commands/bundled/review/index.ts +7 -8
- package/src/extensibility/custom-commands/loader.ts +18 -15
- package/src/extensibility/custom-commands/types.ts +2 -3
- package/src/extensibility/custom-tools/loader.ts +11 -12
- package/src/extensibility/custom-tools/types.ts +7 -8
- package/src/extensibility/custom-tools/wrapper.ts +2 -3
- package/src/extensibility/extensions/loader.ts +76 -54
- package/src/extensibility/extensions/runner.ts +11 -12
- package/src/extensibility/extensions/types.ts +20 -27
- package/src/extensibility/extensions/wrapper.ts +3 -4
- package/src/extensibility/hooks/index.ts +1 -1
- package/src/extensibility/hooks/loader.ts +9 -10
- package/src/extensibility/hooks/runner.ts +7 -8
- package/src/extensibility/hooks/tool-wrapper.ts +0 -1
- package/src/extensibility/hooks/types.ts +11 -18
- package/src/extensibility/plugins/doctor.ts +3 -3
- package/src/extensibility/plugins/installer.ts +27 -27
- package/src/extensibility/plugins/loader.ts +59 -56
- package/src/extensibility/plugins/manager.ts +211 -171
- package/src/extensibility/plugins/parser.ts +1 -1
- package/src/extensibility/plugins/paths.ts +8 -8
- package/src/extensibility/skills.ts +63 -60
- package/src/extensibility/slash-commands.ts +10 -10
- package/src/index.ts +54 -54
- package/src/internal-urls/agent-protocol.ts +21 -11
- package/src/internal-urls/artifact-protocol.ts +17 -13
- package/src/internal-urls/router.ts +1 -2
- package/src/internal-urls/rule-protocol.ts +3 -4
- package/src/internal-urls/skill-protocol.ts +3 -4
- package/src/ipy/executor.ts +109 -9
- package/src/ipy/gateway-coordinator.ts +79 -90
- package/src/ipy/kernel.ts +32 -30
- package/src/ipy/modules.ts +13 -13
- package/src/lsp/client.ts +21 -10
- package/src/lsp/clients/biome-client.ts +1 -2
- package/src/lsp/clients/index.ts +3 -3
- package/src/lsp/clients/lsp-linter-client.ts +4 -5
- package/src/lsp/config.ts +15 -15
- package/src/lsp/edits.ts +4 -5
- package/src/lsp/index.ts +43 -44
- package/src/lsp/lspmux.ts +8 -8
- package/src/lsp/render.ts +99 -61
- package/src/lsp/utils.ts +3 -3
- package/src/main.ts +71 -37
- package/src/mcp/client.ts +2 -3
- package/src/mcp/config.ts +5 -6
- package/src/mcp/json-rpc.ts +0 -1
- package/src/mcp/loader.ts +6 -7
- package/src/mcp/manager.ts +17 -18
- package/src/mcp/tool-bridge.ts +4 -9
- package/src/mcp/tool-cache.ts +2 -3
- package/src/mcp/transports/http.ts +2 -4
- package/src/mcp/transports/stdio.ts +1 -2
- package/src/migrations.ts +63 -52
- package/src/modes/components/armin.ts +4 -5
- package/src/modes/components/assistant-message.ts +33 -5
- package/src/modes/components/bash-execution.ts +7 -8
- package/src/modes/components/bordered-loader.ts +3 -3
- package/src/modes/components/branch-summary-message.ts +3 -3
- package/src/modes/components/compaction-summary-message.ts +3 -3
- package/src/modes/components/countdown-timer.ts +0 -1
- package/src/modes/components/custom-message.ts +5 -5
- package/src/modes/components/diff.ts +1 -1
- package/src/modes/components/dynamic-border.ts +2 -2
- package/src/modes/components/extensions/extension-dashboard.ts +6 -7
- package/src/modes/components/extensions/extension-list.ts +2 -3
- package/src/modes/components/extensions/inspector-panel.ts +3 -4
- package/src/modes/components/extensions/state-manager.ts +25 -26
- package/src/modes/components/extensions/types.ts +1 -2
- package/src/modes/components/footer.ts +47 -43
- package/src/modes/components/history-search.ts +2 -2
- package/src/modes/components/hook-editor.ts +3 -4
- package/src/modes/components/hook-input.ts +2 -3
- package/src/modes/components/hook-message.ts +5 -5
- package/src/modes/components/hook-selector.ts +2 -3
- package/src/modes/components/keybinding-hints.ts +2 -3
- package/src/modes/components/login-dialog.ts +2 -2
- package/src/modes/components/model-selector.ts +12 -12
- package/src/modes/components/oauth-selector.ts +2 -2
- package/src/modes/components/plugin-settings.ts +20 -20
- package/src/modes/components/python-execution.ts +7 -8
- package/src/modes/components/queue-mode-selector.ts +3 -3
- package/src/modes/components/read-tool-group.ts +2 -2
- package/src/modes/components/session-selector.ts +4 -4
- package/src/modes/components/settings-defs.ts +77 -69
- package/src/modes/components/settings-selector.ts +16 -16
- package/src/modes/components/show-images-selector.ts +2 -2
- package/src/modes/components/status-line/segments.ts +4 -4
- package/src/modes/components/status-line/separators.ts +1 -1
- package/src/modes/components/status-line/types.ts +2 -2
- package/src/modes/components/status-line-segment-editor.ts +7 -8
- package/src/modes/components/status-line.ts +12 -12
- package/src/modes/components/theme-selector.ts +8 -7
- package/src/modes/components/thinking-selector.ts +4 -4
- package/src/modes/components/todo-display.ts +2 -2
- package/src/modes/components/todo-reminder.ts +4 -4
- package/src/modes/components/tool-execution.ts +16 -19
- package/src/modes/components/tree-selector.ts +12 -12
- package/src/modes/components/ttsr-notification.ts +5 -5
- package/src/modes/components/user-message-selector.ts +1 -1
- package/src/modes/components/user-message.ts +1 -1
- package/src/modes/components/visual-truncate.ts +0 -1
- package/src/modes/components/welcome.ts +4 -4
- package/src/modes/controllers/command-controller.ts +46 -47
- package/src/modes/controllers/event-controller.ts +16 -20
- package/src/modes/controllers/extension-ui-controller.ts +40 -46
- package/src/modes/controllers/input-controller.ts +17 -18
- package/src/modes/controllers/selector-controller.ts +103 -91
- package/src/modes/index.ts +3 -3
- package/src/modes/interactive-mode.ts +31 -31
- package/src/modes/print-mode.ts +12 -13
- package/src/modes/rpc/rpc-client.ts +7 -8
- package/src/modes/rpc/rpc-mode.ts +24 -28
- package/src/modes/rpc/rpc-types.ts +3 -4
- package/src/modes/theme/mermaid-cache.ts +89 -0
- package/src/modes/theme/theme.ts +130 -53
- package/src/modes/types.ts +10 -10
- package/src/modes/utils/ui-helpers.ts +17 -17
- package/src/patch/applicator.ts +18 -19
- package/src/patch/diff.ts +1 -2
- package/src/patch/fuzzy.ts +1 -2
- package/src/patch/index.ts +11 -18
- package/src/patch/normalize.ts +4 -4
- package/src/patch/normative.ts +1 -2
- package/src/patch/parser.ts +8 -9
- package/src/patch/shared.ts +43 -16
- package/src/prompts/tools/task.md +2 -0
- package/src/sdk.ts +100 -65
- package/src/session/agent-session.ts +84 -85
- package/src/session/agent-storage.ts +43 -39
- package/src/session/artifacts.ts +32 -10
- package/src/session/auth-storage.ts +50 -39
- package/src/session/compaction/branch-summarization.ts +7 -10
- package/src/session/compaction/compaction.ts +8 -19
- package/src/session/compaction/utils.ts +6 -9
- package/src/session/history-storage.ts +10 -10
- package/src/session/messages.ts +4 -5
- package/src/session/session-manager.ts +76 -65
- package/src/session/session-storage.ts +57 -69
- package/src/session/storage-migration.ts +14 -56
- package/src/session/streaming-output.ts +2 -2
- package/src/ssh/connection-manager.ts +43 -50
- package/src/ssh/ssh-executor.ts +2 -2
- package/src/ssh/sshfs-mount.ts +11 -18
- package/src/system-prompt.ts +28 -35
- package/src/task/agents.ts +45 -30
- package/src/task/commands.ts +6 -7
- package/src/task/discovery.ts +39 -76
- package/src/task/executor.ts +14 -15
- package/src/task/index.ts +40 -34
- package/src/task/output-manager.ts +93 -0
- package/src/task/parallel.ts +0 -1
- package/src/task/render.ts +24 -30
- package/src/task/subprocess-tool-registry.ts +1 -2
- package/src/task/worker-protocol.ts +3 -3
- package/src/task/worker.ts +33 -39
- package/src/task/worktree.ts +19 -19
- package/src/tools/ask.ts +41 -20
- package/src/tools/bash-interceptor.ts +1 -5
- package/src/tools/bash.ts +91 -97
- package/src/tools/calculator.ts +49 -47
- package/src/tools/complete.ts +4 -5
- package/src/tools/context.ts +2 -2
- package/src/tools/fetch.ts +84 -124
- package/src/tools/find.ts +94 -98
- package/src/tools/gemini-image.ts +14 -14
- package/src/tools/grep.ts +100 -116
- package/src/tools/index.ts +80 -55
- package/src/tools/list-limit.ts +1 -1
- package/src/tools/ls.ts +44 -70
- package/src/tools/notebook.ts +51 -67
- package/src/tools/output-meta.ts +3 -4
- package/src/tools/output-utils.ts +2 -2
- package/src/tools/path-utils.ts +5 -5
- package/src/tools/python.ts +104 -217
- package/src/tools/read.ts +92 -33
- package/src/tools/render-utils.ts +8 -23
- package/src/tools/renderers.ts +6 -7
- package/src/tools/review.ts +8 -11
- package/src/tools/ssh.ts +69 -49
- package/src/tools/todo-write.ts +37 -25
- package/src/tools/tool-errors.ts +3 -3
- package/src/tools/tool-result.ts +3 -8
- package/src/tools/write.ts +99 -75
- package/src/tui/code-cell.ts +109 -0
- package/src/tui/file-list.ts +47 -0
- package/src/tui/index.ts +11 -0
- package/src/tui/output-block.ts +72 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +55 -0
- package/src/tui/types.ts +16 -0
- package/src/tui/utils.ts +48 -0
- package/src/utils/changelog.ts +9 -10
- package/src/utils/clipboard.ts +11 -11
- package/src/utils/file-mentions.ts +4 -10
- package/src/utils/frontmatter.ts +6 -3
- package/src/utils/fuzzy.ts +2 -2
- package/src/utils/image-convert.ts +1 -1
- package/src/utils/image-resize.ts +1 -1
- package/src/utils/mime.ts +2 -2
- package/src/utils/shell-snapshot.ts +11 -13
- package/src/utils/shell.ts +4 -5
- package/src/utils/title-generator.ts +8 -9
- package/src/utils/tools-manager.ts +23 -23
- package/src/vendor/photon/index.js +1099 -1059
- package/src/vendor/photon/photon_rs_bg.wasm +0 -0
- package/src/web/scrapers/artifacthub.ts +1 -1
- package/src/web/scrapers/arxiv.ts +2 -2
- package/src/web/scrapers/bluesky.ts +2 -2
- package/src/web/scrapers/cheatsh.ts +1 -1
- package/src/web/scrapers/chocolatey.ts +2 -2
- package/src/web/scrapers/choosealicense.ts +5 -5
- package/src/web/scrapers/cisa-kev.ts +1 -1
- package/src/web/scrapers/crossref.ts +2 -2
- package/src/web/scrapers/devto.ts +3 -3
- package/src/web/scrapers/discogs.ts +3 -4
- package/src/web/scrapers/discourse.ts +1 -1
- package/src/web/scrapers/dockerhub.ts +1 -1
- package/src/web/scrapers/fdroid.ts +2 -2
- package/src/web/scrapers/firefox-addons.ts +3 -3
- package/src/web/scrapers/flathub.ts +1 -1
- package/src/web/scrapers/github.ts +3 -3
- package/src/web/scrapers/gitlab.ts +4 -4
- package/src/web/scrapers/hackernews.ts +2 -2
- package/src/web/scrapers/huggingface.ts +1 -1
- package/src/web/scrapers/iacr.ts +2 -2
- package/src/web/scrapers/index.ts +0 -1
- package/src/web/scrapers/jetbrains-marketplace.ts +1 -1
- package/src/web/scrapers/lemmy.ts +2 -2
- package/src/web/scrapers/maven.ts +2 -2
- package/src/web/scrapers/mdn.ts +2 -4
- package/src/web/scrapers/metacpan.ts +2 -2
- package/src/web/scrapers/musicbrainz.ts +1 -2
- package/src/web/scrapers/npm.ts +1 -1
- package/src/web/scrapers/nuget.ts +2 -2
- package/src/web/scrapers/nvd.ts +3 -3
- package/src/web/scrapers/ollama.ts +7 -9
- package/src/web/scrapers/opencorporates.ts +2 -2
- package/src/web/scrapers/openlibrary.ts +6 -6
- package/src/web/scrapers/orcid.ts +0 -1
- package/src/web/scrapers/osv.ts +2 -2
- package/src/web/scrapers/packagist.ts +1 -1
- package/src/web/scrapers/pubmed.ts +1 -2
- package/src/web/scrapers/rawg.ts +2 -2
- package/src/web/scrapers/readthedocs.ts +1 -2
- package/src/web/scrapers/repology.ts +2 -2
- package/src/web/scrapers/rfc.ts +1 -1
- package/src/web/scrapers/searchcode.ts +2 -2
- package/src/web/scrapers/semantic-scholar.ts +1 -1
- package/src/web/scrapers/snapcraft.ts +2 -2
- package/src/web/scrapers/sourcegraph.ts +1 -1
- package/src/web/scrapers/spdx.ts +3 -3
- package/src/web/scrapers/spotify.ts +0 -1
- package/src/web/scrapers/twitter.ts +1 -1
- package/src/web/scrapers/types.ts +1 -2
- package/src/web/scrapers/utils.ts +5 -5
- package/src/web/scrapers/wikidata.ts +3 -3
- package/src/web/scrapers/youtube.ts +9 -14
- package/src/web/search/auth.ts +5 -10
- package/src/web/search/index.ts +11 -21
- package/src/web/search/providers/anthropic.ts +3 -9
- package/src/web/search/providers/exa.ts +6 -10
- package/src/web/search/providers/perplexity.ts +5 -5
- package/src/web/search/render.ts +129 -175
- package/tsconfig.json +0 -42
package/src/discovery/codex.ts
CHANGED
|
@@ -6,31 +6,30 @@
|
|
|
6
6
|
*
|
|
7
7
|
* User directory: ~/.codex
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import type { ContextFile } from "@oh-my-pi/pi-coding-agent/capability/context-file";
|
|
12
|
-
import { contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file";
|
|
13
|
-
import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module";
|
|
14
|
-
import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs";
|
|
15
|
-
import type { Hook } from "@oh-my-pi/pi-coding-agent/capability/hook";
|
|
16
|
-
import { hookCapability } from "@oh-my-pi/pi-coding-agent/capability/hook";
|
|
17
|
-
import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
|
|
18
|
-
import type { MCPServer } from "@oh-my-pi/pi-coding-agent/capability/mcp";
|
|
19
|
-
import { mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp";
|
|
20
|
-
import type { Prompt } from "@oh-my-pi/pi-coding-agent/capability/prompt";
|
|
21
|
-
import { promptCapability } from "@oh-my-pi/pi-coding-agent/capability/prompt";
|
|
22
|
-
import type { Settings } from "@oh-my-pi/pi-coding-agent/capability/settings";
|
|
23
|
-
import { settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings";
|
|
24
|
-
import type { Skill } from "@oh-my-pi/pi-coding-agent/capability/skill";
|
|
25
|
-
import { skillCapability } from "@oh-my-pi/pi-coding-agent/capability/skill";
|
|
26
|
-
import type { SlashCommand } from "@oh-my-pi/pi-coding-agent/capability/slash-command";
|
|
27
|
-
import { slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command";
|
|
28
|
-
import type { CustomTool } from "@oh-my-pi/pi-coding-agent/capability/tool";
|
|
29
|
-
import { toolCapability } from "@oh-my-pi/pi-coding-agent/capability/tool";
|
|
30
|
-
import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types";
|
|
31
|
-
import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter";
|
|
9
|
+
import * as path from "node:path";
|
|
32
10
|
import { logger } from "@oh-my-pi/pi-utils";
|
|
33
11
|
import { parse as parseToml } from "smol-toml";
|
|
12
|
+
import { registerProvider } from "../capability";
|
|
13
|
+
import type { ContextFile } from "../capability/context-file";
|
|
14
|
+
import { contextFileCapability } from "../capability/context-file";
|
|
15
|
+
import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module";
|
|
16
|
+
import { readFile } from "../capability/fs";
|
|
17
|
+
import type { Hook } from "../capability/hook";
|
|
18
|
+
import { hookCapability } from "../capability/hook";
|
|
19
|
+
import type { MCPServer } from "../capability/mcp";
|
|
20
|
+
import { mcpCapability } from "../capability/mcp";
|
|
21
|
+
import type { Prompt } from "../capability/prompt";
|
|
22
|
+
import { promptCapability } from "../capability/prompt";
|
|
23
|
+
import type { Settings } from "../capability/settings";
|
|
24
|
+
import { settingsCapability } from "../capability/settings";
|
|
25
|
+
import type { Skill } from "../capability/skill";
|
|
26
|
+
import { skillCapability } from "../capability/skill";
|
|
27
|
+
import type { SlashCommand } from "../capability/slash-command";
|
|
28
|
+
import { slashCommandCapability } from "../capability/slash-command";
|
|
29
|
+
import type { CustomTool } from "../capability/tool";
|
|
30
|
+
import { toolCapability } from "../capability/tool";
|
|
31
|
+
import type { LoadContext, LoadResult } from "../capability/types";
|
|
32
|
+
import { parseFrontmatter } from "../utils/frontmatter";
|
|
34
33
|
import {
|
|
35
34
|
createSourceMeta,
|
|
36
35
|
discoverExtensionModulePaths,
|
|
@@ -45,7 +44,7 @@ const DISPLAY_NAME = "OpenAI Codex";
|
|
|
45
44
|
const PRIORITY = 70;
|
|
46
45
|
|
|
47
46
|
function getProjectCodexDir(ctx: LoadContext): string {
|
|
48
|
-
return join(ctx.cwd, ".codex");
|
|
47
|
+
return path.join(ctx.cwd, ".codex");
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
// =============================================================================
|
|
@@ -57,7 +56,7 @@ async function loadContextFiles(ctx: LoadContext): Promise<LoadResult<ContextFil
|
|
|
57
56
|
const warnings: string[] = [];
|
|
58
57
|
|
|
59
58
|
// User level only: ~/.codex/AGENTS.md
|
|
60
|
-
const agentsMd = join(ctx.home, SOURCE_PATHS.codex.userBase, "AGENTS.md");
|
|
59
|
+
const agentsMd = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "AGENTS.md");
|
|
61
60
|
const agentsContent = await readFile(agentsMd);
|
|
62
61
|
if (agentsContent) {
|
|
63
62
|
items.push({
|
|
@@ -78,9 +77,9 @@ async function loadContextFiles(ctx: LoadContext): Promise<LoadResult<ContextFil
|
|
|
78
77
|
async function loadMCPServers(ctx: LoadContext): Promise<LoadResult<MCPServer>> {
|
|
79
78
|
const warnings: string[] = [];
|
|
80
79
|
|
|
81
|
-
const userConfigPath = join(ctx.home, SOURCE_PATHS.codex.userBase, "config.toml");
|
|
80
|
+
const userConfigPath = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "config.toml");
|
|
82
81
|
const codexDir = getProjectCodexDir(ctx);
|
|
83
|
-
const projectConfigPath = join(codexDir, "config.toml");
|
|
82
|
+
const projectConfigPath = path.join(codexDir, "config.toml");
|
|
84
83
|
|
|
85
84
|
const [userConfig, projectConfig] = await Promise.all([
|
|
86
85
|
loadTomlConfig(ctx, userConfigPath),
|
|
@@ -210,9 +209,9 @@ function extractMCPServersFromToml(toml: Record<string, unknown>): Record<string
|
|
|
210
209
|
// =============================================================================
|
|
211
210
|
|
|
212
211
|
async function loadSkills(ctx: LoadContext): Promise<LoadResult<Skill>> {
|
|
213
|
-
const userSkillsDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "skills");
|
|
212
|
+
const userSkillsDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "skills");
|
|
214
213
|
const codexDir = getProjectCodexDir(ctx);
|
|
215
|
-
const projectSkillsDir = join(codexDir, "skills");
|
|
214
|
+
const projectSkillsDir = path.join(codexDir, "skills");
|
|
216
215
|
|
|
217
216
|
const results = await Promise.all([
|
|
218
217
|
loadSkillsFromDir(ctx, {
|
|
@@ -227,8 +226,8 @@ async function loadSkills(ctx: LoadContext): Promise<LoadResult<Skill>> {
|
|
|
227
226
|
}),
|
|
228
227
|
]);
|
|
229
228
|
|
|
230
|
-
const items = results.flatMap(
|
|
231
|
-
const warnings = results.flatMap(
|
|
229
|
+
const items = results.flatMap(r => r.items);
|
|
230
|
+
const warnings = results.flatMap(r => r.warnings || []);
|
|
232
231
|
|
|
233
232
|
return { items, warnings };
|
|
234
233
|
}
|
|
@@ -240,9 +239,9 @@ async function loadSkills(ctx: LoadContext): Promise<LoadResult<Skill>> {
|
|
|
240
239
|
async function loadExtensionModules(ctx: LoadContext): Promise<LoadResult<ExtensionModule>> {
|
|
241
240
|
const warnings: string[] = [];
|
|
242
241
|
|
|
243
|
-
const userExtensionsDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "extensions");
|
|
242
|
+
const userExtensionsDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "extensions");
|
|
244
243
|
const codexDir = getProjectCodexDir(ctx);
|
|
245
|
-
const projectExtensionsDir = join(codexDir, "extensions");
|
|
244
|
+
const projectExtensionsDir = path.join(codexDir, "extensions");
|
|
246
245
|
|
|
247
246
|
const [userPaths, projectPaths] = await Promise.all([
|
|
248
247
|
discoverExtensionModulePaths(ctx, userExtensionsDir),
|
|
@@ -250,13 +249,13 @@ async function loadExtensionModules(ctx: LoadContext): Promise<LoadResult<Extens
|
|
|
250
249
|
]);
|
|
251
250
|
|
|
252
251
|
const items: ExtensionModule[] = [
|
|
253
|
-
...userPaths.map(
|
|
252
|
+
...userPaths.map(extPath => ({
|
|
254
253
|
name: getExtensionNameFromPath(extPath),
|
|
255
254
|
path: extPath,
|
|
256
255
|
level: "user" as const,
|
|
257
256
|
_source: createSourceMeta(PROVIDER_ID, extPath, "user"),
|
|
258
257
|
})),
|
|
259
|
-
...projectPaths.map(
|
|
258
|
+
...projectPaths.map(extPath => ({
|
|
260
259
|
name: getExtensionNameFromPath(extPath),
|
|
261
260
|
path: extPath,
|
|
262
261
|
level: "project" as const,
|
|
@@ -272,9 +271,9 @@ async function loadExtensionModules(ctx: LoadContext): Promise<LoadResult<Extens
|
|
|
272
271
|
// =============================================================================
|
|
273
272
|
|
|
274
273
|
async function loadSlashCommands(ctx: LoadContext): Promise<LoadResult<SlashCommand>> {
|
|
275
|
-
const userCommandsDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "commands");
|
|
274
|
+
const userCommandsDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "commands");
|
|
276
275
|
const codexDir = getProjectCodexDir(ctx);
|
|
277
|
-
const projectCommandsDir = join(codexDir, "commands");
|
|
276
|
+
const projectCommandsDir = path.join(codexDir, "commands");
|
|
278
277
|
|
|
279
278
|
const transformCommand =
|
|
280
279
|
(level: "user" | "project") =>
|
|
@@ -301,8 +300,8 @@ async function loadSlashCommands(ctx: LoadContext): Promise<LoadResult<SlashComm
|
|
|
301
300
|
}),
|
|
302
301
|
]);
|
|
303
302
|
|
|
304
|
-
const items = results.flatMap(
|
|
305
|
-
const warnings = results.flatMap(
|
|
303
|
+
const items = results.flatMap(r => r.items);
|
|
304
|
+
const warnings = results.flatMap(r => r.warnings || []);
|
|
306
305
|
|
|
307
306
|
return { items, warnings };
|
|
308
307
|
}
|
|
@@ -312,9 +311,9 @@ async function loadSlashCommands(ctx: LoadContext): Promise<LoadResult<SlashComm
|
|
|
312
311
|
// =============================================================================
|
|
313
312
|
|
|
314
313
|
async function loadPrompts(ctx: LoadContext): Promise<LoadResult<Prompt>> {
|
|
315
|
-
const userPromptsDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "prompts");
|
|
314
|
+
const userPromptsDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "prompts");
|
|
316
315
|
const codexDir = getProjectCodexDir(ctx);
|
|
317
|
-
const projectPromptsDir = join(codexDir, "prompts");
|
|
316
|
+
const projectPromptsDir = path.join(codexDir, "prompts");
|
|
318
317
|
|
|
319
318
|
const transformPrompt = (
|
|
320
319
|
name: string,
|
|
@@ -344,8 +343,8 @@ async function loadPrompts(ctx: LoadContext): Promise<LoadResult<Prompt>> {
|
|
|
344
343
|
}),
|
|
345
344
|
]);
|
|
346
345
|
|
|
347
|
-
const items = results.flatMap(
|
|
348
|
-
const warnings = results.flatMap(
|
|
346
|
+
const items = results.flatMap(r => r.items);
|
|
347
|
+
const warnings = results.flatMap(r => r.warnings || []);
|
|
349
348
|
|
|
350
349
|
return { items, warnings };
|
|
351
350
|
}
|
|
@@ -355,9 +354,9 @@ async function loadPrompts(ctx: LoadContext): Promise<LoadResult<Prompt>> {
|
|
|
355
354
|
// =============================================================================
|
|
356
355
|
|
|
357
356
|
async function loadHooks(ctx: LoadContext): Promise<LoadResult<Hook>> {
|
|
358
|
-
const userHooksDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "hooks");
|
|
357
|
+
const userHooksDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "hooks");
|
|
359
358
|
const codexDir = getProjectCodexDir(ctx);
|
|
360
|
-
const projectHooksDir = join(codexDir, "hooks");
|
|
359
|
+
const projectHooksDir = path.join(codexDir, "hooks");
|
|
361
360
|
|
|
362
361
|
const transformHook =
|
|
363
362
|
(level: "user" | "project") =>
|
|
@@ -387,8 +386,8 @@ async function loadHooks(ctx: LoadContext): Promise<LoadResult<Hook>> {
|
|
|
387
386
|
}),
|
|
388
387
|
]);
|
|
389
388
|
|
|
390
|
-
const items = results.flatMap(
|
|
391
|
-
const warnings = results.flatMap(
|
|
389
|
+
const items = results.flatMap(r => r.items);
|
|
390
|
+
const warnings = results.flatMap(r => r.warnings || []);
|
|
392
391
|
|
|
393
392
|
return { items, warnings };
|
|
394
393
|
}
|
|
@@ -398,9 +397,9 @@ async function loadHooks(ctx: LoadContext): Promise<LoadResult<Hook>> {
|
|
|
398
397
|
// =============================================================================
|
|
399
398
|
|
|
400
399
|
async function loadTools(ctx: LoadContext): Promise<LoadResult<CustomTool>> {
|
|
401
|
-
const userToolsDir = join(ctx.home, SOURCE_PATHS.codex.userBase, "tools");
|
|
400
|
+
const userToolsDir = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "tools");
|
|
402
401
|
const codexDir = getProjectCodexDir(ctx);
|
|
403
|
-
const projectToolsDir = join(codexDir, "tools");
|
|
402
|
+
const projectToolsDir = path.join(codexDir, "tools");
|
|
404
403
|
|
|
405
404
|
const transformTool =
|
|
406
405
|
(level: "user" | "project") =>
|
|
@@ -425,8 +424,8 @@ async function loadTools(ctx: LoadContext): Promise<LoadResult<CustomTool>> {
|
|
|
425
424
|
}),
|
|
426
425
|
]);
|
|
427
426
|
|
|
428
|
-
const items = results.flatMap(
|
|
429
|
-
const warnings = results.flatMap(
|
|
427
|
+
const items = results.flatMap(r => r.items);
|
|
428
|
+
const warnings = results.flatMap(r => r.warnings || []);
|
|
430
429
|
|
|
431
430
|
return { items, warnings };
|
|
432
431
|
}
|
|
@@ -438,9 +437,9 @@ async function loadTools(ctx: LoadContext): Promise<LoadResult<CustomTool>> {
|
|
|
438
437
|
async function loadSettings(ctx: LoadContext): Promise<LoadResult<Settings>> {
|
|
439
438
|
const warnings: string[] = [];
|
|
440
439
|
|
|
441
|
-
const userConfigPath = join(ctx.home, SOURCE_PATHS.codex.userBase, "config.toml");
|
|
440
|
+
const userConfigPath = path.join(ctx.home, SOURCE_PATHS.codex.userBase, "config.toml");
|
|
442
441
|
const codexDir = getProjectCodexDir(ctx);
|
|
443
|
-
const projectConfigPath = join(codexDir, "config.toml");
|
|
442
|
+
const projectConfigPath = path.join(codexDir, "config.toml");
|
|
444
443
|
|
|
445
444
|
const [userConfig, projectConfig] = await Promise.all([
|
|
446
445
|
loadTomlConfig(ctx, userConfigPath),
|
package/src/discovery/cursor.ts
CHANGED
|
@@ -13,16 +13,15 @@
|
|
|
13
13
|
* - rules: From rules/*.mdc files with MDC frontmatter (description, globs, alwaysApply)
|
|
14
14
|
* - settings: From settings.json if present
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
import { readFile } from "
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter";
|
|
16
|
+
import { registerProvider } from "../capability";
|
|
17
|
+
import { readFile } from "../capability/fs";
|
|
18
|
+
import { type MCPServer, mcpCapability } from "../capability/mcp";
|
|
19
|
+
import type { Rule } from "../capability/rule";
|
|
20
|
+
import { ruleCapability } from "../capability/rule";
|
|
21
|
+
import type { Settings } from "../capability/settings";
|
|
22
|
+
import { settingsCapability } from "../capability/settings";
|
|
23
|
+
import type { LoadContext, LoadResult } from "../capability/types";
|
|
24
|
+
import { parseFrontmatter } from "../utils/frontmatter";
|
|
26
25
|
import {
|
|
27
26
|
createSourceMeta,
|
|
28
27
|
expandEnvVarsDeep,
|
package/src/discovery/gemini.ts
CHANGED
|
@@ -15,21 +15,16 @@
|
|
|
15
15
|
* - extensions: From extensions/STAR/gemini-extension.json manifests (STAR = wildcard)
|
|
16
16
|
* - settings: From settings.json
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
import { type ContextFile, contextFileCapability } from "
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from "
|
|
26
|
-
import { type
|
|
27
|
-
import {
|
|
28
|
-
import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
|
|
29
|
-
import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp";
|
|
30
|
-
import { type Settings, settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings";
|
|
31
|
-
import { type SystemPrompt, systemPromptCapability } from "@oh-my-pi/pi-coding-agent/capability/system-prompt";
|
|
32
|
-
import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
import { registerProvider } from "../capability";
|
|
20
|
+
import { type ContextFile, contextFileCapability } from "../capability/context-file";
|
|
21
|
+
import { type Extension, type ExtensionManifest, extensionCapability } from "../capability/extension";
|
|
22
|
+
import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module";
|
|
23
|
+
import { readDirEntries, readFile } from "../capability/fs";
|
|
24
|
+
import { type MCPServer, mcpCapability } from "../capability/mcp";
|
|
25
|
+
import { type Settings, settingsCapability } from "../capability/settings";
|
|
26
|
+
import { type SystemPrompt, systemPromptCapability } from "../capability/system-prompt";
|
|
27
|
+
import type { LoadContext, LoadResult } from "../capability/types";
|
|
33
28
|
import {
|
|
34
29
|
calculateDepth,
|
|
35
30
|
createSourceMeta,
|
|
@@ -150,7 +145,7 @@ async function loadContextFiles(ctx: LoadContext): Promise<LoadResult<ContextFil
|
|
|
150
145
|
const content = await readFile(projectGeminiMd);
|
|
151
146
|
if (content) {
|
|
152
147
|
const projectBase = getProjectPath(ctx, "gemini", "");
|
|
153
|
-
const depth = projectBase ? calculateDepth(ctx.cwd, projectBase, sep) : 0;
|
|
148
|
+
const depth = projectBase ? calculateDepth(ctx.cwd, projectBase, path.sep) : 0;
|
|
154
149
|
|
|
155
150
|
items.push({
|
|
156
151
|
path: projectGeminiMd,
|
|
@@ -194,12 +189,12 @@ async function loadExtensions(ctx: LoadContext): Promise<LoadResult<Extension>>
|
|
|
194
189
|
|
|
195
190
|
async function loadExtensionsFromDir(extensionsDir: string, level: "user" | "project"): Promise<LoadResult<Extension>> {
|
|
196
191
|
const entries = await readDirEntries(extensionsDir);
|
|
197
|
-
const dirEntries = entries.filter(
|
|
192
|
+
const dirEntries = entries.filter(entry => entry.isDirectory());
|
|
198
193
|
|
|
199
194
|
const results = await Promise.all(
|
|
200
|
-
dirEntries.map(async
|
|
201
|
-
const extPath = join(extensionsDir, entry.name);
|
|
202
|
-
const manifestPath = join(extPath, "gemini-extension.json");
|
|
195
|
+
dirEntries.map(async entry => {
|
|
196
|
+
const extPath = path.join(extensionsDir, entry.name);
|
|
197
|
+
const manifestPath = path.join(extPath, "gemini-extension.json");
|
|
203
198
|
const content = await readFile(manifestPath);
|
|
204
199
|
return { entry, extPath, manifestPath, content };
|
|
205
200
|
}),
|
|
@@ -243,13 +238,13 @@ async function loadExtensionModules(ctx: LoadContext): Promise<LoadResult<Extens
|
|
|
243
238
|
]);
|
|
244
239
|
|
|
245
240
|
const items: ExtensionModule[] = [
|
|
246
|
-
...userPaths.map(
|
|
241
|
+
...userPaths.map(extPath => ({
|
|
247
242
|
name: getExtensionNameFromPath(extPath),
|
|
248
243
|
path: extPath,
|
|
249
244
|
level: "user" as const,
|
|
250
245
|
_source: createSourceMeta(PROVIDER_ID, extPath, "user"),
|
|
251
246
|
})),
|
|
252
|
-
...projectPaths.map(
|
|
247
|
+
...projectPaths.map(extPath => ({
|
|
253
248
|
name: getExtensionNameFromPath(extPath),
|
|
254
249
|
path: extPath,
|
|
255
250
|
level: "project" as const,
|
package/src/discovery/github.ts
CHANGED
|
@@ -11,14 +11,13 @@
|
|
|
11
11
|
* - context-files: copilot-instructions.md in .github/
|
|
12
12
|
* - instructions: *.instructions.md in .github/instructions/ with applyTo frontmatter
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import { type ContextFile, contextFileCapability } from "
|
|
17
|
-
import { readFile } from "
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter";
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import { registerProvider } from "../capability";
|
|
16
|
+
import { type ContextFile, contextFileCapability } from "../capability/context-file";
|
|
17
|
+
import { readFile } from "../capability/fs";
|
|
18
|
+
import { type Instruction, instructionCapability } from "../capability/instruction";
|
|
19
|
+
import type { LoadContext, LoadResult, SourceMeta } from "../capability/types";
|
|
20
|
+
import { parseFrontmatter } from "../utils/frontmatter";
|
|
22
21
|
import { calculateDepth, createSourceMeta, getProjectPath, loadFilesFromDir } from "./helpers";
|
|
23
22
|
|
|
24
23
|
const PROVIDER_ID = "github";
|
|
@@ -37,8 +36,8 @@ async function loadContextFiles(ctx: LoadContext): Promise<LoadResult<ContextFil
|
|
|
37
36
|
if (copilotInstructionsPath) {
|
|
38
37
|
const content = await readFile(copilotInstructionsPath);
|
|
39
38
|
if (content) {
|
|
40
|
-
const fileDir = dirname(copilotInstructionsPath);
|
|
41
|
-
const depth = calculateDepth(ctx.cwd, fileDir, sep);
|
|
39
|
+
const fileDir = path.dirname(copilotInstructionsPath);
|
|
40
|
+
const depth = calculateDepth(ctx.cwd, fileDir, path.sep);
|
|
42
41
|
|
|
43
42
|
items.push({
|
|
44
43
|
path: copilotInstructionsPath,
|
|
@@ -74,23 +73,23 @@ async function loadInstructions(ctx: LoadContext): Promise<LoadResult<Instructio
|
|
|
74
73
|
return { items, warnings };
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
function transformInstruction(name: string, content: string,
|
|
76
|
+
function transformInstruction(name: string, content: string, filePath: string, source: SourceMeta): Instruction | null {
|
|
78
77
|
// Only process .instructions.md files
|
|
79
78
|
if (!name.endsWith(".instructions.md")) {
|
|
80
79
|
return null;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
const { frontmatter, body } = parseFrontmatter(content, { source:
|
|
82
|
+
const { frontmatter, body } = parseFrontmatter(content, { source: filePath });
|
|
84
83
|
|
|
85
84
|
// Extract applyTo glob pattern from frontmatter
|
|
86
85
|
const applyTo = typeof frontmatter.applyTo === "string" ? frontmatter.applyTo : undefined;
|
|
87
86
|
|
|
88
87
|
// Derive name from filename (strip .instructions.md suffix)
|
|
89
|
-
const instructionName = basename(name, ".instructions.md");
|
|
88
|
+
const instructionName = path.basename(name, ".instructions.md");
|
|
90
89
|
|
|
91
90
|
return {
|
|
92
91
|
name: instructionName,
|
|
93
|
-
path,
|
|
92
|
+
path: filePath,
|
|
94
93
|
content: body,
|
|
95
94
|
applyTo,
|
|
96
95
|
_source: source,
|
package/src/discovery/helpers.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared helpers for discovery providers.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import { join, resolve } from "node:path";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import * as path from "node:path";
|
|
7
6
|
import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
8
|
-
import { readDirEntries, readFile } from "
|
|
9
|
-
import type { Skill, SkillFrontmatter } from "
|
|
10
|
-
import type { LoadContext, LoadResult, SourceMeta } from "
|
|
11
|
-
import { parseFrontmatter } from "
|
|
7
|
+
import { readDirEntries, readFile } from "../capability/fs";
|
|
8
|
+
import type { Skill, SkillFrontmatter } from "../capability/skill";
|
|
9
|
+
import type { LoadContext, LoadResult, SourceMeta } from "../capability/types";
|
|
10
|
+
import { parseFrontmatter } from "../utils/frontmatter";
|
|
12
11
|
|
|
13
12
|
const VALID_THINKING_LEVELS: readonly string[] = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
14
13
|
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
|
|
@@ -26,10 +25,10 @@ export function normalizeUnicodeSpaces(str: string): string {
|
|
|
26
25
|
export function expandPath(p: string): string {
|
|
27
26
|
const normalized = normalizeUnicodeSpaces(p);
|
|
28
27
|
if (normalized.startsWith("~/")) {
|
|
29
|
-
return join(homedir(), normalized.slice(2));
|
|
28
|
+
return path.join(os.homedir(), normalized.slice(2));
|
|
30
29
|
}
|
|
31
30
|
if (normalized.startsWith("~")) {
|
|
32
|
-
return join(homedir(), normalized.slice(1));
|
|
31
|
+
return path.join(os.homedir(), normalized.slice(1));
|
|
33
32
|
}
|
|
34
33
|
return normalized;
|
|
35
34
|
}
|
|
@@ -94,7 +93,7 @@ export type SourceId = keyof typeof SOURCE_PATHS;
|
|
|
94
93
|
export function getUserPath(ctx: LoadContext, source: SourceId, subpath: string): string | null {
|
|
95
94
|
const paths = SOURCE_PATHS[source];
|
|
96
95
|
if (!paths.userAgent) return null;
|
|
97
|
-
return join(ctx.home, paths.userAgent, subpath);
|
|
96
|
+
return path.join(ctx.home, paths.userAgent, subpath);
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
/**
|
|
@@ -104,17 +103,17 @@ export function getProjectPath(ctx: LoadContext, source: SourceId, subpath: stri
|
|
|
104
103
|
const paths = SOURCE_PATHS[source];
|
|
105
104
|
if (!paths.projectDir) return null;
|
|
106
105
|
|
|
107
|
-
return join(ctx.cwd, paths.projectDir, subpath);
|
|
106
|
+
return path.join(ctx.cwd, paths.projectDir, subpath);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
111
110
|
* Create source metadata for an item.
|
|
112
111
|
*/
|
|
113
|
-
export function createSourceMeta(provider: string,
|
|
112
|
+
export function createSourceMeta(provider: string, filePath: string, level: "user" | "project"): SourceMeta {
|
|
114
113
|
return {
|
|
115
114
|
provider,
|
|
116
115
|
providerName: "", // Filled in by registry
|
|
117
|
-
path: resolve(
|
|
116
|
+
path: path.resolve(filePath),
|
|
118
117
|
level,
|
|
119
118
|
};
|
|
120
119
|
}
|
|
@@ -137,7 +136,7 @@ export function parseThinkingLevel(frontmatter: Record<string, unknown>): Thinki
|
|
|
137
136
|
export function parseCSV(value: string): string[] {
|
|
138
137
|
return value
|
|
139
138
|
.split(",")
|
|
140
|
-
.map(
|
|
139
|
+
.map(s => s.trim())
|
|
141
140
|
.filter(Boolean);
|
|
142
141
|
}
|
|
143
142
|
|
|
@@ -224,12 +223,12 @@ export async function loadSkillsFromDir(
|
|
|
224
223
|
|
|
225
224
|
const entries = await readDirEntries(dir);
|
|
226
225
|
const skillDirs = entries.filter(
|
|
227
|
-
|
|
226
|
+
entry => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules",
|
|
228
227
|
);
|
|
229
228
|
|
|
230
229
|
const results = await Promise.all(
|
|
231
|
-
skillDirs.map(async
|
|
232
|
-
const skillFile = join(dir, entry.name, "SKILL.md");
|
|
230
|
+
skillDirs.map(async entry => {
|
|
231
|
+
const skillFile = path.join(dir, entry.name, "SKILL.md");
|
|
233
232
|
const content = await readFile(skillFile);
|
|
234
233
|
if (!content) {
|
|
235
234
|
return { item: null as Skill | null, warning: null as string | null };
|
|
@@ -283,7 +282,7 @@ export function expandEnvVarsDeep<T>(obj: T, extraEnv?: Record<string, string>):
|
|
|
283
282
|
return expandEnvVars(obj, extraEnv) as T;
|
|
284
283
|
}
|
|
285
284
|
if (Array.isArray(obj)) {
|
|
286
|
-
return obj.map(
|
|
285
|
+
return obj.map(item => expandEnvVarsDeep(item, extraEnv)) as T;
|
|
287
286
|
}
|
|
288
287
|
if (obj !== null && typeof obj === "object") {
|
|
289
288
|
const result: Record<string, unknown> = {};
|
|
@@ -314,24 +313,26 @@ export async function loadFilesFromDir<T>(
|
|
|
314
313
|
): Promise<LoadResult<T>> {
|
|
315
314
|
const entries = await readDirEntries(dir);
|
|
316
315
|
|
|
317
|
-
const visibleEntries = entries.filter(
|
|
316
|
+
const visibleEntries = entries.filter(entry => !entry.name.startsWith("."));
|
|
318
317
|
|
|
319
|
-
const directories = options.recursive ? visibleEntries.filter(
|
|
318
|
+
const directories = options.recursive ? visibleEntries.filter(entry => entry.isDirectory()) : [];
|
|
320
319
|
|
|
321
320
|
const files = visibleEntries
|
|
322
|
-
.filter(
|
|
323
|
-
.filter(
|
|
321
|
+
.filter(entry => entry.isFile())
|
|
322
|
+
.filter(entry => {
|
|
324
323
|
if (!options.extensions) return true;
|
|
325
|
-
return options.extensions.some(
|
|
324
|
+
return options.extensions.some(ext => entry.name.endsWith(`.${ext}`));
|
|
326
325
|
});
|
|
327
326
|
|
|
328
327
|
const [subResults, fileResults] = await Promise.all([
|
|
329
|
-
Promise.all(directories.map((entry) => loadFilesFromDir(_ctx, join(dir, entry.name), provider, level, options))),
|
|
330
328
|
Promise.all(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
329
|
+
directories.map(entry => loadFilesFromDir(_ctx, path.join(dir, entry.name), provider, level, options)),
|
|
330
|
+
),
|
|
331
|
+
Promise.all(
|
|
332
|
+
files.map(async entry => {
|
|
333
|
+
const filePath = path.join(dir, entry.name);
|
|
334
|
+
const content = await readFile(filePath);
|
|
335
|
+
return { entry, path: filePath, content };
|
|
335
336
|
}),
|
|
336
337
|
),
|
|
337
338
|
]);
|
|
@@ -427,7 +428,7 @@ export async function discoverExtensionModulePaths(ctx: LoadContext, dir: string
|
|
|
427
428
|
for (const entry of entries) {
|
|
428
429
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
429
430
|
|
|
430
|
-
const entryPath = join(dir, entry.name);
|
|
431
|
+
const entryPath = path.join(dir, entry.name);
|
|
431
432
|
|
|
432
433
|
// 1. Direct files: *.ts or *.js
|
|
433
434
|
if (entry.isFile() && isExtensionModuleFile(entry.name)) {
|
|
@@ -438,15 +439,15 @@ export async function discoverExtensionModulePaths(ctx: LoadContext, dir: string
|
|
|
438
439
|
// 2 & 3. Subdirectories
|
|
439
440
|
if (entry.isDirectory()) {
|
|
440
441
|
const subEntries = await readDirEntries(entryPath);
|
|
441
|
-
const subFileNames = new Set(subEntries.filter(
|
|
442
|
+
const subFileNames = new Set(subEntries.filter(e => e.isFile()).map(e => e.name));
|
|
442
443
|
|
|
443
444
|
// Check for package.json with "omp"/"pi" field first
|
|
444
445
|
if (subFileNames.has("package.json")) {
|
|
445
|
-
const packageJsonPath = join(entryPath, "package.json");
|
|
446
|
+
const packageJsonPath = path.join(entryPath, "package.json");
|
|
446
447
|
const manifest = await readExtensionModuleManifest(ctx, packageJsonPath);
|
|
447
448
|
if (manifest?.extensions && Array.isArray(manifest.extensions)) {
|
|
448
449
|
for (const extPath of manifest.extensions) {
|
|
449
|
-
const resolvedExtPath = resolve(entryPath, extPath);
|
|
450
|
+
const resolvedExtPath = path.resolve(entryPath, extPath);
|
|
450
451
|
const content = await readFile(resolvedExtPath);
|
|
451
452
|
if (content !== null) {
|
|
452
453
|
discovered.push(resolvedExtPath);
|
|
@@ -458,9 +459,9 @@ export async function discoverExtensionModulePaths(ctx: LoadContext, dir: string
|
|
|
458
459
|
|
|
459
460
|
// Check for index.ts or index.js
|
|
460
461
|
if (subFileNames.has("index.ts")) {
|
|
461
|
-
discovered.push(join(entryPath, "index.ts"));
|
|
462
|
+
discovered.push(path.join(entryPath, "index.ts"));
|
|
462
463
|
} else if (subFileNames.has("index.js")) {
|
|
463
|
-
discovered.push(join(entryPath, "index.js"));
|
|
464
|
+
discovered.push(path.join(entryPath, "index.js"));
|
|
464
465
|
}
|
|
465
466
|
}
|
|
466
467
|
}
|
package/src/discovery/index.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Auto-registers all providers by importing them.
|
|
5
5
|
* Import this module to ensure all providers are registered with the capability registry.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
// Import capability definitions (ensures capabilities are defined before providers register)
|
|
9
8
|
import "../capability/context-file";
|
|
10
9
|
import "../capability/extension";
|
|
@@ -17,28 +16,23 @@ import "../capability/rule";
|
|
|
17
16
|
import "../capability/settings";
|
|
18
17
|
import "../capability/skill";
|
|
19
18
|
import "../capability/slash-command";
|
|
20
|
-
import "../capability/system-prompt";
|
|
21
19
|
import "../capability/ssh";
|
|
20
|
+
import "../capability/system-prompt";
|
|
22
21
|
import "../capability/tool";
|
|
23
|
-
|
|
24
22
|
// Import providers (each registers itself on import)
|
|
23
|
+
import "./agents-md";
|
|
25
24
|
import "./builtin";
|
|
26
25
|
import "./claude";
|
|
26
|
+
import "./cline";
|
|
27
27
|
import "./codex";
|
|
28
|
-
import "./gemini";
|
|
29
28
|
import "./cursor";
|
|
30
|
-
import "./
|
|
31
|
-
import "./cline";
|
|
29
|
+
import "./gemini";
|
|
32
30
|
import "./github";
|
|
33
|
-
import "./vscode";
|
|
34
|
-
import "./agents-md";
|
|
35
31
|
import "./mcp-json";
|
|
36
32
|
import "./ssh";
|
|
33
|
+
import "./vscode";
|
|
34
|
+
import "./windsurf";
|
|
37
35
|
|
|
38
|
-
export type { ContextFile } from "@oh-my-pi/pi-coding-agent/capability/context-file";
|
|
39
|
-
export type { Extension, ExtensionManifest } from "@oh-my-pi/pi-coding-agent/capability/extension";
|
|
40
|
-
export type { ExtensionModule } from "@oh-my-pi/pi-coding-agent/capability/extension-module";
|
|
41
|
-
export type { Hook } from "@oh-my-pi/pi-coding-agent/capability/hook";
|
|
42
36
|
// Re-export the main API from capability registry
|
|
43
37
|
export {
|
|
44
38
|
cacheStats,
|
|
@@ -62,18 +56,22 @@ export {
|
|
|
62
56
|
// Cache management
|
|
63
57
|
reset,
|
|
64
58
|
setDisabledProviders,
|
|
65
|
-
} from "
|
|
66
|
-
export type {
|
|
59
|
+
} from "../capability";
|
|
60
|
+
export type { ContextFile } from "../capability/context-file";
|
|
61
|
+
export type { Extension, ExtensionManifest } from "../capability/extension";
|
|
62
|
+
export type { ExtensionModule } from "../capability/extension-module";
|
|
63
|
+
export type { Hook } from "../capability/hook";
|
|
64
|
+
export type { Instruction } from "../capability/instruction";
|
|
67
65
|
// Re-export capability item types
|
|
68
|
-
export type { MCPServer } from "
|
|
69
|
-
export type { Prompt } from "
|
|
70
|
-
export type { Rule, RuleFrontmatter } from "
|
|
71
|
-
export type { Settings } from "
|
|
72
|
-
export type { Skill, SkillFrontmatter } from "
|
|
73
|
-
export type { SlashCommand } from "
|
|
74
|
-
export type { SSHHost } from "
|
|
75
|
-
export type { SystemPrompt } from "
|
|
76
|
-
export type { CustomTool } from "
|
|
66
|
+
export type { MCPServer } from "../capability/mcp";
|
|
67
|
+
export type { Prompt } from "../capability/prompt";
|
|
68
|
+
export type { Rule, RuleFrontmatter } from "../capability/rule";
|
|
69
|
+
export type { Settings } from "../capability/settings";
|
|
70
|
+
export type { Skill, SkillFrontmatter } from "../capability/skill";
|
|
71
|
+
export type { SlashCommand } from "../capability/slash-command";
|
|
72
|
+
export type { SSHHost } from "../capability/ssh";
|
|
73
|
+
export type { SystemPrompt } from "../capability/system-prompt";
|
|
74
|
+
export type { CustomTool } from "../capability/tool";
|
|
77
75
|
// Re-export types
|
|
78
76
|
export type {
|
|
79
77
|
Capability,
|
|
@@ -85,4 +83,4 @@ export type {
|
|
|
85
83
|
Provider,
|
|
86
84
|
ProviderInfo,
|
|
87
85
|
SourceMeta,
|
|
88
|
-
} from "
|
|
86
|
+
} from "../capability/types";
|