@north-light/crouter 0.3.352 → 0.3.354
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/dist/api/client.d.ts +35 -25
- package/dist/api/client.js +2 -2
- package/dist/api/dto/broker-ops.d.ts +2 -36
- package/dist/api/dto/canvas.d.ts +8 -13
- package/dist/api/dto/config.d.ts +4 -0
- package/dist/api/dto/delivery.d.ts +61 -0
- package/dist/api/dto/docs.d.ts +133 -0
- package/dist/api/dto/docs.js +1 -0
- package/dist/api/dto/health.d.ts +26 -79
- package/dist/api/dto/node-outcomes.d.ts +1 -3
- package/dist/api/dto/nodes.d.ts +5 -26
- package/dist/api/dto/objects.d.ts +167 -0
- package/dist/api/dto/objects.js +1 -0
- package/dist/api/dto/profiles.d.ts +14 -8
- package/dist/api/dto/reports.d.ts +9 -7
- package/dist/api/dto/reviews.d.ts +9 -3
- package/dist/api/dto/worktree.d.ts +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes.d.ts +14 -12
- package/dist/api/routes.js +1 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
- package/dist/builtin-memory/04-orchestration-kernel.md +7 -7
- package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
- package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
- package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
- package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
- package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
- package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +5 -6
- package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
- package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
- package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
- package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
- package/dist/builtin-memory/explore/exploration-doc.md +4 -4
- package/dist/builtin-memory/insights/capture.md +6 -6
- package/dist/builtin-memory/insights/init.md +14 -14
- package/dist/builtin-memory/internal/INDEX.md +4 -4
- package/dist/builtin-memory/internal/agent-shaping.md +20 -20
- package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
- package/dist/builtin-memory/internal/marketplaces.md +2 -2
- package/dist/builtin-memory/internal/memory-loading.md +31 -30
- package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
- package/dist/builtin-memory/internal/plugins.md +16 -14
- package/dist/builtin-memory/internal/storage-tiers.md +4 -4
- package/dist/builtin-memory/memory-read-orientation.md +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
- package/dist/clients/attach/input/controller.js +1 -1
- package/dist/clients/attach/input/ref-autocomplete.js +1 -1
- package/dist/clients/attach/input/titled-editor.js +1 -1
- package/dist/clients/attach/render/chat-view.js +1 -1
- package/dist/clients/attach/render/crtr-output.d.ts +1 -2
- package/dist/clients/attach/render/crtr-output.js +17 -17
- package/dist/clients/attach/render/group-activity.d.ts +8 -8
- package/dist/clients/attach/render/group-activity.js +2 -2
- package/dist/clients/attach/render/group-recap.js +1 -1
- package/dist/clients/attach/render/tool-calls.d.ts +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/slash/dispatch.js +1 -1
- package/dist/clients/attach/viewer.js +806 -1553
- package/dist/commands/api-client.d.ts +2 -0
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/canvas/edges.d.ts +2 -0
- package/dist/commands/canvas/edges.js +2 -0
- package/dist/commands/canvas/list.d.ts +4 -0
- package/dist/commands/canvas/list.js +3 -0
- package/dist/commands/canvas/read.d.ts +8 -0
- package/dist/commands/canvas/read.js +5 -0
- package/dist/commands/canvas/search.d.ts +2 -0
- package/dist/commands/canvas/search.js +3 -0
- package/dist/commands/canvas/unwatch.d.ts +2 -0
- package/dist/commands/canvas/unwatch.js +1 -0
- package/dist/commands/canvas/watch.d.ts +3 -0
- package/dist/commands/canvas/watch.js +1 -0
- package/dist/commands/canvas-analytics.js +1 -1
- package/dist/commands/canvas-history/grep.js +4 -4
- package/dist/commands/canvas-history/read.js +2 -2
- package/dist/commands/canvas-history/search.js +7 -7
- package/dist/commands/canvas-history/shared.d.ts +0 -1
- package/dist/commands/canvas-history/shared.js +1 -1
- package/dist/commands/canvas-history/stats.js +2 -2
- package/dist/commands/canvas-history.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/doc/delete.d.ts +2 -0
- package/dist/commands/doc/delete.js +1 -0
- package/dist/commands/doc/edit.d.ts +2 -0
- package/dist/commands/doc/edit.js +1 -0
- package/dist/commands/doc/history.d.ts +2 -0
- package/dist/commands/doc/history.js +2 -0
- package/dist/commands/doc/lint.d.ts +2 -0
- package/dist/commands/doc/lint.js +2 -0
- package/dist/commands/doc/list.d.ts +2 -0
- package/dist/commands/doc/list.js +1 -0
- package/dist/commands/doc/move.d.ts +2 -0
- package/dist/commands/doc/move.js +1 -0
- package/dist/commands/doc/read.d.ts +2 -0
- package/dist/commands/doc/read.js +1 -0
- package/dist/commands/doc/shared.d.ts +25 -0
- package/dist/commands/doc/shared.js +2 -0
- package/dist/commands/doc/write.d.ts +2 -0
- package/dist/commands/doc/write.js +1 -0
- package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
- package/dist/commands/doc.js +1 -0
- package/dist/commands/human/review.js +1 -1
- package/dist/commands/node/bash.js +2 -2
- package/dist/commands/node/create.js +1 -1
- package/dist/commands/node/inspect.js +10 -10
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node/outcome.js +1 -1
- package/dist/commands/node/subscription.js +1 -1
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/doc-view.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +9 -17
- package/dist/commands/pkg/plugin-inspect.js +1 -1
- package/dist/commands/pkg/plugin-manage.d.ts +4 -8
- package/dist/commands/pkg/plugin-manage.js +15 -17
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/context/admin/actions.d.ts +18 -43
- package/dist/commands/sys/context/admin/actions.js +1 -2
- package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
- package/dist/commands/sys/context/admin/detail-panel.js +2 -1
- package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
- package/dist/commands/sys/context/admin/docs-panel.js +1 -1
- package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
- package/dist/commands/sys/context/admin/list-view.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +96 -69
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
- package/dist/commands/sys/context/admin/rail-panel.js +1 -1
- package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
- package/dist/commands/sys/context/admin/read-view.js +1 -2
- package/dist/commands/sys/context/admin/shell.d.ts +26 -31
- package/dist/commands/sys/context/admin/shell.js +1 -1
- package/dist/commands/sys/context/admin.js +2 -2
- package/dist/commands/sys/context/doc.js +2 -3
- package/dist/commands/sys/context/expose.js +2 -2
- package/dist/commands/sys/context/prompt-review.js +4 -4
- package/dist/commands/sys/context/resolve.d.ts +92 -65
- package/dist/commands/sys/context/resolve.js +7 -9
- package/dist/commands/sys/context.js +1 -1
- package/dist/commands/sys/doctor.js +1 -1
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/sync-deps.d.ts +6 -11
- package/dist/commands/sys/sync-deps.js +7 -8
- package/dist/commands/sys/sync-project-guidance.js +5 -4
- package/dist/commands/sys/sync-shared.d.ts +41 -4
- package/dist/commands/sys/sync-shared.js +1 -1
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/sync.js +1 -1
- package/dist/core/bash-job-supervisor.d.ts +2 -3
- package/dist/core/bash-job-supervisor.js +3 -3
- package/dist/core/bash-jobs.d.ts +0 -5
- package/dist/core/bash-jobs.js +7 -7
- package/dist/core/bootstrap.js +2 -2
- package/dist/core/canvas/canvas.d.ts +6 -50
- package/dist/core/canvas/canvas.js +16 -21
- package/dist/core/canvas/db.d.ts +4 -1
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/history.d.ts +11 -39
- package/dist/core/canvas/history.js +9 -20
- package/dist/core/canvas/install-id.d.ts +2 -2
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/memory-reads.d.ts +5 -0
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/migrations.js +215 -41
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.js +1 -1
- package/dist/core/canvas/paths.d.ts +0 -4
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
- package/dist/core/canvas/remote-canvas-source.js +1 -1
- package/dist/core/canvas/render-source.d.ts +9 -6
- package/dist/core/canvas/render-source.js +6 -6
- package/dist/core/canvas/sessions.js +2 -2
- package/dist/core/canvas/source.d.ts +6 -0
- package/dist/core/canvas/tree.d.ts +29 -0
- package/dist/core/canvas/tree.js +12 -0
- package/dist/core/canvas/types.d.ts +0 -20
- package/dist/core/command-plugins/bundle.js +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/conversation-store/listener.js +4 -2
- package/dist/core/feed/feed.d.ts +9 -7
- package/dist/core/feed/feed.js +3 -7
- package/dist/core/feed/inbox.d.ts +3 -5
- package/dist/core/feed/inbox.js +1 -10
- package/dist/core/feed/messages.d.ts +33 -6
- package/dist/core/feed/messages.js +10 -7
- package/dist/core/feed/reports.d.ts +10 -0
- package/dist/core/feed/reports.js +2 -0
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/graph/access.d.ts +24 -0
- package/dist/core/graph/access.js +8 -0
- package/dist/core/graph/bodies.d.ts +6 -0
- package/dist/core/graph/bodies.js +1 -0
- package/dist/core/graph/deletion.d.ts +9 -0
- package/dist/core/graph/deletion.js +5 -0
- package/dist/core/graph/diff.d.ts +4 -0
- package/dist/core/graph/diff.js +4 -0
- package/dist/core/graph/documents.d.ts +160 -0
- package/dist/core/graph/documents.js +7 -0
- package/dist/core/graph/edges.d.ts +24 -0
- package/dist/core/graph/edges.js +1 -0
- package/dist/core/graph/events.d.ts +26 -0
- package/dist/core/graph/events.js +6 -0
- package/dist/core/graph/exposures.d.ts +53 -0
- package/dist/core/graph/exposures.js +4 -0
- package/dist/core/graph/jobs.d.ts +31 -0
- package/dist/core/graph/jobs.js +2 -0
- package/dist/core/graph/names.d.ts +28 -0
- package/dist/core/graph/names.js +3 -0
- package/dist/core/graph/objects.d.ts +55 -0
- package/dist/core/graph/objects.js +9 -0
- package/dist/core/graph/package-docs.d.ts +31 -0
- package/dist/core/graph/package-docs.js +5 -0
- package/dist/core/graph/package-files.d.ts +20 -0
- package/dist/core/graph/package-files.js +2 -0
- package/dist/core/graph/reader.d.ts +21 -0
- package/dist/core/graph/reader.js +3 -0
- package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
- package/dist/core/graph/repo-sync/exchange.js +2 -0
- package/dist/core/graph/repo-sync/identity.d.ts +30 -0
- package/dist/core/graph/repo-sync/identity.js +1 -0
- package/dist/core/graph/repo-sync/index.d.ts +4 -0
- package/dist/core/graph/repo-sync/index.js +1 -0
- package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
- package/dist/core/graph/repo-sync/mirror.js +6 -0
- package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
- package/dist/core/graph/repo-sync/ref-format.js +2 -0
- package/dist/core/graph/repo-sync/repos.d.ts +17 -0
- package/dist/core/graph/repo-sync/repos.js +3 -0
- package/dist/core/graph/repo-sync/sync.d.ts +42 -0
- package/dist/core/graph/repo-sync/sync.js +2 -0
- package/dist/core/graph/rules.d.ts +26 -0
- package/dist/core/graph/rules.js +3 -0
- package/dist/core/graph/spaces/app.d.ts +3 -0
- package/dist/core/graph/spaces/app.js +1 -0
- package/dist/core/graph/spaces/index.d.ts +19 -0
- package/dist/core/graph/spaces/index.js +1 -0
- package/dist/core/graph/spaces/person.d.ts +5 -0
- package/dist/core/graph/spaces/person.js +2 -0
- package/dist/core/graph/spaces/repo.d.ts +4 -0
- package/dist/core/graph/spaces/repo.js +1 -0
- package/dist/core/graph/types.d.ts +75 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/graph/watches.d.ts +62 -0
- package/dist/core/graph/watches.js +18 -0
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/requests.d.ts +3 -1
- package/dist/core/human/requests.js +6 -6
- package/dist/core/inspector/model.js +2 -2
- package/dist/core/io.js +5 -5
- package/dist/core/layout-migrate/index.d.ts +24 -1
- package/dist/core/layout-migrate/index.js +4 -4
- package/dist/core/layout-migrate/paths.d.ts +4 -0
- package/dist/core/layout-migrate/paths.js +1 -1
- package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -11
- package/dist/core/layout-migrate/stores.d.ts +19 -6
- package/dist/core/layout-migrate/stores.js +3 -4
- package/dist/core/manifest.d.ts +0 -2
- package/dist/core/manifest.js +1 -1
- package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
- package/dist/core/plugin-extensions.js +1 -0
- package/dist/core/preview-registry.d.ts +1 -1
- package/dist/core/preview-registry.js +3 -2
- package/dist/core/profiles/manifest.d.ts +7 -7
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/select.js +3 -3
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/stage.d.ts +12 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +2 -0
- package/dist/core/review/store.js +1 -1
- package/dist/core/review/types.d.ts +7 -1
- package/dist/core/runs/events.js +1 -1
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.js +2 -2
- package/dist/core/runtime/bearings-render.d.ts +13 -7
- package/dist/core/runtime/bearings-render.js +12 -12
- package/dist/core/runtime/bearings.d.ts +8 -18
- package/dist/core/runtime/bearings.js +7 -7
- package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -4
- package/dist/core/runtime/broker/inbox.js +1 -10
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
- package/dist/core/runtime/broker/retry-card-elision.js +1 -0
- package/dist/core/runtime/broker-extension-render.d.ts +0 -13
- package/dist/core/runtime/broker-extension-render.js +2 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -4
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/kickoff.js +17 -19
- package/dist/core/runtime/launch-target.d.ts +7 -0
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +10 -0
- package/dist/core/runtime/ledger.js +3 -0
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/nodes.d.ts +10 -2
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +2 -2
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +2 -2
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/prospective-inventory-cli.js +2 -2
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +17 -9
- package/dist/core/runtime/roadmap.js +4 -4
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -3
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/structured-output.d.ts +3 -1
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/scope.d.ts +1 -32
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +2 -1
- package/dist/core/scoped-state/migrate.js +2 -2
- package/dist/core/scoped-state/profiles.d.ts +11 -0
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +1 -1
- package/dist/core/scoped-state/schema.js +7 -5
- package/dist/core/spaces/permissions.d.ts +0 -14
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/stop.d.ts +13 -0
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/storage/tables.d.ts +1 -1
- package/dist/core/substrate/delivery/corpus.d.ts +21 -0
- package/dist/core/substrate/delivery/corpus.js +3 -0
- package/dist/core/substrate/delivery/deliver.d.ts +76 -0
- package/dist/core/substrate/delivery/deliver.js +6 -0
- package/dist/core/substrate/delivery/listings.d.ts +27 -0
- package/dist/core/substrate/delivery/listings.js +4 -0
- package/dist/core/substrate/delivery/match.d.ts +28 -0
- package/dist/core/substrate/delivery/match.js +1 -0
- package/dist/core/substrate/delivery/plan.d.ts +67 -0
- package/dist/core/substrate/delivery/plan.js +3 -0
- package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
- package/dist/core/substrate/delivery/render-boot.js +54 -0
- package/dist/core/substrate/delivery/render-event.d.ts +47 -0
- package/dist/core/substrate/delivery/render-event.js +6 -0
- package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
- package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
- package/dist/core/substrate/delivery/types.d.ts +30 -0
- package/dist/core/substrate/delivery/types.js +0 -0
- package/dist/core/substrate/gate-explain.d.ts +0 -13
- package/dist/core/substrate/gate-explain.js +1 -1
- package/dist/core/substrate/schema.d.ts +11 -139
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/substrate/subject-fields.d.ts +3 -0
- package/dist/core/substrate/subject.d.ts +2 -1
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/app-listener.js +11 -11
- package/dist/daemon/api/handlers/app-profiles.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -2
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +5 -5
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/delivery.d.ts +2 -0
- package/dist/daemon/api/handlers/delivery.js +1 -0
- package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
- package/dist/daemon/api/handlers/docs.js +1 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/modelauth.d.ts +3 -0
- package/dist/daemon/api/handlers/modelauth.js +1 -1
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.d.ts +2 -0
- package/dist/daemon/api/handlers/objects.js +5 -0
- package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
- package/dist/daemon/api/handlers/package-docs.js +1 -0
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +2 -2
- package/dist/daemon/api/handlers/reports.js +4 -4
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/vendor-status.d.ts +8 -0
- package/dist/daemon/api/handlers/vendor-status.js +1 -0
- package/dist/daemon/api/map.d.ts +2 -2
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/principal.d.ts +5 -0
- package/dist/daemon/api/principal.js +1 -1
- package/dist/daemon/api/reader.d.ts +17 -0
- package/dist/daemon/api/reader.js +1 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/control.d.ts +2 -3
- package/dist/daemon/crtrd.js +8 -6
- package/dist/daemon/fleet.js +4 -4
- package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/review/deliver.js +2 -2
- package/dist/daemon/review/finish.js +1 -1
- package/dist/hook-authoring.d.ts +0 -1
- package/dist/hook-authoring.js +3 -3
- package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
- package/dist/migrations/004-canvas-documents/apply.js +1 -0
- package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
- package/dist/migrations/004-canvas-documents/fields.js +2 -0
- package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/index.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
- package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
- package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
- package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
- package/dist/migrations/004-canvas-documents/plan.js +3 -0
- package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
- package/dist/migrations/004-canvas-documents/pointers.js +4 -0
- package/dist/migrations/activation.d.ts +9 -18
- package/dist/migrations/activation.js +2 -2
- package/dist/pi-extensions/broker-local.d.ts +2 -2
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.js +5 -4
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/dist/pi-extensions/canvas-passive-context.js +1 -1
- package/dist/pi-extensions/canvas-recap.js +2 -2
- package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/prompts/review.js +3 -3
- package/dist/shared/env.d.ts +5 -0
- package/dist/shared/env.js +1 -1
- package/dist/shared/generated-context.js +2 -10
- package/dist/shared/inbox-entry-body.d.ts +22 -0
- package/dist/shared/inbox-entry-body.js +10 -0
- package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
- package/dist/shared/inline-ref-guidance.js +2 -0
- package/dist/types.d.ts +3 -1
- package/docs/cli/memory-and-preferences.md +12 -14
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/lifecycle-and-wakes.md +1 -1
- package/docs/concepts/memory.md +15 -15
- package/docs/concepts/nodes-and-the-canvas.md +1 -1
- package/docs/concepts/profiles-kinds-and-modes.md +5 -5
- package/docs/concepts/scopes-and-trust.md +1 -1
- package/docs/concepts/why-a-daemon.md +1 -1
- package/docs/sdk/README.md +5 -6
- package/docs/sdk/errors.md +0 -13
- package/docs/sdk/guides/README.md +0 -1
- package/docs/sdk/nodes.md +0 -2
- package/docs/sdk/resources.md +0 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +11 -11
- package/dist/api/dto/memory.d.ts +0 -171
- package/dist/api/dto/memory.js +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
- package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
- package/dist/commands/broker-permissions.d.ts +0 -2
- package/dist/commands/broker-permissions.js +0 -1
- package/dist/commands/memory/client.d.ts +0 -11
- package/dist/commands/memory/client.js +0 -1
- package/dist/commands/memory/delete.d.ts +0 -1
- package/dist/commands/memory/delete.js +0 -1
- package/dist/commands/memory/edit.d.ts +0 -1
- package/dist/commands/memory/edit.js +0 -21
- package/dist/commands/memory/find.d.ts +0 -1
- package/dist/commands/memory/find.js +0 -1
- package/dist/commands/memory/history.d.ts +0 -1
- package/dist/commands/memory/history.js +0 -5
- package/dist/commands/memory/lint.d.ts +0 -1
- package/dist/commands/memory/lint.js +0 -1
- package/dist/commands/memory/list.d.ts +0 -1
- package/dist/commands/memory/list.js +0 -1
- package/dist/commands/memory/move.d.ts +0 -1
- package/dist/commands/memory/move.js +0 -1
- package/dist/commands/memory/origin.d.ts +0 -1
- package/dist/commands/memory/origin.js +0 -1
- package/dist/commands/memory/read.d.ts +0 -1
- package/dist/commands/memory/read.js +0 -6
- package/dist/commands/memory/shared.d.ts +0 -22
- package/dist/commands/memory/shared.js +0 -1
- package/dist/commands/memory/write.d.ts +0 -1
- package/dist/commands/memory/write.js +0 -13
- package/dist/commands/memory.js +0 -1
- package/dist/commands/node-inspect-artifacts.d.ts +0 -1
- package/dist/commands/node-inspect-artifacts.js +0 -8
- package/dist/core/help/memory-extensions.d.ts +0 -3
- package/dist/core/help/memory-extensions.js +0 -2
- package/dist/core/memory/cli-selector.d.ts +0 -13
- package/dist/core/memory/cli-selector.js +0 -1
- package/dist/core/memory/doc-link-grammar.d.ts +0 -20
- package/dist/core/memory/doc-link-grammar.js +0 -2
- package/dist/core/memory/extensions.js +0 -1
- package/dist/core/memory/history.d.ts +0 -87
- package/dist/core/memory/history.js +0 -6
- package/dist/core/memory/identity.d.ts +0 -65
- package/dist/core/memory/identity.js +0 -1
- package/dist/core/memory/inline-ref-guidance.js +0 -2
- package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
- package/dist/core/memory/inline-ref-inventory.js +0 -1
- package/dist/core/memory/lint.d.ts +0 -163
- package/dist/core/memory/lint.js +0 -2
- package/dist/core/memory/mutation-domain.d.ts +0 -113
- package/dist/core/memory/mutation-domain.js +0 -12
- package/dist/core/memory/mutations.d.ts +0 -74
- package/dist/core/memory/mutations.js +0 -1
- package/dist/core/memory/project-namespace.d.ts +0 -31
- package/dist/core/memory/project-namespace.js +0 -2
- package/dist/core/memory/repository-association.d.ts +0 -31
- package/dist/core/memory/repository-association.js +0 -1
- package/dist/core/memory/service.d.ts +0 -145
- package/dist/core/memory/service.js +0 -2
- package/dist/core/memory/tree.d.ts +0 -39
- package/dist/core/memory/tree.js +0 -1
- package/dist/core/memory-resolver.d.ts +0 -280
- package/dist/core/memory-resolver.js +0 -2
- package/dist/core/nested-stores.d.ts +0 -18
- package/dist/core/nested-stores.js +0 -1
- package/dist/core/runtime/memory.d.ts +0 -3
- package/dist/core/runtime/memory.js +0 -1
- package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
- package/dist/core/substrate/frontmatter-validation.js +0 -1
- package/dist/core/substrate/gate.d.ts +0 -16
- package/dist/core/substrate/gate.js +0 -1
- package/dist/core/substrate/index.d.ts +0 -18
- package/dist/core/substrate/index.js +0 -1
- package/dist/core/substrate/injected-store.d.ts +0 -75
- package/dist/core/substrate/injected-store.js +0 -2
- package/dist/core/substrate/listings.d.ts +0 -28
- package/dist/core/substrate/listings.js +0 -1
- package/dist/core/substrate/memory-events.d.ts +0 -6
- package/dist/core/substrate/memory-events.js +0 -1
- package/dist/core/substrate/on-read-node.d.ts +0 -6
- package/dist/core/substrate/on-read-node.js +0 -1
- package/dist/core/substrate/on-read.d.ts +0 -101
- package/dist/core/substrate/on-read.js +0 -9
- package/dist/core/substrate/plan.d.ts +0 -94
- package/dist/core/substrate/plan.js +0 -1
- package/dist/core/substrate/render-node.d.ts +0 -12
- package/dist/core/substrate/render-node.js +0 -1
- package/dist/core/substrate/render.d.ts +0 -41
- package/dist/core/substrate/render.js +0 -65
- package/dist/core/substrate/session-cache.d.ts +0 -27
- package/dist/core/substrate/session-cache.js +0 -1
- package/dist/core/substrate/surface-match.d.ts +0 -73
- package/dist/core/substrate/surface-match.js +0 -1
- package/dist/daemon/api/handlers/memory.js +0 -5
- package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
- package/dist/migrations/001-surfaces-frontmatter.js +0 -1
- package/dist/migrations/002-profile-project-memory.d.ts +0 -2
- package/dist/migrations/002-profile-project-memory.js +0 -1
- package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
- package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
- package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
- package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
- package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
- package/dist/migrations/convergent.d.ts +0 -43
- package/dist/migrations/convergent.js +0 -2
- package/dist/migrations/corpus.d.ts +0 -75
- package/dist/migrations/corpus.js +0 -3
- package/dist/migrations/frontmatter-splice.d.ts +0 -15
- package/dist/migrations/frontmatter-splice.js +0 -8
- package/dist/migrations/profile-manifests.d.ts +0 -30
- package/dist/migrations/profile-manifests.js +0 -2
- package/dist/migrations/registry.d.ts +0 -7
- package/dist/migrations/registry.js +0 -1
- package/dist/migrations/runner.d.ts +0 -43
- package/dist/migrations/runner.js +0 -1
- package/dist/migrations/types.d.ts +0 -211
- package/dist/shared/birth-announcement.d.ts +0 -12
- package/dist/shared/birth-announcement.js +0 -1
- package/docs/sdk/guides/app-memory.md +0 -22
- package/docs/sdk/memory.md +0 -85
- /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)},"render")});
|
|
1
|
+
var b=Object.defineProperty;var r=(n,t)=>b(n,"name",{value:t,configurable:!0});import{resolve as D,sep as h}from"node:path";import{defineLeaf as x}from"../../../core/command.js";import{InputError as p}from"../../../core/io.js";import{ApiError as N}from"../../../api/index.js";import{cliClient as g}from"../../api-client.js";import{envNodeId as _}from"../../../shared/env.js";import{PLANNED_EVENTS as T}from"./resolve.js";const L=x({name:"admin",description:"browse and edit what documents deliver, interactively",whenToUse:"you are shaping what agents load rather than answering one question about it \u2014 comparing node configurations, sweeping which documents deliver on which activity, and editing their rules in place",help:{name:"sys context admin",summary:"interactive browser and editor for document delivery",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Open on this live node: its own documents, cwd, profile, and configuration. Defaults to the calling node (CRTR_NODE_ID); outside a node, the page opens on a node that does not exist, working in the current directory."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Opening node kind. Defaults to the node\u2019s kind, else `general`."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,constraint:"Opening node mode. Defaults to the node\u2019s mode, else `base`."},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Profile (id or name) whose delivery limits apply. Defaults to the node\u2019s profile, else the profile pinned to the directory."},{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Directory the simulated node works in; the repos enclosing it apply. Defaults to the node\u2019s cwd, else the current directory."},{kind:"flag",name:"event",type:"enum",choices:[...T],required:!1,constraint:"Opening activity. Defaults to `boot`."}],output:[{name:"edited",type:"array",required:!1,constraint:"Names of the documents changed during the session; absent when nothing was changed."}],outputKind:"object",effects:["Interactive: requires a TTY.","Edits documents through the routes `crtr doc edit` and `crtr doc move` use, with rationale `editor`, when you choose an edit action."]},run:r(async n=>{if(!process.stdout.isTTY)throw new p({error:"not_a_tty",message:"sys context admin is interactive and needs a TTY",next:"Run it in a terminal, or use `crtr sys context resolve` and `crtr sys context doc` for scriptable reads."});const t=g(),i=a(n.node)??a(_()),e=i===void 0?null:await w(i),o=await t.listProfiles(),y=o.map(d=>({id:d.id,name:d.name})),u=a(n.cwd),f=u!==void 0?D(u):e?.cwd??process.cwd(),s=a(n.profile);let l;if(s!==void 0){const d=o.find(m=>m.id===s||m.name===s);if(d===void 0)throw new p({error:"unknown_profile",message:`No profile is named ${s}.`,next:"Run `crtr profile list` for the profile ids and names."});l=d.id}else l=e!==null?e.profile_id:q(o,f);const v={kind:a(n.kind)??e?.kind??"general",mode:n.mode??e?.mode??"base",lifecycle:e?.lifecycle??"terminal",hasManager:e?.parent!=null,profileId:l,cwd:f,nodeId:e?.node_id??null,...e===null?{}:{grantee:e.grantee},depth:e===null?0:await E(e),event:n.event??"boot",file:"",docName:"",command:"",seed:e===null?null:{cwd:e.cwd,profileId:e.profile_id}},{runContextAdmin:k}=await import("./admin/shell.js"),c=await k(v,y);return c===void 0||c.edited.length===0?{}:{edited:c.edited}},"run"),render:r(n=>{const t=n.edited??[];return t.length===0?"Closed the context admin with nothing changed.":t.map(i=>`- edited ${i}`).join(`
|
|
2
|
+
`)},"render")});function a(n){if(typeof n!="string")return;const t=n.trim();return t===""?void 0:t}r(a,"optional");function q(n,t){let i=null;for(const e of n){const o=e.default_dir;o!=null&&(t!==o&&!t.startsWith(o.endsWith(h)?o:`${o}${h}`)||(i===null||o.length>i.depth)&&(i={id:e.id,depth:o.length}))}return i?.id??null}r(q,"pinnedProfileFor");async function w(n){try{return await g().getNode(n)}catch(t){if(t instanceof N&&t.status===404)return null;throw t}}r(w,"fetchNodeOrNull");async function E(n){const t=new Set([n.node_id]);let i=n.parent,e=0;for(;i!=null&&!t.has(i);){t.add(i),e+=1;const o=await w(i);if(o===null)break;i=o.parent}return e}r(E,"spineDepth");export{L as adminLeaf};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
var v=Object.defineProperty;var a=(
|
|
2
|
-
`)}a(
|
|
3
|
-
`)}a(f,"table");export{H as docLeaf};
|
|
1
|
+
var v=Object.defineProperty;var a=(n,e)=>v(n,"name",{value:e,configurable:!0});import{defineLeaf as g}from"../../../core/command.js";import{InputError as b}from"../../../core/io.js";import{PLANNED_EVENTS as h,SNAPSHOT_PARAMS as _,buildSnapshot as j,delivers as f,describeSubject as q,dryRun as x,exclusionReason as k,nodeLine as R,snapshotHead as T,gateText as $,optionalString as l,ruleText as N,subjectFor as P,subjectSummary as S,table as p}from"./resolve.js";const W=g({name:"doc",description:"show one document\u2019s delivery across every event for one node",whenToUse:"a document is reaching a node it should not, or failing to reach one it should \u2014 this says which event delivers it, at what level, and what excluded it everywhere else",help:{name:"sys context doc",summary:"show where one document delivers to a node, at what level, and what excludes it elsewhere",params:[{kind:"positional",name:"name",required:!0,constraint:"The document as the node names it, exactly as `crtr canvas read` takes it: its bare name, or `<owner>/<name>` for a document another owner holds under the same name."},..._,{kind:"flag",name:"event",type:"enum",choices:[...h],required:!1,constraint:"Report only this rule `on` name instead of all of them."},{kind:"flag",name:"file",type:"path",required:!1,constraint:"Payload for the file-read event: the file being read. Without it, no file-read rule matches."},{kind:"flag",name:"read-name",type:"string",required:!1,constraint:"Payload for the document-read event: the document read, as `crtr canvas read` takes it. Without it, no document-read rule matches."},{kind:"flag",name:"command",type:"string",required:!1,constraint:"Payload for the command and pre-command events: the command string."}],output:[{name:"name",type:"string",required:!0,constraint:"The document\u2019s name as the node sees it."},{name:"kind",type:"string",required:!0,constraint:"knowledge or preference."},{name:"owner",type:"string",required:!0,constraint:"The owner handle: a node id, or the space or profile name."},{name:"ref",type:"string",required:!0,constraint:"The document\u2019s object id."},{name:"node",type:"string",required:!1,constraint:"The node the dry runs ran for, or the node --cwd and --profile dialled away from. Absent when the node is simulated."},{name:"cwd",type:"string",required:!1,constraint:"The simulated node\u2019s directory. Present when the node is simulated."},{name:"node_missing",type:"boolean",required:!1,constraint:"Present when --node named a node that does not exist, so the node was simulated."},{name:"subject",type:"object",required:!0,constraint:"The node configuration every row was computed under."},{name:"rules",type:"array",required:!0,constraint:"The document\u2019s rules for the reported events: on, match, if, deliver."},{name:"events",type:"array",required:!0,constraint:"One row per event: event, delivers, authored_rung, limit, capped_rung, final_rung, gate, matched_rule, winner, shadowed_by, excluded."}],outputKind:"object",effects:["None. Read-only; the dry runs record nothing."]},run:a(async n=>{const e=await j(n),r=n.name,w=l(n.event)===null?[...h]:[n.event],y={file:l(n.file),readName:l(n.readName),command:l(n.command)};let t=null,u=null;const m=[],c=[];for(const o of w){const{plan:d}=await x(e,o,P(o,y));u??=d.subject;const i=d.docs.find(s=>t!==null?s.doc.object.id===t.object.id:A(s.doc,r))??null;i!==null&&(t??=i.doc,m.push(...i.authoredRules.map(s=>s.rule))),c.push({event:o,record:i})}if(t===null)throw new b({error:"not_found",message:`no document ${r} with a delivery rule in ${e.nodeId===null?"the simulated node":`node ${e.nodeId}`}\u2019s view for these events`,field:"name",next:"Check the name with `crtr sys context resolve --all-events --all`, which lists every document the node considers."});return{name:t.displayName,kind:t.kind,owner:t.ownerHandle,ref:t.object.id,...T(e),subject:S(u),rules:m.map(E),events:c.map(({event:o,record:d})=>H(o,d,u))}},"run"),render:a(n=>L(n),"render")});function A(n,e){return n.displayName===e||`${n.ownerHandle}/${n.name}`===e}a(A,"matchesName");function E(n){return{on:n.on,match:n.match===void 0?null:n.match.join(", "),if:n.if!==void 0,deliver:n.deliver}}a(E,"ruleRow");function H(n,e,r){return e===null?{event:n,delivers:!1,authored_rung:"none",limit:null,capped_rung:"none",final_rung:"none",gate:null,matched_rule:null,winner:!1,shadowed_by:null,excluded:"no rule for this event"}:{event:n,delivers:f(e),authored_rung:e.authoredRung,limit:e.limit,capped_rung:e.cappedRung,final_rung:e.finalRung,gate:$(e,r),matched_rule:N(e.matchedRule),winner:e.winner,shadowed_by:e.shadowedBy===null?null:`${e.shadowedBy.ownerHandle}/${e.shadowedBy.name}`,excluded:f(e)?null:k(e,r)}}a(H,"eventRow");function L(n){return[`# ${n.name}`,"",`- kind: ${n.kind}`,`- owner: ${n.owner}`,`- ref: ${n.ref}`,"",R(n),`subject: ${q(n.subject)}`,"","## Rules","",n.rules.length===0?"None for these events.":p(["on","deliver","match","if"],n.rules.map(e=>[e.on,e.deliver,e.match??"\u2014",e.if?"yes":"\u2014"])),"","## Delivery per event","",p(["event","delivers","authored","limit","final","matched","if","why not"],n.events.map(e=>[e.event,e.delivers?"yes":"no",e.authored_rung,e.limit??"\u2014",e.final_rung,e.matched_rule??"\u2014",e.gate??"\u2014",e.excluded??"\u2014"]))].join(`
|
|
2
|
+
`)}a(L,"renderDoc");export{W as docLeaf};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}},"run"),render:a(
|
|
1
|
+
var d=Object.defineProperty;var a=(n,t)=>d(n,"name",{value:t,configurable:!0});import{accessSync as l,constants as c,realpathSync as f,statSync as u}from"node:fs";import{resolve as h}from"node:path";import{defineLeaf as p}from"../../../core/command.js";import{expandTilde as m}from"../../../core/fs-utils.js";import{brokerDelivery as y}from"../../../core/runtime/broker/daemon-ops.js";import{envExecutionId as v,envNodeId as b}from"../../../shared/env.js";function g(n){const t=[],o=new Set;for(const s of n)try{const e=f(h(m(s)));if(l(e,c.R_OK),!u(e).isFile()||o.has(e))continue;o.add(e),t.push(e)}catch{}return t}a(g,"readableRegularFiles");const D=p({name:"expose",description:"deliver file-read documents for file content a local command displays",whenToUse:"a local command has successfully rendered file contents and must place the documents their file-read rules deliver in that same output",help:{name:"sys context expose",summary:"deliver file-read documents for files displayed by a command",params:[{kind:"flag",name:"file",type:"path",required:!0,repeatable:!0,constraint:"Files whose contents the caller displays. Relative paths resolve against this process\u2019s cwd; leading ~ expands as for Read. Symlinks resolve to their target. Missing, unreadable, and non-file paths contribute nothing."}],output:[{name:"content",type:"string",required:!1,constraint:"The delivered <auto-loaded-context> blocks, one per displayed file with new matches. Absent when nothing new matches or the caller is not inside a node. Prose output is the blocks alone, without a field label or acknowledgement."}],outputKind:"object",effects:["Delivers through the current node\u2019s file-read activity: records its exposures, and a watch and read event for each document delivered at content. Inherits node identity from CRTR_NODE_ID. The caller must include the returned blocks in the same output as the displayed files; this is not a preview operation."]},run:a(async n=>{const t=b()?.trim();if(t===void 0||t==="")return{};const o=g(n.file);if(o.length===0)return{};const s=v();if(s===void 0||s==="")return{};const e=[];for(const i of o){const r=await y(t,{activity:"file-read",subject:i});r.content!==""&&e.push(r.content)}return e.length===0?{}:{content:e.join(`
|
|
2
|
+
`)}},"run"),render:a(n=>n.content??"","render")});export{D as exposeLeaf};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $=Object.defineProperty;var o=(n,e)=>$(n,"name",{value:e,configurable:!0});import{mkdirSync as q,writeFileSync as S}from"node:fs";import{join as y}from"node:path";import{defineLeaf as P}from"../../../core/command.js";import{InputError as c,readStdinRaw as _}from"../../../core/io.js";import{userScopeRoot as j}from"../../../core/scope.js";import{ApiError as M}from"../../../api/index.js";import{cliClient as w}from"../../api-client.js";import{envNodeId as D}from"../../../shared/env.js";import{readMergedLaunchConfig as L,subKindsAvailableTo as O}from"../../../core/config.js";import{LAUNCH_SYSTEM_PROMPT as u}from"../../../core/runtime/launch-prompt.js";function R(n,e){return e!==void 0?e:n==="orchestrator"?"resident":"terminal"}o(R,"resolveLifecycle");function N(n){try{return JSON.parse(n)}catch(e){throw new c({error:"invalid_json",message:`stdin is not valid JSON: ${String(e)}`,field:"stdin",next:"Pass the comments deck JSON on stdin."})}}o(N,"readJson");function b(n,e,r){if(n===void 0)return r;if(n===!0||n===!1)return n;if(typeof n!="string")throw new c({error:"invalid_field",message:`${e} must be true or false`,field:e,next:`Use true or false for ${e}.`});const t=n.trim().toLowerCase();if(t==="true")return!0;if(t==="false")return!1;throw new c({error:"invalid_field",message:`${e} must be true or false`,field:e,next:`Use true or false for ${e}.`})}o(b,"parseBool");function T(n){return typeof n=="string"&&n.trim()!==""?n:null}o(T,"optionalString");function p(n){return Math.ceil(n.length/4)}o(p,"approxTokens");function C(){const n=L().kinds;return Object.entries(n).filter(([e])=>!e.includes("/")).map(([e,r])=>({kind:e,whenToUse:r.whenToUse})).sort((e,r)=>e.kind.localeCompare(r.kind))}o(C,"topLevelKinds");function U(n){return O(n)}o(U,"subKindsFor");function I(){const n=C(),e={};for(const{kind:r}of n)e[r]=U(r);return{kinds:n,modes:["base","orchestrator"],lifecycles:["terminal","resident"],subPersonas:e}}o(I,"reviewList");async function A(n){if(n===null)return null;try{return await w().getNode(n)}catch(e){if(e instanceof M&&e.status===404)return null;throw e}}o(A,"fetchNodeOrNull");async function k(n,e,r){const t=await w().nodeDelivery(n,{dry_run:!0,activity:e,subject_override:r});return{content:t.content,docs:t.plan?.docs??[]}}o(k,"dryRun");function E(n,e){const t=n.indexOf(`
|
|
2
2
|
|
|
3
3
|
Guidelines:`);return t===-1?`${n}
|
|
4
4
|
|
|
5
5
|
${e}`:`${n.slice(0,t)}
|
|
6
6
|
|
|
7
|
-
${e}${n.slice(t)}`}
|
|
7
|
+
${e}${n.slice(t)}`}o(E,"spliceIntoScaffold");function J(){const n=y(j(),"prompt-reviews");return q(n,{recursive:!0}),y(n,`${new Date().toISOString()}.md`)}o(J,"promptReviewPath");function K(n){const e=[];if(e.push(`# Prompt review \u2014 ${n.config.kind}/${n.config.mode}`),e.push(""),e.push("## Config"),e.push(`- timestamp: ${new Date().toISOString()}`),e.push(`- kind: ${n.config.kind}`),e.push(`- mode: ${n.config.mode}`),e.push(`- lifecycle: ${n.config.lifecycle}`),e.push(`- hasManager: ${String(n.config.hasManager)}`),e.push(`- node: ${n.config.node??"(none)"}`),e.push(""),e.push("## Comments"),n.comments.length===0)e.push("- none");else{for(const t of n.comments)e.push(`### ${t.label} (${t.layerId})`),e.push(`- source: \`${t.sourcePath??"(generated)"}\` (${t.scope})`),t.anchor!==null&&e.push("> "+t.anchor.split(`
|
|
8
8
|
`).join(`
|
|
9
|
-
> `)),e.push(t.body),e.push("");e[e.length-1]===""&&e.pop()}e.push(""),e.push("## Prompt sources (edit these)");const r=new Set;for(const t of n.sources){const i=`${t.scope}:${t.path}`;r.has(i)||(r.add(i),e.push(`- ${t.label} \u2014 \`${t.path}\` (${t.scope})`))}return e.push(""),e.push("These are review comments on an assembled system prompt; edit the listed
|
|
9
|
+
> `)),e.push(t.body),e.push("");e[e.length-1]===""&&e.pop()}e.push(""),e.push("## Prompt sources (edit these documents)");const r=new Set;for(const t of n.sources){const i=`${t.scope}:${t.path}`;r.has(i)||(r.add(i),e.push(`- ${t.label} \u2014 \`${t.path}\` (${t.scope})`))}return e.push(""),e.push("These are review comments on an assembled system prompt; edit the listed documents (ref and owner) with `crtr doc edit` to address them."),e.join(`
|
|
10
10
|
`)+`
|
|
11
|
-
`}
|
|
11
|
+
`}o(K,"renderExportDeck");function B(n){const e=J();return S(e,K(n),"utf8"),{path:e}}o(B,"exportReview");async function F(n){const e=n.kind,r=n.mode??"base",t=R(r,n.lifecycle),i=b(n.hasManager,"hasManager",!0),f=T(n.node);if(e===void 0||e.trim()==="")throw new c({error:"missing_parameter",message:"kind is required",field:"kind",next:"Pass --kind <kind> or use --list."});const a=await A(f??D()??null);if(a===null)throw new c({error:"missing_parameter",message:"prompt-review needs an existing node whose view it renders",field:"node",next:"Pass --node <id> of a node that exists, or run from inside a node."});const g={kind:e,mode:r,lifecycle:t,hasManager:i},d=(await k(a.node_id,"system-prompt",g)).content,l=await k(a.node_id,"boot",g),x=l.docs.filter(s=>s.winner&&s.finalRung==="content"&&!s.doc.ownNode&&s.doc.kind==="preference"),m=[{id:"launch-scaffold",label:"Launch scaffold",group:"generated",source:"generated: launch scaffold",sourcePath:null,scope:"generated",included:!0,condition:null,text:u,tokens:p(u),chars:u.length}];d!==""&&m.push({id:"preferences",label:"Preferences",group:"substrate",source:"delivery: system-prompt",sourcePath:null,scope:"generated",included:!0,condition:null,text:d,tokens:p(d),chars:d.length}),l.content!==""&&m.push({id:"boot-context",label:"Boot context \u2014 context message, not system prompt",group:"substrate",source:"delivery: boot",sourcePath:null,scope:"runtime",included:!1,condition:"session_start context message, not the system prompt",text:l.content,tokens:p(l.content),chars:l.content.length});const h=E(u,d),v=x.map(s=>({id:s.doc.displayName,label:s.doc.displayName,path:s.doc.object.id,scope:s.doc.ownerHandle}));return{config:{kind:e,mode:r,lifecycle:t,hasManager:i,node:a?.node_id??null},layers:m,assembled:h,total:{tokens:p(h),chars:h.length},sources:v}}o(F,"resolveDeck");const te=P({name:"prompt-review",description:"inspect an assembled prompt and export review notes",whenToUse:"you want to inspect a composed persona prompt for a kind/mode combo, compare the space around it, or export review notes back to source files",help:{name:"sys context prompt-review",summary:"inspect an assembled prompt and export review notes",params:[{kind:"positional",name:"action",type:"string",required:!1,constraint:"Optional subcommand: export. Omit for the assembled prompt contract."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Persona kind to inspect. Required unless --list or export."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,default:"base",constraint:"Persona mode. Default: base."},{kind:"flag",name:"lifecycle",type:"enum",choices:["terminal","resident"],required:!1,constraint:"Lifecycle axis. Default: base -> terminal, orchestrator -> resident."},{kind:"flag",name:"has-manager",type:"string",required:!1,default:"true",constraint:"Whether the node reports to a manager. Use true or false. Default: true."},{kind:"flag",name:"node",type:"string",required:!1,constraint:"The node whose view and profile limits render the prompt. Defaults to the calling node (CRTR_NODE_ID); the node must exist unless --list or export."},{kind:"flag",name:"list",type:"bool",required:!1,constraint:"List the available kinds, modes, lifecycles, and sub-personas."}],output:[{name:"config",type:"object",required:!1,constraint:"Resolved config: {kind, mode, lifecycle, hasManager, node}."},{name:"layers",type:"object[]",required:!1,constraint:"Ordered prompt layers, including excluded alternatives and provenance."},{name:"assembled",type:"string",required:!1,constraint:"The assembled prompt string."},{name:"total",type:"object",required:!1,constraint:"Approximate token/char totals for included layers."},{name:"sources",type:"object[]",required:!1,constraint:"The preference documents delivered into the prompt: {id, label, path (the document ref), scope (the owner)}."},{name:"kinds",type:"object[]",required:!1,constraint:"Available kinds for --list."},{name:"modes",type:"string[]",required:!1,constraint:"Mode choices for --list."},{name:"lifecycles",type:"string[]",required:!1,constraint:"Lifecycle choices for --list."},{name:"subPersonas",type:"object",required:!1,constraint:"Available sub-personas keyed by kind for --list."},{name:"path",type:"string",required:!1,constraint:"Written markdown path for export."}],outputKind:"object",effects:["Read-only inspection, or writes a review markdown file under `~/.crouter/prompt-reviews/`."]},run:o(async n=>{const e=n.action,r=n.list===!0,t=b(n.hasManager,"hasManager",!0);if(e!==void 0&&e!=="export")throw new c({error:"unknown_action",message:`unknown action: ${e}`,field:"action",next:"Use `export` or omit the positional action."});if(e==="export"){const f=await _(),a=N(f);return B(a)}return r?I():await F({...n,hasManager:t})},"run")});export{te as promptReviewLeaf};
|
|
@@ -1,88 +1,115 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { InputParam } from '../../../core/help.js';
|
|
2
|
+
import type { DeliveryActivity, HypotheticalNodeDTO } from '../../../api/dto/delivery.js';
|
|
3
|
+
import type { NodeConfigSubject } from '../../../core/substrate/subject-fields.js';
|
|
4
|
+
import { type Rung } from '../../../core/substrate/schema.js';
|
|
5
|
+
/** The activities whose dry run carries a plan: each is a rule `on` name. */
|
|
6
|
+
export declare const PLANNED_EVENTS: readonly ["boot", "workspace-open", "file-read", "document-read", "command", "pre-command", "slash-command"];
|
|
7
|
+
export type PlannedEvent = (typeof PLANNED_EVENTS)[number];
|
|
8
|
+
declare const SNAPSHOT_PARAMS: InputParam[];
|
|
9
|
+
export { SNAPSHOT_PARAMS };
|
|
7
10
|
export declare const resolveLeaf: import("../../../core/command.js").LeafDef;
|
|
8
11
|
export interface ContextSnapshot {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
+
/** A live node the dry run reads, or starts a simulation from. */
|
|
13
|
+
nodeId: string | null;
|
|
14
|
+
/** The simulated node; null when the dry run reads a live node as it is. */
|
|
15
|
+
hypothetical: HypotheticalNodeDTO | null;
|
|
16
|
+
override: Partial<NodeConfigSubject>;
|
|
17
|
+
/** --node named an id that does not exist; the node is simulated. */
|
|
12
18
|
nodeMissing: boolean;
|
|
13
19
|
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
20
|
+
/** A live node when one is named (or this runs inside one) and neither --cwd
|
|
21
|
+
* nor --profile dials it; otherwise a simulated node, starting from the live
|
|
22
|
+
* node when there is one. */
|
|
17
23
|
export declare function buildSnapshot(input: Record<string, unknown>): Promise<ContextSnapshot>;
|
|
18
|
-
/** The
|
|
19
|
-
|
|
24
|
+
/** The fields every result leads with: which node, or which simulated one. */
|
|
25
|
+
export declare function snapshotHead(snapshot: ContextSnapshot): Record<string, unknown>;
|
|
20
26
|
export interface PayloadFlags {
|
|
21
27
|
file: string | null;
|
|
28
|
+
/** `document-read`: the document read. */
|
|
22
29
|
readName: string | null;
|
|
23
30
|
command: string | null;
|
|
24
31
|
}
|
|
25
|
-
/** The
|
|
26
|
-
* without its payload matches nothing
|
|
27
|
-
export declare function
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
/** The activity's subject string from the flags that carry it. An activity
|
|
33
|
+
* invoked without its payload matches nothing. */
|
|
34
|
+
export declare function subjectFor(event: PlannedEvent, flags: PayloadFlags): string | undefined;
|
|
35
|
+
export interface PlanRule {
|
|
36
|
+
on: string;
|
|
37
|
+
match?: string[];
|
|
38
|
+
matchFrontmatter?: Record<string, unknown>;
|
|
39
|
+
if?: unknown;
|
|
40
|
+
deliver: Rung;
|
|
41
|
+
}
|
|
42
|
+
export interface PlanDoc {
|
|
43
|
+
object: {
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
ownerHandle: string;
|
|
47
|
+
kind: string;
|
|
48
|
+
name: string;
|
|
49
|
+
displayName: string;
|
|
33
50
|
}
|
|
51
|
+
export type GateOutcome = {
|
|
52
|
+
pass: true;
|
|
53
|
+
} | {
|
|
54
|
+
pass: false;
|
|
55
|
+
reason: string;
|
|
56
|
+
};
|
|
57
|
+
export interface PlanRecord {
|
|
58
|
+
doc: PlanDoc;
|
|
59
|
+
authoredRules: Array<{
|
|
60
|
+
rule: PlanRule;
|
|
61
|
+
matched: boolean;
|
|
62
|
+
gate: GateOutcome;
|
|
63
|
+
}>;
|
|
64
|
+
matchedRule: PlanRule | null;
|
|
65
|
+
authoredRung: Rung;
|
|
66
|
+
limit: Rung | null;
|
|
67
|
+
cappedRung: Rung;
|
|
68
|
+
ruleGate: GateOutcome | null;
|
|
69
|
+
finalRung: Rung;
|
|
70
|
+
winner: boolean;
|
|
71
|
+
shadowedBy: PlanDoc | null;
|
|
72
|
+
}
|
|
73
|
+
export interface Plan {
|
|
74
|
+
on: string;
|
|
75
|
+
subject: NodeConfigSubject | null;
|
|
76
|
+
docs: PlanRecord[];
|
|
77
|
+
}
|
|
78
|
+
export declare function dryRun(snapshot: ContextSnapshot, activity: DeliveryActivity, subject?: string): Promise<{
|
|
79
|
+
plan: Plan;
|
|
80
|
+
content: string;
|
|
81
|
+
}>;
|
|
82
|
+
export declare function subjectSummary(subject: NodeConfigSubject | null): Record<string, unknown>;
|
|
83
|
+
export declare function optionalString(value: unknown): string | null;
|
|
34
84
|
export interface DocRow {
|
|
35
85
|
name: string;
|
|
36
86
|
kind: string;
|
|
37
|
-
|
|
38
|
-
|
|
87
|
+
owner: string;
|
|
88
|
+
ref: string;
|
|
39
89
|
authored_rung: Rung;
|
|
40
|
-
|
|
90
|
+
limit: Rung | null;
|
|
41
91
|
capped_rung: Rung;
|
|
42
92
|
final_rung: Rung;
|
|
43
93
|
winner: boolean;
|
|
44
94
|
shadowed_by: string | null;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
matched_entry: string | null;
|
|
48
|
-
delivery_cause?: string;
|
|
95
|
+
gate: string | null;
|
|
96
|
+
matched_rule: string | null;
|
|
49
97
|
excluded?: string;
|
|
50
98
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export declare function docRow(record: EffectiveDeliveryRecord, includeAll: boolean, subject: NodeConfigSubject | null): DocRow;
|
|
66
|
-
/** A gate verdict as one cell: `pass`, or `fail:` plus the clauses that failed
|
|
67
|
-
* — the planner's generic sentence only when the explainer cannot decompose
|
|
68
|
-
* the predicate. */
|
|
69
|
-
export declare function gateText(gate: GateOutcome, clauses: readonly GateClause[]): string;
|
|
70
|
-
export declare function entryText(entry: SurfaceEntry | null): string | null;
|
|
71
|
-
/** Why a considered document delivers nothing, in the order the planner applies
|
|
72
|
-
* its checks — the first failing one is the answer an engineer acts on. */
|
|
73
|
-
export declare function exclusionReason(record: DeliveryRecord, subject: NodeConfigSubject | null): string;
|
|
74
|
-
/** Every renderer resolves its corpus from the AMBIENT process (cwd plus the
|
|
75
|
-
* two env seams), not from a target argument, so a snapshot dialed away from
|
|
76
|
-
* this process is only honored by standing in its place for the call. The
|
|
77
|
-
* session parse cache is cleared on both sides so neither the emulated corpus
|
|
78
|
-
* nor the real one is served from the other's scan. */
|
|
79
|
-
export interface AccountedEventRender {
|
|
80
|
-
assembled: string;
|
|
81
|
-
accounting: ReturnType<typeof deliveryAccounting>;
|
|
82
|
-
}
|
|
83
|
-
/** Run the production renderer once and retain the structured document
|
|
84
|
-
* deliveries it recorded. Context diagnostics and the admin viewer consume
|
|
85
|
-
* this result rather than reconstructing attachment/companion fixpoints. */
|
|
86
|
-
export declare function assembleEventAccounting(snapshot: ContextSnapshot, event: SurfaceEvent, payload: DeliveryPayload): AccountedEventRender;
|
|
99
|
+
/** A document delivers when it holds its name and resolved to a level above none. */
|
|
100
|
+
export declare function delivers(record: PlanRecord): boolean;
|
|
101
|
+
export declare function docRow(record: PlanRecord, includeAll: boolean, subject: NodeConfigSubject | null): DocRow;
|
|
102
|
+
/** The rule `if` verdict as one cell: `pass`, or `fail:` plus the failing clauses. */
|
|
103
|
+
export declare function gateText(record: PlanRecord, subject: NodeConfigSubject | null): string | null;
|
|
104
|
+
export declare function ruleText(rule: PlanRule | null): string | null;
|
|
105
|
+
/** Why a considered document delivers nothing, in the order the planner applies its checks. */
|
|
106
|
+
export declare function exclusionReason(record: PlanRecord, subject: NodeConfigSubject | null): string;
|
|
107
|
+
/** Which node the result describes, live or simulated. */
|
|
108
|
+
export declare function nodeLine(head: {
|
|
109
|
+
node?: string;
|
|
110
|
+
cwd?: string;
|
|
111
|
+
node_missing?: boolean;
|
|
112
|
+
}): string;
|
|
87
113
|
export declare function describeSubject(subject: Record<string, unknown>): string;
|
|
88
114
|
export declare function cell(v: unknown): string;
|
|
115
|
+
export declare function table(cols: string[], rows: string[][]): string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
var k=Object.defineProperty;var d=(e,n)=>k(e,"name",{value:n,configurable:!0});import{existsSync as $}from"node:fs";import{resolve as h}from"node:path";import{defineLeaf as S}from"../../../core/command.js";import{InputError as I}from"../../../core/io.js";import{ApiError as g}from"../../../api/index.js";import{cliClient as y}from"../../api-client.js";import{envGrantee as D,envNodeId as C,envProfileId as E}from"../../../shared/env.js";import{realpathOrSelf as f}from"../../../core/fs-utils.js";import{ambientMemoryTarget as N,resolveMemoryDocForTarget as q}from"../../../core/memory-resolver.js";import{planDelivery as v}from"../../../core/substrate/plan.js";import{explainRecordGate as m,formatClause as T}from"../../../core/substrate/gate-explain.js";import{emptyContextExposureState as F,exposureTarget as P}from"../../../core/substrate/injected-store.js";import{renderPreferencesForSubject as G,renderKnowledgeForSubject as O}from"../../../core/substrate/render.js";import{deliveryAccounting as M,memoryReadDocBlocks as A,renderOnCommandDocsForSubject as B,renderOnReadDocsForSubject as L,renderPreCommandDocsForSubject as W,renderWorkspaceOpenDocsForSubject as K}from"../../../core/substrate/on-read.js";import{clearSessionCache as w}from"../../../core/substrate/session-cache.js";import{parseSubstrateDoc as U,rungAtLeast as b,SURFACE_EVENTS as _}from"../../../core/substrate/schema.js";import{effectiveScopes as V,scopeForCwd as z,profileNameFor as H}from"../../../core/substrate/subject-fields.js";import{resetScopeCache as x}from"../../../core/scope.js";import{getDefaultProfileId as J}from"../../../core/profiles/default-binding.js";const Ge=S({name:"resolve",description:"resolve what a configuration snapshot loads for one surface event",whenToUse:"you are asking what a node (or a hypothetical configuration) actually receives \u2014 at boot, on opening a workspace, on reading a file, on a memory read, or around a command",help:{name:"sys context resolve",summary:"resolve the documents a configuration snapshot loads for one surface event",params:[{kind:"flag",name:"node",type:"string",required:!1,constraint:"Resolve for this live node \u2014 derives kind, mode, lifecycle, has-manager, profile, and cwd from it. A node id that does not exist degrades to a synthetic subject and says so."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Node kind of the synthetic subject. Defaults to the --node value, else `general`."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,constraint:"Node mode of the synthetic subject. Defaults to `base`."},{kind:"flag",name:"lifecycle",type:"enum",choices:["terminal","resident"],required:!1,constraint:"Node lifecycle of the synthetic subject. Defaults to `terminal` for base, `resident` for orchestrator."},{kind:"flag",name:"has-manager",type:"enum",choices:["true","false"],required:!1,constraint:"Treat the subject as having a manager (a subscriber above it). Defaults to the --node value, else true."},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Profile id whose memory store and project-memory caps apply. Defaults to the selected profile."},{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Directory the project stores resolve from. Defaults to the current directory."},{kind:"flag",name:"event",type:"enum",choices:[..._],required:!1,constraint:"The surface event to resolve. Defaults to `boot`. Ignored when --all-events is set."},{kind:"flag",name:"all-events",type:"bool",required:!1,constraint:"Resolve every surface event instead of one, and report each plan separately."},{kind:"flag",name:"file",type:"path",required:!1,constraint:"Payload for `--event read`: the file that was read. Without it, no read entry matches."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Payload for `--event memory-read`: the exact canonical name the read resolved to."},{kind:"flag",name:"command",type:"string",required:!1,constraint:"Payload for `--event command` / `--event pre-command`: the command string."},{kind:"flag",name:"granularity",type:"enum",choices:["summary","docs","assembled"],required:!1,constraint:"`summary` folds to per-rung counts; `docs` reports one row per document; `assembled` returns the real rendered text by calling the event\u2019s renderer. Defaults to `docs`. `--all` applies only at `docs` granularity; with `assembled` it is reported as ignored."},{kind:"flag",name:"all",type:"bool",required:!1,constraint:"At `docs` granularity, include every considered document, not just the ones that deliver \u2014 shadowed, gated-out, and capped-to-none documents with the reason each was excluded. Ignored at `summary` and `assembled` granularity."}],output:[{name:"event",type:"string",required:!1,constraint:"The resolved event. Absent with --all-events, where every entry in `plans` carries its own."},{name:"subject",type:"object",required:!0,constraint:"The configuration snapshot used: kind, mode, lifecycle, hasManager, profile, scope."},{name:"target",type:"object",required:!0,constraint:"Store resolution inputs: cwd, profileId, nodeId."},{name:"docs",type:"array",required:!1,constraint:"One entry per document, at `docs`/`all` granularity: name, kind, scope, store_path, authored_rung, project_memory_cap, capped_rung, final_rung, winner, shadowed_by, doc_gate, entry_gate, matched_entry, delivery_cause when the renderer raised it through a content attachment, and excluded when --all includes a non-delivering document."},{name:"counts",type:"object",required:!1,constraint:"At `summary` granularity: {considered, delivered: {content, preview, name}, delivered_total, excluded: {<reason>: count}}."},{name:"all_ignored",type:"boolean",required:!1,constraint:"Present only when --all is supplied with --granularity assembled; true means assembled text is unchanged because --all applies only to docs granularity."},{name:"assembled",type:"string",required:!1,constraint:"At `assembled` granularity: the exact text the node would receive for this event."},{name:"plans",type:"array",required:!1,constraint:"With --all-events: one plan result per surface event, each shaped as above."},{name:"node_missing",type:"boolean",required:!1,constraint:"Present when --node named a node that does not exist and a synthetic subject was used instead."}],outputKind:"object",effects:["None. Read-only."]},run:d(async e=>{const n=await Q(e),t=e.granularity??"docs",r=e.all===!0,s=e.allEvents===!0?[..._]:[e.event??"boot"],a={file:l(e.file),readName:l(e.name),command:l(e.command)},o=s.map(c=>te(n,c,X(c,a,n.target),t,r)),i={subject:Y(n.subject),target:n.target,...n.nodeMissing?{node_missing:!0}:{},...t==="assembled"&&r?{all_ignored:!0}:{}};return s.length===1?{...i,...o[0]}:{...i,plans:o}},"run"),render:d(e=>fe(e),"render")});async function Q(e){const n=l(e.node),t=await ee(n),r=t===null?null:await ne(t.node_id),s=e.mode??r?.mode??"base",a=e.lifecycle??r?.lifecycle??(s==="orchestrator"?"resident":"terminal"),o=Z(l(e.cwd)??r?.cwd??process.cwd()),i=l(e.profile)??t?.profile_id??N().profileId??J(o),c=l(e.hasManager);return{subject:{kind:l(e.kind)??r?.kind??"general",mode:s,lifecycle:a,hasManager:c===null?r?.hasManager??!0:c==="true",cwd:o,scope:z(o),orchestration:{depth:r?.orchestration.depth??0},profile:H(i),scopes:r?.scopes??V(null)},target:{cwd:o,profileId:i,nodeId:t?.node_id??null,...t===null?{}:{grantee:t.grantee}},nodeMissing:n!==null&&t===null}}d(Q,"buildSnapshot");function X(e,n,t){return e==="read"?n.file===null?{}:{absoluteFile:h(n.file)}:e==="memory-read"?n.readName===null?{}:{resolvedCanonicalName:n.readName,resolvedDocPath:ue(n.readName,t)}:e==="command"||e==="pre-command"?n.command===null?{}:{command:n.command}:{}}d(X,"payloadFor");function Y(e){return{kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,hasManager:e.hasManager,scope:e.scope,profile:e.profile,depth:e.orchestration.depth}}d(Y,"subjectSummary");function Z(e){const n=h(e);if(!$(n))throw new I({error:"invalid_field",message:`cwd does not exist: ${n}`,field:"cwd",next:"Pass --cwd a directory that exists, or omit it to use the current directory."});return f(n)}d(Z,"resolveCwd");function l(e){return typeof e=="string"&&e.trim()!==""?e:null}d(l,"optionalString");async function ee(e){if(e===null)return null;try{return await y().getNode(e)}catch(n){if(n instanceof g&&n.status===404)return null;throw n}}d(ee,"fetchNodeOrNull");async function ne(e){try{return await y().nodeSubject(e)}catch(n){if(n instanceof g&&n.status===404)return null;throw n}}d(ne,"fetchSubjectOrNull");function te(e,n,t,r,s){const a=ce(e,n,t);if(r==="assembled")return{event:n,assembled:a.assembled};const o=re(v(e.subject,e.target,n,t),a.accounting.deliveries,t);if(r==="summary")return{event:n,counts:de(o)};const i=o.docs.filter(c=>s||p(c)).map(c=>oe(c,s,o.subject));return{event:n,docs:i}}d(te,"planSection");function re(e,n,t={}){const r=new Set,s=e.docs.map(a=>{r.add(f(a.doc.path));const o=n.get(f(a.doc.path));if(o===void 0||!b(o.rung,a.finalRung))return a;const i=o.rung!==a.finalRung;return{...a,...i?{winner:!0,shadowedBy:null}:{},finalRung:o.rung,...i&&o.cause!==void 0?{deliveryCause:o.cause}:{}}});for(const a of n.values()){if(a.source===void 0||r.has(f(a.source.path)))continue;const o=U(a.source);if(o===null)continue;const i=v(e.subject,e.target,e.event,t,[{doc:o,source:a.source}]).docs[0];i!==void 0&&s.push({...i,winner:!0,shadowedBy:null,finalRung:a.rung,...a.cause===void 0?{}:{deliveryCause:a.cause}})}return{...e,docs:s}}d(re,"effectivePlan");function p(e){return e.winner&&b(e.finalRung,"name")}d(p,"delivers");function oe(e,n,t){const r={name:e.name,kind:e.kind,scope:e.scope,store_path:e.storePath,authored_rung:e.authoredRung,project_memory_cap:e.projectMemoryCap,capped_rung:e.cappedRung,final_rung:e.finalRung,winner:e.winner,shadowed_by:e.shadowedBy===null?null:`${e.shadowedBy.scope}:${e.shadowedBy.path}`,doc_gate:j(e.docGate,m(e,"doc",t)),entry_gate:e.entryGate===null?null:j(e.entryGate,m(e,"entry",t)),matched_entry:ae(e.matchedEntry),...e.deliveryCause===void 0?{}:{delivery_cause:e.deliveryCause}};return n&&!p(e)&&(r.excluded=se(e,t)),r}d(oe,"docRow");function j(e,n){return e.pass?"pass":`fail: ${R(e.reason,n)}`}d(j,"gateText");function R(e,n){return n.length===0?e:n.map(T).join("; ")}d(R,"gateReason");function ae(e){if(e===null)return null;const n=[`at=${e.at}`];return e.match!==void 0&&n.push(`match=${e.match.join(",")}`),e.matchFrontmatter!==void 0&&n.push("match-frontmatter"),e.gate!==void 0&&n.push("gate"),n.join(" ")}d(ae,"entryText");function se(e,n){return e.docGate.pass?e.shadowedBy!==null?`shadowed by ${e.shadowedBy.scope}:${e.shadowedBy.path}`:e.authoredEntries.length===0?"no surface entry for this event":e.matchedEntry===null?e.entryGate!==null&&!e.entryGate.pass?`entry gate: ${R(e.entryGate.reason,m(e,"entry",n))}`:"no authored entry matched this event\u2019s payload":e.cappedRung==="none"?`capped to none by the profile\u2019s project-memory setting (authored ${e.authoredRung})`:`resolved to rung none (authored ${e.authoredRung})`:"document gate"}d(se,"exclusionReason");function de(e){const n={content:0,preview:0,name:0},t={};for(const r of e.docs){if(p(r)){n[r.finalRung]=(n[r.finalRung]??0)+1;continue}const s=ie(r);t[s]=(t[s]??0)+1}return{considered:e.docs.length,delivered:n,delivered_total:n.content+n.preview+n.name,excluded:t}}d(de,"countsOf");function ie(e){return e.docGate.pass?e.shadowedBy!==null?"shadowed":e.authoredEntries.length===0?"no_entry":e.matchedEntry===null?e.entryGate!==null&&!e.entryGate.pass?"entry_gate":"no_match":e.cappedRung==="none"?"capped":"rung_none":"document_gate"}d(ie,"exclusionBucket");function ce(e,n,t){const r={cwd:process.cwd(),profileId:E(),nodeId:C(),grantee:D()},s=M();w(),x();try{return process.chdir(e.target.cwd),u("CRTR_PROFILE_ID",e.target.profileId??void 0),u("CRTR_NODE_ID",e.target.nodeId??void 0),u("CRTR_GRANTEE",e.target.grantee),{assembled:le(e,n,t,s),accounting:s}}finally{process.chdir(r.cwd),u("CRTR_PROFILE_ID",r.profileId),u("CRTR_NODE_ID",r.nodeId),u("CRTR_GRANTEE",r.grantee),w(),x()}}d(ce,"assembleEventAccounting");function u(e,n){n===void 0?delete process.env[e]:process.env[e]=n}d(u,"setEnv");function le(e,n,t,r){const{subject:s,target:a}=e;switch(n){case"boot":{const{block:o}=G(s,void 0,r),i=a.nodeId===null?"":O(s,a.nodeId,void 0,r,a.grantee);return i===""?o:`${o}
|
|
1
|
+
var x=Object.defineProperty;var r=(e,n)=>x(e,"name",{value:n,configurable:!0});import{resolve as h}from"node:path";import{defineLeaf as k}from"../../../core/command.js";import{ApiError as $}from"../../../api/index.js";import{cliClient as p}from"../../api-client.js";import{envNodeId as _}from"../../../shared/env.js";import{explainGate as R,formatClause as j}from"../../../core/substrate/gate-explain.js";import{rungAtLeast as q}from"../../../core/substrate/schema.js";const y=["boot","workspace-open","file-read","document-read","command","pre-command","slash-command"],g=[{kind:"flag",name:"node",type:"string",required:!1,constraint:"The node whose view, owners, and profile limits apply. Defaults to the calling node (CRTR_NODE_ID). A node that does not exist is simulated from the other flags and reported as `node_missing`."},{kind:"flag",name:"cwd",type:"path",required:!1,constraint:"Simulate the node working in this directory: the repos enclosing it apply. Without --node and outside a node, the node simulated is one that does not exist, working in the current directory."},{kind:"flag",name:"profile",type:"string",required:!1,constraint:"Simulate the node under this profile (id or name), whose delivery limits apply. Defaults to the node\u2019s profile, else the profile pinned to the directory."},{kind:"flag",name:"kind",type:"string",required:!1,constraint:"Override the node kind that rule `if` conditions see. A simulated node defaults to `general`."},{kind:"flag",name:"mode",type:"enum",choices:["base","orchestrator"],required:!1,constraint:"Override the node mode that rule `if` conditions see. A simulated node defaults to `base`."},{kind:"flag",name:"lifecycle",type:"enum",choices:["terminal","resident"],required:!1,constraint:"Override the node lifecycle that rule `if` conditions see. A simulated node defaults to `terminal` for base, `resident` for orchestrator."},{kind:"flag",name:"has-manager",type:"enum",choices:["true","false"],required:!1,constraint:"Override whether rule `if` conditions see the node as having a manager. A simulated node defaults to true."}],ne=k({name:"resolve",description:"resolve what a node receives for one delivery activity",whenToUse:"you are asking what a node (or one that does not exist yet) actually receives \u2014 at boot, on opening a workspace, on reading a file or a document, around a command, or as slash commands \u2014 and why each document is in or out",help:{name:"sys context resolve",summary:"resolve the documents a node receives for one delivery activity",params:[...g,{kind:"flag",name:"event",type:"enum",choices:[...y],required:!1,constraint:"The rule `on` name to resolve. Defaults to `boot`. Ignored when --all-events is set."},{kind:"flag",name:"all-events",type:"bool",required:!1,constraint:"Resolve every event instead of one, and report each plan separately."},{kind:"flag",name:"file",type:"path",required:!1,constraint:"Payload for `--event file-read`: the file that was read. Without it, no file-read rule matches."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Payload for `--event document-read`: the document read, as `crtr canvas read` takes it. Without it, no document-read rule matches."},{kind:"flag",name:"command",type:"string",required:!1,constraint:"Payload for `--event command` / `--event pre-command`: the command string."},{kind:"flag",name:"granularity",type:"enum",choices:["summary","docs","assembled"],required:!1,constraint:"`summary` folds to per-level counts; `docs` reports one row per document; `assembled` returns the rendered text (at boot, the system-prompt preferences followed by the boot context). Defaults to `docs`."},{kind:"flag",name:"all",type:"bool",required:!1,constraint:"At `docs` granularity, include every considered document, not just the ones that deliver, with the reason each was excluded."}],output:[{name:"node",type:"string",required:!1,constraint:"The node the dry run ran for, or the node --cwd and --profile dialled away from. Absent when the node is simulated."},{name:"cwd",type:"string",required:!1,constraint:"The simulated node\u2019s directory. Present when the node is simulated."},{name:"node_missing",type:"boolean",required:!1,constraint:"Present when --node named a node that does not exist, so the node was simulated."},{name:"subject",type:"object",required:!0,constraint:"The node configuration rule `if` conditions were evaluated against, overrides applied."},{name:"event",type:"string",required:!1,constraint:"The resolved event. Absent with --all-events, where every entry in `plans` carries its own."},{name:"docs",type:"array",required:!1,constraint:"At `docs` granularity, one entry per document: name, kind, owner, ref, authored_rung, limit, capped_rung, final_rung, winner, shadowed_by, gate, matched_rule, and excluded when --all includes a non-delivering document."},{name:"counts",type:"object",required:!1,constraint:"At `summary` granularity: {considered, delivered: {content, preview, name}, delivered_total, excluded: {<reason>: count}}."},{name:"assembled",type:"string",required:!1,constraint:"At `assembled` granularity: the text the node would receive."},{name:"plans",type:"array",required:!1,constraint:"With --all-events: one result per event, each shaped as above."}],outputKind:"object",effects:["None. Read-only; the dry run records no watch, event, or exposure."]},run:r(async e=>{const n=await A(e),t=e.granularity??"docs",o=e.all===!0,d=e.allEvents===!0?[...y]:[e.event??"boot"],a={file:s(e.file),readName:s(e.name),command:s(e.command)},i=[];let l=null;for(const c of d){const{plan:m,content:b}=await w(n,c,T(c,a));l??=m.subject,i.push(await M(n,c,m,b,t,o))}const u={...N(n),subject:O(l)};return d.length===1?{...u,...i[0]}:{...u,plans:i}},"run"),render:r(e=>H(e),"render")});async function A(e){const n=s(e.node);let t=n??s(_()),o=!1;t!==null&&!await S(t)&&(n===null||(o=!0),t=null);const d=s(e.cwd),a=s(e.profile),i={},l=s(e.kind);l!==null&&(i.kind=l),e.mode!==void 0&&(i.mode=e.mode),e.lifecycle!==void 0&&(i.lifecycle=e.lifecycle);const u=s(e.hasManager);if(u!==null&&(i.hasManager=u==="true"),t!==null&&d===null&&a===null)return{nodeId:t,hypothetical:null,override:i,nodeMissing:o};const c={...d!==null?{cwd:h(d)}:t===null?{cwd:process.cwd()}:{},...a===null?{}:{profile:a},...i.kind===void 0?{}:{kind:i.kind},...i.mode===void 0?{}:{mode:i.mode},...i.lifecycle===void 0?{}:{lifecycle:i.lifecycle},...i.hasManager===void 0?{}:{has_manager:i.hasManager}};return{nodeId:t,hypothetical:c,override:{},nodeMissing:o}}r(A,"buildSnapshot");async function S(e){try{return await p().getNode(e),!0}catch(n){if(n instanceof $&&n.status===404)return!1;throw n}}r(S,"nodeExists");function N(e){return{...e.nodeId===null?{}:{node:e.nodeId},...e.hypothetical?.cwd===void 0?{}:{cwd:e.hypothetical.cwd},...e.nodeMissing?{node_missing:!0}:{}}}r(N,"snapshotHead");function T(e,n){if(e==="file-read")return n.file===null?void 0:h(n.file);if(e==="document-read")return n.readName??void 0;if(e==="command"||e==="pre-command")return n.command??void 0}r(T,"subjectFor");async function w(e,n,t){if(t===void 0&&(n==="file-read"||n==="document-read"||n==="command"||n==="pre-command"))return{plan:{on:n,subject:null,docs:[]},content:""};const o={activity:n,...t===void 0?{}:{subject:t},...e.nodeId===null?{}:{node:e.nodeId},...e.hypothetical===null?{}:{hypothetical:e.hypothetical},...Object.keys(e.override).length===0?{}:{subject_override:e.override}},d=await p().deliveryDryRun(o);return{plan:d.plan??{on:n,subject:null,docs:[]},content:d.content}}r(w,"dryRun");function O(e){return e===null?{}:{kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,hasManager:e.hasManager,profile:e.profile,repo:e.repo,depth:e.orchestration.depth}}r(O,"subjectSummary");function s(e){return typeof e=="string"&&e.trim()!==""?e:null}r(s,"optionalString");async function M(e,n,t,o,d,a){if(d==="assembled"){if(n!=="boot")return{event:n,assembled:o};const i=(await w(e,"system-prompt")).content;return{event:n,assembled:[i,o].filter(l=>l!=="").join(`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
${
|
|
5
|
-
`)}
|
|
6
|
-
|
|
7
|
-
`)}
|
|
8
|
-
`)
|
|
9
|
-
`)}d(pe,"renderSection");function he(e){const n=e.delivered,t=e.excluded,r=Object.keys(t).length===0?"none":Object.entries(t).map(([s,a])=>`${s}=${a}`).join(" ");return[`- considered: ${String(e.considered)}`,`- delivered: ${String(e.delivered_total)} (content=${n.content} preview=${n.preview} name=${n.name})`,`- excluded: ${r}`].join(`
|
|
10
|
-
`)}d(he,"renderCounts");function ge(e){return String(e).replace(/\|/g,"\\|").replace(/\n/g," ")}d(ge,"cell");export{ce as assembleEventAccounting,Q as buildSnapshot,ge as cell,p as delivers,me as describeSubject,oe as docRow,re as effectivePlan,ae as entryText,se as exclusionReason,j as gateText,l as optionalString,X as payloadFor,Ge as resolveLeaf,Y as subjectSummary};
|
|
3
|
+
`)}}return d==="summary"?{event:n,counts:G(t)}:{event:n,docs:t.docs.filter(i=>a||f(i)).map(i=>P(i,a,t.subject))}}r(M,"planSection");function f(e){return e.winner&&q(e.finalRung,"name")}r(f,"delivers");function P(e,n,t){const o={name:e.doc.displayName,kind:e.doc.kind,owner:e.doc.ownerHandle,ref:e.doc.object.id,authored_rung:e.authoredRung,limit:e.limit,capped_rung:e.cappedRung,final_rung:e.finalRung,winner:e.winner,shadowed_by:e.shadowedBy===null?null:`${e.shadowedBy.ownerHandle}/${e.shadowedBy.name}`,gate:B(e,t),matched_rule:D(e.matchedRule)};return n&&!f(e)&&(o.excluded=E(e,t)),o}r(P,"docRow");function B(e,n){const t=e.ruleGate;return t===null?null:t.pass?"pass":`fail: ${v(e,n,t.reason)}`}r(B,"gateText");function v(e,n,t){const o=e.authoredRules.find(a=>!a.gate.pass)?.rule.if,d=o===void 0||n===null?[]:R(o,n);return d.length===0?t:d.map(j).join("; ")}r(v,"gateReason");function D(e){if(e===null)return null;const n=[`deliver=${e.deliver}`];return e.match!==void 0&&n.push(`match=${e.match.join(",")}`),e.matchFrontmatter!==void 0&&n.push("match-frontmatter"),e.if!==void 0&&n.push("if"),n.join(" ")}r(D,"ruleText");function E(e,n){return e.shadowedBy!==null?`shadowed by ${e.shadowedBy.ownerHandle}/${e.shadowedBy.name}`:e.authoredRules.length===0?"no rule for this event":e.matchedRule===null?e.ruleGate!==null&&!e.ruleGate.pass?`rule if: ${v(e,n,e.ruleGate.reason)}`:"no rule matched this event\u2019s payload":e.cappedRung==="none"?`limited to none by the profile\u2019s delivery limit (authored ${e.authoredRung})`:`resolved to none (authored ${e.authoredRung})`}r(E,"exclusionReason");function I(e){return e.shadowedBy!==null?"shadowed":e.authoredRules.length===0?"no_rule":e.matchedRule===null?e.ruleGate!==null&&!e.ruleGate.pass?"rule_if":"no_match":e.cappedRung==="none"?"limited":"none"}r(I,"exclusionBucket");function G(e){const n={content:0,preview:0,name:0},t={};for(const o of e.docs){if(f(o)){n[o.finalRung]=(n[o.finalRung]??0)+1;continue}const d=I(o);t[d]=(t[d]??0)+1}return{considered:e.docs.length,delivered:n,delivered_total:n.content+n.preview+n.name,excluded:t}}r(G,"countsOf");function H(e){const n=[L(e),`subject: ${C(e.subject)}`],t=e.plans??[{event:e.event,docs:e.docs,counts:e.counts,assembled:e.assembled}];for(const o of t)n.push("",`## ${o.event}`,"",W(o));return n.join(`
|
|
4
|
+
`)}r(H,"renderResolve");function L(e){return e.cwd===void 0?`node: ${e.node??""}`:`node: simulated (${e.node===void 0?"a node that does not exist":`${e.node}, dialled`}; cwd ${e.cwd})${e.node_missing===!0?" \u2014 the named node does not exist":""}`}r(L,"nodeLine");function C(e){return Object.entries(e).map(([n,t])=>`${n}=${Array.isArray(t)?t.join(",")||"(none)":String(t)}`).join(" ")}r(C,"describeSubject");function W(e){if(e.assembled!==void 0)return e.assembled===""?"Nothing is delivered for this event.":["```",e.assembled,"```"].join(`
|
|
5
|
+
`);if(e.counts!==void 0)return F(e.counts);const n=e.docs??[];if(n.length===0)return"No document delivers for this event.";const t=n.some(a=>a.excluded!==void 0),o=["document","owner","kind","authored","limit","final","matched","if",...t?["excluded"]:[]],d=n.map(a=>[a.name,a.owner,a.kind,a.authored_rung,a.limit??"\u2014",a.final_rung,a.matched_rule??"\u2014",a.gate??"\u2014",...t?[a.excluded??""]:[]]);return[`${n.length} document${n.length===1?"":"s"}:`,"",U(o,d)].join(`
|
|
6
|
+
`)}r(W,"renderSection");function F(e){const n=e.delivered,t=e.excluded,o=Object.keys(t).length===0?"none":Object.entries(t).map(([d,a])=>`${d}=${a}`).join(" ");return[`- considered: ${String(e.considered)}`,`- delivered: ${String(e.delivered_total)} (content=${n.content} preview=${n.preview} name=${n.name})`,`- excluded: ${o}`].join(`
|
|
7
|
+
`)}r(F,"renderCounts");function K(e){return String(e).replace(/\|/g,"\\|").replace(/\n/g," ")}r(K,"cell");function U(e,n){return[`| ${e.join(" | ")} |`,`| ${e.map(()=>"---").join(" | ")} |`,...n.map(t=>`| ${t.map(K).join(" | ")} |`)].join(`
|
|
8
|
+
`)}r(U,"table");export{y as PLANNED_EVENTS,g as SNAPSHOT_PARAMS,A as buildSnapshot,K as cell,f as delivers,C as describeSubject,P as docRow,w as dryRun,E as exclusionReason,B as gateText,L as nodeLine,s as optionalString,ne as resolveLeaf,D as ruleText,N as snapshotHead,T as subjectFor,O as subjectSummary,U as table};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineBranch as e}from"../../core/command.js";import{resolveLeaf as o}from"./context/resolve.js";import{docLeaf as
|
|
1
|
+
import{defineBranch as e}from"../../core/command.js";import{resolveLeaf as o}from"./context/resolve.js";import{docLeaf as r}from"./context/doc.js";import{sysSyspromptLeaf as t}from"./context/sysprompt.js";import{promptReviewLeaf as a}from"./context/prompt-review.js";import{adminLeaf as n}from"./context/admin.js";import{exposeLeaf as s}from"./context/expose.js";const f=e({name:"context",description:"inspect what documents a node\u2019s delivery rules hand it",whenToUse:"you are asking what a node loads, why a document does or does not reach it, or what a prompt assembles to",help:{name:"sys context",summary:"inspect the documents delivery hands a node, and assembled prompts",model:"A document reaches a node when one of its rules fires for an event (boot, file-read, command, pre-command, slash-command), the rule `if` holds for the node, and the document wins its bare name against owners earlier in the node\u2019s view; the profile\u2019s delivery limit for the owner caps the level at boot only. resolve answers that forward \u2014 node plus event to the delivered set; expose delivers the file-read documents for files a local command displays. doc answers it in reverse \u2014 one document across every event. Both read the daemon\u2019s dry run and record nothing. sysprompt and prompt-review read assembled prompts (a live node\u2019s captured one, and one rendered for a chosen kind and mode). admin is the interactive surface over all of it: dial a node, see what every activity delivers, and edit the rules that decide it."},children:[o,s,r,t,a,n]});export{f as contextBranch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var D=Object.defineProperty;var p=(n,a)=>D(n,"name",{value:a,configurable:!0});import{envProfileId as b}from"../../shared/env.js";import{createHash as x}from"node:crypto";import{lstat as w,readFile as F,readdir as _,readlink as C}from"node:fs/promises";import{dirname as S,isAbsolute as j,join as h,relative as q,resolve as E,sep as I}from"node:path";import{defineLeaf as H}from"../../core/command.js";import{normalizeRequires as M,readConfig as T,updateConfig as L}from"../../core/config.js";import{scopeRoot as A,listScopes as B,marketplacesDir as K,pluginsDir as z}from"../../core/scope.js";import{readMarketplaceManifest as G,readPluginManifest as W}from"../../core/manifest.js";import{pathExists as y,listDirs as O,removePath as J}from"../../core/fs-utils.js";import{lsRemote as V}from"../../core/git.js";import{cliClient as U}from"../api-client.js";import{detectNerdFont as Z,nerdFontInstallCommand as Q,NERD_FONT_SELECT_HINT as P}from"../../core/runtime/nerd-font.js";import{detectPackageManager as X}from"./setup-core.js";import{validateEffectiveCommandPlugins as Y}from"../../core/command-plugins/discovery.js";import{adaptPluginContributions as ee}from"../../core/command-plugins/compose.js";import{resolveCommandRegistry as ne}from"../../core/command-manifests/registry.js";import{applyCommandExtensions as te,orphanCommandExtensionValidations as ie}from"../../core/command-plugins/extensions.js";import{discoverHookRegistry as oe}from"../../core/command-hooks/discovery.js";import{resolveBinContributions as ae}from"../../core/runtime/bin-contributions.js";import{inspectHumanActions as se}from"../../core/human-actions.js";import{buildBrokerEnv as re,resolvePathExecutable as ce}from"../../core/runtime/spawn-env.js";import{listAllPlugins as le}from"../../core/resolver.js";import{SUBTREE_NAMES as ue,coreCommandPaths as de,coreHookCatalog as me,extensibleCoreBranches as pe}from"../../build-root.js";import{processGeneration as fe,processLocatedGeneration as he,runtimeManifest as $,selectedGeneration as ge}from"./shared.js";import{CONFIG_FILE as ye}from"../../types.js";function f(n,a,t){return{scope:n,name:a,status:"pass",message:t}}p(f,"pass");function m(n,a,t,r){return{scope:n,name:a,status:"fail",message:t,...r?{remediation:r}:{}}}p(m,"failCheck");function k(n){try{switch(n.kind){case"remove_config_key":{if(!n.scope||!n.configKey)return!1;const a=n.configKey.split(".");return L(n.scope,t=>{let r=t;for(let i=0;i<a.length-1;i++){const e=r[a[i]];if(typeof e!="object"||e===null)return;r=e}delete r[a[a.length-1]]}),!0}case"rm_path":return n.path?(J(n.path),!0):!1;case"human_action":return!1;default:return!1}}catch{return!1}}p(k,"applyRemediation");function $e(n){return[`${n.link} ${n.kind}`,`disposition=${n.retry.disposition}`,typeof n.retry.attempt=="number"&&typeof n.retry.max=="number"?`attempt=${n.retry.attempt}/${n.retry.max}`:void 0,typeof n.retry.nextAt=="string"?`nextAt=${n.retry.nextAt}`:void 0].filter(t=>t!==void 0).join(" \xB7 ")}p($e,"faultMessage");function R(n){return/^[A-Za-z0-9._:/@%+=,-]+$/u.test(n)?n:`'${n.replaceAll("'","'\\''")}'`}p(R,"shellArgument");function ve(n,a){const t={connection:"restore connectivity","rate-limit":"wait for the rate limit to clear",overloaded:"wait for load to drop",auth:"re-authenticate",protocol:"fix the protocol mismatch","context-overflow":"shrink the task or loaded context, or choose a larger-context model before spawning the node again",other:"fix the underlying issue",wedged:"read `crtr memory read wedged-child-on-runaway-bash` \u2014 if a runaway subprocess is to blame, kill it (not the node); if the broker had no subprocess, the daemon SIGTERM-kicks it and starts a fresh recovery cycle automatically","model-not-found":"pass a valid `--model provider/id` or configure credentials for an authenticated provider, then revive the node (`crtr node lifecycle revive <id>`)"},r=n.retry.disposition==="auto"?n.retry.by==="client"?"client redialing":typeof n.retry.attempt=="number"&&typeof n.retry.max=="number"?`auto-retrying, attempt ${n.retry.attempt}/${n.retry.max}`:"auto-retrying":n.retry.disposition==="fatal"?"parked fatal":"manual",i=`crtr sys logs --node ${R(a)} --operation ${R(n.operation_id)}`;return{kind:"human_action",description:`${t[n.kind]}; ${r}; inspect the correlated operation with ${i}`,command:i}}p(ve,"faultRemediation");async function ke(n){const a=[],t=new Set(n),r=new Set(ue),[i,e]=await Promise.all([de(),pe()]),c=Y(r,void 0,void 0,i,e);for(const l of c){const o=l.plugin;if(!t.has(o.scope))continue;const u=l.issues.filter(s=>s.code!=="command_collision");if(u.length===0){const s=l.contributions.map(d=>d.node.name).join(", ");a.push(f(o.scope,`plugin:${o.name}:commands`,s.length>0?`contributes top-level command(s): ${s}`:"command manifest valid"));continue}u.forEach((s,d)=>{const g={kind:"human_action",description:`${s.next} Inspect with \`pkg plugin show ${o.name}\`; then update (\`pkg plugin update --name ${o.name}\`) or remove (\`pkg plugin remove ${o.name}\`) the plugin.`},v=s.path!==void 0?` at ${s.path}`:"";a.push(m(o.scope,`plugin:${o.name}:commands[${d}]`,`${s.code}${v}: ${s.message} (received ${s.received}, expected ${s.expected})`,g))})}if(t.has("project")){const l=ne(ee(c.flatMap(s=>s.contributions)).contributions,r),u=[...te(l.contributions).validations,...ie(l.contributions)];for(const s of u){if(s.issue===void 0){a.push(f("project",`extension:${s.branch}`,`repository fragment valid: ${s.fragmentPath}`));continue}const d=s.issue;a.push(m("project",`extension:${s.branch}`,`${d.code} at ${d.path??s.fragmentPath}: ${d.message} (received ${d.received}, expected ${d.expected})`,{kind:"human_action",description:d.next}))}}return a}p(ke,"runCommandPluginChecks");async function we(n){const a=new Set(n),t=oe(await me()),r=[];for(const i of t.validations){const e=i.plugin;if(!a.has(e.scope))continue;const c=t.issues.filter(l=>l.plugin===e.name&&l.scope===e.scope);if(c.length===0){const l=i.hooks.map(u=>`${u.target} [${u.phase} ${u.op}]`),o=(i.manifest?.schemaVersion===2?i.manifest.lifecycle:[]).map(u=>`${u.event} [${u.phase} ${u.op}; effects: ${u.effects.join(", ")}]`);r.push(f(e.scope,`plugin:${e.name}:hooks`,`effective hook declaration(s): ${[...l,...o].join("; ")}`));continue}c.forEach((l,o)=>{const u=i.manifestPath??h(e.root,".crouter-plugin","plugin.json"),s=l.path!==void 0?`${u}:${l.path}`:u;r.push(m(e.scope,`plugin:${e.name}:hooks[${o}]`,`${l.code} at ${s}: ${l.message} (received ${l.received}, expected ${l.expected})`,{kind:"human_action",description:`${l.next} Inspect with \`crtr pkg plugin show ${e.name}\`; then disable (\`crtr pkg plugin disable ${e.name} --scope ${e.scope}\`), update (\`crtr pkg plugin update --name ${e.name}\`), or remove (\`crtr pkg plugin remove ${e.name}\`) the plugin.`}))})}return r}p(we,"runHookPluginChecks");function be(n){const a=new Set(n),{bins:t,issues:r}=ae(process.cwd(),b()||null),i=[];for(const e of r)a.has(e.scope)&&i.push(m(e.scope,`bin:${e.name}`,`${e.origin}: ${e.message}`,{kind:"human_action",description:`Fix the \`bin.${e.name}\` declaration in ${e.origin} \u2014 point it at an executable regular file inside that contributor's own root, or remove it. A same-precedence collision is resolved by renaming one of the claimants.`}));for(const e of t.values())a.has(e.scope)&&i.push(f(e.scope,`bin:${e.name}`,`${e.origin} \u2192 ${e.target}`));return i}p(be,"runBinContributionChecks");function xe(n){const a=new Set(n),t=h(A("user"),ye),r=[],i=new Map;for(const e of se(process.cwd())){if("kind"in e){if(e.kind==="unknown_action")continue;const u=e.configOrigin===t?"user":"project",s=e.block===!0,d=s?void 0:i.get(e.name);if(!s&&d===void 0&&i.set(e.name,e.configOrigin),!a.has(u))continue;const g=s?`humanActions:block@${e.configOrigin}`:`humanActions:${e.name}@${e.configOrigin}`,v={kind:"human_action",description:s?`Fix or remove the \`humanActions\` block in ${e.configOrigin}. Actions run argv directly without a shell.`:`Fix or remove the \`humanActions.${e.name}\` declaration in ${e.configOrigin}. Actions run argv directly without a shell.`};d!==void 0?r.push({scope:u,name:g,status:"pass",message:`warning: shadowed by ${d}; ${e.configOrigin}: ${e.reason}`,remediation:v}):r.push(m(u,g,`${e.configOrigin}: ${e.reason}`,v));continue}const c=e.configOrigin===t?"user":"project",l=i.get(e.name);if(l===void 0&&i.set(e.name,e.configOrigin),!a.has(c))continue;const o=l===void 0?"":`shadowed by ${l}; `;r.push(f(c,`humanActions:${e.name}@${e.configOrigin}`,`${o}${e.configOrigin} \u2192 ${e.argv[0]} (cwd ${e.cwd})`))}return r}p(xe,"runHumanActionChecks");function _e(n){const a=new Set(n),t=re({argv:[],env:{CRTR_NODE_CWD:process.cwd(),CRTR_PROFILE_ID:b()??""}}),r=[];for(const i of le())if(!(!a.has(i.scope)||!i.enabled||i.manifest.requires===void 0))for(const[e,c]of Object.entries(M(i.manifest.requires))){const l=ce(e,t,process.cwd());l!==null?r.push(f(i.scope,`requires:${e}`,`plugin "${i.name}" \u2192 ${l}`)):r.push(m(i.scope,`requires:${e}`,`plugin "${i.name}" requires executable "${e}" on PATH`,{kind:"human_action",description:c}))}return r}p(_e,"runRequiresChecks");async function Ce(n){const a=[];async function t(r){for(const i of await _(r)){const e=h(r,i),c=q(n,e).replaceAll(I,"/");if(c==="generation.json")continue;const l=await w(e);if(l.isDirectory())await t(e);else if(l.isFile()){const o=await F(e);a.push({path:c,size:l.size,sha256:x("sha256").update(o).digest("hex")})}else if(l.isSymbolicLink()){const o=await C(e);if(j(o)||!$.contained(n,E(S(e),o)))throw new Error(`generation symlink escapes root: ${c}`);a.push({path:c,size:Buffer.byteLength(o),sha256:x("sha256").update(o).digest("hex"),symlink:!0})}else throw new Error(`unsupported generation file: ${c}`)}}return p(t,"walk"),await t(n),$.sortInventory(a)}p(Ce,"inventory");async function Se(n){async function a(t){const r=await w(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`generation directory is invalid: ${t}`);if((r.mode&146)!==0)throw new Error(`generation path is writable: ${t}`);for(const i of await _(t)){const e=h(t,i),c=await w(e);if(c.isDirectory())await a(e);else if(c.isFile()){if((c.mode&146)!==0)throw new Error(`generation path is writable: ${e}`)}else if(c.isSymbolicLink()){const l=await C(e);if(j(l)||!$.contained(n,E(S(e),l)))throw new Error(`generation symlink escapes root: ${e}`)}else throw new Error(`unsupported generation file: ${e}`)}}p(a,"walk"),await a(n)}p(Se,"verifySealed");function je(){const n=Z();if(n.installed)return f("user","terminal:nerd-font",`installed (${n.evidence}) \u2014 if icons still render as boxes, ${P}`);const a=Q(X());return m("user","terminal:nerd-font","no Nerd Font installed \u2014 viewer tool/command icons will render as tofu boxes",{kind:"human_action",description:`Install a Nerd Font (${a.hint}), ${P}`,...a.command?{command:a.command}:{}})}p(je,"runNerdFontCheck");async function N(n,a,t){if(a.generation===null){const c=a.error??"no runtime generation";return[t?f("canvas",`runtime:${n}`,c):m("canvas",`runtime:${n}`,c)]}const r=a.generation,i=[],e=$.validateManifestShape(r.manifest,{id:r.id,entryName:"cli"});if(!e.ok)return[m("canvas",`runtime:${n}:manifest`,e.error)];i.push(f("canvas",`runtime:${n}:manifest`,`${r.id} ${r.manifest.packageVersion}`));try{await Se(r.root),i.push(f("canvas",`runtime:${n}:sealing`,"generation tree is sealed and contained"))}catch(c){i.push(m("canvas",`runtime:${n}:sealing`,c instanceof Error?c.message:String(c)))}try{const c=await Ce(r.root),l=$.sortInventory(r.manifest.files);JSON.stringify(r.manifest.files)!==JSON.stringify(l)?i.push(m("canvas",`runtime:${n}:inventory`,"manifest inventory is not in canonical runtime-generation-manifest order")):JSON.stringify(c)!==JSON.stringify(l)?i.push(m("canvas",`runtime:${n}:inventory`,"full generation inventory hash does not match generation.json")):i.push(f("canvas",`runtime:${n}:inventory`,`${c.length} files hash-verified`))}catch(c){i.push(m("canvas",`runtime:${n}:inventory`,c instanceof Error?c.message:String(c)))}return i}p(N,"generationChecks");async function Ee(){const n=[];for(const a of await U().listNodes()){const t=a.fault??null;if(t===null)continue;const r=`fault:${a.node_id}:${t.link}`,i=ve(t,a.node_id);n.push(m("canvas",r,$e(t),i))}return n}p(Ee,"runFaultChecks");function Ae(n,a){const t=[];if(!A(n))return t;const i=T(n),e=K(n);for(const o of Object.keys(i.marketplaces)){if(!e){t.push(m(n,`marketplace:${o}:dir`,"marketplaces directory unavailable"));continue}const u=h(e,o);if(y(u))t.push(f(n,`marketplace:${o}:dir`,"directory exists"));else{const s={kind:"remove_config_key",description:`Drop stale config entry config.${n}.marketplaces.${o}`,scope:n,configKey:`marketplaces.${o}`};a.fix&&k(s)?t.push({scope:n,name:`marketplace:${o}:dir`,status:"fail",message:"directory missing \u2014 removed stale config entry",fixed:!0,remediation:s}):t.push(m(n,`marketplace:${o}:dir`,`directory missing: ${u}`,s))}}const c=z(n);for(const o of Object.keys(i.plugins)){if(!c){t.push(m(n,`plugin:${o}:dir`,"plugins directory unavailable"));continue}const u=h(c,o);if(y(u))t.push(f(n,`plugin:${o}:dir`,"directory exists"));else{const s={kind:"remove_config_key",description:`Drop stale config entry config.${n}.plugins.${o}`,scope:n,configKey:`plugins.${o}`};a.fix&&k(s)?t.push({scope:n,name:`plugin:${o}:dir`,status:"fail",message:"directory missing \u2014 removed stale config entry",fixed:!0,remediation:s}):t.push(m(n,`plugin:${o}:dir`,`directory missing: ${u}`,s))}}if(e&&y(e))for(const o of O(e)){const u=h(e,o),s=G(u);if(s){t.push(f(n,`marketplace:${o}:manifest`,"manifest valid"));for(const d of s.plugins){if(d.source.startsWith("http://")||d.source.startsWith("https://")||d.source.startsWith("git@"))continue;const g=h(u,d.source);y(g)?t.push(f(n,`marketplace:${o}:plugin-source:${d.name}`,"source resolves")):t.push(m(n,`marketplace:${o}:plugin-source:${d.name}`,`source path does not resolve: ${g}`))}}else{const d={kind:"rm_path",description:"Remove dangling marketplace directory (no valid .crouter-marketplace/marketplace.json)",path:u};a.fix&&k(d)?t.push({scope:n,name:`marketplace:${o}:manifest`,status:"fail",message:"no valid marketplace.json \u2014 removed dangling directory",fixed:!0,remediation:d}):t.push(m(n,`marketplace:${o}:manifest`,`no valid marketplace.json in ${u}`,d))}}const l=new Map;if(c&&y(c))for(const o of O(c)){const u=h(c,o),s=W(u);if(!s){const d={kind:"rm_path",description:"Remove dangling plugin directory (no valid .crouter-plugin/plugin.json)",path:u};a.fix&&k(d)?t.push({scope:n,name:`plugin:${o}:manifest`,status:"fail",message:"no valid plugin.json \u2014 removed dangling directory",fixed:!0,remediation:d}):t.push(m(n,`plugin:${o}:manifest`,`no valid plugin.json in ${u}`,d));continue}t.push(f(n,`plugin:${o}:manifest`,"manifest valid")),l.has(o)?t.push(m(n,`plugin:${o}:duplicate`,`duplicate plugin name within scope (also at ${l.get(o)})`)):l.set(o,u),a.remote&&s.source&&(V(s.source).status!==0?t.push(m(n,`plugin:${o}:remote`,`git remote unreachable: ${s.source}`)):t.push(f(n,`plugin:${o}:remote`,"git remote reachable")))}return t}p(Ae,"runChecksForScope");const tn=H({name:"doctor",description:"diagnose installation health",whenToUse:"something in your crtr install looks off and you want it diagnosed \u2014 a plugin or marketplace manifest is missing, a config entry points at a directory that no longer exists, or a plugin command/hook declaration is malformed. Reports each problem with a structured remediation, and can apply the safe repairs for you.",help:{name:"sys doctor",summary:"diagnose runtime integrity, missing manifests, and broken config entries",params:[{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Scope to check. Default: all scopes."},{kind:"flag",name:"fix",type:"bool",required:!1,constraint:"Apply each non-pass check's remediation and report what was fixed."},{kind:"flag",name:"remote",type:"bool",required:!1,constraint:"Check git remotes with ls-remote (slow \u2014 makes network calls)."}],output:[{name:"checks",type:"object[]",required:!0,constraint:"Each: {scope, name, status, message, fixed?, remediation?}. status: pass | fail. scope may be user | project | canvas. bin:<name> checks report bare-binary contributions (a `bin` block in a plugin manifest or a scope config.json): a pass names the contributor and the resolved target, a fail names an unsafe/reserved command name, malformed target declaration, missing/non-executable/escaping target, or same-precedence name collision that installed nothing; their remediation is always a human_action. humanActions:<name>@<config-origin> checks validate each user/project scope completion-action declaration: action-name and argv shape, cwd directory, argv[0] regular-file existence, and execute permission; they never execute an action. A malformed effective declaration fails; a malformed shadowed declaration is a pass-level warning that names the winning and shadowed origins. requires:<name> checks report each enabled plugin manifest PATH requirement: a pass names the plugin and resolved executable path; a fail names the plugin and carries its declared install hint as remediation. Runtime checks validate selected and process generation manifests, sealing/containment, and full SHA-256 inventories. terminal:nerd-font (user scope) reports whether a Nerd Font is installed for the viewer's icon glyphs; its remediation is always a human_action carrying the platform install command, never auto-fixed. Plugin checks appear as plugin:<name>:commands and plugin:<name>:hooks; both are validated statically and never execute plugin code. Hook failures identify manifest/path/target/event/collision problems and carry disable/update/remove/show remediation; healthy command hooks list effective target, phase, and op, while lifecycle hooks list event, phase, op, and effects. remediation (when present) is {kind, description, ...payload} where kind is remove_config_key | rm_path | human_action; fault human_action remediations include the canonical logs command. Sorted by scope then name."},{name:"ok",type:"boolean",required:!0,constraint:"True when no unresolved fail checks remain."}],outputKind:"object",effects:["Read-only unless --fix is passed. Runtime verification reads and hashes every selected/process generation file; plugin command and hook manifests, bare-binary (`bin`) declarations, humanActions declarations, and advisory `requires` PATH checks never execute plugin or contributed binaries.","With --fix: applies each non-pass check's `remediation` \u2014 removes stale config entries and deletes dangling plugin/marketplace directories; canvas fault findings and plugin command/hook findings stay read-only (--fix never chmods or rewrites third-party plugin content).","Each non-pass result carries a structured `remediation` describing the fix action (absolute paths, exact config keys, or a human_action with its command) so callers can apply it directly without --fix."]},run:p(async n=>{const a=n.scope,t=n.fix,r=n.remote,i=B(a),e=[];for(const s of i){const d=Ae(s,{fix:t,remote:r});e.push(...d)}i.includes("user")&&e.push(je()),e.push(...await ke(i)),e.push(...await we(i)),e.push(...be(i)),e.push(...xe(i)),e.push(..._e(i)),e.push(...await Ee());const c=fe();e.push(...await N("selected",ge(),c===null)),e.push(...await N("process",he(),!0));const l={user:0,project:1,builtin:2,canvas:3};e.sort((s,d)=>s.scope!==d.scope?l[s.scope]-l[d.scope]:s.name.localeCompare(d.name));const o=!e.some(s=>s.status==="fail"&&s.fixed!==!0),u=e.filter(s=>s.status==="fail"&&s.fixed!==!0).length;return{checks:e,ok:o,failed:u}},"run")});export{ke as runCommandPluginChecks,tn as sysDoctorLeaf};
|
|
1
|
+
var D=Object.defineProperty;var p=(n,a)=>D(n,"name",{value:a,configurable:!0});import{envProfileId as b}from"../../shared/env.js";import{createHash as x}from"node:crypto";import{lstat as w,readFile as F,readdir as _,readlink as C}from"node:fs/promises";import{dirname as S,isAbsolute as j,join as h,relative as q,resolve as E,sep as I}from"node:path";import{defineLeaf as H}from"../../core/command.js";import{normalizeRequires as M,readConfig as T,updateConfig as L}from"../../core/config.js";import{scopeRoot as A,listScopes as B,marketplacesDir as K,pluginsDir as z}from"../../core/scope.js";import{readMarketplaceManifest as G,readPluginManifest as W}from"../../core/manifest.js";import{pathExists as y,listDirs as O,removePath as J}from"../../core/fs-utils.js";import{lsRemote as V}from"../../core/git.js";import{cliClient as U}from"../api-client.js";import{detectNerdFont as Z,nerdFontInstallCommand as Q,NERD_FONT_SELECT_HINT as P}from"../../core/runtime/nerd-font.js";import{detectPackageManager as X}from"./setup-core.js";import{validateEffectiveCommandPlugins as Y}from"../../core/command-plugins/discovery.js";import{adaptPluginContributions as ee}from"../../core/command-plugins/compose.js";import{resolveCommandRegistry as ne}from"../../core/command-manifests/registry.js";import{applyCommandExtensions as te,orphanCommandExtensionValidations as ie}from"../../core/command-plugins/extensions.js";import{discoverHookRegistry as oe}from"../../core/command-hooks/discovery.js";import{resolveBinContributions as ae}from"../../core/runtime/bin-contributions.js";import{inspectHumanActions as se}from"../../core/human-actions.js";import{buildBrokerEnv as re,resolvePathExecutable as ce}from"../../core/runtime/spawn-env.js";import{listAllPlugins as le}from"../../core/resolver.js";import{SUBTREE_NAMES as ue,coreCommandPaths as de,coreHookCatalog as me,extensibleCoreBranches as pe}from"../../build-root.js";import{processGeneration as fe,processLocatedGeneration as he,runtimeManifest as $,selectedGeneration as ge}from"./shared.js";import{CONFIG_FILE as ye}from"../../types.js";function f(n,a,t){return{scope:n,name:a,status:"pass",message:t}}p(f,"pass");function m(n,a,t,r){return{scope:n,name:a,status:"fail",message:t,...r?{remediation:r}:{}}}p(m,"failCheck");function k(n){try{switch(n.kind){case"remove_config_key":{if(!n.scope||!n.configKey)return!1;const a=n.configKey.split(".");return L(n.scope,t=>{let r=t;for(let i=0;i<a.length-1;i++){const e=r[a[i]];if(typeof e!="object"||e===null)return;r=e}delete r[a[a.length-1]]}),!0}case"rm_path":return n.path?(J(n.path),!0):!1;case"human_action":return!1;default:return!1}}catch{return!1}}p(k,"applyRemediation");function $e(n){return[`${n.link} ${n.kind}`,`disposition=${n.retry.disposition}`,typeof n.retry.attempt=="number"&&typeof n.retry.max=="number"?`attempt=${n.retry.attempt}/${n.retry.max}`:void 0,typeof n.retry.nextAt=="string"?`nextAt=${n.retry.nextAt}`:void 0].filter(t=>t!==void 0).join(" \xB7 ")}p($e,"faultMessage");function R(n){return/^[A-Za-z0-9._:/@%+=,-]+$/u.test(n)?n:`'${n.replaceAll("'","'\\''")}'`}p(R,"shellArgument");function ve(n,a){const t={connection:"restore connectivity","rate-limit":"wait for the rate limit to clear",overloaded:"wait for load to drop",auth:"re-authenticate",protocol:"fix the protocol mismatch","context-overflow":"shrink the task or loaded context, or choose a larger-context model before spawning the node again",other:"fix the underlying issue",wedged:"read `crtr canvas read wedged-child-on-runaway-bash` \u2014 if a runaway subprocess is to blame, kill it (not the node); if the broker had no subprocess, the daemon SIGTERM-kicks it and starts a fresh recovery cycle automatically","model-not-found":"pass a valid `--model provider/id` or configure credentials for an authenticated provider, then revive the node (`crtr node lifecycle revive <id>`)"},r=n.retry.disposition==="auto"?n.retry.by==="client"?"client redialing":typeof n.retry.attempt=="number"&&typeof n.retry.max=="number"?`auto-retrying, attempt ${n.retry.attempt}/${n.retry.max}`:"auto-retrying":n.retry.disposition==="fatal"?"parked fatal":"manual",i=`crtr sys logs --node ${R(a)} --operation ${R(n.operation_id)}`;return{kind:"human_action",description:`${t[n.kind]}; ${r}; inspect the correlated operation with ${i}`,command:i}}p(ve,"faultRemediation");async function ke(n){const a=[],t=new Set(n),r=new Set(ue),[i,e]=await Promise.all([de(),pe()]),c=Y(r,void 0,void 0,i,e);for(const l of c){const o=l.plugin;if(!t.has(o.scope))continue;const u=l.issues.filter(s=>s.code!=="command_collision");if(u.length===0){const s=l.contributions.map(d=>d.node.name).join(", ");a.push(f(o.scope,`plugin:${o.name}:commands`,s.length>0?`contributes top-level command(s): ${s}`:"command manifest valid"));continue}u.forEach((s,d)=>{const g={kind:"human_action",description:`${s.next} Inspect with \`pkg plugin show ${o.name}\`; then update (\`pkg plugin update --name ${o.name}\`) or remove (\`pkg plugin remove ${o.name}\`) the plugin.`},v=s.path!==void 0?` at ${s.path}`:"";a.push(m(o.scope,`plugin:${o.name}:commands[${d}]`,`${s.code}${v}: ${s.message} (received ${s.received}, expected ${s.expected})`,g))})}if(t.has("project")){const l=ne(ee(c.flatMap(s=>s.contributions)).contributions,r),u=[...te(l.contributions).validations,...ie(l.contributions)];for(const s of u){if(s.issue===void 0){a.push(f("project",`extension:${s.branch}`,`repository fragment valid: ${s.fragmentPath}`));continue}const d=s.issue;a.push(m("project",`extension:${s.branch}`,`${d.code} at ${d.path??s.fragmentPath}: ${d.message} (received ${d.received}, expected ${d.expected})`,{kind:"human_action",description:d.next}))}}return a}p(ke,"runCommandPluginChecks");async function we(n){const a=new Set(n),t=oe(await me()),r=[];for(const i of t.validations){const e=i.plugin;if(!a.has(e.scope))continue;const c=t.issues.filter(l=>l.plugin===e.name&&l.scope===e.scope);if(c.length===0){const l=i.hooks.map(u=>`${u.target} [${u.phase} ${u.op}]`),o=(i.manifest?.schemaVersion===2?i.manifest.lifecycle:[]).map(u=>`${u.event} [${u.phase} ${u.op}; effects: ${u.effects.join(", ")}]`);r.push(f(e.scope,`plugin:${e.name}:hooks`,`effective hook declaration(s): ${[...l,...o].join("; ")}`));continue}c.forEach((l,o)=>{const u=i.manifestPath??h(e.root,".crouter-plugin","plugin.json"),s=l.path!==void 0?`${u}:${l.path}`:u;r.push(m(e.scope,`plugin:${e.name}:hooks[${o}]`,`${l.code} at ${s}: ${l.message} (received ${l.received}, expected ${l.expected})`,{kind:"human_action",description:`${l.next} Inspect with \`crtr pkg plugin show ${e.name}\`; then disable (\`crtr pkg plugin disable ${e.name} --scope ${e.scope}\`), update (\`crtr pkg plugin update --name ${e.name}\`), or remove (\`crtr pkg plugin remove ${e.name}\`) the plugin.`}))})}return r}p(we,"runHookPluginChecks");function be(n){const a=new Set(n),{bins:t,issues:r}=ae(process.cwd(),b()||null),i=[];for(const e of r)a.has(e.scope)&&i.push(m(e.scope,`bin:${e.name}`,`${e.origin}: ${e.message}`,{kind:"human_action",description:`Fix the \`bin.${e.name}\` declaration in ${e.origin} \u2014 point it at an executable regular file inside that contributor's own root, or remove it. A same-precedence collision is resolved by renaming one of the claimants.`}));for(const e of t.values())a.has(e.scope)&&i.push(f(e.scope,`bin:${e.name}`,`${e.origin} \u2192 ${e.target}`));return i}p(be,"runBinContributionChecks");function xe(n){const a=new Set(n),t=h(A("user"),ye),r=[],i=new Map;for(const e of se(process.cwd())){if("kind"in e){if(e.kind==="unknown_action")continue;const u=e.configOrigin===t?"user":"project",s=e.block===!0,d=s?void 0:i.get(e.name);if(!s&&d===void 0&&i.set(e.name,e.configOrigin),!a.has(u))continue;const g=s?`humanActions:block@${e.configOrigin}`:`humanActions:${e.name}@${e.configOrigin}`,v={kind:"human_action",description:s?`Fix or remove the \`humanActions\` block in ${e.configOrigin}. Actions run argv directly without a shell.`:`Fix or remove the \`humanActions.${e.name}\` declaration in ${e.configOrigin}. Actions run argv directly without a shell.`};d!==void 0?r.push({scope:u,name:g,status:"pass",message:`warning: shadowed by ${d}; ${e.configOrigin}: ${e.reason}`,remediation:v}):r.push(m(u,g,`${e.configOrigin}: ${e.reason}`,v));continue}const c=e.configOrigin===t?"user":"project",l=i.get(e.name);if(l===void 0&&i.set(e.name,e.configOrigin),!a.has(c))continue;const o=l===void 0?"":`shadowed by ${l}; `;r.push(f(c,`humanActions:${e.name}@${e.configOrigin}`,`${o}${e.configOrigin} \u2192 ${e.argv[0]} (cwd ${e.cwd})`))}return r}p(xe,"runHumanActionChecks");function _e(n){const a=new Set(n),t=re({argv:[],env:{CRTR_NODE_CWD:process.cwd(),CRTR_PROFILE_ID:b()??""}}),r=[];for(const i of le())if(!(!a.has(i.scope)||!i.enabled||i.manifest.requires===void 0))for(const[e,c]of Object.entries(M(i.manifest.requires))){const l=ce(e,t,process.cwd());l!==null?r.push(f(i.scope,`requires:${e}`,`plugin "${i.name}" \u2192 ${l}`)):r.push(m(i.scope,`requires:${e}`,`plugin "${i.name}" requires executable "${e}" on PATH`,{kind:"human_action",description:c}))}return r}p(_e,"runRequiresChecks");async function Ce(n){const a=[];async function t(r){for(const i of await _(r)){const e=h(r,i),c=q(n,e).replaceAll(I,"/");if(c==="generation.json")continue;const l=await w(e);if(l.isDirectory())await t(e);else if(l.isFile()){const o=await F(e);a.push({path:c,size:l.size,sha256:x("sha256").update(o).digest("hex")})}else if(l.isSymbolicLink()){const o=await C(e);if(j(o)||!$.contained(n,E(S(e),o)))throw new Error(`generation symlink escapes root: ${c}`);a.push({path:c,size:Buffer.byteLength(o),sha256:x("sha256").update(o).digest("hex"),symlink:!0})}else throw new Error(`unsupported generation file: ${c}`)}}return p(t,"walk"),await t(n),$.sortInventory(a)}p(Ce,"inventory");async function Se(n){async function a(t){const r=await w(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`generation directory is invalid: ${t}`);if((r.mode&146)!==0)throw new Error(`generation path is writable: ${t}`);for(const i of await _(t)){const e=h(t,i),c=await w(e);if(c.isDirectory())await a(e);else if(c.isFile()){if((c.mode&146)!==0)throw new Error(`generation path is writable: ${e}`)}else if(c.isSymbolicLink()){const l=await C(e);if(j(l)||!$.contained(n,E(S(e),l)))throw new Error(`generation symlink escapes root: ${e}`)}else throw new Error(`unsupported generation file: ${e}`)}}p(a,"walk"),await a(n)}p(Se,"verifySealed");function je(){const n=Z();if(n.installed)return f("user","terminal:nerd-font",`installed (${n.evidence}) \u2014 if icons still render as boxes, ${P}`);const a=Q(X());return m("user","terminal:nerd-font","no Nerd Font installed \u2014 viewer tool/command icons will render as tofu boxes",{kind:"human_action",description:`Install a Nerd Font (${a.hint}), ${P}`,...a.command?{command:a.command}:{}})}p(je,"runNerdFontCheck");async function N(n,a,t){if(a.generation===null){const c=a.error??"no runtime generation";return[t?f("canvas",`runtime:${n}`,c):m("canvas",`runtime:${n}`,c)]}const r=a.generation,i=[],e=$.validateManifestShape(r.manifest,{id:r.id,entryName:"cli"});if(!e.ok)return[m("canvas",`runtime:${n}:manifest`,e.error)];i.push(f("canvas",`runtime:${n}:manifest`,`${r.id} ${r.manifest.packageVersion}`));try{await Se(r.root),i.push(f("canvas",`runtime:${n}:sealing`,"generation tree is sealed and contained"))}catch(c){i.push(m("canvas",`runtime:${n}:sealing`,c instanceof Error?c.message:String(c)))}try{const c=await Ce(r.root),l=$.sortInventory(r.manifest.files);JSON.stringify(r.manifest.files)!==JSON.stringify(l)?i.push(m("canvas",`runtime:${n}:inventory`,"manifest inventory is not in canonical runtime-generation-manifest order")):JSON.stringify(c)!==JSON.stringify(l)?i.push(m("canvas",`runtime:${n}:inventory`,"full generation inventory hash does not match generation.json")):i.push(f("canvas",`runtime:${n}:inventory`,`${c.length} files hash-verified`))}catch(c){i.push(m("canvas",`runtime:${n}:inventory`,c instanceof Error?c.message:String(c)))}return i}p(N,"generationChecks");async function Ee(){const n=[];for(const a of await U().listNodes()){const t=a.fault??null;if(t===null)continue;const r=`fault:${a.node_id}:${t.link}`,i=ve(t,a.node_id);n.push(m("canvas",r,$e(t),i))}return n}p(Ee,"runFaultChecks");function Ae(n,a){const t=[];if(!A(n))return t;const i=T(n),e=K(n);for(const o of Object.keys(i.marketplaces)){if(!e){t.push(m(n,`marketplace:${o}:dir`,"marketplaces directory unavailable"));continue}const u=h(e,o);if(y(u))t.push(f(n,`marketplace:${o}:dir`,"directory exists"));else{const s={kind:"remove_config_key",description:`Drop stale config entry config.${n}.marketplaces.${o}`,scope:n,configKey:`marketplaces.${o}`};a.fix&&k(s)?t.push({scope:n,name:`marketplace:${o}:dir`,status:"fail",message:"directory missing \u2014 removed stale config entry",fixed:!0,remediation:s}):t.push(m(n,`marketplace:${o}:dir`,`directory missing: ${u}`,s))}}const c=z(n);for(const o of Object.keys(i.plugins)){if(!c){t.push(m(n,`plugin:${o}:dir`,"plugins directory unavailable"));continue}const u=h(c,o);if(y(u))t.push(f(n,`plugin:${o}:dir`,"directory exists"));else{const s={kind:"remove_config_key",description:`Drop stale config entry config.${n}.plugins.${o}`,scope:n,configKey:`plugins.${o}`};a.fix&&k(s)?t.push({scope:n,name:`plugin:${o}:dir`,status:"fail",message:"directory missing \u2014 removed stale config entry",fixed:!0,remediation:s}):t.push(m(n,`plugin:${o}:dir`,`directory missing: ${u}`,s))}}if(e&&y(e))for(const o of O(e)){const u=h(e,o),s=G(u);if(s){t.push(f(n,`marketplace:${o}:manifest`,"manifest valid"));for(const d of s.plugins){if(d.source.startsWith("http://")||d.source.startsWith("https://")||d.source.startsWith("git@"))continue;const g=h(u,d.source);y(g)?t.push(f(n,`marketplace:${o}:plugin-source:${d.name}`,"source resolves")):t.push(m(n,`marketplace:${o}:plugin-source:${d.name}`,`source path does not resolve: ${g}`))}}else{const d={kind:"rm_path",description:"Remove dangling marketplace directory (no valid .crouter-marketplace/marketplace.json)",path:u};a.fix&&k(d)?t.push({scope:n,name:`marketplace:${o}:manifest`,status:"fail",message:"no valid marketplace.json \u2014 removed dangling directory",fixed:!0,remediation:d}):t.push(m(n,`marketplace:${o}:manifest`,`no valid marketplace.json in ${u}`,d))}}const l=new Map;if(c&&y(c))for(const o of O(c)){const u=h(c,o),s=W(u);if(!s){const d={kind:"rm_path",description:"Remove dangling plugin directory (no valid .crouter-plugin/plugin.json)",path:u};a.fix&&k(d)?t.push({scope:n,name:`plugin:${o}:manifest`,status:"fail",message:"no valid plugin.json \u2014 removed dangling directory",fixed:!0,remediation:d}):t.push(m(n,`plugin:${o}:manifest`,`no valid plugin.json in ${u}`,d));continue}t.push(f(n,`plugin:${o}:manifest`,"manifest valid")),l.has(o)?t.push(m(n,`plugin:${o}:duplicate`,`duplicate plugin name within scope (also at ${l.get(o)})`)):l.set(o,u),a.remote&&s.source&&(V(s.source).status!==0?t.push(m(n,`plugin:${o}:remote`,`git remote unreachable: ${s.source}`)):t.push(f(n,`plugin:${o}:remote`,"git remote reachable")))}return t}p(Ae,"runChecksForScope");const tn=H({name:"doctor",description:"diagnose installation health",whenToUse:"something in your crtr install looks off and you want it diagnosed \u2014 a plugin or marketplace manifest is missing, a config entry points at a directory that no longer exists, or a plugin command/hook declaration is malformed. Reports each problem with a structured remediation, and can apply the safe repairs for you.",help:{name:"sys doctor",summary:"diagnose runtime integrity, missing manifests, and broken config entries",params:[{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Scope to check. Default: all scopes."},{kind:"flag",name:"fix",type:"bool",required:!1,constraint:"Apply each non-pass check's remediation and report what was fixed."},{kind:"flag",name:"remote",type:"bool",required:!1,constraint:"Check git remotes with ls-remote (slow \u2014 makes network calls)."}],output:[{name:"checks",type:"object[]",required:!0,constraint:"Each: {scope, name, status, message, fixed?, remediation?}. status: pass | fail. scope may be user | project | canvas. bin:<name> checks report bare-binary contributions (a `bin` block in a plugin manifest or a scope config.json): a pass names the contributor and the resolved target, a fail names an unsafe/reserved command name, malformed target declaration, missing/non-executable/escaping target, or same-precedence name collision that installed nothing; their remediation is always a human_action. humanActions:<name>@<config-origin> checks validate each user/project scope completion-action declaration: action-name and argv shape, cwd directory, argv[0] regular-file existence, and execute permission; they never execute an action. A malformed effective declaration fails; a malformed shadowed declaration is a pass-level warning that names the winning and shadowed origins. requires:<name> checks report each enabled plugin manifest PATH requirement: a pass names the plugin and resolved executable path; a fail names the plugin and carries its declared install hint as remediation. Runtime checks validate selected and process generation manifests, sealing/containment, and full SHA-256 inventories. terminal:nerd-font (user scope) reports whether a Nerd Font is installed for the viewer's icon glyphs; its remediation is always a human_action carrying the platform install command, never auto-fixed. Plugin checks appear as plugin:<name>:commands and plugin:<name>:hooks; both are validated statically and never execute plugin code. Hook failures identify manifest/path/target/event/collision problems and carry disable/update/remove/show remediation; healthy command hooks list effective target, phase, and op, while lifecycle hooks list event, phase, op, and effects. remediation (when present) is {kind, description, ...payload} where kind is remove_config_key | rm_path | human_action; fault human_action remediations include the canonical logs command. Sorted by scope then name."},{name:"ok",type:"boolean",required:!0,constraint:"True when no unresolved fail checks remain."}],outputKind:"object",effects:["Read-only unless --fix is passed. Runtime verification reads and hashes every selected/process generation file; plugin command and hook manifests, bare-binary (`bin`) declarations, humanActions declarations, and advisory `requires` PATH checks never execute plugin or contributed binaries.","With --fix: applies each non-pass check's `remediation` \u2014 removes stale config entries and deletes dangling plugin/marketplace directories; canvas fault findings and plugin command/hook findings stay read-only (--fix never chmods or rewrites third-party plugin content).","Each non-pass result carries a structured `remediation` describing the fix action (absolute paths, exact config keys, or a human_action with its command) so callers can apply it directly without --fix."]},run:p(async n=>{const a=n.scope,t=n.fix,r=n.remote,i=B(a),e=[];for(const s of i){const d=Ae(s,{fix:t,remote:r});e.push(...d)}i.includes("user")&&e.push(je()),e.push(...await ke(i)),e.push(...await we(i)),e.push(...be(i)),e.push(...xe(i)),e.push(..._e(i)),e.push(...await Ee());const c=fe();e.push(...await N("selected",ge(),c===null)),e.push(...await N("process",he(),!0));const l={user:0,project:1,builtin:2,canvas:3};e.sort((s,d)=>s.scope!==d.scope?l[s.scope]-l[d.scope]:s.name.localeCompare(d.name));const o=!e.some(s=>s.status==="fail"&&s.fixed!==!0),u=e.filter(s=>s.status==="fail"&&s.fixed!==!0).length;return{checks:e,ok:o,failed:u}},"run")});export{ke as runCommandPluginChecks,tn as sysDoctorLeaf};
|