@north-light/crouter 0.3.353 → 0.3.355
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 +135 -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 +168 -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 +11 -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/02-turn-lifecycle/02-resident.md +1 -0
- package/dist/builtin-memory/04-orchestration-kernel.md +10 -31
- 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/overlays/file-review.d.ts +1 -0
- package/dist/clients/attach/overlays/file-review.js +2 -2
- package/dist/clients/attach/render/chat-view.d.ts +6 -0
- package/dist/clients/attach/render/chat-view.js +2 -2
- 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/doc-links.d.ts +34 -0
- package/dist/clients/attach/render/doc-links.js +1 -0
- 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/markdown-source.js +5 -5
- package/dist/clients/attach/render/tool-calls.d.ts +1 -1
- package/dist/clients/attach/session/doc-materialize.d.ts +53 -0
- package/dist/clients/attach/session/doc-materialize.js +3 -0
- package/dist/clients/attach/session/document-links.d.ts +21 -0
- package/dist/clients/attach/session/document-links.js +1 -0
- package/dist/clients/attach/session/file-links.d.ts +2 -0
- package/dist/clients/attach/session/file-links.js +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 +816 -1561
- package/dist/clients/inbox/review/review-client.d.ts +5 -1
- package/dist/clients/inbox/review/review-client.js +1 -1
- 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 +10 -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 +167 -0
- package/dist/core/graph/documents.js +10 -0
- package/dist/core/graph/edges.d.ts +25 -0
- package/dist/core/graph/edges.js +1 -0
- package/dist/core/graph/events.d.ts +26 -0
- package/dist/core/graph/events.js +7 -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 +30 -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 +20 -9
- package/dist/core/runtime/roadmap.js +10 -6
- 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 +30 -0
- package/dist/core/substrate/delivery/listings.js +7 -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 +54 -0
- package/dist/core/substrate/delivery/render-event.js +8 -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/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/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.d.ts +4 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- 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/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/scripts/lib/isolation-env.mjs +8 -2
- 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,27 +0,0 @@
|
|
|
1
|
-
import type { MemoryDoc } from '../memory-resolver.js';
|
|
2
|
-
import type { SubstrateDoc } from './schema.js';
|
|
3
|
-
type ListAllMemoryDocsFn = () => MemoryDoc[];
|
|
4
|
-
type ParseSubstrateDocFn = (doc: MemoryDoc) => SubstrateDoc | null;
|
|
5
|
-
/** A parsed substrate document with the resolver descriptor it came from. The
|
|
6
|
-
* parsed doc carries canonical identity but not the physical form behind it,
|
|
7
|
-
* so the descriptor is what supplies the routing anchor a `./` memory-read
|
|
8
|
-
* glob matches against. */
|
|
9
|
-
export interface EventCorpusDoc {
|
|
10
|
-
doc: SubstrateDoc;
|
|
11
|
-
source: MemoryDoc;
|
|
12
|
-
}
|
|
13
|
-
/** Called by canvas-doc-substrate.ts on every `session_start`.
|
|
14
|
-
* Resets all cached values so the next access triggers a fresh scan. */
|
|
15
|
-
export declare function clearSessionCache(): void;
|
|
16
|
-
/** The FULL corpus (listAllMemoryDocs()), INCLUDING node scope, scanned at
|
|
17
|
-
* most once per session. `listFn` is injected by the caller to avoid
|
|
18
|
-
* circular imports at module init. This is the single filesystem walk the
|
|
19
|
-
* whole module performs — every other entry derives from this result rather
|
|
20
|
-
* than re-scanning. */
|
|
21
|
-
export declare function cachedAllMemoryDocsInclusive(listFn: ListAllMemoryDocsFn): MemoryDoc[];
|
|
22
|
-
/** allMemoryDocsInclusive parsed and paired with its descriptors, INCLUDING
|
|
23
|
-
* node scope — the event corpus, and the module's only parse pass. */
|
|
24
|
-
export declare function cachedEventCorpusInclusive(listFn: ListAllMemoryDocsFn, parseFn: ParseSubstrateDocFn): EventCorpusDoc[];
|
|
25
|
-
/** The parsed docs of the inclusive event corpus, without their descriptors. */
|
|
26
|
-
export declare function cachedSubstrateDocsInclusive(listFn: ListAllMemoryDocsFn, parseFn: ParseSubstrateDocFn): SubstrateDoc[];
|
|
27
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=Object.defineProperty;var l=(s,c)=>t(s,"name",{value:c,configurable:!0});const e={allMemoryDocsInclusive:null,eventCorpusInclusive:null,substrateDocsInclusive:null};function a(){e.allMemoryDocsInclusive=null,e.eventCorpusInclusive=null,e.substrateDocsInclusive=null}l(a,"clearSessionCache");function r(s){return e.allMemoryDocsInclusive===null&&(e.allMemoryDocsInclusive=s()),e.allMemoryDocsInclusive}l(r,"cachedAllMemoryDocsInclusive");function i(s,c){if(e.eventCorpusInclusive===null){const n=[];for(const u of r(s)){const o=c(u);o!==null&&n.push({doc:o,source:u})}e.eventCorpusInclusive=n}return e.eventCorpusInclusive}l(i,"cachedEventCorpusInclusive");function I(s,c){return e.substrateDocsInclusive===null&&(e.substrateDocsInclusive=i(s,c).map(n=>n.doc)),e.substrateDocsInclusive}l(I,"cachedSubstrateDocsInclusive");export{r as cachedAllMemoryDocsInclusive,i as cachedEventCorpusInclusive,I as cachedSubstrateDocsInclusive,a as clearSessionCache};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { type Rung, type SubstrateDoc, type SurfaceEntry, type SurfaceEvent } from './schema.js';
|
|
2
|
-
import type { NodeConfigSubject } from './subject-fields.js';
|
|
3
|
-
/** The project directory owning a doc's store: the path segment stack above
|
|
4
|
-
* the doc's `.crouter` dir. `null` when the doc's path carries no `.crouter`
|
|
5
|
-
* segment (builtin docs). */
|
|
6
|
-
export declare function owningRootOf(doc: Pick<SubstrateDoc, 'path'>): string | null;
|
|
7
|
-
/** True when the (already-realpathed) file sits beneath the doc's store's
|
|
8
|
-
* owning directory. Callers additionally guard on `doc.scope === 'project'`:
|
|
9
|
-
* a profile store's path computes an owning root of `~`, and user/builtin/
|
|
10
|
-
* node docs likewise have no project-owning dir, so a `./`-anchored glob
|
|
11
|
-
* outside a project store must never match. */
|
|
12
|
-
export declare function underOwningRoot(doc: Pick<SubstrateDoc, 'path'>, absFile: string): boolean;
|
|
13
|
-
/** Does a `read` entry fit the read file? `absReadFile` must already be
|
|
14
|
-
* realpathed. `readFrontmatter` is the read file's own parsed YAML (empty
|
|
15
|
-
* for non-markdown files); an empty record never satisfies
|
|
16
|
-
* `matchFrontmatter`. */
|
|
17
|
-
export declare function matchesReadEntry(entry: SurfaceEntry, doc: Pick<SubstrateDoc, 'path' | 'scope'>, subject: NodeConfigSubject | null, absReadFile: string, readFrontmatter: Record<string, unknown>): boolean;
|
|
18
|
-
/** Does a `memory-read` entry on a carrier anchored at `routingAnchor` fit a
|
|
19
|
-
* resolved read of the doc known by its exact canonical `name`? */
|
|
20
|
-
export declare function matchesMemoryReadEntry(entry: SurfaceEntry, routingAnchor: string, subject: NodeConfigSubject | null, name: string): boolean;
|
|
21
|
-
/** Does a `command` entry's parsed command pattern fit, without evaluating its
|
|
22
|
-
* node-config gate? Callers use this only to determine whether resolving a
|
|
23
|
-
* subject could be necessary; delivery must still use `matchesCommandEntry`. */
|
|
24
|
-
export declare function commandEntryMatches(entry: SurfaceEntry, command: string): boolean;
|
|
25
|
-
/** Does a `command` entry fit the executed command string? */
|
|
26
|
-
export declare function matchesCommandEntry(entry: SurfaceEntry, subject: NodeConfigSubject | null, command: string): boolean;
|
|
27
|
-
/** Does a `pre-command` entry's parsed command pattern fit, without evaluating
|
|
28
|
-
* its node-config gate? Callers use this only to determine whether resolving a
|
|
29
|
-
* subject could be necessary; delivery must still use `matchesPreCommandEntry`. */
|
|
30
|
-
export declare function preCommandEntryMatches(entry: SurfaceEntry, command: string): boolean;
|
|
31
|
-
/** Does a `pre-command` entry fit a command that is ABOUT to run? The same
|
|
32
|
-
* glob machinery `command` uses — one matcher, one semantics — applied to the
|
|
33
|
-
* command with its heredoc bodies stripped. Subshell parentheses, backticks,
|
|
34
|
-
* and path-prefixed binaries stay unhandled: this is a guardrail against the
|
|
35
|
-
* faithful-but-uninformed action, not an enforcement boundary. */
|
|
36
|
-
export declare function matchesPreCommandEntry(entry: SurfaceEntry, subject: NodeConfigSubject | null, command: string): boolean;
|
|
37
|
-
/** What an event occurrence exposes for matching. A field the event does not
|
|
38
|
-
* use is ignored; a field the event needs and lacks matches nothing. */
|
|
39
|
-
export interface SurfaceMatchPayload {
|
|
40
|
-
/** `read`: the read file, already realpathed. */
|
|
41
|
-
absoluteFile?: string;
|
|
42
|
-
/** `read`: the read file's own parsed YAML (empty for a non-markdown file). */
|
|
43
|
-
readFrontmatter?: Record<string, unknown>;
|
|
44
|
-
/** `memory-read`: the exact canonical name the read resolved to. */
|
|
45
|
-
resolvedCanonicalName?: string;
|
|
46
|
-
/** `memory-read`: the CARRIER's routing anchor, from its resolver descriptor
|
|
47
|
-
* — not derivable from a canonical name, which cannot say whether the doc
|
|
48
|
-
* fronts its own directory. */
|
|
49
|
-
routingAnchor?: string;
|
|
50
|
-
/** `command` / `pre-command`: the command string. */
|
|
51
|
-
command?: string;
|
|
52
|
-
}
|
|
53
|
-
/** A doc as the matchers see it. `path`/`scope` are consulted only by `read`
|
|
54
|
-
* (a `./`-anchored glob resolves against the store's owning repo dir). */
|
|
55
|
-
type MatchDoc = Pick<SubstrateDoc, 'surfaces'> & Partial<Pick<SubstrateDoc, 'path' | 'scope'>>;
|
|
56
|
-
/** Does ONE entry of `event` fit this occurrence — constraints and the entry's
|
|
57
|
-
* own gate together? */
|
|
58
|
-
export declare function surfaceEntryParticipates(entry: SurfaceEntry, doc: MatchDoc, subject: NodeConfigSubject | null, event: SurfaceEvent, payload: SurfaceMatchPayload): boolean;
|
|
59
|
-
/** The entry that decides this doc's delivery for one event occurrence: the
|
|
60
|
-
* highest-rung participating entry, or null when none participates. */
|
|
61
|
-
export declare function matchingSurfaceEntry(doc: MatchDoc, subject: NodeConfigSubject | null, event: SurfaceEvent, payload: SurfaceMatchPayload): SurfaceEntry | null;
|
|
62
|
-
/** The doc's delivery rung for a read of `absReadFile` (already realpathed). */
|
|
63
|
-
export declare function readDeliveryRung(doc: Pick<SubstrateDoc, 'surfaces' | 'path' | 'scope'>, subject: NodeConfigSubject | null, absReadFile: string, readFrontmatter: Record<string, unknown>): Rung;
|
|
64
|
-
/** The doc's workspace-open rung. */
|
|
65
|
-
export declare function workspaceOpenRung(doc: Pick<SubstrateDoc, 'surfaces'>, subject: NodeConfigSubject | null): Rung;
|
|
66
|
-
/** The doc's delivery rung for a `crtr memory read` that resolved a doc known
|
|
67
|
-
* by its exact canonical `name` — no mount-stripped or other alias. */
|
|
68
|
-
export declare function memoryReadDeliveryRung(doc: Pick<SubstrateDoc, 'surfaces'>, routingAnchor: string, subject: NodeConfigSubject | null, name: string): Rung;
|
|
69
|
-
/** The doc's delivery rung for an executed command string. */
|
|
70
|
-
export declare function commandDeliveryRung(doc: Pick<SubstrateDoc, 'surfaces'>, subject: NodeConfigSubject | null, command: string): Rung;
|
|
71
|
-
/** The doc's delivery rung for a command about to run. */
|
|
72
|
-
export declare function preCommandDeliveryRung(doc: Pick<SubstrateDoc, 'surfaces'>, subject: NodeConfigSubject | null, command: string): Rung;
|
|
73
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var x=Object.defineProperty;var i=(e,t)=>x(e,"name",{value:t,configurable:!0});import{basename as M,isAbsolute as C,matchesGlob as v,relative as p,sep as l}from"node:path";import{commandSegments as G,stripHeredocs as O}from"../shell-segments.js";import{CRTR_DIR_NAME as $}from"../../types.js";import{realpathOrSelf as g}from"../fs-utils.js";import{evalCondition as D}from"../predicate.js";import{surfaceEntryGatePasses as c}from"./gate.js";import{rungRank as R}from"./schema.js";function E(e){const t=e.path.split(l),n=t.lastIndexOf($);return n<=0?null:t.slice(0,n).join(l)||l}i(E,"owningRootOf");function N(e,t){const n=E(e);if(n===null)return!1;const r=p(g(n),t);return r!==""&&!r.startsWith("..")&&!C(r)}i(N,"underOwningRoot");function a(e,t){try{return v(e,t)}catch{return!1}}i(a,"safeGlob");function P(e,t,n){if(e.startsWith("./")){if(t.scope!=="project"||!N(t,n))return!1;const r=E(t);return r===null?!1:a(p(g(r),n),e.slice(2))}return a(n,e)||a(M(n),e)}i(P,"readGlobMatches");function S(e,t,n,r,o){return e.on!=="read"||!c(e,n)||e.match!==void 0&&!e.match.some(s=>P(s,t,r))||e.matchFrontmatter!==void 0&&(Object.keys(o).length===0||!D(e.matchFrontmatter,o))?!1:e.match!==void 0||e.matchFrontmatter!==void 0}i(S,"matchesReadEntry");function W(e,t,n){if(e.startsWith("./")){const r=e.slice(2);return t===""?a(n,r):n.startsWith(t+"/")?a(n.slice(t.length+1),r):!1}return a(n,e)}i(W,"memoryReadGlobMatches");function k(e,t,n,r){return e.on!=="memory-read"||e.match===void 0||!c(e,n)?!1:e.match.some(o=>W(o,t,r))}i(k,"matchesMemoryReadEntry");function F(e){const t=e.trim().split(/\s+/);if(t.length===1&&t[0]==="")return null;const n=[];for(const r of t){const o=r.split("*");for(let s=0;s<o.length;s+=1)o[s]!==""&&n.push({kind:"literal",text:o[s]}),s<o.length-1&&n.push({kind:"any"})}return n}i(F,"commandGlobPattern");function b(e,t){const n=e.split("").map(r=>r==="?"?"[\\s\\S]":r.replace(/[.+^${}()|[\]\\]/g,"\\$&")).join("");return new RegExp(`^${n}$`).test(t)}i(b,"tokenMatches");function _(e,t){const n=new Map,r=i((o,s)=>{const h=`${o}:${s}`,d=n.get(h);if(d!==void 0)return d;let u;if(o===e.length)u=s===t.length;else if(e[o].kind==="any")u=r(o+1,s)||s<t.length&&r(o,s+1);else{const m=t[s];u=m!==void 0&&!m.opaque&&b(e[o].text,m.text)&&r(o+1,s+1)}return n.set(h,u),u},"match");return r(0,0)}i(_,"segmentMatches");function w(e,t){const n=F(e);return n===null?!1:G(t).filter(({tokens:r})=>r.length>0).some(({tokens:r})=>_(n,r))}i(w,"commandGlobMatches");function q(e,t){return e.on==="command"&&e.match!==void 0&&e.match.some(n=>w(n,t))}i(q,"commandEntryMatches");function A(e,t,n){return q(e,n)&&c(e,t)}i(A,"matchesCommandEntry");function H(e,t){return e.on!=="pre-command"||e.match===void 0?!1:e.match.some(n=>w(n,O(t)))}i(H,"preCommandEntryMatches");function T(e,t,n){return H(e,n)&&c(e,t)}i(T,"matchesPreCommandEntry");function j(e,t,n,r,o){if(e.on!==r)return!1;switch(r){case"boot":case"workspace-open":return c(e,n);case"read":return o.absoluteFile===void 0||t.path===void 0||t.scope===void 0?!1:S(e,{path:t.path,scope:t.scope},n,o.absoluteFile,o.readFrontmatter??{});case"memory-read":return o.resolvedCanonicalName===void 0?!1:k(e,o.routingAnchor??"",n,o.resolvedCanonicalName);case"command":return o.command!==void 0&&A(e,n,o.command);case"pre-command":return o.command!==void 0&&T(e,n,o.command)}}i(j,"surfaceEntryParticipates");function f(e,t,n,r){let o=null;for(const s of e.surfaces)j(s,e,t,n,r)&&(o===null||R(s.at)>R(o.at))&&(o=s);return o}i(f,"matchingSurfaceEntry");function X(e,t,n,r){return f(e,t,"read",{absoluteFile:n,readFrontmatter:r})?.at??"none"}i(X,"readDeliveryRung");function Y(e,t){return f(e,t,"workspace-open",{})?.at??"none"}i(Y,"workspaceOpenRung");function Z(e,t,n,r){return f(e,n,"memory-read",{routingAnchor:t,resolvedCanonicalName:r})?.at??"none"}i(Z,"memoryReadDeliveryRung");function y(e,t,n){return f(e,t,"command",{command:n})?.at??"none"}i(y,"commandDeliveryRung");function I(e,t,n){return f(e,t,"pre-command",{command:n})?.at??"none"}i(I,"preCommandDeliveryRung");export{y as commandDeliveryRung,q as commandEntryMatches,A as matchesCommandEntry,k as matchesMemoryReadEntry,T as matchesPreCommandEntry,S as matchesReadEntry,f as matchingSurfaceEntry,Z as memoryReadDeliveryRung,E as owningRootOf,I as preCommandDeliveryRung,H as preCommandEntryMatches,X as readDeliveryRung,j as surfaceEntryParticipates,N as underOwningRoot,Y as workspaceOpenRung};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var Fe=Object.defineProperty;var m=(e,t)=>Fe(e,"name",{value:t,configurable:!0});import{createHash as We}from"node:crypto";import{getNode as Z,findNodeBySessionFile as Be}from"../../../core/canvas/canvas.js";import{interpolateNodePaths as ce}from"../../../core/canvas/paths.js";import{existsSync as Ge,readFileSync as ue,realpathSync as ze,statSync as Ue}from"node:fs";import{join as K,resolve as Ze}from"node:path";import{loadProfileManifest as Ke,resolveProfileOperand as He}from"../../../core/profiles/manifest.js";import{conversationStore as Ve,ConversationNotFoundError as Ye}from"../../../core/conversation-store/index.js";import{ApiError as l}from"../../../api/errors.js";import{paginate as H}from"../../../core/pagination.js";import{appSpace as V}from"../../../core/layout.js";import{memoryPermission as fe,readableProjectForScopes as Je}from"../../../core/spaces/permissions.js";import{canReadRun as Xe,resolvedScopes as Y}from"../router.js";import{CrtrError as J}from"../../../core/errors.js";import{memoryDir as Qe}from"../../../core/runtime/memory.js";import{NEUTRAL_PROJECT_MEMORY as xe,projectScopeRoot as X,projectScopeRootsWithMemory as et,scopeMemoryDir as pe,ensureProjectScopeRoot as tt}from"../../../core/scope.js";import{descendantStoreDiscoveryWarnings as ot}from"../../../core/nested-stores.js";import{profileMemoryDir as nt}from"../../../core/profiles/manifest.js";import{openProjectMemoryStore as Q}from"../../../core/memory-resolver.js";import{effectivePrivacy as x,PRIVACY_LEVELS as B}from"../../../core/substrate/schema.js";import{lintMemoryStore as he,lintMemoryTarget as rt,lintOrphans as it,resolvableCanonicalNames as st}from"../../../core/memory/lint.js";import{createMemoryDocSnapshot as ye,loadMemoryTargetView as ge,memoryStoresInPrecedence as ee}from"../../../core/memory-resolver.js";import{parseSubstrateDoc as we}from"../../../core/substrate/schema.js";import{parseFrontmatterGeneric as be}from"../../../core/frontmatter.js";import{dirDedupKey as at,docsByName as dt,renderDirListing as lt}from"../../../core/substrate/listings.js";import{memoryExtensionEffectiveCatalog as mt,memoryExtensionValidationCatalog as ct,projectEffectiveMemoryExtensions as ut}from"../../../core/memory/extensions.js";import{effectiveDocKind as ft}from"../../../core/substrate/schema.js";import{requireUnambiguousDoc as pt}from"../../../core/memory/mutation-domain.js";import{contentReadAttachments as ve}from"../../../core/substrate/on-read.js";import{assembleNodeSubject as _e}from"../../../core/substrate/subject.js";import{emptyContextExposureState as ht,exposureTarget as G,loadContextExposureState as te,registerDocumentExposure as Se,registerExposure as ke,saveContextExposureState as z}from"../../../core/substrate/injected-store.js";import{insertMemoryReads as yt}from"../../../core/canvas/memory-reads.js";import{emitEvent as gt}from"../../../core/events/emit.js";import{memoryEvents as oe}from"../../../core/substrate/memory-events.js";import{candidateLocation as qe,compareMemoryListKeys as wt,memoryListKey as bt,createDoc as je,deleteDoc as De,listDocs as vt,moveDoc as Re,readDoc as Ee,readHistory as _t,searchDocs as St,updateDoc as $e}from"../../../core/memory/service.js";import{MEMORY_SCOPES as Ie,isMemoryDocName as M}from"../../../api/dto/memory.js";import{invalidRequest as N,isRecord as E,objectBody as C,optionalString as I,requiredString as $}from"./validate.js";const P="read",q="rw",ne=100,Pe=100;function A(e){const t=e.params.name;if(t===void 0||!M(t))throw new l(400,"invalid_memory_doc_name","memory document name must be slash-joined [A-Za-z0-9_-] segments");return t}m(A,"requireName");function O(e){return Object.fromEntries(e.query.entries())}m(O,"queryObject");function F(e,t,o,i){return{scope:e,storeRoot:t,namespace:"",mountStatus:"ready",projectMemory:xe,ownerApp:o,profileId:i}}m(F,"nativeStore");function T(e,t){if(e.principal.class==="person")return!0;const o=e.principal.app;return process.platform!=="linux"&&o==="app:terminal"?!0:Je(t,o,Y(e.principal),e.principal.class==="broker"?e.principal.scopes:null)}m(T,"projectReadable");function v(e,t,o,i="read"){const s=[];for(const u of Object.keys(t))o.includes(u)||s.push({field:u,problem:"is not allowed",received:t[u]});const n=I(t,"node",s),r=I(t,"cwd",s),a=I(t,"profile",s),d=I(t,"store",s),f=I(t,"dir",s),c=I(t,"select_profile",s);if(f!==void 0&&(d!==void 0||c!==void 0)&&s.push({field:"dir",problem:"selects the project store itself and cannot combine with store or select_profile"}),c!==void 0&&d!=="profile"&&s.push({field:"select_profile",problem:"requires store profile"}),d!==void 0&&!Ie.includes(d)&&!/^app:[A-Za-z0-9_-]{1,64}$/.test(d)&&s.push({field:"store",problem:`must be one of ${Ie.join(", ")} or app:<id>`,received:d}),e.principal.class==="app"&&(n!==void 0||r!==void 0||a!==void 0||f!==void 0||c!==void 0||t.mode==="cli"))throw new l(403,"scope_missing","an app server cannot select a node, cwd or profile");if(e.principal.class==="broker"&&(n!==void 0&&n!==e.principal.node||r!==void 0||a!==void 0||f!==void 0||c!==void 0))throw new l(403,"scope_missing","a broker can select only its own node and mounted memory");n!==void 0&&a!==void 0&&s.push({field:"node",problem:"derives profile and cannot be combined with it"}),s.length>0&&N("memory scope",s);let g,k;if(n!==void 0){const u=Z(n);if(u===null)throw new l(404,"node_not_found",`unknown node: ${n}`);g={cwd:r??u.cwd,profileId:u.profile_id??null,nodeId:u.node_id,grantee:u.grantee},k=u.node_id}else g={cwd:r??(e.principal.class==="broker"?Z(e.principal.node)?.cwd??"/":e.principal.class==="app"?V(e.principal.app).files:"/"),profileId:a??(e.principal.class==="broker"?Z(e.principal.node)?.profile_id??null:null),nodeId:e.principal.class==="broker"?e.principal.node:null,grantee:e.principal.class==="person"?void 0:e.principal.app},e.principal.class==="broker"&&(k=e.principal.node);const b=d;if(b==="node"&&k===void 0)throw new l(400,"invalid_request","store node requires node");if(b==="profile"&&g.profileId===null&&c===void 0)throw new l(400,"invalid_request","store profile requires profile or node with a profile");if(c!==void 0&&(g={...g,profileId:He(c).profileId}),f!==void 0){const u=Ze(g.cwd,f);if(!Ge(u)||!Ue(u).isDirectory())throw new l(400,"invalid_request",`--dir does not exist or is not a directory: ${f}`);const R=Q(ze(u));if(!T(e,R.repositoryRoot??R.ownerDir??u))throw new l(403,"scope_missing","project memory is outside the run mounts");return g={...g,allowsStore:m((y,me)=>y.scope==="project"&&T(e,y.repositoryRoot??y.ownerDir??y.storeRoot),"allowsStore"),allowsProject:m(y=>T(e,y),"allowsProject")},{target:g,nodeId:k,store:R,access:i,permitted:m(y=>y.scope==="project"&&T(e,y.repositoryRoot??y.ownerDir??y.storeRoot),"permitted")}}const h=e.principal,w=h.class==="person"?[]:Y(h),p=h.class==="broker"?h.scopes:null,S=h.class==="person"?null:h.app,D=m((u,R)=>h.class==="person"?!0:u.scope==="project"?T(e,u.repositoryRoot??u.ownerDir??u.storeRoot):fe(S,w,p,u,i,R),"permitted");if(g={...g,allowsStore:D,allowsProject:m(u=>T(e,u),"allowsProject")},d?.startsWith("app:")||h.class==="app"&&d===void 0){const u=d??(h.class==="person"?"app:terminal":h.app),R=F("profile",V(u).memory,u);if(!D(R))throw new l(403,"scope_missing",`missing memory permission for ${u}`);return{target:g,nodeId:k,store:R,access:i,permitted:D}}if(b!==void 0&&h.class!=="person"){const u=ee({...g,allowsStore:void 0,allowsProject:void 0},b);if(u.length===0||!u.some(R=>D(R)))throw new l(403,"scope_missing",`missing memory permission for ${b}`)}return{target:g,...b===void 0?{}:{scope:b},...k===void 0?{}:{nodeId:k},access:i,permitted:D}}m(v,"resolveScope");function _(e,t){if(e.access!==t)throw new Error("memory route access mismatch");if(e.store!==void 0&&!e.permitted(e.store))throw new l(403,"scope_missing","memory store is not permitted")}m(_,"requireScope");function U(e,t,o){if(!e.permitted(t,o))throw new l(403,"scope_missing",`missing memory write permission for ${o}`)}m(U,"requireWrite");function j(e,t){const o=e.scope;if(!t)return{...o===void 0?{}:{scope:o},...e.store===void 0?{}:{store:e.store}};if(e.store!==void 0)return{scope:e.store.scope,store:e.store,memoryDir:e.store.storeRoot};const i=o??(e.target.nodeId?"node":X(e.target.cwd)!==null?"project":"user");if(i==="builtin")throw new l(400,"invalid_request","builtin memory is read-only");if(i==="node"){const r=Qe(e.target.nodeId,e.target.grantee),a=F("node",r,e.target.grantee);if(!e.permitted(a))throw new l(403,"scope_missing","node memory is not permitted");return{scope:i,store:a,memoryDir:r}}if(i==="profile"){const{profileId:r,manifest:a}=Ke(e.target.profileId),d=a.grantee?.startsWith("app:")?K(V(a.grantee).memory,"profiles",r):nt(r),f=F("profile",d,a.grantee,r);if(!e.permitted(f))throw new l(403,"scope_missing","profile memory is not permitted");return{scope:i,store:f,memoryDir:d}}if(i==="project"){const r=o==="project"?tt(e.target.cwd):X(e.target.cwd);if(r===null)throw new l(400,"invalid_request","store project requires a project memory store in cwd");const a=Q(r.slice(0,-8).replace(/\/$/,""));if(!e.permitted(a))throw new l(403,"scope_missing","project memory is outside the run mounts");return{scope:i,store:a,memoryDir:a.storeRoot}}const s=pe("user");if(s===null)throw new Error("user memory directory unavailable");const n=F("user",s);if(!e.permitted(n))throw new l(403,"scope_missing","user memory is not permitted");return{scope:"user",store:n,memoryDir:s}}m(j,"selection");function Ae(e,t){return e.length>1?e.map(o=>qe(o,t)):void 0}m(Ae,"candidates");function Te(e){return{name:e.name,short_form:e.shortForm,kind:e.kind,privacy:e.privacy,scope:e.scope,extensions:e.extensions,path:e.path,store_root:e.storeRoot,physical_relative_path:e.physicalRelativePath,...Ae(e.candidates,e.candidates[0])===void 0?{}:{candidates:Ae(e.candidates,e.candidates[0])}}}m(Te,"summary");function re(e){try{const t=Ee(e);if(t.kind==="document")return t}catch(t){if(!(t instanceof J)||t.code!=="not_found")throw t}throw new l(404,"memory_document_not_found",`memory document not found: ${e.name}`)}m(re,"requestedDocument");function ie(e,t,o=j(t,!1),i=!1){const s=re({target:t.target,...o,name:e,frontmatter:i,interpolateNodePaths:!1}),n=s.doc;return{...Te({name:n.name,kind:String(n.frontmatter?.kind??""),privacy:x(n.frontmatter),scope:n.scope,path:n.path,storeRoot:n.root,physicalRelativePath:n.physicalRelativePath,shortForm:String(n.frontmatter?.["short-form"]??""),slash:n.frontmatter?.slash===!0,extensions:n.frontmatter?.extensions??{},candidates:s.candidates}),body:s.content,frontmatter:n.frontmatter===null?null:{...n.frontmatter,privacy:x(n.frontmatter)},representation:n.representation,links:[...s.links]}}m(ie,"document");function se(e,t,o){if(e===void 0)return o;const i=typeof e=="number"?e:Number(e);if(!Number.isInteger(i)||i<1||i>Pe)throw new l(400,"invalid_request",`${t} must be an integer from 1 through ${Pe}`);return i}m(se,"number");function ae(e,t,o){if(e===void 0)return t;const i=typeof e=="number"||typeof e=="string"&&e.trim()!==""?Number(e):NaN;if(!Number.isInteger(i)||i<1||o!==void 0&&i>o)throw new l(400,"invalid_request",`limit must be ${o===void 0?"a positive integer":`an integer from 1 through ${o}`}`);return i}m(ae,"cliLimit");function Oe(e,t){const o=typeof e=="number"?e:Number(e);if(!Number.isFinite(o)||o<1)throw new l(400,"invalid_request",`${t} must be a finite number of at least 1`);return o}m(Oe,"positiveNumber");function W(e,t){const o=e[t];if(o!==void 0){if(o===!0||o==="true")return!0;if(o===!1||o==="false")return!1;throw new l(400,"invalid_request",`${t} must be a boolean`)}}m(W,"optionalBoolean");function Ne(e,t,o=[]){if(e!==void 0&&!E(e))throw new l(400,"invalid_request","frontmatter must be an object");const i=e===void 0?{}:e;for(const r of o)if(r in i)throw new l(400,"invalid_request",`frontmatter.${r} cannot be set directly`);const s={},n={"short-form":"shortForm","when-and-why-to-read":"whenAndWhyToRead","lint-ignore":"lintIgnore",rationale:"docRationale",kind:"kind",privacy:"privacy",unlisted:"unlisted",surfaces:"surface",gate:"gate",slash:"slash"};for(const[r,a]of Object.entries(i)){const d=n[r];if(d===void 0)throw new l(400,"invalid_request",`frontmatter.${r} is not writable through this route`);if(r==="privacy"){if(!B.includes(a))throw new l(400,"invalid_request",`frontmatter.privacy must be one of ${B.join(", ")}`)}else if(r==="unlisted"||r==="slash"){if(a!==!0)throw new l(400,"invalid_request",`frontmatter.${r} must be true; remove it with unset`)}else if(r==="surfaces"){if(!Array.isArray(a)||!a.every(f=>typeof f=="string"))throw new l(400,"invalid_request","frontmatter.surfaces must be a string array")}else if(r==="lint-ignore"){if(!Array.isArray(a)||!a.every(f=>typeof f=="string"))throw new l(400,"invalid_request","frontmatter.lint-ignore must be a string array")}else if(typeof a!="string"||a.trim()==="")throw new l(400,"invalid_request",`frontmatter.${r} must be a non-empty string`);s[d]=a}if(t!==void 0){if(!E(t))throw new l(400,"invalid_request","extensions must be an object");const r=[];for(const[a,d]of Object.entries(t)){if(!E(d))throw new l(400,"invalid_request",`extensions.${a} must be an object`);for(const[f,c]of Object.entries(d))r.push(`extensions.${a}.${f}=${String(c)}`)}s.extension=r}return s}m(Ne,"frontmatterFields");function de(e,t){if(t.nodeId!==void 0&&e.principal.class!=="app"){if(e.principal.class==="broker"&&e.principal.node!==t.nodeId)throw new l(403,"other_app_run","memory exposure can only be recorded for the calling node");return t.nodeId}}m(de,"ledgerNode");function Ce(e,t,o,i){const s=de(e,t);if(s===void 0||i.length===0)return;const n=te(s),r=We("sha256").update(JSON.stringify(i)).digest("hex");ke(G(n,"transcript"),`listing:memory-${o}:${r}`,"content"),z(s,n)}m(Ce,"listingExposure");function Me(e,t){if(t.length!==0)try{yt(e,t)}catch(o){gt({level:"warn",event:"memory_reads.insert_failed",error:o,fields:{node_id:e}})}}m(Me,"recordMemoryReads");function kt(e){const t=O(e),o=[],i=I(t,"kind",o),s=I(t,"after",o);o.length>0&&N("memory list query",o);const n=v(e,t,["node","cwd","profile","store","dir","select_profile","mode","kind","limit","cursor","after"]);_(n,P);const r=vt({target:n.target,...j(n,!1),...i===void 0?{}:{kind:i}});if(t.mode==="cli"){const c=H(r,{limit:ae(t.limit,50,200),cursor:t.cursor},{defaultLimit:50,maxLimit:200,keyOf:bt,compareKeys:wt,total:"count"});return Ce(e,n,"list",c.items),{status:200,body:c}}r.sort((c,g)=>c.name.localeCompare(g.name));const a=s===void 0?r:r.filter(c=>c.name.localeCompare(s)>0),d=a.slice(0,se(t.limit,"limit",ne)).map(Te);return{status:200,body:{object:"list",data:d,has_more:a.length>d.length}}}m(kt,"handleList");function qt(e){const t=O(e);if(t.mode==="cli"){const i=v(e,t,["node","cwd","profile","store","dir","mode","kind","frontmatter"]);_(i,P);const s=A(e),n=Ee({target:i.target,...j(i,!1),name:s,...t.kind===void 0?{}:{kind:String(t.kind)},frontmatter:W(t,"frontmatter")===!0}),r=de(e,i),a=r===void 0?ht():te(r),d=[],f=G(a,"transcript",d);if(n.kind==="directory"){const u=lt(n.listingByName,n.name,r===void 0?null:f,!1);return r!==void 0&&(ke(f,at(n.name),"preview"),z(r,a)),{status:200,body:{name:n.name,listing:u,follow_up:"Each line is readable with `crtr memory read <name>` \u2014 a `[[name]]: <line>` entry is a doc, a bare `[[name]]` is a subdirectory whose read browses deeper. Browse the whole inventory with `crtr memory list`."}}}const{doc:c,candidates:g,content:k,links:b,listingByName:h}=n;Se(G(a,"transcript"),c,"content");const w=ve(c,{subject:i.nodeId===void 0?null:_e(i.nodeId),target:f,byName:h,memoryTarget:i.target,listings:"blocks",explicit:!0});if(r!==void 0){z(r,a);const u=new Date().toISOString();Me(r,[...oe([{name:c.name,scope:c.scope}],"read",u),...oe(d,"loaded",u)])}const p=w.listing,S=p!==void 0&&p.length>0,D=S?b.length>0?"Each `[[name]]` line in `listing` is one of this directory\u2019s immediate members, and the `[[name]]` links in the body are further reading \u2014 follow either with `crtr memory read <name>` only when the task needs that depth.":"Each `[[name]]` line in `listing` is one of this directory\u2019s immediate members, readable with `crtr memory read <name>` \u2014 follow one only when the task needs that depth.":b.length>0?"The `[[name]]` links in the body are further reading \u2014 follow one with `crtr memory read <name>` only when the task needs that depth.":null;return{status:200,body:{name:c.name,local_name:c.localName,kind:ft(c),privacy:x(c.frontmatter),scope:c.scope,path:c.path,store_root:c.root,physical_relative_path:c.physicalRelativePath,representation:c.representation,...g.length>1?{candidates:g.map(u=>qe(u,c))}:{},content:k,attachment_blocks:w.blocks,...S?{listing:p}:{},extensions:ut(c.frontmatter?.extensions,mt(c)),...b.length>0?{links:b}:{},...D===null?{}:{follow_up:D}}}}const o=v(e,t,["node","cwd","profile","store","frontmatter"]);return _(o,P),{status:200,body:ie(A(e),o,j(o,!1),W(t,"frontmatter")===!0)}}m(qt,"handleRetrieve");function jt(e){if(E(e.body)&&e.body.mode==="cli"){const{mode:k,...b}=e.body,h=v(e,e.body,["node","cwd","profile","store","dir","select_profile","fields","mode"],q);_(h,q);const w=[],p=C(b.fields,["name","kind","whenAndWhyToRead","body","privacy","shortForm","unlisted","surface","gate","lintIgnore","slash","rationale","extension"],w),S=$(p,"name",w),D=$(p,"kind",w);$(p,"whenAndWhyToRead",w),$(p,"body",w),D!==void 0&&D!=="knowledge"&&D!=="preference"&&w.push({field:"kind",problem:"must be knowledge or preference",received:D});for(const y of["privacy","shortForm","gate","rationale"])p[y]!==void 0&&(typeof p[y]!="string"||p[y].trim()==="")&&w.push({field:y,problem:"must be a non-empty string",received:p[y]});p.privacy!==void 0&&!B.includes(p.privacy)&&w.push({field:"privacy",problem:`must be one of ${B.join(", ")}`,received:p.privacy});for(const y of["unlisted","slash"])p[y]!==void 0&&typeof p[y]!="boolean"&&w.push({field:y,problem:"must be a boolean",received:p[y]});for(const y of["surface","extension"])p[y]!==void 0&&(!Array.isArray(p[y])||!p[y].every(me=>typeof me=="string"))&&w.push({field:y,problem:"must be a string array",received:p[y]});if(p.lintIgnore!==void 0&&typeof p.lintIgnore!="string"&&(!Array.isArray(p.lintIgnore)||!p.lintIgnore.every(y=>typeof y=="string"))&&w.push({field:"lintIgnore",problem:"must be a string or string array",received:p.lintIgnore}),w.length>0&&N("memory create request",w),!M(S))throw new l(400,"invalid_memory_doc_name","memory document name must be slash-joined [A-Za-z0-9_-] segments");const u=j(h,!0);U(h,u.store,S);const R={created:new Date().toISOString(),cwd:h.target.cwd,...h.target.nodeId===null?{}:{node:h.target.nodeId}};return{status:200,body:je({target:h.target,scope:u.scope,store:u.store,memoryDir:u.memoryDir,isExplicitProjectStore:b.dir!==void 0||b.store==="project",origin:R,fields:p})}}const t=[],o=C(e.body,["name","kind","when_and_why_to_read","body","frontmatter","extensions","node","cwd","profile","store"],t),i=$(o,"name",t),s=$(o,"kind",t),n=$(o,"when_and_why_to_read",t),r=$(o,"body",t);if(t.length>0&&N("memory create request",t),!M(i))throw new l(400,"invalid_memory_doc_name","memory document name must be slash-joined [A-Za-z0-9_-] segments");const a=v(e,o,["name","kind","when_and_why_to_read","body","frontmatter","extensions","node","cwd","profile","store"],q);_(a,q);const d=j(a,!0);U(a,d.store,i);const f={name:i,kind:s,whenAndWhyToRead:n,body:r,...Ne(o.frontmatter,o.extensions,["kind","when-and-why-to-read","origin","last-updated"])},c=je({target:a.target,scope:d.scope,memoryDir:d.memoryDir,store:d.store,isExplicitProjectStore:!1,origin:{created:new Date().toISOString(),cwd:a.target.cwd,...a.target.nodeId===null?{}:{node:a.target.nodeId}},fields:f}),g=ie(c.name,a,d);return{status:200,body:c.findings===void 0?g:{...g,findings:c.findings}}}m(jt,"handleCreate");function Dt(e){if(E(e.body)&&e.body.mode==="cli"){const{mode:a,...d}=e.body,f=v(e,e.body,["node","cwd","profile","store","dir","select_profile","fields","mode"],q);if(_(f,q),!E(d.fields))throw new l(400,"invalid_request","fields must be an object");return{status:200,body:$e({target:f.target,selection:{target:f.target,...j(f,!1)},fields:{...d.fields,name:A(e)}})}}const t=[],o=C(e.body,["rationale","body","frontmatter","extensions","unset","node","cwd","profile","store"],t),i=$(o,"rationale",t);o.body!==void 0&&typeof o.body!="string"&&t.push({field:"body",problem:"must be a string",received:o.body}),o.unset!==void 0&&(!Array.isArray(o.unset)||!o.unset.every(a=>typeof a=="string"))&&t.push({field:"unset",problem:"must be a string array",received:o.unset}),t.length>0&&N("memory update request",t);const s=A(e),n=v(e,o,["rationale","body","frontmatter","extensions","unset","node","cwd","profile","store"],q);_(n,q);const r=Ne(o.frontmatter,o.extensions,["kind","when-and-why-to-read","origin","last-updated"]);return $e({target:n.target,selection:{target:n.target,...j(n,!1)},fields:{name:s,rationale:i,...o.body===void 0?{}:{body:o.body},...o.unset===void 0?{}:{unset:o.unset},...r}}),{status:200,body:ie(s,n)}}m(Dt,"handleUpdate");function Rt(e){if(E(e.body)&&e.body.mode==="cli"){const{mode:s,...n}=e.body,r=v(e,e.body,["node","cwd","profile","store","dir","fields","mode"],q);return _(r,q),{status:200,body:De({target:r.target,selection:{target:r.target,...j(r,!1)},fields:{name:A(e)}})}}const t=v(e,O(e),["node","cwd","profile","store"],q);_(t,q);const o=A(e);return{status:200,body:{...De({target:t.target,selection:{target:t.target,...j(t,!1)},fields:{name:o}}),deleted:!0}}}m(Rt,"handleDelete");function Et(e){if(E(e.body)&&e.body.mode==="cli"){const{mode:a,...d}=e.body,f=v(e,e.body,["node","cwd","profile","store","dir","fields","mode"],q);if(_(f,q),!E(d.fields))throw new l(400,"invalid_request","fields must be an object");if(typeof d.fields.to!="string"||!M(d.fields.to))throw new l(400,"invalid_memory_doc_name","move destination must be a memory document name");return Le(f,A(e),d.fields.to),{status:200,body:Re({target:f.target,selection:{target:f.target,...j(f,!1)},fields:{...d.fields,name:A(e)}})}}const t=[],o=C(e.body,["to","node","cwd","profile","store"],t),i=$(o,"to",t);if(t.length>0&&N("memory move request",t),!M(i))throw new l(400,"invalid_memory_doc_name","memory document name must be slash-joined [A-Za-z0-9_-] segments");const s=v(e,o,["to","node","cwd","profile","store"],q);_(s,q);const n=A(e);return Le(s,n,i),{status:200,body:Re({target:s.target,selection:{target:s.target,...j(s,!1)},fields:{name:n,to:i}})}}m(Et,"handleMove");function Le(e,t,o){const i=re({target:e.target,...j(e,!1),name:t}).doc;U(e,i.store,t),U(e,i.store,o)}m(Le,"requireMoveDestination");function le(e){return"line"in e?`${e.name}\0${e.scope}\0${e.physical_relative_path}\0${String(e.line).padStart(10,"0")}`:e.name}m(le,"grepCursor");function $t(e){const t=[],o=C(e.body,["query","kind","grep","body","limit","cursor","after","min_score","node","cwd","profile","store","dir","mode"],t),i=$(o,"query",t),s=I(o,"kind",t),n=I(o,"after",t);t.length>0&&N("memory search request",t);const r=v(e,o,["query","kind","grep","body","limit","cursor","after","min_score","node","cwd","profile","store","dir","mode"]);_(r,P);const a=W(o,"grep"),d=W(o,"body"),f=o.min_score===void 0?void 0:Oe(o.min_score,"min_score");if(a===!0&&d===!0)throw new l(400,"invalid_request","grep and body cannot both be true");if(a===!0&&f!==void 0)throw new l(400,"invalid_request","min_score is only available in ranked mode");const c=St({target:r.target,...j(r,!1),query:i,...s===void 0?{}:{kind:s},...a===void 0?{}:{grep:a},...d===void 0?{}:{body:d},...f===void 0?{}:{minScore:f}});if(o.mode==="cli"){const h=ae(o.limit,10,100),w=o.cursor,p=c.mode==="grep"?H([...c.hits],{limit:h,cursor:w},{defaultLimit:10,maxLimit:100,keyOf:m(S=>`${S.name}:${S.scope}:${S.physical_relative_path}:${String(S.line).padStart(7,"0")}`,"keyOf"),total:"omit"}):H([...c.hits],{limit:h,cursor:w},{defaultLimit:10,maxLimit:100,keyOf:m(S=>`${String(1e6-S.score).padStart(7,"0")}:${S.scope}:${S.name}:${S.physical_relative_path}`,"keyOf"),total:"omit"});return Ce(e,r,"find",p.items),{status:200,body:{mode:c.mode,matches:c.matches,hits:p.items,next_cursor:p.next_cursor}}}const g=[...c.hits].sort((h,w)=>a===!0?le(h).localeCompare(le(w)):h.name.localeCompare(w.name)),k=n===void 0?g:g.filter(h=>(a===!0?le(h):h.name).localeCompare(n)>0),b=k.slice(0,se(o.limit,"limit",ne));return{status:200,body:{object:"list",data:b,has_more:k.length>b.length}}}m($t,"handleSearch");function It(e){const t=O(e),o=v(e,t,["node","cwd","profile","store","dir","select_profile","mode","limit","revision","diff"]);_(o,P);const i=t.revision===void 0?void 0:Oe(t.revision,"revision"),s=W(t,"diff"),n=_t({target:o.target,...j(o,!1),name:A(e),limit:t.mode==="cli"?ae(t.limit,10):se(t.limit,"limit",ne),...i===void 0?{}:{revision:i},...s===void 0?{}:{diff:s}});return t.mode==="cli"?{status:200,body:n}:{status:200,body:{name:n.name,scope:n.scope,log_path:n.logPath,total:n.total,...n.deleted===void 0?{}:{deleted:n.deleted},..."record"in n?{record:n.record}:{revisions:[...n.revisions]}}}}m(It,"handleHistory");function Pt(e){const t=O(e),o=e.query.get("name");if(o===null||!M(o))throw new l(400,"invalid_memory_doc_name","memory document name must be slash-joined [A-Za-z0-9_-] segments");const i=v(e,t,["name","node","cwd","profile","store","dir","select_profile","mode"]);_(i,P);const s=re({target:i.target,...j(i,!1),name:o});if(t.mode==="cli"){const n=pt({name:o,winner:s.doc,candidates:s.candidates});return{status:200,body:{name:n.name,path:n.path,scope:n.scope,local_name:n.localName,store_root:n.root,physical_relative_path:n.physicalRelativePath,representation:n.representation,origin:n.frontmatter?.origin??null}}}return{status:200,body:{name:s.doc.name,scope:s.doc.scope,path:s.doc.path,store_root:s.doc.root,physical_relative_path:s.doc.physicalRelativePath,...s.doc.plugin===void 0?{}:{plugin:s.doc.plugin}}}}m(Pt,"handleResolve");function At(e){const t=v(e,O(e),["node","cwd","profile"]);_(t,P);const o=ye(t.target),i=new Set,s=[];for(const n of o.docs){if(i.has(n.name))continue;i.add(n.name);const r=we(n);if(r?.slash===!0)try{const a=ue(n.path,"utf8"),d=be(a).body;s.push({name:n.name,short_form:r.shortForm,path:n.path,canonical_body:n.body,execution_body:t.nodeId===void 0?d:ce(d,t.nodeId,t.target.grantee)})}catch(a){s.push({name:n.name,short_form:r.shortForm,path:n.path,canonical_body:n.body,error:a instanceof Error?a.message:String(a)})}}return{status:200,body:s}}m(At,"handleSlashDocs");async function Tt(e){const t=C(e.body,["node","name"],[]),o=v(e,t,["node","name"]);if(_(o,P),o.nodeId===void 0)throw new l(400,"invalid_request","slash attachments require a node");const i=$(t,"name",[]);if(i===void 0)throw new l(400,"invalid_request","slash document name required");const n=ye(o.target).resolve([i]).get(i);if(n===void 0)throw new l(404,"not_found",`memory slash document not found: ${i}`);const r=de(e,o);if(r===void 0)throw new l(403,"permission_error","slash attachments require the calling node");const a=be(ue(n.path,"utf8")),d={...n,frontmatter:a.data,body:a.body};if(we(d)?.slash!==!0)throw new l(404,"not_found",`memory slash document not found: ${i}`);const f=ce(d.body,r,o.target.grantee),c=te(r),g=[],k=G(c,"transcript",g);Se(k,d,"content");const b=ge(o.target,{quiet:!0,includeDescendants:!0}),h=ve(d,{subject:_e(o.nodeId),target:k,byName:dt(b.docs),memoryTarget:o.target,listings:"blocks"}).blocks;return z(r,c),Me(r,oe(g,"loaded")),{status:200,body:{blocks:h,execution_body:f}}}m(Tt,"handleSlashAttachments");function Ot(e){const t=C(e.body,["node","cwd","profile","store","dir","mode"],[]),o=v(e,t,["node","cwd","profile","store","dir","mode"]);if(_(o,P),t.dir!==void 0&&(typeof t.dir!="string"||t.dir===""))throw new l(400,"invalid_request","dir must be a nonempty directory path");if(t.dir!==void 0&&t.store!==void 0)throw new l(400,"invalid_request","dir selects one store and cannot combine with store");if(e.principal.class!=="person"){const n=o.store??(o.scope===void 0?void 0:ee(o.target,o.scope).find(d=>d.mountStatus==="ready"));if(n===void 0||(n.scope==="project"?!T(e,n.repositoryRoot??n.ownerDir??n.storeRoot):!fe(e.principal.app,Y(e.principal),e.principal.class==="broker"?e.principal.scopes:null,n,"read",void 0,!0)))throw new l(403,"scope_missing","memory lint requires a whole-store read grant and an explicit store");const r=he(n),a=m(d=>({rule:d.rule,path:d.path,message:d.message}),"row");return{status:200,body:{checked:r.checked,stores:r.storesLinted,findings:r.errors.map(a),warnings:r.warnings.map(a),notices:r.notices.map(a)}}}const i=t.dir===void 0?rt({target:o.target,...o.scope===void 0?{}:{scope:o.scope}}):(()=>{const n=o.store,r=ge({...o.target,cwd:n.ownerDir??n.storeRoot,nodeId:null},{quiet:!0,includeDescendants:!0}),a=he(n,{resolvable:st(r.docs),frontDoor:"advisory"}),d=it(r.docs,{flagStoreRoot:n.storeRoot});return{...a,findings:[...a.findings,...d],warnings:[...a.warnings,...d]}})(),s=m(n=>({rule:n.rule,path:n.path,message:n.message,...n.name===void 0?{}:{name:n.name},...n.scope===void 0?{}:{scope:n.scope},...n.storeRoot===void 0?{}:{store_root:n.storeRoot},...n.paths===void 0?{}:{paths:[...n.paths]}}),"row");return{status:200,body:{checked:i.checked,stores:i.storesLinted,..."profileProjects"in i?{profile_projects:i.profileProjects}:{},findings:i.errors.map(s),warnings:i.warnings.map(s),notices:i.notices.map(s)}}}m(Ot,"handleLint");function Nt(e){const t=v(e,O(e),["node","cwd","profile"]);_(t,P);const o=X(t.target.cwd),i=o!==null&&T(e,t.target.cwd)?"project":"user",s=i==="user"?pe("user"):K(o,"memory");if(e.principal.class!=="person"&&!t.permitted(i==="user"?F("user",s):Q(t.target.cwd)))throw new l(403,"scope_missing","memory extensions are not permitted");if(s===null)throw new Error("user memory directory unavailable");return{status:200,body:ct({scope:i,path:K(s,".extension-help.md")})}}m(Nt,"handleExtensionCatalog");function L(e,t){const o=E(e.body)&&e.body.mode==="cli"?e.body:O(e);if(!E(o)||o.mode!=="cli")return t(e);const i=Object.fromEntries(["node","cwd","profile","store","dir","select_profile"].filter(r=>o[r]!==void 0).map(r=>[r,o[r]])),s=v(e,i,Object.keys(i)),n=(s.store===void 0?ee(s.target,s.scope,!0,!1):[s.store]).filter(r=>r.mountStatus!=="ready"&&r.mountStatus!=="absent"&&r.diagnostic!==void 0).map(r=>`memory store not mounted: ${r.diagnostic}`);s.store===void 0&&(s.scope===void 0||s.scope==="project")&&n.push(...ot(et(s.target.cwd,s.target.profileId).map(({root:r})=>r).filter(r=>T(e,r))));try{const r=t(e);return n.length===0||!E(r.body)?r:{...r,body:{...r.body,diagnostics:n}}}catch(r){throw n.length>0&&r instanceof l&&r.status===404?new l(r.status,r.code,`${r.message}
|
|
2
|
-
${n.join(`
|
|
3
|
-
`)}`,r.details):n.length>0&&r instanceof J&&r.code==="not_found"?new J(r.code,`${r.message}
|
|
4
|
-
${n.join(`
|
|
5
|
-
`)}`,r.exitCode,r.details):r}}m(L,"withCliDiscovery");function Ct(e){const t=e.query.get("conversation_id");if(t===null||!/^[0-9a-f-]{36}$/i.test(t)||e.query.size!==1)throw new l(400,"invalid_request","conversation_id must be a single conversation UUID");try{const o=Ve().header(t),i=Be(o.path);if(e.principal.class!=="person"&&(i===null||!Xe(e.principal,i.grantee??"app:terminal")))throw new l(404,"not_found",`conversation not found: ${t}`);return{status:200,body:{session_file:o.path}}}catch(o){throw o instanceof Ye?new l(404,"not_found",`conversation not found: ${t}`):o}}m(Ct,"handleOriginConversation");const _o=[{method:"GET",pattern:"/v1/memory/docs",handler:m(e=>L(e,kt),"handler")},{method:"GET",pattern:"/v1/memory/docs/:name",handler:m(e=>L(e,qt),"handler")},{method:"POST",pattern:"/v1/memory/docs",handler:jt},{method:"PATCH",pattern:"/v1/memory/docs/:name",handler:Dt},{method:"DELETE",pattern:"/v1/memory/docs/:name",handler:Rt},{method:"POST",pattern:"/v1/memory/docs/:name/move",handler:Et},{method:"POST",pattern:"/v1/memory/search",handler:m(e=>L(e,$t),"handler")},{method:"GET",pattern:"/v1/memory/docs/:name/history",handler:m(e=>L(e,It),"handler")},{method:"GET",pattern:"/v1/memory/resolve",handler:m(e=>L(e,Pt),"handler")},{method:"GET",pattern:"/v1/memory/origin",handler:Ct},{method:"GET",pattern:"/v1/memory/extensions",handler:Nt},{method:"POST",pattern:"/v1/memory/lint",handler:m(e=>L(e,Ot),"handler")},{method:"GET",pattern:"/v1/memory/slash",handler:At},{method:"POST",pattern:"/v1/memory/slash/attachments",handler:Tt}];export{_o as memoryRoutes};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=Object.defineProperty;var o=(e,n)=>u(e,"name",{value:n,configurable:!0});import{parse as m}from"yaml";import{parseFrontmatterGeneric as d}from"../core/frontmatter.js";import{appendRenderedKey as h,dropTopLevelKeys as g,proveFrontmatterRoundTrip as y,rebuildDocSource as b}from"./frontmatter-splice.js";const a=["system-prompt-visibility","file-read-visibility","applies-to","read-when"],f=["none","name","preview","content"];function p(e){return f.indexOf(e)}o(p,"rungRank");function c(e){return typeof e=="string"&&f.includes(e)?e:"none"}o(c,"parseRung");function v(e){return typeof e=="string"?e.trim()===""?[]:[e]:Array.isArray(e)?e.filter(n=>typeof n=="string"&&n.trim()!==""):[]}o(v,"parseAppliesTo");function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}o(w,"parsePredicate");function l(e){return e.split("/").map(n=>n.replace(/^\d{2}-/,"")).join("/")}o(l,"normalizeName");function k(e){const n=e.frontmatter;if(n===null||n.kind!=="knowledge"&&n.kind!=="preference")return null;const t=l(e.relPath.replace(/\.md$/,"")),r=n.name,i=typeof r=="string"&&r.trim()!==""?l(r.trim()):t;return{doc:e,name:i,spv:c(n["system-prompt-visibility"]),fv:c(n["file-read-visibility"]),appliesTo:v(n["applies-to"]),readWhen:w(n["read-when"]),hasOldFields:a.some(s=>s in n)}}o(k,"classify");function D(e){const n=new Map;for(const t of e){if(t.name!=="INDEX"&&!t.name.endsWith("/INDEX"))continue;const r=t.name==="INDEX"?"":t.name.slice(0,t.name.length-6);n.has(r)||n.set(r,t.spv)}return n}o(D,"buildCeiling");function N(e,n){let t=e.spv;const r=e.name.split("/");r.pop();for(let i=r.length;i>0;i--){const s=n.get(r.slice(0,i).join("/"));s!==void 0&&p(s)<p(t)&&(t=s)}return t}o(N,"effectiveBootRung");function W(e){const n=e.trim();return!n.includes("/")||n.startsWith("/")||n.startsWith("**")||n.startsWith("./")?n:`./${n}`}o(W,"anchorReadGlob");function E(e,n){const t=[];if(e.spv!=="none"&&n!=="none"&&t.push({on:"boot",at:n}),e.fv!=="none"){e.appliesTo.some(i=>i.trim()===".")&&(t.push({on:"workspace-open",at:e.fv}),t.push({on:"read",match:"./**",at:e.fv}));const r=e.appliesTo.filter(i=>i.trim()!==".").map(W);r.length>0&&t.push({on:"read",match:r.length===1?r[0]:r,at:e.fv}),e.readWhen!==void 0&&t.push({on:"read","match-frontmatter":e.readWhen,at:e.fv})}return t}o(E,"planEntries");function F(e,n,t){let r=g(e,a,t);n.length>0?r=h(r,"surfaces",n,t):r=r.replace(/\r?\n$/,"");const i={...m(e)};for(const s of a)delete i[s];return n.length>0&&(i.surfaces=n),y(r,i,t),r}o(F,"migratedYaml");const x={id:"001-surfaces-frontmatter",lane:"convergent",description:"surfaces frontmatter: fold visibility/applies-to/read-when routing into surfaces entries",apply(e){const n=e.docs.map(k).filter(i=>i!==null),t=D(n),r=[];for(const i of n){if(!i.hasOldFields)continue;const s=F(d(i.doc.source).raw,E(i,N(i,t)),i.doc.path);r.push({path:i.doc.path,after:b(i.doc.source,s,i.doc.path)})}return r}};export{x as surfacesFrontmatterMigration};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var a=(r,o)=>m(r,"name",{value:o,configurable:!0});import{PROFILE_PROJECT_MEMORY_VALUES as p}from"../api/dto/profiles.js";import{usage as l}from"../core/errors.js";const y="root-00000000";function t(r,o){return l(`profile manifest cannot be migrated: ${o}`,{received:r.path,field:"projects",next:`Fix ${r.path} by hand \u2014 every project entry is a string (pre-migration) or {"path": "/abs/dir", "memory": one of ${p.join(", ")}} \u2014 then re-run \`crtr sys migrate\`.`})}a(t,"malformed");function h(r){return typeof r=="string"&&p.includes(r)}a(h,"isMemory");const u={id:"002-profile-project-memory",lane:"profile-manifest",description:"profile projects carry an explicit memory value",apply(r){const o=r.raw.projects;if(!Array.isArray(o))throw t(r,`projects is ${o===void 0?"missing":typeof o}, not an array`);const f=r.profileId===y?"preview":"content";let n=!1;const c=o.map(e=>{if(typeof e=="string"){if(e.trim()==="")throw t(r,"a project entry is an empty path");return n=!0,{path:e,memory:f}}if(typeof e!="object"||e===null||Array.isArray(e))throw t(r,`a project entry is ${e===null?"null":typeof e}`);const{path:i,memory:s}=e;if(typeof i!="string"||i.trim()==="")throw t(r,`a project entry has no path: ${JSON.stringify(e)}`);if(!h(s))throw t(r,`project ${i} has an unknown memory value: ${JSON.stringify(s)}`);return e});return n?{...r.raw,projects:c}:null}};export{u as profileProjectMemoryMigration};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { CorpusBlocker, CorpusSnapshot, FrontDoorAction } from '../types.js';
|
|
2
|
-
import type { RepositoryDecision, StorePrefixFacts } from './repository-facts.js';
|
|
3
|
-
export interface FrontDoorPlan {
|
|
4
|
-
repositoryRoot: string;
|
|
5
|
-
/** The repository-root store's key. */
|
|
6
|
-
storeKey: string;
|
|
7
|
-
rootDocPath: string;
|
|
8
|
-
rootAction: 'kept' | 'created' | 'completed';
|
|
9
|
-
/** The unique legacy front door whose workspace-open entries this run removes. It may live
|
|
10
|
-
* in a nested store of the same repository, so it carries its own store key. */
|
|
11
|
-
leafDocPath: string | null;
|
|
12
|
-
leafStoreKey: string | null;
|
|
13
|
-
/** The leaf's FINAL canonical name, for the created root body's `[[link]]`. */
|
|
14
|
-
leafCanonicalName: string | null;
|
|
15
|
-
action: FrontDoorAction;
|
|
16
|
-
}
|
|
17
|
-
export declare function planFrontDoors(repositories: readonly RepositoryDecision[], prefixes: ReadonlyMap<string, StorePrefixFacts>, corpus: CorpusSnapshot, finalNameOf: (realPath: string) => string | undefined): {
|
|
18
|
-
plans: FrontDoorPlan[];
|
|
19
|
-
blockers: CorpusBlocker[];
|
|
20
|
-
};
|
|
21
|
-
/** New repository-root INDEX.md source. `leafCanonicalName` null yields the generic minimal root body. */
|
|
22
|
-
export declare function rootIndexSource(namespace: string, leafCanonicalName: string | null): string;
|
|
23
|
-
/** Add the missing half or halves of the root front-door pair to a complete document source. */
|
|
24
|
-
export declare function completeRootFrontDoor(source: string, docPath: string): string;
|
|
25
|
-
/** Remove every workspace-open entry while preserving the body and every retained authored YAML byte. */
|
|
26
|
-
export declare function demoteLeafSurfaces(source: string, docPath: string): string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var q=Object.defineProperty;var r=(o,e)=>q(o,"name",{value:e,configurable:!0});import{join as v,relative as B}from"node:path";import{parse as M,stringify as G}from"yaml";import{realpathOrSelf as O}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as W}from"../../core/frontmatter.js";import{localNameFromPath as J}from"../../core/memory/identity.js";import{appendRenderedKey as X,dropSequenceItems as z,dropTopLevelKeys as H,proveFrontmatterRoundTrip as Q,rebuildDocSource as T,splitDocSource as Y}from"../frontmatter-splice.js";function R(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}r(R,"record");function j(o){const e=o?.surfaces;return e===void 0?[]:Array.isArray(e)?e.map(R).filter(t=>t!==null):null}r(j,"surfaceEntries");function U(o){return o==="./**"||Array.isArray(o)&&o.includes("./**")}r(U,"matchIncludesOwnerTree");function I(o){return o.some(e=>e.on==="workspace-open"&&e.at==="content")}r(I,"hasWorkspaceOpen");function N(o){return o.some(e=>e.on==="read"&&e.at==="content"&&U(e.match))}r(N,"hasOwnerRead");function C(o){const e=j(o);return e!==null&&I(e)&&N(e)}r(C,"hasCompleteFrontDoor");function V(o){const e=j(o);return e===null?!0:e.some(t=>t.on!=="workspace-open"?!1:t.at!=="content"||Object.hasOwn(t,"match")||Object.hasOwn(t,"gate")||Object.hasOwn(t,"match-frontmatter"))}r(V,"conflictingRootWorkspaceOpen");function Z(o,e){for(const[t,a]of e)if(a.repositoryRoot===o&&a.ownerRelativePath==="")return t;return O(v(o,".crouter","memory"))}r(Z,"rootStoreKey");function _(o,e){return B(o,e).replace(/\\/g,"/")}r(_,"repositoryRelativePath");function $(o,e,t){return{kind:"front-door",message:o,storeRoot:v(t,".crouter","memory"),...e.length===1?{path:e[0]}:{},paths:[...e]}}r($,"frontDoorBlocker");function lo(o,e,t,a){const d=[],u=[];for(const n of o){const y=v(n.repositoryRoot,".crouter","memory","INDEX.md"),f=O(y),p=Z(n.repositoryRoot,e);let s=null;const D=new Map,b=new Map;for(const c of n.storeKeys){const i=e.get(c);if(i===void 0||i.repositoryRoot!==n.repositoryRoot)continue;const k=i.store??t.store(c);if(!(k===void 0||!k.writable)&&!(k.descriptor.scope!=="project"||k.descriptor.plugin!==void 0))for(const h of k.snapshot.docs){const g=O(h.path);if(g===f){s=h;continue}if(i.nestedDeclarationAction==="synthetic-index-removed"&&J(h.relPath)==="")continue;const x={doc:h,storeKey:c,realPath:g};j(h.frontmatter)?.some(E=>E.on==="workspace-open"&&E.at==="content")&&D.set(g,x),C(h.frontmatter)&&b.set(g,x)}}const w=[...b.values()],m=[];if(w.length>1){const c=w.map(i=>i.doc.path);m.push($(`repository ${n.repositoryRoot} has more than one non-root document carrying the complete workspace front door (${c.join(", ")}) \u2014 keep one source guide as the transfer source, remove the other workspace-open entries, and re-run`,c,n.repositoryRoot))}const A=[...D.values()].filter(c=>!b.has(c.realPath));if(A.length>0){const c=A.map(i=>i.doc.path);m.push($(`repository ${n.repositoryRoot} has non-root workspace-open documents without the complete owner-read pair (${c.join(", ")}) \u2014 complete exactly one legacy front door or remove these workspace-open entries, then re-run`,c,n.repositoryRoot))}if(s!==null&&V(s.frontmatter)){const c=[s.path,...w.map(i=>i.doc.path)];m.push($(`repository-root guide ${s.path} carries a workspace-open route that migration cannot make authoritative without changing its predicate \u2014 make every root workspace-open entry exactly {on: workspace-open, at: content} and re-run`,c,n.repositoryRoot))}const l=w.length===1?w[0]:null,K=l===null?null:a(l.realPath);if(l!==null&&K===void 0&&m.push($(`legacy workspace front door ${l.doc.path} has no provable final canonical name \u2014 repair its identity blocker and re-run`,[l.doc.path],n.repositoryRoot)),m.length>0){u.push(...m);continue}const S=s!==null&&C(s.frontmatter),L=s===null?"created":S?"kept":"completed",F=l===null?null:_(n.repositoryRoot,l.doc.path),P=F!==null?`transferred-from:${F}`:S?"kept-root":"created-root";d.push({repositoryRoot:n.repositoryRoot,storeKey:p,rootDocPath:y,rootAction:L,leafDocPath:l?.doc.path??null,leafStoreKey:l?.storeKey??null,leafCanonicalName:K??null,action:P})}return{plans:d,blockers:u}}r(lo,"planFrontDoors");function uo(o,e){const t=o.split("/").at(-1)??o,a=e===null?`# ${t}
|
|
2
|
-
|
|
3
|
-
This project's memory store. Every document here answers at \`${o}/<local name>\`.
|
|
4
|
-
`:`# ${t}
|
|
5
|
-
|
|
6
|
-
This project's memory store. Every document here answers at \`${o}/<local name>\`. Read [[${e}]] for the detailed project guide.
|
|
7
|
-
`;return["---",`namespace: ${JSON.stringify(o)}`,"kind: knowledge",`when-and-why-to-read: When working in \`${o}\`, this knowledge should be read because it names the namespace every document in this repository answers under.`,"surfaces:"," - on: workspace-open"," at: content"," - on: read",' match: "./**"'," at: content","---","",a].join(`
|
|
8
|
-
`)}r(uo,"rootIndexSource");function oo(o){return W(o).data===null?`---
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
${o}`:o}r(oo,"sourceWithFrontmatter");function eo(o,e){let t;try{t=M(o===""?"{}":o)}catch(a){throw new Error(`front-door migration: unparseable frontmatter in ${e}`,{cause:a})}if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`front-door migration: frontmatter is not a mapping in ${e}`);return t}r(eo,"parsedYamlRecord");function fo(o,e){const t=oo(o),{rawYaml:a}=Y(t,e),d=eo(a,e),u=d.surfaces;if(u!==void 0&&!Array.isArray(u))throw new Error(`front-door migration: surfaces is not a sequence in ${e}`);const n=u===void 0?[]:u.map(s=>R(s)??s),y=n.filter(s=>R(s)!==null),f=[...n];if(I(y)||f.push({on:"workspace-open",at:"content"}),N(y)||f.push({on:"read",match:"./**",at:"content"}),f.length===n.length)return t;let p=a;return u!==void 0&&(p=H(p,["surfaces"],e)),p=p===""?G({surfaces:f},{lineWidth:0}).replace(/\r?\n$/,""):X(p,"surfaces",f,e),Q(p,{...d,surfaces:f},e),T(t,p,e)}r(fo,"completeRootFrontDoor");function mo(o,e){if(W(o).data===null)return o;const{rawYaml:t}=Y(o,e),a=z(t,"surfaces",d=>R(d)?.on==="workspace-open",e);return a===t?o:T(o,a,e)}r(mo,"demoteLeafSurfaces");export{fo as completeRootFrontDoor,mo as demoteLeafSurfaces,lo as planFrontDoors,uo as rootIndexSource};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var K=Object.defineProperty;var f=(e,o)=>K(e,"name",{value:o,configurable:!0});import{existsSync as A,readFileSync as j}from"node:fs";import{dirname as N,matchesGlob as z}from"node:path";import{realpathOrSelf as g}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as O}from"../../core/frontmatter.js";import{loadStoreMemoryDocs as T,openProjectMemoryStore as B}from"../../core/memory-resolver.js";import{canonicalSegments as G,composeCanonicalName as $,explicitLocalName as _,INDEX_SEGMENT as Y,localNameFromPath as J,normalizeDocName as U,normalizeNameSegment as X,resolveLocalName as q,stripNamespace as H,validateExplicitLocalName as Q,validateNamespace as V}from"../../core/memory/identity.js";import{lintMemoryStore as W,MEMORY_LINT_IDENTITY_RULES as Z,resolvableCanonicalNames as ee}from"../../core/memory/lint.js";import{completeRootFrontDoor as te,demoteLeafSurfaces as oe,planFrontDoors as ne,rootIndexSource as re}from"./front-door.js";import{planRepositories as ae}from"./repository-facts.js";import{applySplices as S,itemFor as D,keyLineSpan as E,linkRewrites as ie,OldCorpus as se,renderScalar as v,routeRewrites as ce,valueSpan as M,viewsForStore as le,yamlBlock as pe,yamlMap as de}from"./references.js";let h={links:[],routes:[],wrote:new Set,repositories:[]};function F(e=[]){return{blockers:e,consumers:[],identities:[],repositories:[],storePrefixes:[],renames:[],references:[]}}f(F,"emptyPlan");function fe(e){return G(e.replace(/\\/g,"/").replace(/\.md$/i,"")).map(X).join("/")}f(fe,"pathNameNoCollapse");function me(e){const o=e.frontmatter?.name;return typeof o=="string"&&o.trim()!==""?o.trim():null}f(me,"rawExplicitName");function C(e){return e.descriptor.ownerDir??N(N(e.descriptor.storeRoot))}f(C,"ownerDirOf");function x(e){return e.scope==="project"&&e.plugin===void 0}f(x,"isProjectStore");function ue(e){const o=e.descriptor.namespace,r=C(e),p=e.descriptor.plugin??"";return{store:e,storeKey:e.key,storeRoot:e.snapshot.root,ownerDir:r,repositoryKey:"",repositoryRoot:r,ownerRelativePath:"",oldPrefix:p,oldRule:"pre-003",effectivePrefix:o,nestedDeclarationAction:"none",legacyDeclaration:null}}f(ue,"fallbackPrefix");function he(e,o){return o.find(r=>r.repositoryRoot===e.repositoryRoot)}f(he,"repositoryForPrefix");function ye(e,o,r,p){const t=he(o,r),a=[];if(e.snapshot.docs.length===0)return a;if(e.descriptor.plugin!==void 0){const i=V(o.effectivePrefix);i.ok||p.push({kind:"namespace",message:`plugin \`${e.descriptor.plugin}\` mounts its memory under \`${o.effectivePrefix}\`, which is not a valid namespace (${i.reason}) \u2014 fix the plugin package and re-run`,storeRoot:e.key,name:o.effectivePrefix})}for(const i of e.snapshot.docs){const l=J(i.relPath);l===""&&!x(e.descriptor)&&e.descriptor.plugin===void 0&&p.push({kind:"namespace",message:`a root ${Y}.md in a ${e.descriptor.scope} store composes to the empty canonical name \u2014 only a project store's root document answers at its effective prefix; rename this file to a named document (\`<topic>.md\`) or fold its content into the docs it introduces, then re-run`,storeRoot:e.key,path:i.path});const c=me(i),k=c===null?fe(i.relPath):U(c),u=o.oldRule==="per-store-declaration"?$(o.oldPrefix,q(i.frontmatter,l)):$(o.oldPrefix,k);let n=l,d=null;if(l==="")c!==null&&(d="remove");else{const y=_(i.frontmatter);if(y!==null){const s=H(y,o.effectivePrefix)??y;if(s===""||s===l)d="remove";else{const w=Q(s,o.effectivePrefix);w.ok||p.push({kind:"namespace",message:`explicit \`name: ${c}\` cannot become a store-local name (${w.reason}) \u2014 correct it and re-run`,storeRoot:e.key,path:i.path,name:c??s}),n=s,s!==c&&(d={value:s})}}}let m=null;if(l===""&&x(e.descriptor))if(o.ownerRelativePath===""){const y=i.frontmatter?.namespace;t!==void 0&&y!==t.namespace&&(m={value:t.namespace})}else o.nestedDeclarationAction!=="none"&&(m="remove");a.push({doc:i,storeKey:e.key,realPath:g(i.path),oldName:u,finalName:$(o.effectivePrefix,n),finalLocal:n,nameEdit:d,namespaceEdit:m,oldPrefix:o.oldPrefix,deleted:o.nestedDeclarationAction==="synthetic-index-removed"&&l===""})}return a}f(ye,"buildDocFacts");function ge(e,o,r){const p=new Map;for(const t of o){const a=p.get(t.finalName);a===void 0?p.set(t.finalName,[t]):a.push(t)}for(const[t,a]of p)a.length<2||r.push({kind:"collision",message:`${a.length} documents in this store would own canonical name \`${t}\` (${a.map(i=>i.doc.relPath).join(", ")}) \u2014 merge them into one document or rename one, then re-run`,storeRoot:e.key,name:t,paths:a.map(i=>i.doc.path)})}f(ge,"addFinalCollisions");function we(e,o){const r=e.descriptor.plugin!==void 0?`plugin \`${e.descriptor.plugin}\``:"crouter's builtin corpus",p=e.descriptor.plugin!==void 0?`update the plugin package (\`crtr pkg plugin update ${e.descriptor.plugin}\`) once it ships the corrected corpus`:"update crouter (`crtr sys update`) to a release whose builtin corpus already uses repository-root identity";return`${o.doc.relPath} needs an identity rewrite (\`${o.oldName}\` \u2192 \`${o.finalName}\`) in ${r}, a package-owned store this migration never writes \u2014 ${p}`}f(we,"packageOwnedCorpusMessage");function Pe(e,o,r,p){if(r.nameEdit===null&&r.namespaceEdit===null)return[];const t=pe(e);if(t===null)return r.namespaceEdit===null||r.namespaceEdit==="remove"?[]:[{start:0,end:0,text:`---
|
|
2
|
-
namespace: ${v(r.namespaceEdit.value)}
|
|
3
|
-
---
|
|
4
|
-
`}];const a=de(t.raw);if(a===null)return p.blockers.push({kind:"parse-failure",message:`${r.doc.relPath}: frontmatter is not a YAML mapping, so its identity fields cannot be rewritten \u2014 fix the file and re-run`,storeRoot:o.key,path:r.doc.path}),[];const i=[];if(r.namespaceEdit!==null){const l=D(a,"namespace");if(r.namespaceEdit==="remove"){if(l!==null){const c=E(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:""})}}else if(l===null)i.push({start:t.base,end:t.base,text:`namespace: ${v(r.namespaceEdit.value)}
|
|
5
|
-
`});else{const c=M(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:v(r.namespaceEdit.value)})}}if(r.nameEdit!==null){const l=D(a,"name");if(l!==null)if(r.nameEdit==="remove"){const c=E(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:""})}else{const c=M(t.raw,l);c!==null&&i.push({start:t.base+c[0],end:t.base+c[1],text:v(r.nameEdit.value)})}}return i}f(Pe,"identityRewrites");function ve(e,o){const r=e.ownerRelativePath===""?o.find(p=>p.storeKey===e.storeKey)?.action??"none":"none";return{storeRoot:e.storeRoot,ownerDir:e.ownerDir,repositoryRoot:e.repositoryRoot,ownerRelativePath:e.ownerRelativePath,oldPrefix:e.oldPrefix,oldRule:e.oldRule,effectivePrefix:e.effectivePrefix,nestedDeclarationAction:e.nestedDeclarationAction,frontDoorAction:r}}f(ve,"storePrefixRow");function ke(e){return{repositoryRoot:e.repositoryRoot,repositoryKey:e.repositoryKey,declarationPath:e.declarationPath,namespace:e.namespace,source:e.source,action:e.action}}f(ke,"repositoryRow");function Re(e){h={links:[],routes:[],wrote:new Set,repositories:[]};const o=F(),r=ae(e);if(r.blockers.length>0)return F(r.blockers);const p=new Map,t=new Map;for(const n of e.stores){const d=r.prefixes.get(n.key)??ue(n);t.set(n.key,d);const m=ye(n,d,r.repositories,o.blockers);p.set(n.key,m),ge(n,m,o.blockers)}const a=new se(p),i=new Map;for(const n of p.values())for(const d of n)i.set(d.realPath,d.finalName);const l=ne(r.repositories,r.prefixes,e,n=>i.get(g(n)));o.blockers.push(...l.blockers),o.repositories.push(...r.repositories.map(ke)),o.storePrefixes.push(...[...r.prefixes.values()].map(n=>ve(n,l.plans)));const c=new Set(l.plans.filter(n=>n.rootAction==="completed").map(n=>g(n.rootDocPath))),k=new Set(l.plans.map(n=>n.leafDocPath).filter(n=>n!==null).map(g)),u=new Map;for(const n of e.stores){const d=t.get(n.key),m=p.get(n.key)??[],y=n.writable?le(e,n):[];for(const s of m){const w=n.writable?[...ie(a,y,n,s,o,h.links),...ce(a,y,n,s,d,o,h.routes)]:[],P=S(s.doc.source,w);if(s.deleted&&n.writable){u.set(s.realPath,{path:s.doc.path,after:null});continue}const R=c.has(s.realPath)?te(P,s.doc.path):k.has(s.realPath)?oe(P,s.doc.path):P,b=Pe(R,n,s,o),L=S(R,b);if(!n.writable){(s.oldPrefix!==d.effectivePrefix||b.length>0)&&s.oldName!==s.finalName&&o.blockers.push({kind:"package-owned-corpus",message:we(n,s),storeRoot:n.key,path:s.doc.path,name:s.finalName});continue}w.length>0&&o.consumers.push({path:s.doc.path,after:P}),(R!==P||b.length>0)&&u.set(s.realPath,{path:s.doc.path,after:L}),(s.oldPrefix!==d.effectivePrefix||s.nameEdit!==null||s.namespaceEdit!==null)&&s.oldName!==s.finalName&&o.renames.push({storeRoot:n.key,path:s.doc.path,from:s.oldName,to:s.finalName})}}for(const n of l.plans)if(n.rootAction==="created"){const d=r.repositories.find(m=>m.repositoryRoot===n.repositoryRoot);if(d===void 0)throw new Error(`migration 003: no repository decision for ${n.repositoryRoot}`);o.identities.push({path:n.rootDocPath,after:re(d.namespace,n.leafCanonicalName)})}else{const d=g(n.rootDocPath),m=u.get(d);m!==void 0&&(o.identities.push(m),u.delete(d))}for(const n of l.plans){if(n.leafDocPath===null)continue;const d=g(n.leafDocPath),m=u.get(d);m!==void 0&&(o.identities.push(m),u.delete(d))}o.identities.push(...u.values());for(const n of[...o.consumers,...o.identities])h.wrote.add(n.path);return h.repositories=o.repositories.map(n=>({...n})),o}f(Re,"plan");function I(e){return x(e.descriptor)?B(C(e)):e.descriptor}f(I,"freshDescriptor");function be(e,o){if(e.size!==o.size)return!1;for(const r of e)if(!o.has(r))return!1;return!0}f(be,"sameSet");function $e(e,o){try{return z(e,o)}catch{return!1}}f($e,"safeGlob");function xe(e){const o=[];for(const t of h.repositories){if(!A(t.declarationPath)){o.push({kind:"verification",message:`repository declaration ${t.declarationPath} was not written`,path:t.declarationPath,name:t.namespace});continue}try{const a=O(j(t.declarationPath,"utf8")).data?.namespace;if(a===t.namespace)continue;o.push({kind:"verification",message:`repository declaration ${t.declarationPath} declares ${JSON.stringify(a)}, not the planned namespace \`${t.namespace}\``,path:t.declarationPath,name:t.namespace})}catch(a){o.push({kind:"verification",message:`repository declaration ${t.declarationPath} cannot be parsed after the write (${a instanceof Error?a.message:String(a)})`,path:t.declarationPath,name:t.namespace})}}for(const t of e.stores)if(!(!t.writable||t.snapshot.docs.length===0))for(const a of W(I(t)).errors){const i=a.rule==="yaml"&&h.wrote.has(a.path);!Z.has(a.rule)&&!i||o.push({kind:"verification",message:`${a.rule}: ${a.message}`,storeRoot:t.key,path:a.path,...a.name===void 0?{}:{name:a.name}})}const r=new Map,p=f(t=>{const a=r.get(t);if(a!==void 0)return a;const i=e.storesForTarget(t).flatMap(c=>T(I(c),!0)),l={names:ee(i),docs:i.map(c=>({name:c.name,realPath:g(c.path)}))};return r.set(t,l),l},"viewFor");for(const t of h.links)p(t.targetId).names.has(t.name)||o.push({kind:"verification",message:`rewritten link [[${t.name}]] resolves to no document in target ${t.targetId} after the write phases`,path:t.carrier,targetId:t.targetId,name:t.name});for(const t of h.routes){const a=p(t.targetId),i=new Set;for(const l of a.docs)t.globs.some(c=>$e(l.name,c))&&i.add(l.realPath);be(i,new Set(t.expected))||o.push({kind:"verification",message:`rewritten memory-read route \`${t.globs.join(", ")}\` names ${i.size} document(s) in target ${t.targetId}, not the ${t.expected.length} it named before the cut`,path:t.carrier,targetId:t.targetId})}return o}f(xe,"verify");const Oe={id:"003-repository-root-memory-identity",lane:"corpus",description:"repository-root memory identity: one namespace per repository, nested stores derive their prefix from their path under it",plan:Re,verify:xe};export{Oe as repositoryRootMemoryIdentityMigration};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { type Pair, type YAMLMap } from 'yaml';
|
|
2
|
-
import type { CorpusPlan, CorpusSnapshot, CorpusStore, StoreDoc } from '../types.js';
|
|
3
|
-
import type { StorePrefixFacts } from './repository-facts.js';
|
|
4
|
-
export interface DocFacts {
|
|
5
|
-
doc: StoreDoc;
|
|
6
|
-
storeKey: string;
|
|
7
|
-
/** Realpath of the file: the identity a reference proof is keyed by. */
|
|
8
|
-
realPath: string;
|
|
9
|
-
/** The exact name this document answered at before this migration. */
|
|
10
|
-
oldName: string;
|
|
11
|
-
/** Its repository-root canonical name after this migration. */
|
|
12
|
-
finalName: string;
|
|
13
|
-
/** The store-local half of `finalName`; `''` for a store root document. */
|
|
14
|
-
finalLocal: string;
|
|
15
|
-
nameEdit: 'remove' | {
|
|
16
|
-
value: string;
|
|
17
|
-
} | null;
|
|
18
|
-
namespaceEdit: 'remove' | {
|
|
19
|
-
value: string;
|
|
20
|
-
} | null;
|
|
21
|
-
/** True when phase 2 deletes this exact synthetic nested INDEX document. */
|
|
22
|
-
deleted: boolean;
|
|
23
|
-
/** The prefix this document's store answered under before this migration. */
|
|
24
|
-
oldPrefix: string;
|
|
25
|
-
}
|
|
26
|
-
export interface Splice {
|
|
27
|
-
start: number;
|
|
28
|
-
end: number;
|
|
29
|
-
text: string;
|
|
30
|
-
}
|
|
31
|
-
/** Right-to-left, widest-first at a shared start. A whole-key removal beginning
|
|
32
|
-
* at the YAML block base must run before a zero-width insertion there. */
|
|
33
|
-
export declare function applySplices(source: string, splices: readonly Splice[]): string;
|
|
34
|
-
/** Locate the raw YAML within a complete document source. */
|
|
35
|
-
export declare function yamlBlock(source: string): {
|
|
36
|
-
base: number;
|
|
37
|
-
raw: string;
|
|
38
|
-
} | null;
|
|
39
|
-
export declare function yamlMap(raw: string): YAMLMap | null;
|
|
40
|
-
export declare function itemFor(map: YAMLMap, key: string): Pair | null;
|
|
41
|
-
/** Whole-line span of a mapping key, including its multiline value. */
|
|
42
|
-
export declare function keyLineSpan(raw: string, item: Pair): [number, number] | null;
|
|
43
|
-
/** Span of a mapping value with trailing whitespace excluded. */
|
|
44
|
-
export declare function valueSpan(raw: string, item: Pair): [number, number] | null;
|
|
45
|
-
export declare function renderScalar(value: string): string;
|
|
46
|
-
/** Render one or several route globs without expanding a one-line value into a
|
|
47
|
-
* block sequence. */
|
|
48
|
-
export declare function renderGlobList(globs: readonly string[]): string;
|
|
49
|
-
export interface View {
|
|
50
|
-
signature: string;
|
|
51
|
-
storeKeys: readonly string[];
|
|
52
|
-
targetIds: readonly string[];
|
|
53
|
-
}
|
|
54
|
-
export declare function viewsForStore(corpus: CorpusSnapshot, store: CorpusStore): View[];
|
|
55
|
-
export interface LinkProof {
|
|
56
|
-
targetId: string;
|
|
57
|
-
carrier: string;
|
|
58
|
-
name: string;
|
|
59
|
-
}
|
|
60
|
-
export interface RouteProof {
|
|
61
|
-
targetId: string;
|
|
62
|
-
carrier: string;
|
|
63
|
-
globs: readonly string[];
|
|
64
|
-
/** Realpaths the rewritten globs must still name exactly. */
|
|
65
|
-
expected: readonly string[];
|
|
66
|
-
}
|
|
67
|
-
/** Reference resolution under the frozen old corpus view. */
|
|
68
|
-
export declare class OldCorpus {
|
|
69
|
-
private readonly facts;
|
|
70
|
-
private readonly matchCache;
|
|
71
|
-
constructor(docsByStoreKey: ReadonlyMap<string, DocFacts[]>);
|
|
72
|
-
/** The physical old-name winner in one view, including a synthetic document
|
|
73
|
-
* phase 2 will delete. The retired directory-index fallback is part of this
|
|
74
|
-
* frozen lookup. A virtual bare-directory prefix has no physical fact. */
|
|
75
|
-
resolveOldFact(view: View, written: string): DocFacts | null;
|
|
76
|
-
/** The final canonical name a written old name denoted in one view. Deleted
|
|
77
|
-
* physical winners have no final projection; dangling references and
|
|
78
|
-
* unprovable bare-directory mappings likewise return null. */
|
|
79
|
-
resolveOld(view: View, written: string): string | null;
|
|
80
|
-
/** Realpaths a glob names under old or final identity, plus the effective
|
|
81
|
-
* prefixes of stores contributing a match. */
|
|
82
|
-
matchSet(view: View, glob: string, phase: 'old' | 'final'): {
|
|
83
|
-
paths: Set<string>;
|
|
84
|
-
namespaces: Set<string>;
|
|
85
|
-
};
|
|
86
|
-
/** Candidate qualification for both accepted old models. A pre-003 store
|
|
87
|
-
* gains its final prefix; a superseded per-store declaration has its old
|
|
88
|
-
* prefix replaced by the repository-derived one. */
|
|
89
|
-
finalGlobSpellings(views: readonly View[], glob: string): string[];
|
|
90
|
-
}
|
|
91
|
-
/** The minimal glob list naming exactly the old match set under final identity,
|
|
92
|
-
* or null when no exact rewrite can be proved. */
|
|
93
|
-
export declare function provenGlobs(corpus: OldCorpus, views: readonly View[], glob: string): string[] | null;
|
|
94
|
-
export declare function linkRewrites(corpus: OldCorpus, views: readonly View[], store: CorpusStore, fact: DocFacts, result: CorpusPlan, proofs: LinkProof[]): Splice[];
|
|
95
|
-
export declare function routeRewrites(corpus: OldCorpus, views: readonly View[], store: CorpusStore, fact: DocFacts, prefix: StorePrefixFacts, result: CorpusPlan, proofs: RouteProof[]): Splice[];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var E=Object.defineProperty;var u=(t,n)=>E(t,"name",{value:n,configurable:!0});import{matchesGlob as j}from"node:path";import{isMap as M,isSeq as z,parseDocument as _}from"yaml";import{parseFrontmatterGeneric as q}from"../../core/frontmatter.js";import{findDocLinks as B}from"../../core/memory/doc-link-grammar.js";import{canonicalParent as D,composeCanonicalName as b,INDEX_SEGMENT as k,representationForPath as J,routingAnchorFor as T,stripNamespace as Z}from"../../core/memory/identity.js";function de(t,n){let o=t;for(const e of[...n].sort((s,r)=>r.start-s.start||r.end-s.end))o=o.slice(0,e.start)+e.text+o.slice(e.end);return o}u(de,"applySplices");function V(t){const n=q(t);if(n.raw==="")return null;const o=t.length-n.body.length,e=t.slice(0,o).indexOf(n.raw);return e<0?null:{base:e,raw:n.raw}}u(V,"yamlBlock");function X(t){const n=_(t);return n.errors.length===0&&M(n.contents)?n.contents:null}u(X,"yamlMap");function K(t,n){return t.items.find(o=>String(o.key)===n)??null}u(K,"itemFor");function fe(t,n){const o=n.key?.range;if(o===void 0)return null;const e=n.value?.range;let s=t.lastIndexOf(`
|
|
2
|
-
`,o[0]-1)+1,r=e?.[2]??o[2];if(!(r>0&&t[r-1]===`
|
|
3
|
-
`)){for(;r<t.length&&(t[r]===" "||t[r]===" "||t[r]==="\r");)r++;t[r]===`
|
|
4
|
-
`&&r++}return r>=t.length&&s>0&&t[s-1]===`
|
|
5
|
-
`&&(s-=1),[s,r]}u(fe,"keyLineSpan");function Y(t,n){const o=n.value?.range;if(o===void 0)return null;let e=o[1];for(;e>o[0]&&/\s/.test(t[e-1]);)e--;return[o[0],e]}u(Y,"valueSpan");const H=/^[A-Za-z][A-Za-z0-9._\-/]*$/;function ue(t){return H.test(t)?t:JSON.stringify(t)}u(ue,"renderScalar");function Q(t){return t.length===1?JSON.stringify(t[0]):`[${t.map(n=>JSON.stringify(n)).join(", ")}]`}u(Q,"renderGlobList");function he(t,n){if(n.targets.length===0)return[{signature:n.key,storeKeys:[n.key],targetIds:[]}];const o=new Map;for(const e of n.targets){const s=t.storesForTarget(e).map(i=>i.key),r=s.join("\0"),a=o.get(r);a===void 0?o.set(r,{signature:r,storeKeys:s,targetIds:[e]}):a.targetIds.push(e)}return[...o.values()]}u(he,"viewsForStore");function G(t,n){try{return j(t,n)}catch{return!1}}u(G,"safeGlob");function U(t,n){const o=t.doc.relPath.endsWith(`${k}.md`),e=n.doc.relPath.endsWith(`${k}.md`);return o!==e?o?t:n:t.doc.relPath.localeCompare(n.doc.relPath)<=0?t:n}u(U,"oldNameWinner");function ee(t){if(t.finalLocal==="")return t.finalName;if(t.finalName===t.finalLocal)return"";const n=`/${t.finalLocal}`;if(!t.finalName.endsWith(n))throw new Error(`migration 003 reference facts for ${t.doc.path} disagree: final name \`${t.finalName}\` does not compose from local name \`${t.finalLocal}\``);return t.finalName.slice(0,-n.length)}u(ee,"effectivePrefixOf");class me{static{u(this,"OldCorpus")}facts=new Map;matchCache=new Map;constructor(n){for(const[o,e]of n){const s=new Map;let r=null,a=null;for(const i of e){const l=s.get(i.oldName);if(s.set(i.oldName,l===void 0?i:U(l,i)),r===null)r=i.oldPrefix;else if(r!==i.oldPrefix)throw new Error(`migration 003 reference facts for store ${o} disagree on old prefix (\`${r}\` vs \`${i.oldPrefix}\`)`);const h=ee(i);if(a===null)a=h;else if(a!==h)throw new Error(`migration 003 reference facts for store ${o} disagree on effective prefix (\`${a}\` vs \`${h}\`)`)}this.facts.set(o,{docs:e,byOldName:s,oldPrefix:r??"",effectivePrefix:a??""})}}resolveOldFact(n,o){for(const e of n.storeKeys){const s=this.facts.get(e)?.byOldName.get(o);if(s!==void 0)return s}for(const e of n.storeKeys){const s=this.facts.get(e)?.byOldName.get(`${o}/${k}`);if(s!==void 0)return s}return null}resolveOld(n,o){const e=this.resolveOldFact(n,o);if(e!==null)return e.deleted?null:e.finalName;const s=`${o}/`;let r=null,a=!1;for(const i of n.storeKeys)for(const l of this.facts.get(i)?.docs??[]){if(!l.oldName.startsWith(s))continue;a=!0;const h=l.oldName.slice(s.length);if(!l.finalName.endsWith(`/${h}`))return null;const c=l.finalName.slice(0,l.finalName.length-h.length-1);if(r===null)r=c;else if(r!==c)return null}return a?r:null}matchSet(n,o,e){const s=`${n.signature}\0${e}\0${o}`,r=this.matchCache.get(s);if(r!==void 0)return r;const a=new Set,i=new Set;for(const h of n.storeKeys){const c=this.facts.get(h);if(c!==void 0)for(const d of c.docs){if(e==="final"&&d.deleted)continue;const y=e==="old"?d.oldName:d.finalName;y===""||!G(y,o)||(a.add(d.realPath),c.effectivePrefix!==""&&i.add(c.effectivePrefix))}}const l={paths:a,namespaces:i};return this.matchCache.set(s,l),l}finalGlobSpellings(n,o){const e=new Set;for(const s of n)for(const r of s.storeKeys){const a=this.facts.get(r);a===void 0||!a.docs.some(i=>i.oldName!==""&&G(i.oldName,o))||(e.add(b(a.effectivePrefix,o)),a.oldPrefix!==""&&(o===a.oldPrefix?e.add(a.effectivePrefix):o.startsWith(`${a.oldPrefix}/`)&&e.add(b(a.effectivePrefix,o.slice(a.oldPrefix.length+1)))))}return e.delete(""),[...e].sort()}}function C(t,n){for(const o of t)if(!n.has(o))return!1;return!0}u(C,"isSubset");function te(t,n){return t.size===n.size&&C(t,n)}u(te,"sameSet");function ne(t){const n=[],o=u(e=>{e!==""&&!n.includes(e)&&n.push(e)},"push");for(const e of t){o(e);const s=e.endsWith(`/${k}`)?e.slice(0,-(k.length+1)):e.endsWith("/**")?e.slice(0,-3):e.endsWith("/*")?e.slice(0,-2):null;s!==null&&o(s)}return n}u(ne,"candidateSpellings");function oe(t,n,o){const e=n.map(i=>({view:i,expected:t.matchSet(i,o,"old").paths}));if(e.every(({expected:i})=>i.size===0))return[o];let r=ne([o,...t.finalGlobSpellings(n,o)]).filter(i=>e.every(({view:l,expected:h})=>C(t.matchSet(l,i,"final").paths,h)));const a=u(i=>e.every(({view:l,expected:h})=>{const c=new Set;for(const d of i)for(const y of t.matchSet(l,d,"final").paths)c.add(y);return te(c,h)}),"covers");if(!a(r))return null;for(let i=r.length-1;i>=0;i--){const l=r.filter((h,c)=>c!==i);l.length>0&&a(l)&&(r=l)}return r}u(oe,"provenGlobs");function pe(t,n,o,e,s,r){const a=B(e.doc.body);if(a.length===0)return[];const i=e.doc.source.length-e.doc.body.length,l=new Map,h=[];for(const c of a){let d=l.get(c.name);if(d===void 0){const x=n.map(f=>({view:f,fact:t.resolveOldFact(f,c.name)})).filter(f=>f.fact?.deleted===!0);if(x.length>0){const f=[...new Set(x.map(p=>p.fact.doc.path))];s.blockers.push({kind:"divergent-reference",message:`[[${c.name}]] resolves to the synthetic document${f.length===1?"":"s"} ${f.map(p=>`\`${p}\``).join(", ")}, but this migration deletes ${f.length===1?"that exact document":"those exact documents"} and no surviving physical document has the same identity \u2014 rewrite the link to the intended surviving document and re-run`,storeRoot:o.key,path:e.doc.path,name:c.name,paths:f,...x[0]?.view.targetIds[0]===void 0?{}:{targetId:x[0].view.targetIds[0]}}),d=null,l.set(c.name,d);continue}const g=n.map(f=>({view:f,name:t.resolveOld(f,c.name)})).filter(f=>f.name!==null),$=[...new Set(g.map(f=>f.name))];if($.length>1)s.blockers.push({kind:"divergent-reference",message:`[[${c.name}]] resolves to different documents depending on the target view (${$.map(f=>`\`${f}\``).join(" vs ")}) \u2014 this migration never guesses which one the author meant; rewrite the link by hand and re-run`,storeRoot:o.key,path:e.doc.path,name:c.name,...g[0]===void 0||g[0].view.targetIds[0]===void 0?{}:{targetId:g[0].view.targetIds[0]}}),d=null;else if(d=$[0]??null,d!==null&&d!==c.name){for(const f of g){const p=f.view.targetIds[0];p!==void 0&&r.push({targetId:p,carrier:e.doc.path,name:d})}s.references.push({storeRoot:o.key,path:e.doc.path,kind:"link",from:c.name,to:d})}l.set(c.name,d)}d===null||d===c.name||h.push({start:i+c.start,end:i+c.end,text:`[[${d}]]`})}return h}u(pe,"linkRewrites");function ge(t,n,o,e,s,r,a){const i=e.doc.frontmatter?.surfaces;if(!Array.isArray(i))return[];const l=V(e.doc.source);if(l===null)return[];const h=X(l.raw),c=h===null?null:K(h,"surfaces")?.value,d=D(e.oldName),y=Z(d,e.oldPrefix)??d,x=b(s.effectivePrefix,y),g=T(e.finalName,J(e.doc.relPath)),$=g!==x,f=[];for(let p=0;p<i.length;p++){const w=i[p];if(w===null||typeof w!="object"||w.on!=="memory-read")continue;const N=w.match,I=(typeof N=="string"?[N]:Array.isArray(N)?N:[]).filter(m=>typeof m=="string");if(I.length===0)continue;const P=[];let A=!1;for(const m of I){if(m.startsWith("./")){$&&r.blockers.push({kind:"unsafe-route",message:`memory-read glob \`${m}\` is anchored at \`${d}\`, but this document's explicit \`name:\` re-anchors it at \`${g}\` after the identity cut \u2014 a different subtree, which no rewrite of the glob restores; spell the route out absolutely (or give the document the \`${x}/${k}.md\` path its name implies) and re-run`,storeRoot:o.key,path:e.doc.path,name:m}),P.push(m);continue}const v=oe(t,n,m);if(v===null){r.blockers.push({kind:"unsafe-route",message:`memory-read glob \`${m}\` cannot be proved to name the same documents under repository-root identity \u2014 rewrite the entry by hand (or anchor it with \`./\`) and re-run`,storeRoot:o.key,path:e.doc.path,name:m}),P.push(m);continue}if(v.length!==1||v[0]!==m){A=!0;for(const F of n){const L=F.targetIds[0],W=t.matchSet(F,m,"old").paths;L===void 0||W.size===0||a.push({targetId:L,carrier:e.doc.path,globs:v,expected:[...W]})}r.references.push({storeRoot:o.key,path:e.doc.path,kind:"memory-read",from:m,to:v.join(", ")})}P.push(...v)}if(!A)continue;if(!z(c)){r.blockers.push({kind:"unsafe-route",message:`memory-read routes in ${e.doc.relPath} need rewriting but its \`surfaces:\` block is not a YAML sequence \u2014 fix the file and re-run`,storeRoot:o.key,path:e.doc.path});continue}const O=c.items[p],R=M(O)?K(O,"match"):null,S=R===null?null:Y(l.raw,R);if(S===null){r.blockers.push({kind:"unsafe-route",message:`memory-read route in ${e.doc.relPath} needs rewriting but its \`match\` value cannot be located in the frontmatter text \u2014 fix the file and re-run`,storeRoot:o.key,path:e.doc.path});continue}f.push({start:l.base+S[0],end:l.base+S[1],text:Q([...new Set(P)])})}return f}u(ge,"routeRewrites");export{me as OldCorpus,de as applySplices,K as itemFor,fe as keyLineSpan,pe as linkRewrites,oe as provenGlobs,Q as renderGlobList,ue as renderScalar,ge as routeRewrites,Y as valueSpan,he as viewsForStore,V as yamlBlock,X as yamlMap};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type ProjectNamespaceSource } from '../../core/memory/project-namespace.js';
|
|
2
|
-
import type { CorpusBlocker, CorpusSnapshot, CorpusStore } from '../types.js';
|
|
3
|
-
export interface RepositoryDecision {
|
|
4
|
-
repositoryKey: string;
|
|
5
|
-
repositoryRoot: string;
|
|
6
|
-
declarationPath: string;
|
|
7
|
-
namespace: string;
|
|
8
|
-
source: 'declared' | ProjectNamespaceSource;
|
|
9
|
-
action: 'kept' | 'created' | 'filled-linked-root';
|
|
10
|
-
/** Store keys grouped under this repository, in corpus order. */
|
|
11
|
-
storeKeys: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
export type NestedDeclarationAction = 'none' | 'removed' | 'synthetic-index-removed';
|
|
14
|
-
export interface StorePrefixFacts {
|
|
15
|
-
store: CorpusStore;
|
|
16
|
-
storeKey: string;
|
|
17
|
-
storeRoot: string;
|
|
18
|
-
ownerDir: string;
|
|
19
|
-
repositoryKey: string;
|
|
20
|
-
repositoryRoot: string;
|
|
21
|
-
ownerRelativePath: string;
|
|
22
|
-
/** The prefix this store's documents answered under BEFORE this run. */
|
|
23
|
-
oldPrefix: string;
|
|
24
|
-
/** How that prefix was proven: `'per-store-declaration'` when a declaration on
|
|
25
|
-
* disk — this store's own legacy one, or the repository-root one a nested
|
|
26
|
-
* store already answers under — names it, `'pre-003'` when nothing declares
|
|
27
|
-
* it and the documents answered at bare local names. */
|
|
28
|
-
oldRule: 'pre-003' | 'per-store-declaration';
|
|
29
|
-
/** repositoryNamespace ⊕ ownerRelativePath. */
|
|
30
|
-
effectivePrefix: string;
|
|
31
|
-
nestedDeclarationAction: NestedDeclarationAction;
|
|
32
|
-
/** The legacy nested `namespace:` value, when one was present. */
|
|
33
|
-
legacyDeclaration: string | null;
|
|
34
|
-
}
|
|
35
|
-
export declare function planRepositories(corpus: CorpusSnapshot): {
|
|
36
|
-
repositories: RepositoryDecision[];
|
|
37
|
-
prefixes: Map<string, StorePrefixFacts>;
|
|
38
|
-
blockers: CorpusBlocker[];
|
|
39
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var A=Object.defineProperty;var p=(e,t)=>A(e,"name",{value:t,configurable:!0});import{dirname as v}from"node:path";import{realpathOrSelf as g,readTextIfExists as _}from"../../core/fs-utils.js";import{parseFrontmatterGeneric as C}from"../../core/frontmatter.js";import{composeCanonicalName as P,explicitLocalName as D,localNameFromPath as k,validateExplicitLocalName as T,validateNamespace as b}from"../../core/memory/identity.js";import{deriveProjectNamespace as I}from"../../core/memory/project-namespace.js";import{associateRepository as j}from"../../core/memory/repository-association.js";const R="__CROUTER_SYNTHETIC_NAMESPACE__",w="__CROUTER_SYNTHETIC_NAMESPACE_SCALAR__",K=["---","kind: knowledge",`namespace: ${w}`,`when-and-why-to-read: When working in \`${R}\`, this knowledge should be read because it names the namespace every document in this project answers under.`,"surfaces:"," - on: workspace-open"," at: content"," - on: read",' match: "./**"'," at: content","---",`# ${R}`,"",`This project's memory store. Every document here answers at \`${R}/<local name>\`.`,""].join(`
|
|
2
|
-
`);function te(e){const t=[],r=[],n=new Map,a=[];for(const o of e.stores){if(!U(o))continue;const l=g(J(o)),d=j(l);if(!d.ok){t.push({kind:"association",message:`project memory store at ${o.key} owned by ${l} cannot be associated with a repository (${d.reason}) \u2014 repair the repository boundary and re-run`,storeRoot:o.key});continue}const m={store:o,ownerDir:l,association:d.association,rootDoc:o.snapshot.docs.find(N=>k(N.relPath)==="")??null};r.push(m);const h=d.association.kind==="git"?d.association.repositoryKey:`path:${d.association.repositoryRoot}`;let y=n.get(h);y===void 0&&(y={repositoryKey:d.association.repositoryKey,roots:new Map},n.set(h,y));let f=y.roots.get(d.association.repositoryRoot);f===void 0&&(f={association:d.association,stores:[],rootStore:null,index:$(),declaration:{state:"missing"}},y.roots.set(d.association.repositoryRoot,f),a.push(f)),f.stores.push(m),d.association.ownerRelativePath===""&&f.rootStore===null&&(f.rootStore=m)}const s=new Map;for(const o of r){if(o.association.ownerRelativePath===""){s.set(o.store.key,{declaration:{state:"missing"},action:"none"});continue}const l=H(o.rootDoc);let d="none";l.state==="invalid"?t.push(E(o.store.key,o.rootDoc?.path??o.store.key,l,"nested project memory store")):l.state==="valid"&&(d=o.rootDoc!==null&&z(o.rootDoc.source,l.value)?"synthetic-index-removed":"removed"),s.set(o.store.key,{declaration:l,action:d})}for(const o of a)o.index=F(o),o.declaration=o.index.error===null?Y(o.index.frontmatter?.namespace):{state:"invalid",reason:o.index.error,raw:void 0},o.declaration.state==="invalid"&&t.push(E(o.rootStore?.store.key??v(o.association.declarationPath),o.association.declarationPath,o.declaration,"repository root"));const i=new Map;for(const o of n.values())L(o,i,t);const u=[];for(const o of a){const l=i.get(o.association.repositoryRoot);l!==void 0&&u.push(l.decision)}const c=new Map;for(const o of r){const l=i.get(o.association.repositoryRoot),d=s.get(o.store.key);if(l===void 0||d.declaration.state==="invalid")continue;const m=o.association.ownerRelativePath==="",h=P(l.decision.namespace,o.association.ownerRelativePath),{oldPrefix:y,oldRule:f}=M(o.store,m,l.declaration,d.declaration,h);c.set(o.store.key,{store:o.store,storeKey:o.store.key,storeRoot:o.store.key,ownerDir:o.ownerDir,repositoryKey:o.association.repositoryKey,repositoryRoot:o.association.repositoryRoot,ownerRelativePath:o.association.ownerRelativePath,oldPrefix:y,oldRule:f,effectivePrefix:h,nestedDeclarationAction:d.action,legacyDeclaration:!m&&d.declaration.state==="valid"?d.declaration.value:null})}return B(r,i,t),{repositories:u,prefixes:c,blockers:t}}p(te,"planRepositories");function M(e,t,r,n,a){const s=t?r:n;return s.state==="valid"?{oldPrefix:s.value,oldRule:"per-store-declaration"}:!t&&r.state==="valid"&&!O(e,a)?{oldPrefix:a,oldRule:"per-store-declaration"}:{oldPrefix:"",oldRule:"pre-003"}}p(M,"oldAuthority");function O(e,t){return e.snapshot.docs.some(r=>{const n=D(r.frontmatter);return n===null?!1:k(r.relPath)===""||!T(n,t).ok})}p(O,"carriesLegacyExplicitIdentity");function L(e,t,r){const n=[...e.roots.values()];if(n.some(c=>c.declaration.state==="invalid"))return;const a=n.filter(c=>c.declaration.state==="valid"),s=[...new Set(a.map(c=>c.declaration.value))];if(s.length>1){const c=a.map(o=>o.association.declarationPath);r.push({kind:"namespace",message:`linked repository roots for ${e.repositoryKey} declare different namespaces (${s.map(o=>`\`${o}\``).join(", ")}) \u2014 make every root declaration agree and re-run`,paths:c});return}if(s.length===1){const c=s[0];for(const o of n){const l=o.declaration.state==="valid"?"kept":"filled-linked-root";t.set(o.association.repositoryRoot,{declaration:o.declaration,decision:x(e,o,c,"declared",l)})}return}const i=n[0],u=I({ownerDir:i.association.repositoryRoot,rootFrontmatter:i.index.frontmatter,...i.index.exists?{rootBody:i.index.body}:{}});if(!u.ok){r.push({kind:"namespace",message:`repository at ${i.association.repositoryRoot} cannot derive a namespace (${u.reason}) \u2014 declare a valid \`namespace:\` on ${i.association.declarationPath} and re-run`,storeRoot:i.rootStore?.store.key??v(i.association.declarationPath),...i.index.exists?{path:i.association.declarationPath}:{}});return}for(const c of n)t.set(c.association.repositoryRoot,{declaration:c.declaration,decision:x(e,c,u.namespace,u.source,c.index.exists?"kept":"created")})}p(L,"selectGroup");function x(e,t,r,n,a){return{repositoryKey:e.repositoryKey,repositoryRoot:t.association.repositoryRoot,declarationPath:t.association.declarationPath,namespace:r,source:n,action:a,storeKeys:t.stores.map(s=>s.store.key)}}p(x,"repositoryDecision");function F(e){const t=g(e.association.declarationPath),r=e.rootStore?.store.snapshot.docs.find(n=>g(n.path)===t);if(r!==void 0)return{exists:!0,frontmatter:r.frontmatter,body:r.body,error:null};try{const n=_(e.association.declarationPath);if(n===null)return $();const a=C(n);return{exists:!0,frontmatter:a.data,body:a.body,error:null}}catch(n){return{exists:!0,frontmatter:null,body:"",error:`cannot read or parse ${e.association.declarationPath} (${Z(n)})`}}}p(F,"readRootIndex");function $(){return{exists:!1,frontmatter:null,body:"",error:null}}p($,"missingRootIndex");function H(e){return e?.frontmatter===null||e?.frontmatter===void 0||!Object.prototype.hasOwnProperty.call(e.frontmatter,"namespace")?{state:"missing"}:S(e.frontmatter.namespace)}p(H,"legacyNestedDeclarationFacts");function Y(e){return e==null||e===""?{state:"missing"}:S(e)}p(Y,"declarationFacts");function S(e){if(typeof e!="string")return{state:"invalid",reason:`\`namespace:\` is non-string (${JSON.stringify(e)})`,raw:e};const t=b(e);return t.ok?{state:"valid",value:e}:{state:"invalid",reason:`\`namespace: ${e}\` is invalid (${t.reason})`,raw:e}}p(S,"authoredDeclarationFacts");function E(e,t,r,n){return{kind:"namespace",message:`${n} has an invalid namespace declaration at ${t} (${r.reason}) \u2014 correct it and re-run; migration never replaces an unprovable identity`,storeRoot:e,path:t,...typeof r.raw=="string"?{name:r.raw}:{}}}p(E,"invalidDeclarationBlocker");function B(e,t,r){const n=new Map;for(const a of e){const s=`${a.association.repositoryRoot}\0${a.association.ownerRelativePath}`,i=n.get(s);i===void 0?n.set(s,[a]):i.push(a)}for(const a of n.values()){if(a.length<2)continue;const s=a[0],i=t.get(s.association.repositoryRoot),u=i===void 0?s.association.ownerRelativePath:P(i.decision.namespace,s.association.ownerRelativePath),c=a.map(o=>o.ownerDir);r.push({kind:"collision",message:`directories ${c.join(", ")} in repository ${s.association.repositoryRoot} normalize to the same owner path \`${s.association.ownerRelativePath}\` and effective prefix \`${u}\` \u2014 rename one directory and re-run`,storeRoot:s.store.key,name:u,paths:c})}}p(B,"addOwnerPathCollisionBlockers");function z(e,t){return e===K.replaceAll(w,G(t)).replaceAll(R,t)}p(z,"isSupersededSyntheticIndex");function G(e){return/^[A-Za-z][A-Za-z0-9._\-/]*$/.test(e)?e:JSON.stringify(e)}p(G,"renderScalar");function J(e){return e.descriptor.ownerDir??v(v(e.descriptor.storeRoot))}p(J,"ownerDirOf");function U(e){return e.descriptor.scope==="project"&&e.descriptor.plugin===void 0}p(U,"isNativeProjectStore");function Z(e){return(e instanceof Error?e.message:String(e)).split(`
|
|
3
|
-
`)[0]??String(e)}p(Z,"firstLine");export{te as planRepositories};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { DocChange, StateMigration, StoreSnapshot } from './types.js';
|
|
2
|
-
/** A doc excluded from the snapshot because its frontmatter is not valid YAML.
|
|
3
|
-
* Per-doc throw isolation at the collection layer: the bad file is named and
|
|
4
|
-
* the rest of the store still migrates. */
|
|
5
|
-
export interface SkippedDoc {
|
|
6
|
-
relPath: string;
|
|
7
|
-
error: string;
|
|
8
|
-
}
|
|
9
|
-
export interface ConvergentRunResult {
|
|
10
|
-
root: string;
|
|
11
|
-
/** One row per migration that planned real changes, in registry order. */
|
|
12
|
-
applied: {
|
|
13
|
-
migration: string;
|
|
14
|
-
files: string[];
|
|
15
|
-
}[];
|
|
16
|
-
skipped: SkippedDoc[];
|
|
17
|
-
/** The store's docs with every planned change folded in — the bytes on disk
|
|
18
|
-
* after a write run, and the bytes a write run WOULD have produced under
|
|
19
|
-
* `--dry-run`. What the corpus lane plans against. */
|
|
20
|
-
snapshot: StoreSnapshot;
|
|
21
|
-
}
|
|
22
|
-
/** Snapshot every parseable `.md` under `root` (hidden dirs — `.history`
|
|
23
|
-
* sidecars and the like — skipped, mirroring substrate doc enumeration).
|
|
24
|
-
* `SKILL.md` bundles are Agent Skills, not memory docs: they carry no
|
|
25
|
-
* canonical identity and are never rewritten. */
|
|
26
|
-
export declare function loadStoreSnapshot(root: string): {
|
|
27
|
-
snapshot: StoreSnapshot;
|
|
28
|
-
skipped: SkippedDoc[];
|
|
29
|
-
};
|
|
30
|
-
/** Fold one applied change back into the in-memory snapshot so the NEXT
|
|
31
|
-
* migration plans against post-change state (dry runs included — that is what
|
|
32
|
-
* makes a dry-run diff equal the real run's writes). A migration that emits
|
|
33
|
-
* invalid YAML is a defect and throws here, before anything else compounds
|
|
34
|
-
* on its output. */
|
|
35
|
-
export declare function foldDocChange(snapshot: StoreSnapshot, change: DocChange): void;
|
|
36
|
-
/** Run every registered convergent migration over the store at `root`, in
|
|
37
|
-
* registry order. No-op changes (identical text) are filtered; each real
|
|
38
|
-
* change is written atomically unless `dryRun`. Journaled migrations in the
|
|
39
|
-
* list are the db chain's business and are skipped here. */
|
|
40
|
-
export declare function runConvergentMigrations(root: string, opts?: {
|
|
41
|
-
dryRun?: boolean;
|
|
42
|
-
migrations?: readonly StateMigration[];
|
|
43
|
-
}): ConvergentRunResult;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var p=(o,t)=>m(o,"name",{value:t,configurable:!0});import{relative as l,sep as d}from"node:path";import{atomicWriteText as h,readText as S,removePath as g,walkFiles as x}from"../core/fs-utils.js";import{parseFrontmatterGeneric as u}from"../core/frontmatter.js";import{STATE_MIGRATIONS as y}from"./registry.js";function T(o,t){const s=l(o,t).split(d).join("/"),n=S(t);try{const{data:r,body:a}=u(n);return{doc:{path:t,relPath:s,source:n,frontmatter:r,body:a}}}catch(r){return{error:(r instanceof Error?r.message:String(r)).split(`
|
|
2
|
-
`)[0]}}}p(T,"parseDoc");function v(o){const t=[],s=[];for(const n of x(o,r=>r.endsWith(".md")&&r!=="SKILL.md",r=>r.startsWith("."))){const r=T(o,n);"doc"in r?t.push(r.doc):s.push({relPath:l(o,n).split(d).join("/"),error:r.error})}return{snapshot:{root:o,docs:t},skipped:s}}p(v,"loadStoreSnapshot");function I(o,t){const s=o.docs.findIndex(c=>c.path===t.path);if(t.after===null){s>=0&&o.docs.splice(s,1);return}const n=l(o.root,t.path).split(d).join("/"),{data:r,body:a}=u(t.after),i={path:t.path,relPath:n,source:t.after,frontmatter:r,body:a};s>=0?o.docs[s]=i:o.docs.push(i)}p(I,"foldDocChange");function W(o,t={}){const s=(t.migrations??y).filter(i=>i.lane==="convergent"),{snapshot:n,skipped:r}=v(o),a=[];for(const i of s){const c=new Map(n.docs.map(e=>[e.path,e.source])),f=i.apply(n).filter(e=>e.after===null?c.has(e.path):c.get(e.path)!==e.after);if(f.length!==0){for(const e of f)t.dryRun!==!0&&(e.after===null?g(e.path):h(e.path,e.after)),I(n,e);a.push({migration:i.description,files:f.map(e=>e.path)})}}return{root:o,applied:a,skipped:r,snapshot:n}}p(W,"runConvergentMigrations");export{I as foldDocChange,v as loadStoreSnapshot,W as runConvergentMigrations};
|