@bastani/atomic 0.9.4 → 0.9.5-alpha.10
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 +136 -2
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/cursor/src/model-mapper.ts +6 -3
- package/dist/builtin/intercom/CHANGELOG.md +31 -0
- package/dist/builtin/intercom/README.md +29 -21
- package/dist/builtin/intercom/broker/broker.ts +9 -120
- package/dist/builtin/intercom/broker/client.ts +29 -54
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
- package/dist/builtin/intercom/broker/paths.ts +42 -5
- package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
- package/dist/builtin/intercom/broker/send-handler.ts +106 -0
- package/dist/builtin/intercom/broker/send-signature.ts +37 -0
- package/dist/builtin/intercom/broker/spawn.ts +78 -10
- package/dist/builtin/intercom/config.ts +6 -3
- package/dist/builtin/intercom/contact-supervisor-tool.ts +6 -4
- package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
- package/dist/builtin/intercom/index-heavy.ts +50 -54
- package/dist/builtin/intercom/index.ts +320 -272
- package/dist/builtin/intercom/intercom-tool.ts +9 -3
- package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
- package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
- package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
- package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
- package/dist/builtin/intercom/lifecycle.ts +37 -20
- package/dist/builtin/intercom/package.json +12 -6
- package/dist/builtin/intercom/reply-routing.ts +17 -0
- package/dist/builtin/intercom/result-renderers.ts +1 -1
- package/dist/builtin/intercom/subagent-relay.ts +58 -12
- package/dist/builtin/intercom/types.ts +3 -3
- package/dist/builtin/intercom/ui/compose.ts +2 -2
- package/dist/builtin/intercom/ui/inline-message.ts +2 -2
- package/dist/builtin/intercom/ui/session-list.ts +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +23 -0
- package/dist/builtin/mcp/OAUTH.md +1 -0
- package/dist/builtin/mcp/README.md +10 -6
- package/dist/builtin/mcp/apps-cancellation.ts +32 -0
- package/dist/builtin/mcp/call-tool-result.ts +9 -0
- package/dist/builtin/mcp/caller-wait.ts +50 -0
- package/dist/builtin/mcp/command-registration.ts +82 -0
- package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
- package/dist/builtin/mcp/direct-tools.ts +40 -255
- package/dist/builtin/mcp/host-html-template.ts +4 -2
- package/dist/builtin/mcp/index.ts +274 -239
- package/dist/builtin/mcp/init.ts +96 -126
- package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
- package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
- package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
- package/dist/builtin/mcp/metadata-hydration.ts +52 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +4 -4
- package/dist/builtin/mcp/proxy-call.ts +111 -40
- package/dist/builtin/mcp/proxy-connect.ts +35 -15
- package/dist/builtin/mcp/proxy-info-modes.ts +106 -23
- package/dist/builtin/mcp/proxy-modes.ts +3 -3
- package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/state-lease.ts +12 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/mcp/ui-server.ts +8 -8
- package/dist/builtin/mcp/ui-session.ts +9 -18
- package/dist/builtin/subagents/CHANGELOG.md +60 -0
- package/dist/builtin/subagents/README.md +30 -29
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
- package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
- package/dist/builtin/subagents/src/extension/index.ts +289 -320
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
- package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +26 -20
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
- package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +177 -233
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +29 -15
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +63 -46
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +55 -12
- package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
- package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +20 -10
- package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +15 -48
- package/dist/builtin/subagents/src/tui/render-layout.ts +9 -0
- package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +27 -25
- package/dist/builtin/subagents/src/tui/render-widget.ts +177 -132
- package/dist/builtin/subagents/src/tui/render.ts +1 -1
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/README.md +4 -0
- package/dist/builtin/web-access/content-tools.ts +8 -3
- package/dist/builtin/web-access/index-heavy.ts +1 -1
- package/dist/builtin/web-access/index.ts +190 -46
- package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/result-renderers.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/web-access/web-search-activity.ts +1 -1
- package/dist/builtin/web-access/web-search-return.ts +7 -0
- package/dist/builtin/web-access/web-search-summary.ts +1 -1
- package/dist/builtin/web-access/web-search-tool.ts +4 -2
- package/dist/builtin/workflows/CHANGELOG.md +98 -0
- package/dist/builtin/workflows/README.md +20 -16
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +33 -9
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +3 -1
- package/dist/builtin/workflows/builtin/goal-ledger.ts +3 -0
- package/dist/builtin/workflows/builtin/goal-prompts.ts +39 -5
- package/dist/builtin/workflows/builtin/goal-reducer.ts +21 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +23 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +85 -6
- package/dist/builtin/workflows/builtin/goal-runner.ts +122 -49
- package/dist/builtin/workflows/builtin/goal-schemas.ts +22 -0
- package/dist/builtin/workflows/builtin/goal-types.ts +25 -1
- package/dist/builtin/workflows/builtin/goal.d.ts +5 -0
- package/dist/builtin/workflows/builtin/goal.ts +13 -2
- package/dist/builtin/workflows/builtin/index.d.ts +8 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +16 -5
- package/dist/builtin/workflows/builtin/ralph-core.ts +100 -15
- package/dist/builtin/workflows/builtin/ralph-models.ts +98 -66
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +37 -5
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +159 -0
- package/dist/builtin/workflows/builtin/ralph-runner.ts +75 -165
- package/dist/builtin/workflows/builtin/ralph.d.ts +3 -0
- package/dist/builtin/workflows/builtin/ralph.ts +4 -1
- package/dist/builtin/workflows/builtin/review-convergence.ts +111 -0
- package/dist/builtin/workflows/builtin/shared-prompts.ts +20 -1
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +12 -8
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +63 -2
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +28 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +167 -28
- package/dist/builtin/workflows/src/durable/types.ts +30 -1
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +32 -32
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -17
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +13 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +8 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +18 -19
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +38 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-tool-execution-buffer.ts +47 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +18 -1
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +23 -5
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-pending-tools.ts +9 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +27 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +5 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/bun/internal-intercom-broker.d.ts +6 -0
- package/dist/bun/internal-intercom-broker.d.ts.map +1 -0
- package/dist/bun/internal-intercom-broker.js +39 -0
- package/dist/bun/internal-intercom-broker.js.map +1 -0
- package/dist/bun/split-loader.d.ts +2 -0
- package/dist/bun/split-loader.d.ts.map +1 -0
- package/dist/bun/split-loader.js +50 -0
- package/dist/bun/split-loader.js.map +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +26 -6
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +178 -19
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +25 -4
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +12 -2
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +1 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +13 -4
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +2 -2
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -1
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +2 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +152 -4
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +4 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +15 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +5 -5
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +42 -32
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +15 -15
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +14 -9
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +8 -4
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +79 -46
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
- package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
- package/dist/core/compaction/context-assistant-turns.js +87 -0
- package/dist/core/compaction/context-assistant-turns.js.map +1 -0
- package/dist/core/compaction/context-compaction-critical.d.ts +15 -0
- package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-critical.js +57 -0
- package/dist/core/compaction/context-compaction-critical.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts +12 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.js +222 -0
- package/dist/core/compaction/context-compaction-eviction.js.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +1 -1
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts +7 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +113 -21
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/compaction/context-compaction-types.d.ts +2 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-types.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +5 -4
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +17 -15
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-store.js +1 -1
- package/dist/core/compaction/context-deletion-store.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +36 -31
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +4 -2
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +36 -40
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-anthropic-sse-repair.d.ts +23 -0
- package/dist/core/copilot-anthropic-sse-repair.d.ts.map +1 -0
- package/dist/core/copilot-anthropic-sse-repair.js +340 -0
- package/dist/core/copilot-anthropic-sse-repair.js.map +1 -0
- package/dist/core/copilot-gemini-reasoning.d.ts +16 -8
- package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
- package/dist/core/copilot-gemini-reasoning.js +27 -22
- package/dist/core/copilot-gemini-reasoning.js.map +1 -1
- package/dist/core/copilot-hosts.d.ts +12 -0
- package/dist/core/copilot-hosts.d.ts.map +1 -0
- package/dist/core/copilot-hosts.js +33 -0
- package/dist/core/copilot-hosts.js.map +1 -0
- package/dist/core/copilot-model-catalog.d.ts.map +1 -1
- package/dist/core/copilot-model-catalog.js +3 -2
- package/dist/core/copilot-model-catalog.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.js +3 -1
- package/dist/core/copilot-model-synthesis.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +1 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +6 -0
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +10 -4
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -7
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +5 -5
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +9 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +100 -18
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +5 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +49 -8
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +11 -5
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +8 -0
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +93 -8
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +24 -12
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +7 -6
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +23 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +33 -5
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +6 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +12 -7
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +9 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +12 -4
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver.d.ts +4 -3
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +7 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -0
- package/dist/core/openai-responses-payload-sanitizer.js +74 -0
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -0
- package/dist/core/package-manager-auto-resources.d.ts +2 -2
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +32 -52
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +23 -14
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-resource-collector.d.ts +3 -3
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
- package/dist/core/package-manager-resource-collector.js +76 -73
- package/dist/core/package-manager-resource-collector.js.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts +9 -8
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.js +92 -81
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts +3 -0
- package/dist/core/prompt-templates-async.d.ts.map +1 -0
- package/dist/core/prompt-templates-async.js +118 -0
- package/dist/core/prompt-templates-async.js.map +1 -0
- package/dist/core/provider-context-usage.d.ts +11 -0
- package/dist/core/provider-context-usage.d.ts.map +1 -0
- package/dist/core/provider-context-usage.js +58 -0
- package/dist/core/provider-context-usage.js.map +1 -0
- package/dist/core/resource-loader-assets.d.ts +3 -3
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +66 -83
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts +1 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -10
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +5 -5
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +4 -0
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +54 -7
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +7 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +9 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-entry-normalization.d.ts +7 -0
- package/dist/core/session-entry-normalization.d.ts.map +1 -0
- package/dist/core/session-entry-normalization.js +14 -0
- package/dist/core/session-entry-normalization.js.map +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +127 -108
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +6 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +3 -2
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +2 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +2 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills-async.d.ts +3 -0
- package/dist/core/skills-async.d.ts.map +1 -0
- package/dist/core/skills-async.js +269 -0
- package/dist/core/skills-async.js.map +1 -0
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/trust-manager.d.ts +9 -0
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +44 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +33 -0
- package/dist/main-deferred-startup.d.ts.map +1 -0
- package/dist/main-deferred-startup.js +44 -0
- package/dist/main-deferred-startup.js.map +1 -0
- package/dist/main-early-input.d.ts +41 -0
- package/dist/main-early-input.d.ts.map +1 -0
- package/dist/main-early-input.js +154 -0
- package/dist/main-early-input.js.map +1 -0
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts +0 -6
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +47 -39
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +15 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.js +3 -1
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +37 -2
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +0 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-child-ordering.js +26 -0
- package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts +8 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +86 -26
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +13 -13
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +16 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +4 -3
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +360 -230
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +19 -4
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +46 -4
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +3 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +3 -3
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +27 -17
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +8 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +14 -10
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts +0 -9
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.js +24 -201
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +43 -9
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +93 -10
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +3 -2
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +10 -8
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +9 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +102 -98
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +3 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/child-process.d.ts +8 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +39 -6
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +3 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/event-loop.d.ts +7 -0
- package/dist/utils/event-loop.d.ts.map +1 -0
- package/dist/utils/event-loop.js +14 -0
- package/dist/utils/event-loop.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/json.d.ts +4 -0
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js +8 -0
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/module-require.d.ts +11 -0
- package/dist/utils/module-require.d.ts.map +1 -1
- package/dist/utils/module-require.js +14 -1
- package/dist/utils/module-require.js.map +1 -1
- package/dist/utils/split-launcher.d.ts +38 -0
- package/dist/utils/split-launcher.d.ts.map +1 -0
- package/dist/utils/split-launcher.js +63 -0
- package/dist/utils/split-launcher.js.map +1 -0
- package/docs/changelog.mdx +19 -0
- package/docs/compaction.md +100 -64
- package/docs/custom-provider.md +18 -5
- package/docs/development.md +4 -0
- package/docs/extensions.md +11 -2
- package/docs/json.md +3 -1
- package/docs/keybindings.md +2 -2
- package/docs/models.md +69 -10
- package/docs/providers.md +3 -2
- package/docs/quickstart.md +15 -11
- package/docs/rpc.md +5 -3
- package/docs/sdk.md +1 -1
- package/docs/settings.md +33 -3
- package/docs/subagents.md +40 -5
- package/docs/terminal-setup.md +4 -0
- package/docs/tools.md +1 -1
- package/docs/usage.md +8 -6
- package/docs/windows.md +4 -0
- package/docs/workflows.md +59 -36
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/subagent/README.md +2 -2
- package/examples/extensions/subagent/index.ts +1 -2
- package/examples/extensions/subagent/schemas.ts +4 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/npm-shrinkwrap.json +538 -51
- package/package.json +10 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
1
|
+
import { access, readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import ignore from "ignore";
|
|
4
|
-
import {
|
|
4
|
+
import { yieldToEventLoopIfSlow } from "../utils/event-loop.js";
|
|
5
|
+
import { getManifestFromPackageJson } from "./package-manager-manifest.js";
|
|
5
6
|
import { toPosixPath } from "./package-manager-resource-patterns.js";
|
|
6
7
|
import { FILE_PATTERNS } from "./package-manager-types.js";
|
|
7
8
|
const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
9
|
+
const RESOURCE_DISCOVERY_YIELD_AFTER_MS = 8;
|
|
10
|
+
async function exists(path) {
|
|
11
|
+
try {
|
|
12
|
+
await access(path);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
function prefixIgnorePattern(line, prefix) {
|
|
9
20
|
const trimmed = line.trim();
|
|
10
|
-
if (!trimmed)
|
|
11
|
-
return null;
|
|
12
|
-
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
21
|
+
if (!trimmed || (trimmed.startsWith("#") && !trimmed.startsWith("\\#")))
|
|
13
22
|
return null;
|
|
14
23
|
let pattern = line;
|
|
15
24
|
let negated = false;
|
|
@@ -17,42 +26,36 @@ function prefixIgnorePattern(line, prefix) {
|
|
|
17
26
|
negated = true;
|
|
18
27
|
pattern = pattern.slice(1);
|
|
19
28
|
}
|
|
20
|
-
else if (pattern.startsWith("\\!"))
|
|
29
|
+
else if (pattern.startsWith("\\!"))
|
|
21
30
|
pattern = pattern.slice(1);
|
|
22
|
-
|
|
23
|
-
if (pattern.startsWith("/")) {
|
|
31
|
+
if (pattern.startsWith("/"))
|
|
24
32
|
pattern = pattern.slice(1);
|
|
25
|
-
}
|
|
26
33
|
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
27
34
|
return negated ? `!${prefixed}` : prefixed;
|
|
28
35
|
}
|
|
29
|
-
function addIgnoreRules(ig, dir, rootDir) {
|
|
36
|
+
async function addIgnoreRules(ig, dir, rootDir) {
|
|
30
37
|
const relativeDir = relative(rootDir, dir);
|
|
31
38
|
const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
|
|
32
39
|
for (const filename of IGNORE_FILE_NAMES) {
|
|
33
|
-
const ignorePath = join(dir, filename);
|
|
34
|
-
if (!existsSync(ignorePath))
|
|
35
|
-
continue;
|
|
36
40
|
try {
|
|
37
|
-
const content =
|
|
41
|
+
const content = await readFile(join(dir, filename), "utf-8");
|
|
38
42
|
const patterns = content
|
|
39
43
|
.split(/\r?\n/)
|
|
40
44
|
.map((line) => prefixIgnorePattern(line, prefix))
|
|
41
45
|
.filter((line) => Boolean(line));
|
|
42
|
-
if (patterns.length > 0)
|
|
46
|
+
if (patterns.length > 0)
|
|
43
47
|
ig.add(patterns);
|
|
44
|
-
}
|
|
45
48
|
}
|
|
46
49
|
catch { }
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
function getEntryInfo(dir, name, isDirectory, isFileEntry, isSymlink) {
|
|
52
|
+
async function getEntryInfo(dir, name, isDirectory, isFileEntry, isSymlink) {
|
|
50
53
|
const fullPath = join(dir, name);
|
|
51
54
|
let isDir = isDirectory;
|
|
52
55
|
let isFile = isFileEntry;
|
|
53
56
|
if (isSymlink) {
|
|
54
57
|
try {
|
|
55
|
-
const stats =
|
|
58
|
+
const stats = await stat(fullPath);
|
|
56
59
|
isDir = stats.isDirectory();
|
|
57
60
|
isFile = stats.isFile();
|
|
58
61
|
}
|
|
@@ -62,51 +65,50 @@ function getEntryInfo(dir, name, isDirectory, isFileEntry, isSymlink) {
|
|
|
62
65
|
}
|
|
63
66
|
return { fullPath, isDir, isFile };
|
|
64
67
|
}
|
|
65
|
-
export function collectFiles(dir, filePattern, skipNodeModules = true, ignoreMatcher, rootDir) {
|
|
68
|
+
export async function collectFiles(dir, filePattern, skipNodeModules = true, ignoreMatcher, rootDir) {
|
|
66
69
|
const files = [];
|
|
67
|
-
if (!
|
|
70
|
+
if (!(await exists(dir)))
|
|
68
71
|
return files;
|
|
69
72
|
const root = rootDir ?? dir;
|
|
70
73
|
const ig = ignoreMatcher ?? ignore();
|
|
71
|
-
addIgnoreRules(ig, dir, root);
|
|
74
|
+
await addIgnoreRules(ig, dir, root);
|
|
75
|
+
const startedAt = Date.now();
|
|
72
76
|
try {
|
|
73
|
-
const entries =
|
|
77
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
74
78
|
for (const entry of entries) {
|
|
75
|
-
|
|
79
|
+
await yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);
|
|
80
|
+
if (entry.name.startsWith(".") || (skipNodeModules && entry.name === "node_modules"))
|
|
76
81
|
continue;
|
|
77
|
-
|
|
78
|
-
continue;
|
|
79
|
-
const info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
82
|
+
const info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
80
83
|
if (!info)
|
|
81
84
|
continue;
|
|
82
85
|
const relPath = toPosixPath(relative(root, info.fullPath));
|
|
83
86
|
const ignorePath = info.isDir ? `${relPath}/` : relPath;
|
|
84
87
|
if (ig.ignores(ignorePath))
|
|
85
88
|
continue;
|
|
86
|
-
if (info.isDir)
|
|
87
|
-
files.push(...collectFiles(info.fullPath, filePattern, skipNodeModules, ig, root));
|
|
88
|
-
|
|
89
|
-
else if (info.isFile && filePattern.test(entry.name)) {
|
|
89
|
+
if (info.isDir)
|
|
90
|
+
files.push(...await collectFiles(info.fullPath, filePattern, skipNodeModules, ig, root));
|
|
91
|
+
else if (info.isFile && filePattern.test(entry.name))
|
|
90
92
|
files.push(info.fullPath);
|
|
91
|
-
}
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
catch { }
|
|
95
96
|
return files;
|
|
96
97
|
}
|
|
97
|
-
function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
98
|
+
async function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
98
99
|
const entries = [];
|
|
99
|
-
if (!
|
|
100
|
+
if (!(await exists(dir)))
|
|
100
101
|
return entries;
|
|
101
102
|
const root = rootDir ?? dir;
|
|
102
103
|
const ig = ignoreMatcher ?? ignore();
|
|
103
|
-
addIgnoreRules(ig, dir, root);
|
|
104
|
+
await addIgnoreRules(ig, dir, root);
|
|
105
|
+
const startedAt = Date.now();
|
|
104
106
|
try {
|
|
105
|
-
const dirEntries =
|
|
107
|
+
const dirEntries = await readdir(dir, { withFileTypes: true });
|
|
106
108
|
for (const entry of dirEntries) {
|
|
107
109
|
if (entry.name !== "SKILL.md")
|
|
108
110
|
continue;
|
|
109
|
-
const info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
111
|
+
const info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
110
112
|
if (!info)
|
|
111
113
|
continue;
|
|
112
114
|
const relPath = toPosixPath(relative(root, info.fullPath));
|
|
@@ -116,11 +118,10 @@ function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
for (const entry of dirEntries) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (entry.name === "node_modules")
|
|
121
|
+
await yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);
|
|
122
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
122
123
|
continue;
|
|
123
|
-
const info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
124
|
+
const info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
124
125
|
if (!info)
|
|
125
126
|
continue;
|
|
126
127
|
const relPath = toPosixPath(relative(root, info.fullPath));
|
|
@@ -130,19 +131,19 @@ function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
|
130
131
|
}
|
|
131
132
|
if (!info.isDir || ig.ignores(`${relPath}/`))
|
|
132
133
|
continue;
|
|
133
|
-
entries.push(...collectSkillEntries(info.fullPath, mode, ig, root));
|
|
134
|
+
entries.push(...await collectSkillEntries(info.fullPath, mode, ig, root));
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
catch { }
|
|
137
138
|
return entries;
|
|
138
139
|
}
|
|
139
|
-
export function collectAutoSkillEntries(dir, mode) {
|
|
140
|
+
export async function collectAutoSkillEntries(dir, mode) {
|
|
140
141
|
return collectSkillEntries(dir, mode);
|
|
141
142
|
}
|
|
142
|
-
function findGitRepoRoot(startDir) {
|
|
143
|
+
async function findGitRepoRoot(startDir) {
|
|
143
144
|
let dir = resolve(startDir);
|
|
144
145
|
while (true) {
|
|
145
|
-
if (
|
|
146
|
+
if (await exists(join(dir, ".git")))
|
|
146
147
|
return dir;
|
|
147
148
|
const parent = dirname(dir);
|
|
148
149
|
if (parent === dir)
|
|
@@ -150,10 +151,10 @@ function findGitRepoRoot(startDir) {
|
|
|
150
151
|
dir = parent;
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
|
-
export function collectAncestorAgentsSkillDirs(startDir) {
|
|
154
|
+
export async function collectAncestorAgentsSkillDirs(startDir) {
|
|
154
155
|
const skillDirs = [];
|
|
155
156
|
const resolvedStartDir = resolve(startDir);
|
|
156
|
-
const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
|
|
157
|
+
const gitRepoRoot = await findGitRepoRoot(resolvedStartDir);
|
|
157
158
|
let dir = resolvedStartDir;
|
|
158
159
|
while (true) {
|
|
159
160
|
skillDirs.push(join(dir, ".agents", "skills"));
|
|
@@ -166,18 +167,20 @@ export function collectAncestorAgentsSkillDirs(startDir) {
|
|
|
166
167
|
}
|
|
167
168
|
return skillDirs;
|
|
168
169
|
}
|
|
169
|
-
function collectFlatEntries(dir, extension) {
|
|
170
|
+
async function collectFlatEntries(dir, extension) {
|
|
170
171
|
const entries = [];
|
|
171
|
-
if (!
|
|
172
|
+
if (!(await exists(dir)))
|
|
172
173
|
return entries;
|
|
173
174
|
const ig = ignore();
|
|
174
|
-
addIgnoreRules(ig, dir, dir);
|
|
175
|
+
await addIgnoreRules(ig, dir, dir);
|
|
176
|
+
const startedAt = Date.now();
|
|
175
177
|
try {
|
|
176
|
-
const dirEntries =
|
|
178
|
+
const dirEntries = await readdir(dir, { withFileTypes: true });
|
|
177
179
|
for (const entry of dirEntries) {
|
|
180
|
+
await yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);
|
|
178
181
|
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
179
182
|
continue;
|
|
180
|
-
const info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
183
|
+
const info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
181
184
|
if (!info)
|
|
182
185
|
continue;
|
|
183
186
|
const relPath = toPosixPath(relative(dir, info.fullPath));
|
|
@@ -190,61 +193,66 @@ function collectFlatEntries(dir, extension) {
|
|
|
190
193
|
catch { }
|
|
191
194
|
return entries;
|
|
192
195
|
}
|
|
193
|
-
export function collectAutoPromptEntries(dir) {
|
|
196
|
+
export async function collectAutoPromptEntries(dir) {
|
|
194
197
|
return collectFlatEntries(dir, ".md");
|
|
195
198
|
}
|
|
196
|
-
export function collectAutoThemeEntries(dir) {
|
|
199
|
+
export async function collectAutoThemeEntries(dir) {
|
|
197
200
|
return collectFlatEntries(dir, ".json");
|
|
198
201
|
}
|
|
199
|
-
export function resolveExtensionEntries(dir) {
|
|
202
|
+
export async function resolveExtensionEntries(dir) {
|
|
200
203
|
const packageJsonPath = join(dir, "package.json");
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
if (await exists(packageJsonPath)) {
|
|
205
|
+
try {
|
|
206
|
+
const pkg = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
207
|
+
const manifest = getManifestFromPackageJson(pkg);
|
|
208
|
+
if (manifest?.extensions?.length) {
|
|
209
|
+
const entries = [];
|
|
210
|
+
for (const extPath of manifest.extensions) {
|
|
211
|
+
const resolvedExtPath = resolve(dir, extPath);
|
|
212
|
+
if (await exists(resolvedExtPath))
|
|
213
|
+
entries.push(resolvedExtPath);
|
|
214
|
+
}
|
|
215
|
+
if (entries.length > 0)
|
|
216
|
+
return entries;
|
|
209
217
|
}
|
|
210
|
-
if (entries.length > 0)
|
|
211
|
-
return entries;
|
|
212
218
|
}
|
|
219
|
+
catch { }
|
|
213
220
|
}
|
|
214
221
|
const indexTs = join(dir, "index.ts");
|
|
215
222
|
const indexJs = join(dir, "index.js");
|
|
216
|
-
if (
|
|
223
|
+
if (await exists(indexTs))
|
|
217
224
|
return [indexTs];
|
|
218
|
-
if (
|
|
225
|
+
if (await exists(indexJs))
|
|
219
226
|
return [indexJs];
|
|
220
227
|
return null;
|
|
221
228
|
}
|
|
222
|
-
export function collectAutoExtensionEntries(dir) {
|
|
229
|
+
export async function collectAutoExtensionEntries(dir) {
|
|
223
230
|
const entries = [];
|
|
224
|
-
if (!
|
|
231
|
+
if (!(await exists(dir)))
|
|
225
232
|
return entries;
|
|
226
|
-
const rootEntries = resolveExtensionEntries(dir);
|
|
233
|
+
const rootEntries = await resolveExtensionEntries(dir);
|
|
227
234
|
if (rootEntries)
|
|
228
235
|
return rootEntries;
|
|
229
236
|
const ig = ignore();
|
|
230
|
-
addIgnoreRules(ig, dir, dir);
|
|
237
|
+
await addIgnoreRules(ig, dir, dir);
|
|
238
|
+
const startedAt = Date.now();
|
|
231
239
|
try {
|
|
232
|
-
const dirEntries =
|
|
240
|
+
const dirEntries = await readdir(dir, { withFileTypes: true });
|
|
233
241
|
for (const entry of dirEntries) {
|
|
242
|
+
await yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);
|
|
234
243
|
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
235
244
|
continue;
|
|
236
|
-
const info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
245
|
+
const info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());
|
|
237
246
|
if (!info)
|
|
238
247
|
continue;
|
|
239
248
|
const relPath = toPosixPath(relative(dir, info.fullPath));
|
|
240
249
|
const ignorePath = info.isDir ? `${relPath}/` : relPath;
|
|
241
250
|
if (ig.ignores(ignorePath))
|
|
242
251
|
continue;
|
|
243
|
-
if (info.isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js")))
|
|
252
|
+
if (info.isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js")))
|
|
244
253
|
entries.push(info.fullPath);
|
|
245
|
-
}
|
|
246
254
|
else if (info.isDir) {
|
|
247
|
-
const resolvedEntries = resolveExtensionEntries(info.fullPath);
|
|
255
|
+
const resolvedEntries = await resolveExtensionEntries(info.fullPath);
|
|
248
256
|
if (resolvedEntries)
|
|
249
257
|
entries.push(...resolvedEntries);
|
|
250
258
|
}
|
|
@@ -253,13 +261,16 @@ export function collectAutoExtensionEntries(dir) {
|
|
|
253
261
|
catch { }
|
|
254
262
|
return entries;
|
|
255
263
|
}
|
|
256
|
-
export function collectResourceFiles(dir, resourceType) {
|
|
257
|
-
if (resourceType === "skills")
|
|
264
|
+
export async function collectResourceFiles(dir, resourceType) {
|
|
265
|
+
if (resourceType === "skills")
|
|
258
266
|
return collectSkillEntries(dir, "pi");
|
|
259
|
-
|
|
260
|
-
if (resourceType === "extensions") {
|
|
267
|
+
if (resourceType === "extensions")
|
|
261
268
|
return collectAutoExtensionEntries(dir);
|
|
262
|
-
}
|
|
263
269
|
return collectFiles(dir, FILE_PATTERNS[resourceType]);
|
|
264
270
|
}
|
|
271
|
+
export function isPathUnder(target, root) {
|
|
272
|
+
const resolvedRoot = resolve(root);
|
|
273
|
+
const resolvedTarget = resolve(target);
|
|
274
|
+
return resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot.endsWith(sep) ? resolvedRoot : `${resolvedRoot}${sep}`);
|
|
275
|
+
}
|
|
265
276
|
//# sourceMappingURL=package-manager-resource-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-resource-files.js","sourceRoot":"","sources":["../../src/core/package-manager-resource-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAqB,MAAM,4BAA4B,CAAC;AAE9E,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AASjE,SAAS,mBAAmB,CAAC,IAAY,EAAE,MAAc;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO;QAAE,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0B;IAC3E,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;QACnC,OAAO,2BAA2B,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,YAAY,CAAC,GAAG,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport ignore from \"ignore\";\nimport { readPiManifestFile } from \"./package-manager-manifest.ts\";\nimport { toPosixPath } from \"./package-manager-resource-patterns.ts\";\nimport { FILE_PATTERNS, type ResourceType } from \"./package-manager-types.ts\";\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\ntype DirEntryInfo = {\n\tfullPath: string;\n\tisDir: boolean;\n\tisFile: boolean;\n};\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nfunction getEntryInfo(dir: string, name: string, isDirectory: boolean, isFileEntry: boolean, isSymlink: boolean): DirEntryInfo | null {\n\tconst fullPath = join(dir, name);\n\tlet isDir = isDirectory;\n\tlet isFile = isFileEntry;\n\tif (isSymlink) {\n\t\ttry {\n\t\t\tconst stats = statSync(fullPath);\n\t\t\tisDir = stats.isDirectory();\n\t\t\tisFile = stats.isFile();\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn { fullPath, isDir, isFile };\n}\n\nexport function collectFiles(\n\tdir: string,\n\tfilePattern: RegExp,\n\tskipNodeModules = true,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): string[] {\n\tconst files: string[] = [];\n\tif (!existsSync(dir)) return files;\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (skipNodeModules && entry.name === \"node_modules\") continue;\n\n\t\t\tconst info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tconst ignorePath = info.isDir ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) continue;\n\n\t\t\tif (info.isDir) {\n\t\t\t\tfiles.push(...collectFiles(info.fullPath, filePattern, skipNodeModules, ig, root));\n\t\t\t} else if (info.isFile && filePattern.test(entry.name)) {\n\t\t\t\tfiles.push(info.fullPath);\n\t\t\t}\n\t\t}\n\t} catch {}\n\n\treturn files;\n}\n\ntype SkillDiscoveryMode = \"pi\" | \"agents\";\n\nfunction collectSkillEntries(\n\tdir: string,\n\tmode: SkillDiscoveryMode,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst dirEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name !== \"SKILL.md\") continue;\n\t\t\tconst info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tif (info.isFile && !ig.ignores(relPath)) {\n\t\t\t\tentries.push(info.fullPath);\n\t\t\t\treturn entries;\n\t\t\t}\n\t\t}\n\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (entry.name === \"node_modules\") continue;\n\t\t\tconst info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tif (mode === \"pi\" && dir === root && info.isFile && entry.name.endsWith(\".md\") && !ig.ignores(relPath)) {\n\t\t\t\tentries.push(info.fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!info.isDir || ig.ignores(`${relPath}/`)) continue;\n\t\t\tentries.push(...collectSkillEntries(info.fullPath, mode, ig, root));\n\t\t}\n\t} catch {}\n\n\treturn entries;\n}\n\nexport function collectAutoSkillEntries(dir: string, mode: SkillDiscoveryMode): string[] {\n\treturn collectSkillEntries(dir, mode);\n}\n\nfunction findGitRepoRoot(startDir: string): string | null {\n\tlet dir = resolve(startDir);\n\twhile (true) {\n\t\tif (existsSync(join(dir, \".git\"))) return dir;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\nexport function collectAncestorAgentsSkillDirs(startDir: string): string[] {\n\tconst skillDirs: string[] = [];\n\tconst resolvedStartDir = resolve(startDir);\n\tconst gitRepoRoot = findGitRepoRoot(resolvedStartDir);\n\n\tlet dir = resolvedStartDir;\n\twhile (true) {\n\t\tskillDirs.push(join(dir, \".agents\", \"skills\"));\n\t\tif (gitRepoRoot && dir === gitRepoRoot) break;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) break;\n\t\tdir = parent;\n\t}\n\treturn skillDirs;\n}\n\nfunction collectFlatEntries(dir: string, extension: string): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\n\tconst ig = ignore();\n\taddIgnoreRules(ig, dir, dir);\n\ttry {\n\t\tconst dirEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\t\tconst info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(dir, info.fullPath));\n\t\t\tif (ig.ignores(relPath)) continue;\n\t\t\tif (info.isFile && entry.name.endsWith(extension)) entries.push(info.fullPath);\n\t\t}\n\t} catch {}\n\treturn entries;\n}\n\nexport function collectAutoPromptEntries(dir: string): string[] {\n\treturn collectFlatEntries(dir, \".md\");\n}\n\nexport function collectAutoThemeEntries(dir: string): string[] {\n\treturn collectFlatEntries(dir, \".json\");\n}\n\nexport function resolveExtensionEntries(dir: string): string[] | null {\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\tconst manifest = readPiManifestFile(packageJsonPath);\n\t\tif (manifest?.extensions?.length) {\n\t\t\tconst entries: string[] = [];\n\t\t\tfor (const extPath of manifest.extensions) {\n\t\t\t\tconst resolvedExtPath = resolve(dir, extPath);\n\t\t\t\tif (existsSync(resolvedExtPath)) entries.push(resolvedExtPath);\n\t\t\t}\n\t\t\tif (entries.length > 0) return entries;\n\t\t}\n\t}\n\n\tconst indexTs = join(dir, \"index.ts\");\n\tconst indexJs = join(dir, \"index.js\");\n\tif (existsSync(indexTs)) return [indexTs];\n\tif (existsSync(indexJs)) return [indexJs];\n\treturn null;\n}\n\nexport function collectAutoExtensionEntries(dir: string): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\n\tconst rootEntries = resolveExtensionEntries(dir);\n\tif (rootEntries) return rootEntries;\n\n\tconst ig = ignore();\n\taddIgnoreRules(ig, dir, dir);\n\ttry {\n\t\tconst dirEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\t\tconst info = getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\n\t\t\tconst relPath = toPosixPath(relative(dir, info.fullPath));\n\t\t\tconst ignorePath = info.isDir ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) continue;\n\n\t\t\tif (info.isFile && (entry.name.endsWith(\".ts\") || entry.name.endsWith(\".js\"))) {\n\t\t\t\tentries.push(info.fullPath);\n\t\t\t} else if (info.isDir) {\n\t\t\t\tconst resolvedEntries = resolveExtensionEntries(info.fullPath);\n\t\t\t\tif (resolvedEntries) entries.push(...resolvedEntries);\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn entries;\n}\n\nexport function collectResourceFiles(dir: string, resourceType: ResourceType): string[] {\n\tif (resourceType === \"skills\") {\n\t\treturn collectSkillEntries(dir, \"pi\");\n\t}\n\tif (resourceType === \"extensions\") {\n\t\treturn collectAutoExtensionEntries(dir);\n\t}\n\treturn collectFiles(dir, FILE_PATTERNS[resourceType]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-manager-resource-files.js","sourceRoot":"","sources":["../../src/core/package-manager-resource-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAqB,MAAM,4BAA4B,CAAC;AAE9E,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACjE,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAU5C,KAAK,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,CAAC;QAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;AACjE,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY,EAAE,MAAc;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAA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} from \"node:fs/promises\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { yieldToEventLoopIfSlow } from \"../utils/event-loop.ts\";\nimport { getManifestFromPackageJson } from \"./package-manager-manifest.ts\";\nimport { toPosixPath } from \"./package-manager-resource-patterns.ts\";\nimport { FILE_PATTERNS, type ResourceType } from \"./package-manager-types.ts\";\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\nconst RESOURCE_DISCOVERY_YIELD_AFTER_MS = 8;\ntype IgnoreMatcher = ReturnType<typeof ignore>;\ntype SkillDiscoveryMode = \"pi\" | \"agents\";\n\ntype DirEntryInfo = {\n\tfullPath: string;\n\tisDir: boolean;\n\tisFile: boolean;\n};\n\nasync function exists(path: string): Promise<boolean> {\n\ttry { await access(path); return true; } catch { return false; }\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed || (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\"))) return null;\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) { negated = true; pattern = pattern.slice(1); }\n\telse if (pattern.startsWith(\"\\\\!\")) pattern = pattern.slice(1);\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nasync function addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): Promise<void> {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\ttry {\n\t\t\tconst content = await readFile(join(dir, filename), \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t} catch {}\n\t}\n}\n\nasync function getEntryInfo(dir: string, name: string, isDirectory: boolean, isFileEntry: boolean, isSymlink: boolean): Promise<DirEntryInfo | null> {\n\tconst fullPath = join(dir, name);\n\tlet isDir = isDirectory;\n\tlet isFile = isFileEntry;\n\tif (isSymlink) {\n\t\ttry {\n\t\t\tconst stats = await stat(fullPath);\n\t\t\tisDir = stats.isDirectory();\n\t\t\tisFile = stats.isFile();\n\t\t} catch { return null; }\n\t}\n\treturn { fullPath, isDir, isFile };\n}\n\nexport async function collectFiles(dir: string, filePattern: RegExp, skipNodeModules = true, ignoreMatcher?: IgnoreMatcher, rootDir?: string): Promise<string[]> {\n\tconst files: string[] = [];\n\tif (!(await exists(dir))) return files;\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\tawait addIgnoreRules(ig, dir, root);\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);\n\t\t\tif (entry.name.startsWith(\".\") || (skipNodeModules && entry.name === \"node_modules\")) continue;\n\t\t\tconst info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tconst ignorePath = info.isDir ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) continue;\n\t\t\tif (info.isDir) files.push(...await collectFiles(info.fullPath, filePattern, skipNodeModules, ig, root));\n\t\t\telse if (info.isFile && filePattern.test(entry.name)) files.push(info.fullPath);\n\t\t}\n\t} catch {}\n\treturn files;\n}\n\nasync function collectSkillEntries(dir: string, mode: SkillDiscoveryMode, ignoreMatcher?: IgnoreMatcher, rootDir?: string): Promise<string[]> {\n\tconst entries: string[] = [];\n\tif (!(await exists(dir))) return entries;\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\tawait addIgnoreRules(ig, dir, root);\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst dirEntries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name !== \"SKILL.md\") continue;\n\t\t\tconst info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tif (info.isFile && !ig.ignores(relPath)) { entries.push(info.fullPath); return entries; }\n\t\t}\n\t\tfor (const entry of dirEntries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);\n\t\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\t\tconst info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(root, info.fullPath));\n\t\t\tif (mode === \"pi\" && dir === root && info.isFile && entry.name.endsWith(\".md\") && !ig.ignores(relPath)) {\n\t\t\t\tentries.push(info.fullPath);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!info.isDir || ig.ignores(`${relPath}/`)) continue;\n\t\t\tentries.push(...await collectSkillEntries(info.fullPath, mode, ig, root));\n\t\t}\n\t} catch {}\n\treturn entries;\n}\n\nexport async function collectAutoSkillEntries(dir: string, mode: SkillDiscoveryMode): Promise<string[]> {\n\treturn collectSkillEntries(dir, mode);\n}\n\nasync function findGitRepoRoot(startDir: string): Promise<string | null> {\n\tlet dir = resolve(startDir);\n\twhile (true) {\n\t\tif (await exists(join(dir, \".git\"))) return dir;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) return null;\n\t\tdir = parent;\n\t}\n}\n\nexport async function collectAncestorAgentsSkillDirs(startDir: string): Promise<string[]> {\n\tconst skillDirs: string[] = [];\n\tconst resolvedStartDir = resolve(startDir);\n\tconst gitRepoRoot = await findGitRepoRoot(resolvedStartDir);\n\tlet dir = resolvedStartDir;\n\twhile (true) {\n\t\tskillDirs.push(join(dir, \".agents\", \"skills\"));\n\t\tif (gitRepoRoot && dir === gitRepoRoot) break;\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) break;\n\t\tdir = parent;\n\t}\n\treturn skillDirs;\n}\n\nasync function collectFlatEntries(dir: string, extension: string): Promise<string[]> {\n\tconst entries: string[] = [];\n\tif (!(await exists(dir))) return entries;\n\tconst ig = ignore();\n\tawait addIgnoreRules(ig, dir, dir);\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst dirEntries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);\n\t\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\t\tconst info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(dir, info.fullPath));\n\t\t\tif (ig.ignores(relPath)) continue;\n\t\t\tif (info.isFile && entry.name.endsWith(extension)) entries.push(info.fullPath);\n\t\t}\n\t} catch {}\n\treturn entries;\n}\n\nexport async function collectAutoPromptEntries(dir: string): Promise<string[]> {\n\treturn collectFlatEntries(dir, \".md\");\n}\n\nexport async function collectAutoThemeEntries(dir: string): Promise<string[]> {\n\treturn collectFlatEntries(dir, \".json\");\n}\n\nexport async function resolveExtensionEntries(dir: string): Promise<string[] | null> {\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (await exists(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst pkg = JSON.parse(await readFile(packageJsonPath, \"utf-8\")) as Record<string, unknown>;\n\t\t\tconst manifest = getManifestFromPackageJson(pkg);\n\t\t\tif (manifest?.extensions?.length) {\n\t\t\t\tconst entries: string[] = [];\n\t\t\t\tfor (const extPath of manifest.extensions) {\n\t\t\t\t\tconst resolvedExtPath = resolve(dir, extPath);\n\t\t\t\t\tif (await exists(resolvedExtPath)) entries.push(resolvedExtPath);\n\t\t\t\t}\n\t\t\t\tif (entries.length > 0) return entries;\n\t\t\t}\n\t\t} catch {}\n\t}\n\tconst indexTs = join(dir, \"index.ts\");\n\tconst indexJs = join(dir, \"index.js\");\n\tif (await exists(indexTs)) return [indexTs];\n\tif (await exists(indexJs)) return [indexJs];\n\treturn null;\n}\n\nexport async function collectAutoExtensionEntries(dir: string): Promise<string[]> {\n\tconst entries: string[] = [];\n\tif (!(await exists(dir))) return entries;\n\tconst rootEntries = await resolveExtensionEntries(dir);\n\tif (rootEntries) return rootEntries;\n\tconst ig = ignore();\n\tawait addIgnoreRules(ig, dir, dir);\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst dirEntries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, RESOURCE_DISCOVERY_YIELD_AFTER_MS);\n\t\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\t\tconst info = await getEntryInfo(dir, entry.name, entry.isDirectory(), entry.isFile(), entry.isSymbolicLink());\n\t\t\tif (!info) continue;\n\t\t\tconst relPath = toPosixPath(relative(dir, info.fullPath));\n\t\t\tconst ignorePath = info.isDir ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) continue;\n\t\t\tif (info.isFile && (entry.name.endsWith(\".ts\") || entry.name.endsWith(\".js\"))) entries.push(info.fullPath);\n\t\t\telse if (info.isDir) {\n\t\t\t\tconst resolvedEntries = await resolveExtensionEntries(info.fullPath);\n\t\t\t\tif (resolvedEntries) entries.push(...resolvedEntries);\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn entries;\n}\n\nexport async function collectResourceFiles(dir: string, resourceType: ResourceType): Promise<string[]> {\n\tif (resourceType === \"skills\") return collectSkillEntries(dir, \"pi\");\n\tif (resourceType === \"extensions\") return collectAutoExtensionEntries(dir);\n\treturn collectFiles(dir, FILE_PATTERNS[resourceType]);\n}\n\nexport function isPathUnder(target: string, root: string): boolean {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedTarget = resolve(target);\n\treturn resolvedTarget === resolvedRoot || resolvedTarget.startsWith(resolvedRoot.endsWith(sep) ? resolvedRoot : `${resolvedRoot}${sep}`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-templates-async.d.ts","sourceRoot":"","sources":["../../src/core/prompt-templates-async.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAuDxF,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CA0C7G","sourcesContent":["import { access, readdir, readFile, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { yieldToEventLoopIfSlow } from \"../utils/event-loop.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { LoadPromptTemplatesOptions, PromptTemplate } from \"./prompt-templates.ts\";\n\nconst YIELD_AFTER_MS = 8;\n\nasync function exists(path: string): Promise<boolean> {\n\ttry { await access(path); return true; } catch { return false; }\n}\n\nasync function loadTemplateFromFile(filePath: string, sourceInfo: SourceInfo): Promise<PromptTemplate | null> {\n\ttry {\n\t\tconst rawContent = await readFile(filePath, \"utf-8\");\n\t\tconst { frontmatter, body } = parseFrontmatter<Record<string, string>>(rawContent);\n\t\tconst name = basename(filePath).replace(/\\.md$/, \"\");\n\t\tlet description = frontmatter.description || \"\";\n\t\tif (!description) {\n\t\t\tconst firstLine = body.split(\"\\n\").find((line) => line.trim());\n\t\t\tif (firstLine) description = firstLine.length > 60 ? `${firstLine.slice(0, 60)}...` : firstLine;\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\t...(frontmatter[\"argument-hint\"] && { argumentHint: frontmatter[\"argument-hint\"] }),\n\t\t\tcontent: body,\n\t\t\tsourceInfo,\n\t\t\tfilePath,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function loadTemplatesFromDir(\n\tdir: string,\n\tgetSourceInfo: (filePath: string) => Promise<SourceInfo>,\n): Promise<PromptTemplate[]> {\n\tconst templates: PromptTemplate[] = [];\n\tif (!(await exists(dir))) return templates;\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry { isFile = (await stat(fullPath)).isFile(); } catch { continue; }\n\t\t\t}\n\t\t\tif (!isFile || !entry.name.endsWith(\".md\")) continue;\n\t\t\tconst template = await loadTemplateFromFile(fullPath, await getSourceInfo(fullPath));\n\t\t\tif (template) templates.push(template);\n\t\t}\n\t} catch {}\n\treturn templates;\n}\n\nexport async function loadPromptTemplatesAsync(options: LoadPromptTemplatesOptions): Promise<PromptTemplate[]> {\n\tconst resolvedCwd = resolvePath(options.cwd);\n\tconst resolvedAgentDir = resolvePath(options.agentDir);\n\tconst promptPaths = options.promptPaths ?? [];\n\tconst includeDefaults = options.includeDefaults ?? true;\n\tconst templates: PromptTemplate[] = [];\n\tconst globalPromptsDir = join(resolvedAgentDir, \"prompts\");\n\tconst projectPromptsDir = resolve(resolvedCwd, CONFIG_DIR_NAME, \"prompts\");\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\treturn target === normalizedRoot || target.startsWith(normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`);\n\t};\n\tconst getSourceInfo = async (resolvedPath: string): Promise<SourceInfo> => {\n\t\tif (isUnderPath(resolvedPath, globalPromptsDir)) {\n\t\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", scope: \"user\", baseDir: globalPromptsDir });\n\t\t}\n\t\tif (isUnderPath(resolvedPath, projectPromptsDir)) {\n\t\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", scope: \"project\", baseDir: projectPromptsDir });\n\t\t}\n\t\tconst stats = await stat(resolvedPath);\n\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", baseDir: stats.isDirectory() ? resolvedPath : dirname(resolvedPath) });\n\t};\n\tif (includeDefaults) {\n\t\ttemplates.push(...await loadTemplatesFromDir(globalPromptsDir, getSourceInfo));\n\t\ttemplates.push(...await loadTemplatesFromDir(projectPromptsDir, getSourceInfo));\n\t}\n\tconst startedAt = Date.now();\n\tfor (const rawPath of promptPaths) {\n\t\tawait yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);\n\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\tif (!(await exists(resolvedPath))) continue;\n\t\ttry {\n\t\t\tconst stats = await stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\ttemplates.push(...await loadTemplatesFromDir(resolvedPath, getSourceInfo));\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst template = await loadTemplateFromFile(resolvedPath, await getSourceInfo(resolvedPath));\n\t\t\t\tif (template) templates.push(template);\n\t\t\t}\n\t\t} catch {}\n\t}\n\treturn templates;\n}\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { access, readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
3
|
+
import { CONFIG_DIR_NAME } from "../config.js";
|
|
4
|
+
import { parseFrontmatter } from "../utils/frontmatter.js";
|
|
5
|
+
import { yieldToEventLoopIfSlow } from "../utils/event-loop.js";
|
|
6
|
+
import { resolvePath } from "../utils/paths.js";
|
|
7
|
+
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
8
|
+
const YIELD_AFTER_MS = 8;
|
|
9
|
+
async function exists(path) {
|
|
10
|
+
try {
|
|
11
|
+
await access(path);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function loadTemplateFromFile(filePath, sourceInfo) {
|
|
19
|
+
try {
|
|
20
|
+
const rawContent = await readFile(filePath, "utf-8");
|
|
21
|
+
const { frontmatter, body } = parseFrontmatter(rawContent);
|
|
22
|
+
const name = basename(filePath).replace(/\.md$/, "");
|
|
23
|
+
let description = frontmatter.description || "";
|
|
24
|
+
if (!description) {
|
|
25
|
+
const firstLine = body.split("\n").find((line) => line.trim());
|
|
26
|
+
if (firstLine)
|
|
27
|
+
description = firstLine.length > 60 ? `${firstLine.slice(0, 60)}...` : firstLine;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
...(frontmatter["argument-hint"] && { argumentHint: frontmatter["argument-hint"] }),
|
|
33
|
+
content: body,
|
|
34
|
+
sourceInfo,
|
|
35
|
+
filePath,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function loadTemplatesFromDir(dir, getSourceInfo) {
|
|
43
|
+
const templates = [];
|
|
44
|
+
if (!(await exists(dir)))
|
|
45
|
+
return templates;
|
|
46
|
+
const startedAt = Date.now();
|
|
47
|
+
try {
|
|
48
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
await yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);
|
|
51
|
+
const fullPath = join(dir, entry.name);
|
|
52
|
+
let isFile = entry.isFile();
|
|
53
|
+
if (entry.isSymbolicLink()) {
|
|
54
|
+
try {
|
|
55
|
+
isFile = (await stat(fullPath)).isFile();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!isFile || !entry.name.endsWith(".md"))
|
|
62
|
+
continue;
|
|
63
|
+
const template = await loadTemplateFromFile(fullPath, await getSourceInfo(fullPath));
|
|
64
|
+
if (template)
|
|
65
|
+
templates.push(template);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch { }
|
|
69
|
+
return templates;
|
|
70
|
+
}
|
|
71
|
+
export async function loadPromptTemplatesAsync(options) {
|
|
72
|
+
const resolvedCwd = resolvePath(options.cwd);
|
|
73
|
+
const resolvedAgentDir = resolvePath(options.agentDir);
|
|
74
|
+
const promptPaths = options.promptPaths ?? [];
|
|
75
|
+
const includeDefaults = options.includeDefaults ?? true;
|
|
76
|
+
const templates = [];
|
|
77
|
+
const globalPromptsDir = join(resolvedAgentDir, "prompts");
|
|
78
|
+
const projectPromptsDir = resolve(resolvedCwd, CONFIG_DIR_NAME, "prompts");
|
|
79
|
+
const isUnderPath = (target, root) => {
|
|
80
|
+
const normalizedRoot = resolve(root);
|
|
81
|
+
return target === normalizedRoot || target.startsWith(normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`);
|
|
82
|
+
};
|
|
83
|
+
const getSourceInfo = async (resolvedPath) => {
|
|
84
|
+
if (isUnderPath(resolvedPath, globalPromptsDir)) {
|
|
85
|
+
return createSyntheticSourceInfo(resolvedPath, { source: "local", scope: "user", baseDir: globalPromptsDir });
|
|
86
|
+
}
|
|
87
|
+
if (isUnderPath(resolvedPath, projectPromptsDir)) {
|
|
88
|
+
return createSyntheticSourceInfo(resolvedPath, { source: "local", scope: "project", baseDir: projectPromptsDir });
|
|
89
|
+
}
|
|
90
|
+
const stats = await stat(resolvedPath);
|
|
91
|
+
return createSyntheticSourceInfo(resolvedPath, { source: "local", baseDir: stats.isDirectory() ? resolvedPath : dirname(resolvedPath) });
|
|
92
|
+
};
|
|
93
|
+
if (includeDefaults) {
|
|
94
|
+
templates.push(...await loadTemplatesFromDir(globalPromptsDir, getSourceInfo));
|
|
95
|
+
templates.push(...await loadTemplatesFromDir(projectPromptsDir, getSourceInfo));
|
|
96
|
+
}
|
|
97
|
+
const startedAt = Date.now();
|
|
98
|
+
for (const rawPath of promptPaths) {
|
|
99
|
+
await yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);
|
|
100
|
+
const resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });
|
|
101
|
+
if (!(await exists(resolvedPath)))
|
|
102
|
+
continue;
|
|
103
|
+
try {
|
|
104
|
+
const stats = await stat(resolvedPath);
|
|
105
|
+
if (stats.isDirectory()) {
|
|
106
|
+
templates.push(...await loadTemplatesFromDir(resolvedPath, getSourceInfo));
|
|
107
|
+
}
|
|
108
|
+
else if (stats.isFile() && resolvedPath.endsWith(".md")) {
|
|
109
|
+
const template = await loadTemplateFromFile(resolvedPath, await getSourceInfo(resolvedPath));
|
|
110
|
+
if (template)
|
|
111
|
+
templates.push(template);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
}
|
|
116
|
+
return templates;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=prompt-templates-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-templates-async.js","sourceRoot":"","sources":["../../src/core/prompt-templates-async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QA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IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACzB,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;YAC5E,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,YAAY,EAAE,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC7F,IAAI,QAAQ;oBAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACX,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { access, readdir, readFile, stat } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve, sep } from \"node:path\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { yieldToEventLoopIfSlow } from \"../utils/event-loop.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { LoadPromptTemplatesOptions, PromptTemplate } from \"./prompt-templates.ts\";\n\nconst YIELD_AFTER_MS = 8;\n\nasync function exists(path: string): Promise<boolean> {\n\ttry { await access(path); return true; } catch { return false; }\n}\n\nasync function loadTemplateFromFile(filePath: string, sourceInfo: SourceInfo): Promise<PromptTemplate | null> {\n\ttry {\n\t\tconst rawContent = await readFile(filePath, \"utf-8\");\n\t\tconst { frontmatter, body } = parseFrontmatter<Record<string, string>>(rawContent);\n\t\tconst name = basename(filePath).replace(/\\.md$/, \"\");\n\t\tlet description = frontmatter.description || \"\";\n\t\tif (!description) {\n\t\t\tconst firstLine = body.split(\"\\n\").find((line) => line.trim());\n\t\t\tif (firstLine) description = firstLine.length > 60 ? `${firstLine.slice(0, 60)}...` : firstLine;\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\t...(frontmatter[\"argument-hint\"] && { argumentHint: frontmatter[\"argument-hint\"] }),\n\t\t\tcontent: body,\n\t\t\tsourceInfo,\n\t\t\tfilePath,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function loadTemplatesFromDir(\n\tdir: string,\n\tgetSourceInfo: (filePath: string) => Promise<SourceInfo>,\n): Promise<PromptTemplate[]> {\n\tconst templates: PromptTemplate[] = [];\n\tif (!(await exists(dir))) return templates;\n\tconst startedAt = Date.now();\n\ttry {\n\t\tconst entries = await readdir(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tawait yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry { isFile = (await stat(fullPath)).isFile(); } catch { continue; }\n\t\t\t}\n\t\t\tif (!isFile || !entry.name.endsWith(\".md\")) continue;\n\t\t\tconst template = await loadTemplateFromFile(fullPath, await getSourceInfo(fullPath));\n\t\t\tif (template) templates.push(template);\n\t\t}\n\t} catch {}\n\treturn templates;\n}\n\nexport async function loadPromptTemplatesAsync(options: LoadPromptTemplatesOptions): Promise<PromptTemplate[]> {\n\tconst resolvedCwd = resolvePath(options.cwd);\n\tconst resolvedAgentDir = resolvePath(options.agentDir);\n\tconst promptPaths = options.promptPaths ?? [];\n\tconst includeDefaults = options.includeDefaults ?? true;\n\tconst templates: PromptTemplate[] = [];\n\tconst globalPromptsDir = join(resolvedAgentDir, \"prompts\");\n\tconst projectPromptsDir = resolve(resolvedCwd, CONFIG_DIR_NAME, \"prompts\");\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\treturn target === normalizedRoot || target.startsWith(normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`);\n\t};\n\tconst getSourceInfo = async (resolvedPath: string): Promise<SourceInfo> => {\n\t\tif (isUnderPath(resolvedPath, globalPromptsDir)) {\n\t\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", scope: \"user\", baseDir: globalPromptsDir });\n\t\t}\n\t\tif (isUnderPath(resolvedPath, projectPromptsDir)) {\n\t\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", scope: \"project\", baseDir: projectPromptsDir });\n\t\t}\n\t\tconst stats = await stat(resolvedPath);\n\t\treturn createSyntheticSourceInfo(resolvedPath, { source: \"local\", baseDir: stats.isDirectory() ? resolvedPath : dirname(resolvedPath) });\n\t};\n\tif (includeDefaults) {\n\t\ttemplates.push(...await loadTemplatesFromDir(globalPromptsDir, getSourceInfo));\n\t\ttemplates.push(...await loadTemplatesFromDir(projectPromptsDir, getSourceInfo));\n\t}\n\tconst startedAt = Date.now();\n\tfor (const rawPath of promptPaths) {\n\t\tawait yieldToEventLoopIfSlow(startedAt, YIELD_AFTER_MS);\n\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\tif (!(await exists(resolvedPath))) continue;\n\t\ttry {\n\t\t\tconst stats = await stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\ttemplates.push(...await loadTemplatesFromDir(resolvedPath, getSourceInfo));\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst template = await loadTemplateFromFile(resolvedPath, await getSourceInfo(resolvedPath));\n\t\t\t\tif (template) templates.push(template);\n\t\t\t}\n\t\t} catch {}\n\t}\n\treturn templates;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { SessionEntry } from "./session-manager.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Provider-side token-budget estimators use the last assistant usage in the
|
|
5
|
+
* request context as an anchor. After logical context compaction, retained
|
|
6
|
+
* pre-compaction assistant messages still carry usage from the old, larger
|
|
7
|
+
* context. Scrub only the provider-bound clone so the durable transcript keeps
|
|
8
|
+
* historical billing data while the next request estimates the compacted prompt.
|
|
9
|
+
*/
|
|
10
|
+
export declare function scrubPreCompactionAssistantUsage(messages: AgentMessage[], entries: readonly SessionEntry[]): AgentMessage[];
|
|
11
|
+
//# sourceMappingURL=provider-context-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-context-usage.d.ts","sourceRoot":"","sources":["../../src/core/provider-context-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,KAAK,EAA0B,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAqCjF;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC/C,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO,EAAE,SAAS,YAAY,EAAE,GAC9B,YAAY,EAAE,CAqBhB","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AssistantMessage, Usage } from \"@earendil-works/pi-ai/compat\";\nimport type { ContextCompactionEntry, SessionEntry } from \"./session-manager.ts\";\n\nfunction findLatestCompactionBoundary(entries: readonly SessionEntry[]): ContextCompactionEntry | undefined {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type === \"context_compaction\") {\n\t\t\treturn entry;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction hasTokenUsage(usage: Usage): boolean {\n\treturn usage.input > 0 || usage.output > 0 || usage.cacheRead > 0 || usage.cacheWrite > 0 || usage.totalTokens > 0;\n}\n\nfunction createZeroUsage(usage: Usage): Usage {\n\tconst zeroed: Usage = {\n\t\t...usage,\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t};\n\n\tif (usage.cacheWrite1h !== undefined) {\n\t\tzeroed.cacheWrite1h = 0;\n\t}\n\tif (usage.reasoning !== undefined) {\n\t\tzeroed.reasoning = 0;\n\t}\n\n\treturn zeroed;\n}\n\n/**\n * Provider-side token-budget estimators use the last assistant usage in the\n * request context as an anchor. After logical context compaction, retained\n * pre-compaction assistant messages still carry usage from the old, larger\n * context. Scrub only the provider-bound clone so the durable transcript keeps\n * historical billing data while the next request estimates the compacted prompt.\n */\nexport function scrubPreCompactionAssistantUsage(\n\tmessages: AgentMessage[],\n\tentries: readonly SessionEntry[],\n): AgentMessage[] {\n\tconst compactionBoundary = findLatestCompactionBoundary(entries);\n\tif (!compactionBoundary) return messages;\n\n\tconst boundaryTime = Date.parse(compactionBoundary.timestamp);\n\tif (!Number.isFinite(boundaryTime)) return messages;\n\n\tlet changed = false;\n\tconst scrubbed = messages.map((message) => {\n\t\tif (message.role !== \"assistant\") return message;\n\n\t\tconst assistant = message as AssistantMessage;\n\t\tif (assistant.timestamp > boundaryTime || !hasTokenUsage(assistant.usage)) {\n\t\t\treturn message;\n\t\t}\n\n\t\tchanged = true;\n\t\treturn { ...assistant, usage: createZeroUsage(assistant.usage) };\n\t});\n\n\treturn changed ? scrubbed : messages;\n}\n"]}
|