@north-light/crouter 0.3.352 → 0.3.354
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +35 -25
- package/dist/api/client.js +2 -2
- package/dist/api/dto/broker-ops.d.ts +2 -36
- package/dist/api/dto/canvas.d.ts +8 -13
- package/dist/api/dto/config.d.ts +4 -0
- package/dist/api/dto/delivery.d.ts +61 -0
- package/dist/api/dto/docs.d.ts +133 -0
- package/dist/api/dto/docs.js +1 -0
- package/dist/api/dto/health.d.ts +26 -79
- package/dist/api/dto/node-outcomes.d.ts +1 -3
- package/dist/api/dto/nodes.d.ts +5 -26
- package/dist/api/dto/objects.d.ts +167 -0
- package/dist/api/dto/objects.js +1 -0
- package/dist/api/dto/profiles.d.ts +14 -8
- package/dist/api/dto/reports.d.ts +9 -7
- package/dist/api/dto/reviews.d.ts +9 -3
- package/dist/api/dto/worktree.d.ts +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes.d.ts +14 -12
- package/dist/api/routes.js +1 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
- package/dist/builtin-memory/04-orchestration-kernel.md +7 -7
- package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
- package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
- package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
- package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
- package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
- package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +5 -6
- package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
- package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
- package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
- package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
- package/dist/builtin-memory/explore/exploration-doc.md +4 -4
- package/dist/builtin-memory/insights/capture.md +6 -6
- package/dist/builtin-memory/insights/init.md +14 -14
- package/dist/builtin-memory/internal/INDEX.md +4 -4
- package/dist/builtin-memory/internal/agent-shaping.md +20 -20
- package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
- package/dist/builtin-memory/internal/marketplaces.md +2 -2
- package/dist/builtin-memory/internal/memory-loading.md +31 -30
- package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
- package/dist/builtin-memory/internal/plugins.md +16 -14
- package/dist/builtin-memory/internal/storage-tiers.md +4 -4
- package/dist/builtin-memory/memory-read-orientation.md +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
- package/dist/clients/attach/input/controller.js +1 -1
- package/dist/clients/attach/input/ref-autocomplete.js +1 -1
- package/dist/clients/attach/input/titled-editor.js +1 -1
- package/dist/clients/attach/render/chat-view.js +1 -1
- package/dist/clients/attach/render/crtr-output.d.ts +1 -2
- package/dist/clients/attach/render/crtr-output.js +17 -17
- package/dist/clients/attach/render/group-activity.d.ts +8 -8
- package/dist/clients/attach/render/group-activity.js +2 -2
- package/dist/clients/attach/render/group-recap.js +1 -1
- package/dist/clients/attach/render/tool-calls.d.ts +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/slash/dispatch.js +1 -1
- package/dist/clients/attach/viewer.js +806 -1553
- package/dist/commands/api-client.d.ts +2 -0
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/canvas/edges.d.ts +2 -0
- package/dist/commands/canvas/edges.js +2 -0
- package/dist/commands/canvas/list.d.ts +4 -0
- package/dist/commands/canvas/list.js +3 -0
- package/dist/commands/canvas/read.d.ts +8 -0
- package/dist/commands/canvas/read.js +5 -0
- package/dist/commands/canvas/search.d.ts +2 -0
- package/dist/commands/canvas/search.js +3 -0
- package/dist/commands/canvas/unwatch.d.ts +2 -0
- package/dist/commands/canvas/unwatch.js +1 -0
- package/dist/commands/canvas/watch.d.ts +3 -0
- package/dist/commands/canvas/watch.js +1 -0
- package/dist/commands/canvas-analytics.js +1 -1
- package/dist/commands/canvas-history/grep.js +4 -4
- package/dist/commands/canvas-history/read.js +2 -2
- package/dist/commands/canvas-history/search.js +7 -7
- package/dist/commands/canvas-history/shared.d.ts +0 -1
- package/dist/commands/canvas-history/shared.js +1 -1
- package/dist/commands/canvas-history/stats.js +2 -2
- package/dist/commands/canvas-history.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/doc/delete.d.ts +2 -0
- package/dist/commands/doc/delete.js +1 -0
- package/dist/commands/doc/edit.d.ts +2 -0
- package/dist/commands/doc/edit.js +1 -0
- package/dist/commands/doc/history.d.ts +2 -0
- package/dist/commands/doc/history.js +2 -0
- package/dist/commands/doc/lint.d.ts +2 -0
- package/dist/commands/doc/lint.js +2 -0
- package/dist/commands/doc/list.d.ts +2 -0
- package/dist/commands/doc/list.js +1 -0
- package/dist/commands/doc/move.d.ts +2 -0
- package/dist/commands/doc/move.js +1 -0
- package/dist/commands/doc/read.d.ts +2 -0
- package/dist/commands/doc/read.js +1 -0
- package/dist/commands/doc/shared.d.ts +25 -0
- package/dist/commands/doc/shared.js +2 -0
- package/dist/commands/doc/write.d.ts +2 -0
- package/dist/commands/doc/write.js +1 -0
- package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
- package/dist/commands/doc.js +1 -0
- package/dist/commands/human/review.js +1 -1
- package/dist/commands/node/bash.js +2 -2
- package/dist/commands/node/create.js +1 -1
- package/dist/commands/node/inspect.js +10 -10
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node/outcome.js +1 -1
- package/dist/commands/node/subscription.js +1 -1
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/doc-view.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +9 -17
- package/dist/commands/pkg/plugin-inspect.js +1 -1
- package/dist/commands/pkg/plugin-manage.d.ts +4 -8
- package/dist/commands/pkg/plugin-manage.js +15 -17
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/context/admin/actions.d.ts +18 -43
- package/dist/commands/sys/context/admin/actions.js +1 -2
- package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
- package/dist/commands/sys/context/admin/detail-panel.js +2 -1
- package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
- package/dist/commands/sys/context/admin/docs-panel.js +1 -1
- package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
- package/dist/commands/sys/context/admin/list-view.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +96 -69
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
- package/dist/commands/sys/context/admin/rail-panel.js +1 -1
- package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
- package/dist/commands/sys/context/admin/read-view.js +1 -2
- package/dist/commands/sys/context/admin/shell.d.ts +26 -31
- package/dist/commands/sys/context/admin/shell.js +1 -1
- package/dist/commands/sys/context/admin.js +2 -2
- package/dist/commands/sys/context/doc.js +2 -3
- package/dist/commands/sys/context/expose.js +2 -2
- package/dist/commands/sys/context/prompt-review.js +4 -4
- package/dist/commands/sys/context/resolve.d.ts +92 -65
- package/dist/commands/sys/context/resolve.js +7 -9
- package/dist/commands/sys/context.js +1 -1
- package/dist/commands/sys/doctor.js +1 -1
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/sync-deps.d.ts +6 -11
- package/dist/commands/sys/sync-deps.js +7 -8
- package/dist/commands/sys/sync-project-guidance.js +5 -4
- package/dist/commands/sys/sync-shared.d.ts +41 -4
- package/dist/commands/sys/sync-shared.js +1 -1
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/sync.js +1 -1
- package/dist/core/bash-job-supervisor.d.ts +2 -3
- package/dist/core/bash-job-supervisor.js +3 -3
- package/dist/core/bash-jobs.d.ts +0 -5
- package/dist/core/bash-jobs.js +7 -7
- package/dist/core/bootstrap.js +2 -2
- package/dist/core/canvas/canvas.d.ts +6 -50
- package/dist/core/canvas/canvas.js +16 -21
- package/dist/core/canvas/db.d.ts +4 -1
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/history.d.ts +11 -39
- package/dist/core/canvas/history.js +9 -20
- package/dist/core/canvas/install-id.d.ts +2 -2
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/memory-reads.d.ts +5 -0
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/migrations.js +215 -41
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.js +1 -1
- package/dist/core/canvas/paths.d.ts +0 -4
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
- package/dist/core/canvas/remote-canvas-source.js +1 -1
- package/dist/core/canvas/render-source.d.ts +9 -6
- package/dist/core/canvas/render-source.js +6 -6
- package/dist/core/canvas/sessions.js +2 -2
- package/dist/core/canvas/source.d.ts +6 -0
- package/dist/core/canvas/tree.d.ts +29 -0
- package/dist/core/canvas/tree.js +12 -0
- package/dist/core/canvas/types.d.ts +0 -20
- package/dist/core/command-plugins/bundle.js +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/conversation-store/listener.js +4 -2
- package/dist/core/feed/feed.d.ts +9 -7
- package/dist/core/feed/feed.js +3 -7
- package/dist/core/feed/inbox.d.ts +3 -5
- package/dist/core/feed/inbox.js +1 -10
- package/dist/core/feed/messages.d.ts +33 -6
- package/dist/core/feed/messages.js +10 -7
- package/dist/core/feed/reports.d.ts +10 -0
- package/dist/core/feed/reports.js +2 -0
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/graph/access.d.ts +24 -0
- package/dist/core/graph/access.js +8 -0
- package/dist/core/graph/bodies.d.ts +6 -0
- package/dist/core/graph/bodies.js +1 -0
- package/dist/core/graph/deletion.d.ts +9 -0
- package/dist/core/graph/deletion.js +5 -0
- package/dist/core/graph/diff.d.ts +4 -0
- package/dist/core/graph/diff.js +4 -0
- package/dist/core/graph/documents.d.ts +160 -0
- package/dist/core/graph/documents.js +7 -0
- package/dist/core/graph/edges.d.ts +24 -0
- package/dist/core/graph/edges.js +1 -0
- package/dist/core/graph/events.d.ts +26 -0
- package/dist/core/graph/events.js +6 -0
- package/dist/core/graph/exposures.d.ts +53 -0
- package/dist/core/graph/exposures.js +4 -0
- package/dist/core/graph/jobs.d.ts +31 -0
- package/dist/core/graph/jobs.js +2 -0
- package/dist/core/graph/names.d.ts +28 -0
- package/dist/core/graph/names.js +3 -0
- package/dist/core/graph/objects.d.ts +55 -0
- package/dist/core/graph/objects.js +9 -0
- package/dist/core/graph/package-docs.d.ts +31 -0
- package/dist/core/graph/package-docs.js +5 -0
- package/dist/core/graph/package-files.d.ts +20 -0
- package/dist/core/graph/package-files.js +2 -0
- package/dist/core/graph/reader.d.ts +21 -0
- package/dist/core/graph/reader.js +3 -0
- package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
- package/dist/core/graph/repo-sync/exchange.js +2 -0
- package/dist/core/graph/repo-sync/identity.d.ts +30 -0
- package/dist/core/graph/repo-sync/identity.js +1 -0
- package/dist/core/graph/repo-sync/index.d.ts +4 -0
- package/dist/core/graph/repo-sync/index.js +1 -0
- package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
- package/dist/core/graph/repo-sync/mirror.js +6 -0
- package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
- package/dist/core/graph/repo-sync/ref-format.js +2 -0
- package/dist/core/graph/repo-sync/repos.d.ts +17 -0
- package/dist/core/graph/repo-sync/repos.js +3 -0
- package/dist/core/graph/repo-sync/sync.d.ts +42 -0
- package/dist/core/graph/repo-sync/sync.js +2 -0
- package/dist/core/graph/rules.d.ts +26 -0
- package/dist/core/graph/rules.js +3 -0
- package/dist/core/graph/spaces/app.d.ts +3 -0
- package/dist/core/graph/spaces/app.js +1 -0
- package/dist/core/graph/spaces/index.d.ts +19 -0
- package/dist/core/graph/spaces/index.js +1 -0
- package/dist/core/graph/spaces/person.d.ts +5 -0
- package/dist/core/graph/spaces/person.js +2 -0
- package/dist/core/graph/spaces/repo.d.ts +4 -0
- package/dist/core/graph/spaces/repo.js +1 -0
- package/dist/core/graph/types.d.ts +75 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/graph/watches.d.ts +62 -0
- package/dist/core/graph/watches.js +18 -0
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/requests.d.ts +3 -1
- package/dist/core/human/requests.js +6 -6
- package/dist/core/inspector/model.js +2 -2
- package/dist/core/io.js +5 -5
- package/dist/core/layout-migrate/index.d.ts +24 -1
- package/dist/core/layout-migrate/index.js +4 -4
- package/dist/core/layout-migrate/paths.d.ts +4 -0
- package/dist/core/layout-migrate/paths.js +1 -1
- package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -11
- package/dist/core/layout-migrate/stores.d.ts +19 -6
- package/dist/core/layout-migrate/stores.js +3 -4
- package/dist/core/manifest.d.ts +0 -2
- package/dist/core/manifest.js +1 -1
- package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
- package/dist/core/plugin-extensions.js +1 -0
- package/dist/core/preview-registry.d.ts +1 -1
- package/dist/core/preview-registry.js +3 -2
- package/dist/core/profiles/manifest.d.ts +7 -7
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/select.js +3 -3
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/stage.d.ts +12 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +2 -0
- package/dist/core/review/store.js +1 -1
- package/dist/core/review/types.d.ts +7 -1
- package/dist/core/runs/events.js +1 -1
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.js +2 -2
- package/dist/core/runtime/bearings-render.d.ts +13 -7
- package/dist/core/runtime/bearings-render.js +12 -12
- package/dist/core/runtime/bearings.d.ts +8 -18
- package/dist/core/runtime/bearings.js +7 -7
- package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -4
- package/dist/core/runtime/broker/inbox.js +1 -10
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
- package/dist/core/runtime/broker/retry-card-elision.js +1 -0
- package/dist/core/runtime/broker-extension-render.d.ts +0 -13
- package/dist/core/runtime/broker-extension-render.js +2 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -4
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/kickoff.js +17 -19
- package/dist/core/runtime/launch-target.d.ts +7 -0
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +10 -0
- package/dist/core/runtime/ledger.js +3 -0
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/nodes.d.ts +10 -2
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +2 -2
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +2 -2
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/prospective-inventory-cli.js +2 -2
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +17 -9
- package/dist/core/runtime/roadmap.js +4 -4
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -3
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/structured-output.d.ts +3 -1
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/scope.d.ts +1 -32
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +2 -1
- package/dist/core/scoped-state/migrate.js +2 -2
- package/dist/core/scoped-state/profiles.d.ts +11 -0
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +1 -1
- package/dist/core/scoped-state/schema.js +7 -5
- package/dist/core/spaces/permissions.d.ts +0 -14
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/stop.d.ts +13 -0
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/storage/tables.d.ts +1 -1
- package/dist/core/substrate/delivery/corpus.d.ts +21 -0
- package/dist/core/substrate/delivery/corpus.js +3 -0
- package/dist/core/substrate/delivery/deliver.d.ts +76 -0
- package/dist/core/substrate/delivery/deliver.js +6 -0
- package/dist/core/substrate/delivery/listings.d.ts +27 -0
- package/dist/core/substrate/delivery/listings.js +4 -0
- package/dist/core/substrate/delivery/match.d.ts +28 -0
- package/dist/core/substrate/delivery/match.js +1 -0
- package/dist/core/substrate/delivery/plan.d.ts +67 -0
- package/dist/core/substrate/delivery/plan.js +3 -0
- package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
- package/dist/core/substrate/delivery/render-boot.js +54 -0
- package/dist/core/substrate/delivery/render-event.d.ts +47 -0
- package/dist/core/substrate/delivery/render-event.js +6 -0
- package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
- package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
- package/dist/core/substrate/delivery/types.d.ts +30 -0
- package/dist/core/substrate/delivery/types.js +0 -0
- package/dist/core/substrate/gate-explain.d.ts +0 -13
- package/dist/core/substrate/gate-explain.js +1 -1
- package/dist/core/substrate/schema.d.ts +11 -139
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/substrate/subject-fields.d.ts +3 -0
- package/dist/core/substrate/subject.d.ts +2 -1
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/app-listener.js +11 -11
- package/dist/daemon/api/handlers/app-profiles.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -2
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +5 -5
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/delivery.d.ts +2 -0
- package/dist/daemon/api/handlers/delivery.js +1 -0
- package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
- package/dist/daemon/api/handlers/docs.js +1 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/modelauth.d.ts +3 -0
- package/dist/daemon/api/handlers/modelauth.js +1 -1
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.d.ts +2 -0
- package/dist/daemon/api/handlers/objects.js +5 -0
- package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
- package/dist/daemon/api/handlers/package-docs.js +1 -0
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +2 -2
- package/dist/daemon/api/handlers/reports.js +4 -4
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/vendor-status.d.ts +8 -0
- package/dist/daemon/api/handlers/vendor-status.js +1 -0
- package/dist/daemon/api/map.d.ts +2 -2
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/principal.d.ts +5 -0
- package/dist/daemon/api/principal.js +1 -1
- package/dist/daemon/api/reader.d.ts +17 -0
- package/dist/daemon/api/reader.js +1 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/control.d.ts +2 -3
- package/dist/daemon/crtrd.js +8 -6
- package/dist/daemon/fleet.js +4 -4
- package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/review/deliver.js +2 -2
- package/dist/daemon/review/finish.js +1 -1
- package/dist/hook-authoring.d.ts +0 -1
- package/dist/hook-authoring.js +3 -3
- package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
- package/dist/migrations/004-canvas-documents/apply.js +1 -0
- package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
- package/dist/migrations/004-canvas-documents/fields.js +2 -0
- package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/index.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
- package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
- package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
- package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
- package/dist/migrations/004-canvas-documents/plan.js +3 -0
- package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
- package/dist/migrations/004-canvas-documents/pointers.js +4 -0
- package/dist/migrations/activation.d.ts +9 -18
- package/dist/migrations/activation.js +2 -2
- package/dist/pi-extensions/broker-local.d.ts +2 -2
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.js +5 -4
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/dist/pi-extensions/canvas-passive-context.js +1 -1
- package/dist/pi-extensions/canvas-recap.js +2 -2
- package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/prompts/review.js +3 -3
- package/dist/shared/env.d.ts +5 -0
- package/dist/shared/env.js +1 -1
- package/dist/shared/generated-context.js +2 -10
- package/dist/shared/inbox-entry-body.d.ts +22 -0
- package/dist/shared/inbox-entry-body.js +10 -0
- package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
- package/dist/shared/inline-ref-guidance.js +2 -0
- package/dist/types.d.ts +3 -1
- package/docs/cli/memory-and-preferences.md +12 -14
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/lifecycle-and-wakes.md +1 -1
- package/docs/concepts/memory.md +15 -15
- package/docs/concepts/nodes-and-the-canvas.md +1 -1
- package/docs/concepts/profiles-kinds-and-modes.md +5 -5
- package/docs/concepts/scopes-and-trust.md +1 -1
- package/docs/concepts/why-a-daemon.md +1 -1
- package/docs/sdk/README.md +5 -6
- package/docs/sdk/errors.md +0 -13
- package/docs/sdk/guides/README.md +0 -1
- package/docs/sdk/nodes.md +0 -2
- package/docs/sdk/resources.md +0 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +11 -11
- package/dist/api/dto/memory.d.ts +0 -171
- package/dist/api/dto/memory.js +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
- package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
- package/dist/commands/broker-permissions.d.ts +0 -2
- package/dist/commands/broker-permissions.js +0 -1
- package/dist/commands/memory/client.d.ts +0 -11
- package/dist/commands/memory/client.js +0 -1
- package/dist/commands/memory/delete.d.ts +0 -1
- package/dist/commands/memory/delete.js +0 -1
- package/dist/commands/memory/edit.d.ts +0 -1
- package/dist/commands/memory/edit.js +0 -21
- package/dist/commands/memory/find.d.ts +0 -1
- package/dist/commands/memory/find.js +0 -1
- package/dist/commands/memory/history.d.ts +0 -1
- package/dist/commands/memory/history.js +0 -5
- package/dist/commands/memory/lint.d.ts +0 -1
- package/dist/commands/memory/lint.js +0 -1
- package/dist/commands/memory/list.d.ts +0 -1
- package/dist/commands/memory/list.js +0 -1
- package/dist/commands/memory/move.d.ts +0 -1
- package/dist/commands/memory/move.js +0 -1
- package/dist/commands/memory/origin.d.ts +0 -1
- package/dist/commands/memory/origin.js +0 -1
- package/dist/commands/memory/read.d.ts +0 -1
- package/dist/commands/memory/read.js +0 -6
- package/dist/commands/memory/shared.d.ts +0 -22
- package/dist/commands/memory/shared.js +0 -1
- package/dist/commands/memory/write.d.ts +0 -1
- package/dist/commands/memory/write.js +0 -13
- package/dist/commands/memory.js +0 -1
- package/dist/commands/node-inspect-artifacts.d.ts +0 -1
- package/dist/commands/node-inspect-artifacts.js +0 -8
- package/dist/core/help/memory-extensions.d.ts +0 -3
- package/dist/core/help/memory-extensions.js +0 -2
- package/dist/core/memory/cli-selector.d.ts +0 -13
- package/dist/core/memory/cli-selector.js +0 -1
- package/dist/core/memory/doc-link-grammar.d.ts +0 -20
- package/dist/core/memory/doc-link-grammar.js +0 -2
- package/dist/core/memory/extensions.js +0 -1
- package/dist/core/memory/history.d.ts +0 -87
- package/dist/core/memory/history.js +0 -6
- package/dist/core/memory/identity.d.ts +0 -65
- package/dist/core/memory/identity.js +0 -1
- package/dist/core/memory/inline-ref-guidance.js +0 -2
- package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
- package/dist/core/memory/inline-ref-inventory.js +0 -1
- package/dist/core/memory/lint.d.ts +0 -163
- package/dist/core/memory/lint.js +0 -2
- package/dist/core/memory/mutation-domain.d.ts +0 -113
- package/dist/core/memory/mutation-domain.js +0 -12
- package/dist/core/memory/mutations.d.ts +0 -74
- package/dist/core/memory/mutations.js +0 -1
- package/dist/core/memory/project-namespace.d.ts +0 -31
- package/dist/core/memory/project-namespace.js +0 -2
- package/dist/core/memory/repository-association.d.ts +0 -31
- package/dist/core/memory/repository-association.js +0 -1
- package/dist/core/memory/service.d.ts +0 -145
- package/dist/core/memory/service.js +0 -2
- package/dist/core/memory/tree.d.ts +0 -39
- package/dist/core/memory/tree.js +0 -1
- package/dist/core/memory-resolver.d.ts +0 -280
- package/dist/core/memory-resolver.js +0 -2
- package/dist/core/nested-stores.d.ts +0 -18
- package/dist/core/nested-stores.js +0 -1
- package/dist/core/runtime/memory.d.ts +0 -3
- package/dist/core/runtime/memory.js +0 -1
- package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
- package/dist/core/substrate/frontmatter-validation.js +0 -1
- package/dist/core/substrate/gate.d.ts +0 -16
- package/dist/core/substrate/gate.js +0 -1
- package/dist/core/substrate/index.d.ts +0 -18
- package/dist/core/substrate/index.js +0 -1
- package/dist/core/substrate/injected-store.d.ts +0 -75
- package/dist/core/substrate/injected-store.js +0 -2
- package/dist/core/substrate/listings.d.ts +0 -28
- package/dist/core/substrate/listings.js +0 -1
- package/dist/core/substrate/memory-events.d.ts +0 -6
- package/dist/core/substrate/memory-events.js +0 -1
- package/dist/core/substrate/on-read-node.d.ts +0 -6
- package/dist/core/substrate/on-read-node.js +0 -1
- package/dist/core/substrate/on-read.d.ts +0 -101
- package/dist/core/substrate/on-read.js +0 -9
- package/dist/core/substrate/plan.d.ts +0 -94
- package/dist/core/substrate/plan.js +0 -1
- package/dist/core/substrate/render-node.d.ts +0 -12
- package/dist/core/substrate/render-node.js +0 -1
- package/dist/core/substrate/render.d.ts +0 -41
- package/dist/core/substrate/render.js +0 -65
- package/dist/core/substrate/session-cache.d.ts +0 -27
- package/dist/core/substrate/session-cache.js +0 -1
- package/dist/core/substrate/surface-match.d.ts +0 -73
- package/dist/core/substrate/surface-match.js +0 -1
- package/dist/daemon/api/handlers/memory.js +0 -5
- package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
- package/dist/migrations/001-surfaces-frontmatter.js +0 -1
- package/dist/migrations/002-profile-project-memory.d.ts +0 -2
- package/dist/migrations/002-profile-project-memory.js +0 -1
- package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
- package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
- package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
- package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
- package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
- package/dist/migrations/convergent.d.ts +0 -43
- package/dist/migrations/convergent.js +0 -2
- package/dist/migrations/corpus.d.ts +0 -75
- package/dist/migrations/corpus.js +0 -3
- package/dist/migrations/frontmatter-splice.d.ts +0 -15
- package/dist/migrations/frontmatter-splice.js +0 -8
- package/dist/migrations/profile-manifests.d.ts +0 -30
- package/dist/migrations/profile-manifests.js +0 -2
- package/dist/migrations/registry.d.ts +0 -7
- package/dist/migrations/registry.js +0 -1
- package/dist/migrations/runner.d.ts +0 -43
- package/dist/migrations/runner.js +0 -1
- package/dist/migrations/types.d.ts +0 -211
- package/dist/shared/birth-announcement.d.ts +0 -12
- package/dist/shared/birth-announcement.js +0 -1
- package/docs/sdk/guides/app-memory.md +0 -22
- package/docs/sdk/memory.md +0 -85
- /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s=Object.defineProperty;var n=(o,e)=>s(o,"name",{value:e,configurable:!0});import{defineLeaf as i}from"../../core/command.js";import{general as d}from"../../core/errors.js";import{cliClient as l,rethrowAsCliError as u}from"../api-client.js";import{layoutNeedsMigration as m}from"../../core/layout.js";import{migrateLayout as h}from"../../core/layout-migrate/index.js";const v=i({name:"migrate",description:"migrate an old runtime layout offline, then import the legacy memory stores into the canvas",whenToUse:"when the daemon reports startup `blocked` by the canvas import, or after moving from a release that kept memory as markdown stores. Run --dry-run first to see the plan and what it resolves; a write run on an imported home does nothing.",help:{name:"sys migrate",summary:"move an old runtime layout offline, then plan or run the daemon-owned canvas import",guide:"A layout migration requires the daemon to be stopped, runs in this process, and stops after writing the layout version; start the daemon and run `crtr sys migrate` again. The daemon then plans the canvas import: every legacy store (the user store, each profile store, every repository `.crouter/memory` reached from a profile project or a node's cwd, node context folders and reports) becomes documents with their revision history, owned by the person, a profile, a repo, or a node. Both stages resolve leftovers and clashes themselves (a folder with no node row is set aside, two repos with one namespace get distinct handles, an unparseable file imports as its raw text, and so on) and list each in `layout_resolutions` and `resolutions`, on the dry run too. The daemon runs the import itself at startup; only a blocker (the store migrations of a skipped release never ran) makes it write nothing and hold startup in `blocked`. The import writes in one transaction and resumes startup. The markdown files are left on disk and are never read again.",params:[{kind:"flag",name:"dry-run",type:"bool",required:!1,constraint:"Plan and report without writing. On an imported home, returns the recorded report with pending false."}],output:[{name:"layout_moved",type:"number",required:!1,constraint:"Old-layout paths moved or stored paths rewritten on this run; present when the layout migration ran."},{name:"layout_resolutions",type:"string[]",required:!1,constraint:"One line per leftover the layout migration resolved (or, under --dry-run, will resolve): set-aside folders, moved profile files, closed worktree rows, cleared transcript paths."},{name:"layout_absent_credentials",type:"string[]",required:!1,constraint:"Old credential files the layout migration looked for and did not find (or, under --dry-run, will not find); present when the layout migration ran. An absent file is legitimate when the old home never held that credential."},{name:"stores",type:"object[]",required:!1,constraint:"Every store root found: {root, owner, docs, skipped?}; skipped is duplicate-worktree for a second checkout of an imported repo."},{name:"counts",type:"object",required:!1,constraint:"Planned (or written) totals: documents.<kind>, documents.owner.<person|profile|repo|node>, revisions, documents.rewritten, owners, stores, profile-limits, and informational counts. Empty on a write run over an imported home."},{name:"rewrites",type:"object[]",required:!1,constraint:"Pointer rewrites in head bodies: {path, from, to}."},{name:"dropped_fields",type:"object[]",required:!1,constraint:"Frontmatter fields with no canvas equivalent: {path, field}."},{name:"skipped",type:"object[]",required:!1,constraint:"Files or roots not imported, with the reason: {path, reason}."},{name:"resolutions",type:"object[]",required:!1,constraint:"Clashes the import resolved itself: {kind, message, paths}; kind is invalid-source, invalid-history, name-clash, repo-handle, profile-handle, repo-identity, or delivery-limit."},{name:"blockers",type:"object[]",required:!1,constraint:"{kind, message, paths}; kind is marker (the store migrations of a skipped release never ran). A blocker makes the command fail with this whole report in `received`; nothing is written."},{name:"dryRun",type:"boolean",required:!0,constraint:"True when nothing was written."},{name:"pending",type:"boolean",required:!1,constraint:"True while this home has not been imported."},{name:"resumed",type:"boolean",required:!1,constraint:"True only when this run resumed a blocked daemon startup."},{name:"resume_error",type:"string",required:!1,constraint:"Present when the import succeeded but normal daemon startup then failed."}],outputKind:"object",effects:["With an old layout and no layout version, refuses while a daemon answers, moves the runtime records, sets aside leftovers under runtime/set-aside/, rewrites stored paths and writes the layout version last, then stops; the next run, with the daemon started, plans or runs the canvas import.","Without --dry-run and with no blockers: stores revision bodies, converts profile project memory caps into profile delivery limits, and writes owners, documents, revisions, links, and the authoring nodes' watches in one canvas transaction, recorded so it runs once.","Under --dry-run: read-only, writes nothing."]},run:n(async o=>{const e=o.dryRun===!0,t=m()?await h(e):null;if(e&&t!==null)return{layout_resolutions:t.resolutions,layout_absent_credentials:t.absentCredentials,dryRun:e,follow_up:"Preview only \u2014 re-run without --dry-run to migrate the layout; the canvas import is planned after it."};if(t!==null)return{layout_moved:t.moved,layout_resolutions:t.resolutions,layout_absent_credentials:t.absentCredentials,dryRun:e,follow_up:"Layout migrated. Start the daemon (in a container, `docker compose exec`), then run `crtr sys migrate --dry-run` against it to plan the canvas import."};let r;try{r=await l().migrateState({dry_run:e})}catch(a){u(a)}if(r.blockers.length>0)throw d(`canvas import blocked by ${r.blockers.length} finding(s) \u2014 nothing was written`,{received:r,next:"Do what received.blockers[].message says, then run `crtr sys migrate` again."});return{...r,follow_up:r.pending?"Preview only \u2014 re-run without --dry-run to import.":e?"Already imported \u2014 this is the recorded report.":void 0}},"run")});export{v as sysMigrateLeaf};
|
|
@@ -4,6 +4,7 @@ export declare class ProfilesPanel implements SetupPanel {
|
|
|
4
4
|
private readonly onChange;
|
|
5
5
|
private readonly nameInput;
|
|
6
6
|
private readonly dirInput;
|
|
7
|
+
private readonly limitInput;
|
|
7
8
|
private entries;
|
|
8
9
|
private listIndex;
|
|
9
10
|
private dirIndex;
|
|
@@ -48,7 +49,8 @@ export declare class ProfilesPanel implements SetupPanel {
|
|
|
48
49
|
private togglePin;
|
|
49
50
|
private submitName;
|
|
50
51
|
private submitDir;
|
|
51
|
-
|
|
52
|
+
/** `<owner handle> <level>` sets one entry of the profile's `delivery_limits`. */
|
|
53
|
+
private submitLimit;
|
|
52
54
|
private askRemoveDir;
|
|
53
55
|
private removeDir;
|
|
54
56
|
private togglePause;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var L=Object.defineProperty;var g=(m,e)=>L(m,"name",{value:e,configurable:!0});import{envNodeId as R}from"../../../shared/env.js";import{Input as C,matchesKey as I,truncateToWidth as u}from"@earendil-works/pi-tui";import{basename as O}from"node:path";import{PROFILE_PROJECT_MEMORY_VALUES as v}from"../../../api/dto/profiles.js";import{cliClient as E}from"../../api-client.js";import{clearDefaultProfile as N,defaultProfileDirs as F,getDefaultProfileId as S,setDefaultProfileId as H}from"../../../core/profiles/default-binding.js";import{ROOT_PROFILE_ID as P,addProfileProject as w,createProfile as V,listProfiles as A,pauseProfile as U,removeProfileProject as W,renameProfile as B,resumeProfile as J}from"../../../core/profiles/manifest.js";import{tildify as l}from"../../../core/fs-utils.js";import{profileCoversCwd as M}from"../../../core/profiles/select.js";import{padAnsi as h,theme as o,visibleRange as _,wrapText as j}from"../../../core/tui/panel.js";function D(m){if(m===null)return"never used";const e=Date.parse(m);if(Number.isNaN(e))return"used recently";const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return"used just now";const n=Math.floor(t/60);if(n<60)return`used ${n}m ago`;const i=Math.floor(n/60);if(i<24)return`used ${i}h ago`;const s=Math.floor(i/24);if(s<30)return`used ${s}d ago`;const r=Math.floor(s/30);return r<12?`used ${r}mo ago`:`used ${Math.floor(r/12)}y ago`}g(D,"relativeUsed");function T(m){return m instanceof Error?m.message:String(m)}g(T,"messageOf");class ie{static{g(this,"ProfilesPanel")}cwd;onChange;nameInput=new C;dirInput=new C;entries=[];listIndex=0;dirIndex=0;mode="list";openId=null;notice;noticeTone="success";mutating=!1;constructor(e,t){this.cwd=e,this.onChange=t,this.nameInput.onSubmit=()=>{this.submitName(),this.onChange()},this.nameInput.onEscape=()=>{this.mode=this.openId!==null?"detail":"list",this.leaveField(),this.onChange()},this.dirInput.onSubmit=()=>{this.submitDir(),this.onChange()},this.dirInput.onEscape=()=>{this.mode="detail",this.leaveField(),this.onChange()},this.reload()}badge(){return String(this.entries.length)}ownsInput(e){return this.mode==="list"?!1:this.mode==="detail"?I(e,"escape")||I(e,"left"):!0}reload(){const e=g(i=>i.profileId===P?2:M(i,this.cwd)?0:1,"rank"),t=g(i=>i.manifest.last_used_at??"","used");this.entries=A().sort((i,s)=>{const r=e(i)-e(s);if(r!==0)return r;const d=t(s).localeCompare(t(i));return d!==0?d:i.manifest.name.localeCompare(s.manifest.name)}),this.listIndex>=this.entries.length&&(this.listIndex=Math.max(0,this.entries.length-1));const n=this.open();n===null?(this.mode!=="list"&&(this.mode="list"),this.openId=null):this.dirIndex>=n.manifest.projects.length&&(this.dirIndex=Math.max(0,n.manifest.projects.length-1))}selected(){return this.entries[this.listIndex]??null}open(){return this.openId===null?null:this.entries.find(e=>e.profileId===this.openId)??null}currentDir(){return this.open()?.manifest.projects[this.dirIndex]??null}pinnedHere(){return S(this.cwd)}say(e,t="success"){this.notice=e,this.noticeTone=t}attempt(e,t){try{e(),this.reload(),this.say(t)}catch(n){this.say(T(n),"warning")}}handleInput(e,t){const n=this.route(e,t);return n&&this.onChange(),n}route(e,t){switch(this.mode){case"new-name":case"rename":return this.routeText(this.nameInput,e);case"add-dir":return this.routeText(this.dirInput,e);case"confirm-delete":return this.routeConfirm(e,()=>{this.deleteOpen()});case"confirm-remove-dir":return this.routeConfirm(e,()=>this.removeDir());case"detail":return this.routeDetail(e,t);case"list":return this.routeList(e,t)}}routeText(e,t){return e.handleInput(t),!0}routeConfirm(e,t){const n=e.toLowerCase();return n==="y"?t():(n==="n"||I(e,"escape")||I(e,"return"))&&(this.mode=this.openId!==null?"detail":"list",this.say("Cancelled.")),!0}routeList(e,t){if(t?.("crtr.setup.list-down",e)===!0)return this.move(1),!0;if(t?.("crtr.setup.list-up",e)===!0)return this.move(-1),!0;if(t?.("crtr.setup.advance",e)===!0){const n=this.selected();return n!==null&&(this.openId=n.profileId,this.dirIndex=0,this.mode="detail",this.notice=void 0),!0}switch(e.toLowerCase()){case"a":return this.addCwdTo(this.selected());case"d":return this.togglePin();case"n":return this.mode="new-name",this.edit(this.nameInput,O(this.cwd)||"profile"),!0;case"x":return this.askDelete();default:return!1}}routeDetail(e,t){const n=this.open();if(n===null)return this.mode="list",!0;if(I(e,"escape")||I(e,"left"))return this.mode="list",this.notice=void 0,!0;if(t?.("crtr.setup.list-down",e)===!0)return this.moveDir(1),!0;if(t?.("crtr.setup.list-up",e)===!0)return this.moveDir(-1),!0;switch(e.toLowerCase()){case"a":return this.mode="add-dir",this.edit(this.dirInput,this.cwd),!0;case"m":return this.cycleMemory();case"x":return this.askRemoveDir();case"r":return this.mode="rename",this.edit(this.nameInput,n.manifest.name),!0;case"p":return this.togglePause();default:return!1}}edit(e,t){e.setValue(t),e.handleInput(""),e.focused=!0,this.notice=void 0}leaveField(){this.nameInput.focused=!1,this.dirInput.focused=!1}move(e){this.entries.length!==0&&(this.listIndex=(this.listIndex+e+this.entries.length)%this.entries.length,this.notice=void 0)}moveDir(e){const t=this.open()?.manifest.projects.length??0;t!==0&&(this.dirIndex=(this.dirIndex+e+t)%t,this.notice=void 0)}addCwdTo(e){return e===null||this.attempt(()=>w(e.profileId,this.cwd,{memory:"content"}),`${l(this.cwd)} now belongs to "${e.manifest.name}".`),!0}togglePin(){const e=this.selected();return e===null||(this.pinnedHere()===e.profileId?(N(this.cwd),this.say(`${l(this.cwd)} no longer defaults to any profile.`)):(H(this.cwd,e.profileId),this.say(`${l(this.cwd)} now starts as "${e.manifest.name}" without asking.`)),this.onChange()),!0}submitName(){const e=this.nameInput.getValue().trim(),t=this.mode==="new-name";if(this.mode=t?"list":"detail",this.leaveField(),e===""){this.say("A profile name cannot be empty.","warning");return}if(t){let i=null;this.attempt(()=>{i=V(e,[{path:this.cwd,memory:"content"}]).profileId},`Created "${e}", owning ${l(this.cwd)}.`);const s=this.entries.findIndex(r=>r.profileId===i);s>=0&&(this.listIndex=s);return}const n=this.open();n!==null&&this.attempt(()=>B(n.profileId,e),`Renamed to "${e}".`)}submitDir(){const e=this.dirInput.getValue().trim(),t=this.open();if(this.mode="detail",this.leaveField(),t!==null){if(e===""){this.say("Type the directory to add.","warning");return}this.attempt(()=>w(t.profileId,e,{memory:"content"}),`${l(e)} added to "${t.manifest.name}".`)}}cycleMemory(){const e=this.open(),t=this.currentDir();if(e===null||t===null)return!0;const n=v[(v.indexOf(t.memory)+1)%v.length];return this.attempt(()=>w(e.profileId,t.path,{memory:n}),`${l(t.path)} discloses up to "${n}".`),!0}askRemoveDir(){return this.currentDir()===null?(this.say("This profile owns no directories.","warning"),!0):(this.mode="confirm-remove-dir",this.notice=void 0,!0)}removeDir(){const e=this.open(),t=this.currentDir();this.mode="detail",!(e===null||t===null)&&this.attempt(()=>W(e.profileId,t.path),`${l(t.path)} removed from "${e.manifest.name}".`)}togglePause(){const e=this.open();if(e===null)return!0;const t=e.manifest.paused_at!==null;return this.attempt(()=>t?J(e.profileId):U(e.profileId),t?`"${e.manifest.name}" is active again.`:`"${e.manifest.name}" is paused \u2014 no new nodes start under it.`),!0}askDelete(){const e=this.selected();return e===null?!0:e.profileId===P?(this.say("The root profile is the fallback identity for uncovered directories and cannot be deleted.","warning"),!0):(this.openId=e.profileId,this.mode="confirm-delete",this.notice=void 0,!0)}async deleteOpen(){const e=this.open();if(this.mode="list",!(e===null||this.mutating)){this.mutating=!0,this.say(`Deleting "${e.manifest.name}"\u2026`),this.onChange();try{const t=await E().deleteProfile(e.profileId,{force:!0,caller_node_id:R()??null});this.openId=null,this.reload(),this.say(`Deleted "${t.name}" \u2014 ${t.nodes} nodes, ${t.crons} crons, ${t.default_pins} pins.`)}catch(t){this.say(T(t),"warning")}finally{this.mutating=!1,this.onChange()}}}footerHint(){switch(this.mode){case"new-name":return"type a name \xB7 enter create \xB7 esc cancel";case"rename":return"type a name \xB7 enter save \xB7 esc cancel";case"add-dir":return"type a directory \xB7 enter add \xB7 esc cancel";case"confirm-delete":case"confirm-remove-dir":return"y confirm \xB7 n cancel";case"detail":return"\u2191\u2193 dir \xB7 a add \xB7 m memory \xB7 x remove \xB7 r rename \xB7 p pause \xB7 esc back";case"list":return"\u2191\u2193 move \xB7 enter open \xB7 a add this dir \xB7 d pin here \xB7 n new \xB7 x delete"}}render(e,t){const i=this.mode==="list"||this.mode==="new-name"||this.mode==="confirm-delete"?this.renderList(e,t):this.renderDetail(e,t);if(this.notice!==void 0){i.push("");for(const s of j(this.notice,e))i.push(u(o.fg(this.noticeTone,s),e))}return i}header(e,t,n){const i=o.fg("accent",o.bold(t)),s=o.fg("dim",n);return u(`${i} ${s}`,e)}renderList(e,t){const n=[this.header(e,"Profiles",`${this.entries.length} profile${this.entries.length===1?"":"s"}`),u(o.fg("dim",`Identities your sessions run under. Here: ${l(this.cwd)}`),e),""];if(this.mode==="new-name")return[...n,...this.field(e,"New profile name",this.nameInput)];if(this.mode==="confirm-delete")return[...n,...this.deletePrompt(e)];if(this.entries.length===0)return n.push(u(o.fg("dim"," No profiles yet \u2014 press n to create one here."),e)),n;const i=this.pinnedHere(),s=Math.min(22,Math.max(...this.entries.map(f=>f.manifest.name.length))),r=Math.max(1,t-8),d=_(this.entries.length,this.listIndex,r);for(let f=d.start;f<d.end;f+=1){const c=this.entries[f],y=c.manifest.projects.length,$=y===0?"\u2014":`${y} dir${y===1?"":"s"}`,a=[];M(c,this.cwd)&&a.push("covers here"),i===c.profileId&&a.push("pinned"),c.manifest.paused_at!==null&&a.push("paused");const p=`${h(c.manifest.name,s)} ${h($,8)} ${h(D(c.manifest.last_used_at),14)} ${a.join(" \xB7 ")}`;f===this.listIndex?n.push(o.bg("selectedBg",h(`\u25B8 ${p}`,e))):n.push(u(` ${h(c.manifest.name,s)} ${o.fg("dim",`${h($,8)} ${h(D(c.manifest.last_used_at),14)}`)} ${o.fg("muted",a.join(" \xB7 "))}`,e))}return(d.start>0||d.end<this.entries.length)&&n.push(u(o.fg("dim",` ${this.listIndex+1}/${this.entries.length}`),e)),n}renderDetail(e,t){const n=this.open();if(n===null)return this.renderList(e,t);const i=n.manifest,s=[`app ${i.grantee??"app:terminal"}`,`kind ${i.default_kind??"general"}`,D(i.last_used_at),...i.paused_at!==null?["paused"]:[]],r=[this.header(e,i.name,n.profileId),u(o.fg("dim",s.join(" \xB7 ")),e),""];if(this.mode==="rename")return[...r,...this.field(e,"Rename profile",this.nameInput)];if(this.mode==="add-dir")return[...r,...this.field(e,"Directory to add to this profile",this.dirInput)];const d=i.projects;if(d.length===0)return r.push(u(o.fg("dim"," Owns no directories \u2014 press a to add one."),e)),r;const f=new Set(F(n.profileId)),c=Math.min(Math.max(20,e-26),Math.max(...d.map(a=>l(a.path).length))),y=Math.max(1,t-8),$=_(d.length,this.dirIndex,y);for(let a=$.start;a<$.end;a+=1){const p=d[a],x=[];f.has(p.path)&&x.push("pinned"),p.path===this.cwd&&x.push("\u2190 here");const b=h(l(p.path),c),k=`${b} ${h(p.memory,8)} ${x.join(" \xB7 ")}`;a===this.dirIndex?r.push(o.bg("selectedBg",h(`\u25B8 ${k}`,e))):r.push(u(` ${b} ${o.fg("success",h(p.memory,8))} ${o.fg("muted",x.join(" \xB7 "))}`,e))}if(this.mode==="confirm-remove-dir"){const a=this.currentDir();r.push(""),r.push(u(o.fg("warning",`Remove ${a!==null?l(a.path):"this directory"} from "${i.name}"? Its files are untouched. y / n`),e))}return r}field(e,t,n){return[u(o.fg("accent",t),e),u(` ${n.render(Math.max(8,e-2))[0]??""}`,e)]}deletePrompt(e){const n=this.open()?.manifest.name??"",i=[];for(const s of j(`Delete "${n}" and everything it owns \u2014 every node, cron, inbox ticket and review under it, plus its memory store and directory pins? This cannot be undone.`,e))i.push(u(o.fg("warning",s),e));return i.push(""),i.push(u(o.fg("dim"," y delete n cancel"),e)),i}}export{ie as ProfilesPanel};
|
|
1
|
+
var R=Object.defineProperty;var g=(m,e)=>R(m,"name",{value:e,configurable:!0});import{envNodeId as O}from"../../../shared/env.js";import{Input as x,matchesKey as I,truncateToWidth as a}from"@earendil-works/pi-tui";import{basename as E}from"node:path";import{PROFILE_PROJECT_MEMORY_VALUES as C}from"../../../api/dto/profiles.js";import{cliClient as F}from"../../api-client.js";import{clearDefaultProfile as N,defaultProfileDirs as S,getDefaultProfileId as H,setDefaultProfileId as V}from"../../../core/profiles/default-binding.js";import{ROOT_PROFILE_ID as P,addProfileProject as _,createProfile as A,listProfiles as U,pauseProfile as W,removeProfileProject as B,setProfileDeliveryLimit as J,renameProfile as K,resumeProfile as Y}from"../../../core/profiles/manifest.js";import{tildify as c}from"../../../core/fs-utils.js";import{profileCoversCwd as j}from"../../../core/profiles/select.js";import{padAnsi as f,theme as o,visibleRange as M,wrapText as T}from"../../../core/tui/panel.js";function b(m){if(m===null)return"never used";const e=Date.parse(m);if(Number.isNaN(e))return"used recently";const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return"used just now";const i=Math.floor(t/60);if(i<60)return`used ${i}m ago`;const n=Math.floor(i/60);if(n<24)return`used ${n}h ago`;const r=Math.floor(n/24);if(r<30)return`used ${r}d ago`;const s=Math.floor(r/30);return s<12?`used ${s}mo ago`:`used ${Math.floor(s/12)}y ago`}g(b,"relativeUsed");function L(m){return m instanceof Error?m.message:String(m)}g(L,"messageOf");class re{static{g(this,"ProfilesPanel")}cwd;onChange;nameInput=new x;dirInput=new x;limitInput=new x;entries=[];listIndex=0;dirIndex=0;mode="list";openId=null;notice;noticeTone="success";mutating=!1;constructor(e,t){this.cwd=e,this.onChange=t,this.nameInput.onSubmit=()=>{this.submitName(),this.onChange()},this.nameInput.onEscape=()=>{this.mode=this.openId!==null?"detail":"list",this.leaveField(),this.onChange()},this.dirInput.onSubmit=()=>{this.submitDir(),this.onChange()},this.dirInput.onEscape=()=>{this.mode="detail",this.leaveField(),this.onChange()},this.limitInput.onSubmit=()=>{this.submitLimit(),this.onChange()},this.limitInput.onEscape=()=>{this.mode="detail",this.leaveField(),this.onChange()},this.reload()}badge(){return String(this.entries.length)}ownsInput(e){return this.mode==="list"?!1:this.mode==="detail"?I(e,"escape")||I(e,"left"):!0}reload(){const e=g(n=>n.profileId===P?2:j(n,this.cwd)?0:1,"rank"),t=g(n=>n.manifest.last_used_at??"","used");this.entries=U().sort((n,r)=>{const s=e(n)-e(r);if(s!==0)return s;const d=t(r).localeCompare(t(n));return d!==0?d:n.manifest.name.localeCompare(r.manifest.name)}),this.listIndex>=this.entries.length&&(this.listIndex=Math.max(0,this.entries.length-1));const i=this.open();i===null?(this.mode!=="list"&&(this.mode="list"),this.openId=null):this.dirIndex>=i.manifest.projects.length&&(this.dirIndex=Math.max(0,i.manifest.projects.length-1))}selected(){return this.entries[this.listIndex]??null}open(){return this.openId===null?null:this.entries.find(e=>e.profileId===this.openId)??null}currentDir(){return this.open()?.manifest.projects[this.dirIndex]??null}pinnedHere(){return H(this.cwd)}say(e,t="success"){this.notice=e,this.noticeTone=t}attempt(e,t){try{e(),this.reload(),this.say(t)}catch(i){this.say(L(i),"warning")}}handleInput(e,t){const i=this.route(e,t);return i&&this.onChange(),i}route(e,t){switch(this.mode){case"new-name":case"rename":return this.routeText(this.nameInput,e);case"add-dir":return this.routeText(this.dirInput,e);case"set-limit":return this.routeText(this.limitInput,e);case"confirm-delete":return this.routeConfirm(e,()=>{this.deleteOpen()});case"confirm-remove-dir":return this.routeConfirm(e,()=>this.removeDir());case"detail":return this.routeDetail(e,t);case"list":return this.routeList(e,t)}}routeText(e,t){return e.handleInput(t),!0}routeConfirm(e,t){const i=e.toLowerCase();return i==="y"?t():(i==="n"||I(e,"escape")||I(e,"return"))&&(this.mode=this.openId!==null?"detail":"list",this.say("Cancelled.")),!0}routeList(e,t){if(t?.("crtr.setup.list-down",e)===!0)return this.move(1),!0;if(t?.("crtr.setup.list-up",e)===!0)return this.move(-1),!0;if(t?.("crtr.setup.advance",e)===!0){const i=this.selected();return i!==null&&(this.openId=i.profileId,this.dirIndex=0,this.mode="detail",this.notice=void 0),!0}switch(e.toLowerCase()){case"a":return this.addCwdTo(this.selected());case"d":return this.togglePin();case"n":return this.mode="new-name",this.edit(this.nameInput,E(this.cwd)||"profile"),!0;case"x":return this.askDelete();default:return!1}}routeDetail(e,t){const i=this.open();if(i===null)return this.mode="list",!0;if(I(e,"escape")||I(e,"left"))return this.mode="list",this.notice=void 0,!0;if(t?.("crtr.setup.list-down",e)===!0)return this.moveDir(1),!0;if(t?.("crtr.setup.list-up",e)===!0)return this.moveDir(-1),!0;switch(e.toLowerCase()){case"a":return this.mode="add-dir",this.edit(this.dirInput,this.cwd),!0;case"l":return this.mode="set-limit",this.edit(this.limitInput,""),!0;case"x":return this.askRemoveDir();case"r":return this.mode="rename",this.edit(this.nameInput,i.manifest.name),!0;case"p":return this.togglePause();default:return!1}}edit(e,t){e.setValue(t),e.handleInput(""),e.focused=!0,this.notice=void 0}leaveField(){this.nameInput.focused=!1,this.dirInput.focused=!1,this.limitInput.focused=!1}move(e){this.entries.length!==0&&(this.listIndex=(this.listIndex+e+this.entries.length)%this.entries.length,this.notice=void 0)}moveDir(e){const t=this.open()?.manifest.projects.length??0;t!==0&&(this.dirIndex=(this.dirIndex+e+t)%t,this.notice=void 0)}addCwdTo(e){return e===null||this.attempt(()=>_(e.profileId,this.cwd),`${c(this.cwd)} now belongs to "${e.manifest.name}".`),!0}togglePin(){const e=this.selected();return e===null||(this.pinnedHere()===e.profileId?(N(this.cwd),this.say(`${c(this.cwd)} no longer defaults to any profile.`)):(V(this.cwd,e.profileId),this.say(`${c(this.cwd)} now starts as "${e.manifest.name}" without asking.`)),this.onChange()),!0}submitName(){const e=this.nameInput.getValue().trim(),t=this.mode==="new-name";if(this.mode=t?"list":"detail",this.leaveField(),e===""){this.say("A profile name cannot be empty.","warning");return}if(t){let n=null;this.attempt(()=>{n=A(e,[{path:this.cwd}]).profileId},`Created "${e}", owning ${c(this.cwd)}.`);const r=this.entries.findIndex(s=>s.profileId===n);r>=0&&(this.listIndex=r);return}const i=this.open();i!==null&&this.attempt(()=>K(i.profileId,e),`Renamed to "${e}".`)}submitDir(){const e=this.dirInput.getValue().trim(),t=this.open();if(this.mode="detail",this.leaveField(),t!==null){if(e===""){this.say("Type the directory to add.","warning");return}this.attempt(()=>_(t.profileId,e),`${c(e)} added to "${t.manifest.name}".`)}}submitLimit(){const e=this.limitInput.getValue().trim().split(/\s+/),t=this.open();if(this.mode="detail",this.leaveField(),t===null)return;const[i,n]=e;if(e.length!==2||i===void 0||n===void 0||!C.includes(n)){this.say(`Type an owner handle and a level (${C.join(", ")}), e.g. "crouter preview".`,"warning");return}this.attempt(()=>J(t.profileId,i,n),n==="content"?`${i} is no longer limited.`:`${i} is delivered automatically up to "${n}".`)}askRemoveDir(){return this.currentDir()===null?(this.say("This profile owns no directories.","warning"),!0):(this.mode="confirm-remove-dir",this.notice=void 0,!0)}removeDir(){const e=this.open(),t=this.currentDir();this.mode="detail",!(e===null||t===null)&&this.attempt(()=>B(e.profileId,t.path),`${c(t.path)} removed from "${e.manifest.name}".`)}togglePause(){const e=this.open();if(e===null)return!0;const t=e.manifest.paused_at!==null;return this.attempt(()=>t?Y(e.profileId):W(e.profileId),t?`"${e.manifest.name}" is active again.`:`"${e.manifest.name}" is paused \u2014 no new nodes start under it.`),!0}askDelete(){const e=this.selected();return e===null?!0:e.profileId===P?(this.say("The root profile is the fallback identity for uncovered directories and cannot be deleted.","warning"),!0):(this.openId=e.profileId,this.mode="confirm-delete",this.notice=void 0,!0)}async deleteOpen(){const e=this.open();if(this.mode="list",!(e===null||this.mutating)){this.mutating=!0,this.say(`Deleting "${e.manifest.name}"\u2026`),this.onChange();try{const t=await F().deleteProfile(e.profileId,{force:!0,caller_node_id:O()??null});this.openId=null,this.reload(),this.say(`Deleted "${t.name}" \u2014 ${t.nodes} nodes, ${t.crons} crons, ${t.default_pins} pins.`)}catch(t){this.say(L(t),"warning")}finally{this.mutating=!1,this.onChange()}}}footerHint(){switch(this.mode){case"new-name":return"type a name \xB7 enter create \xB7 esc cancel";case"rename":return"type a name \xB7 enter save \xB7 esc cancel";case"add-dir":return"type a directory \xB7 enter add \xB7 esc cancel";case"set-limit":return"type <owner> <level> \xB7 enter save \xB7 esc cancel";case"confirm-delete":case"confirm-remove-dir":return"y confirm \xB7 n cancel";case"detail":return"\u2191\u2193 dir \xB7 a add \xB7 l limit \xB7 x remove \xB7 r rename \xB7 p pause \xB7 esc back";case"list":return"\u2191\u2193 move \xB7 enter open \xB7 a add this dir \xB7 d pin here \xB7 n new \xB7 x delete"}}render(e,t){const n=this.mode==="list"||this.mode==="new-name"||this.mode==="confirm-delete"?this.renderList(e,t):this.renderDetail(e,t);if(this.notice!==void 0){n.push("");for(const r of T(this.notice,e))n.push(a(o.fg(this.noticeTone,r),e))}return n}header(e,t,i){const n=o.fg("accent",o.bold(t)),r=o.fg("dim",i);return a(`${n} ${r}`,e)}renderList(e,t){const i=[this.header(e,"Profiles",`${this.entries.length} profile${this.entries.length===1?"":"s"}`),a(o.fg("dim",`Identities your sessions run under. Here: ${c(this.cwd)}`),e),""];if(this.mode==="new-name")return[...i,...this.field(e,"New profile name",this.nameInput)];if(this.mode==="confirm-delete")return[...i,...this.deletePrompt(e)];if(this.entries.length===0)return i.push(a(o.fg("dim"," No profiles yet \u2014 press n to create one here."),e)),i;const n=this.pinnedHere(),r=Math.min(22,Math.max(...this.entries.map(u=>u.manifest.name.length))),s=Math.max(1,t-8),d=M(this.entries.length,this.listIndex,s);for(let u=d.start;u<d.end;u+=1){const h=this.entries[u],$=h.manifest.projects.length,v=$===0?"\u2014":`${$} dir${$===1?"":"s"}`,p=[];j(h,this.cwd)&&p.push("covers here"),n===h.profileId&&p.push("pinned"),h.manifest.paused_at!==null&&p.push("paused");const l=`${f(h.manifest.name,r)} ${f(v,8)} ${f(b(h.manifest.last_used_at),14)} ${p.join(" \xB7 ")}`;u===this.listIndex?i.push(o.bg("selectedBg",f(`\u25B8 ${l}`,e))):i.push(a(` ${f(h.manifest.name,r)} ${o.fg("dim",`${f(v,8)} ${f(b(h.manifest.last_used_at),14)}`)} ${o.fg("muted",p.join(" \xB7 "))}`,e))}return(d.start>0||d.end<this.entries.length)&&i.push(a(o.fg("dim",` ${this.listIndex+1}/${this.entries.length}`),e)),i}renderDetail(e,t){const i=this.open();if(i===null)return this.renderList(e,t);const n=i.manifest,r=[`app ${n.grantee??"app:terminal"}`,`kind ${n.default_kind??"general"}`,b(n.last_used_at),...n.paused_at!==null?["paused"]:[]],s=[this.header(e,n.name,i.profileId),a(o.fg("dim",r.join(" \xB7 ")),e),""];if(this.mode==="rename")return[...s,...this.field(e,"Rename profile",this.nameInput)];if(this.mode==="add-dir")return[...s,...this.field(e,"Directory to add to this profile",this.dirInput)];if(this.mode==="set-limit")return[...s,...this.field(e,"Delivery limit: owner handle and level (content removes it)",this.limitInput)];const d=Object.entries(n.delivery_limits??{});d.length>0&&(s.push(a(o.fg("dim",`limits ${d.map(([l,y])=>`${l} ${y}`).join(" \xB7 ")}`),e)),s.push(""));const u=n.projects;if(u.length===0)return s.push(a(o.fg("dim"," Owns no directories \u2014 press a to add one."),e)),s;const h=new Set(S(i.profileId)),$=Math.min(Math.max(20,e-16),Math.max(...u.map(l=>c(l.path).length))),v=Math.max(1,t-8),p=M(u.length,this.dirIndex,v);for(let l=p.start;l<p.end;l+=1){const y=u[l],w=[];h.has(y.path)&&w.push("pinned"),y.path===this.cwd&&w.push("\u2190 here");const D=f(c(y.path),$),k=`${D} ${w.join(" \xB7 ")}`;l===this.dirIndex?s.push(o.bg("selectedBg",f(`\u25B8 ${k}`,e))):s.push(a(` ${D} ${o.fg("muted",w.join(" \xB7 "))}`,e))}if(this.mode==="confirm-remove-dir"){const l=this.currentDir();s.push(""),s.push(a(o.fg("warning",`Remove ${l!==null?c(l.path):"this directory"} from "${n.name}"? Its files are untouched. y / n`),e))}return s}field(e,t,i){return[a(o.fg("accent",t),e),a(` ${i.render(Math.max(8,e-2))[0]??""}`,e)]}deletePrompt(e){const i=this.open()?.manifest.name??"",n=[];for(const r of T(`Delete "${i}" and everything it owns \u2014 every node, cron, inbox ticket and review under it, plus its memory store and directory pins? This cannot be undone.`,e))n.push(a(o.fg("warning",r),e));return n.push(""),n.push(a(o.fg("dim"," y delete n cancel"),e)),n}}export{re as ProfilesPanel};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* the wipe guard: `deps` only ever deletes a deps/ dir whose INDEX carries
|
|
3
|
-
* this marker. */
|
|
1
|
+
import type { CrtrClient } from '../../api/index.js';
|
|
4
2
|
export declare const DEPS_GENERATED_MARKER = "crtr sys sync deps";
|
|
5
|
-
/** Row shape structurally compatible with sync.ts's ImportResult. */
|
|
6
3
|
interface DepsRow {
|
|
7
4
|
source: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* except on an `excluded` row, which names the excluded package selector. */
|
|
5
|
+
/** Full name of the vendored document (`<repo>/deps/...`), except on an
|
|
6
|
+
* `excluded` row, which names the excluded package selector. */
|
|
11
7
|
name: string;
|
|
12
|
-
|
|
13
|
-
status: 'imported' | 'would-import' | 'skipped' | 'excluded';
|
|
8
|
+
status: 'imported' | 'unchanged' | 'would-import' | 'deleted' | 'would-delete' | 'skipped' | 'excluded';
|
|
14
9
|
reason?: string;
|
|
15
10
|
}
|
|
16
|
-
export declare function runDepsSync(opts: {
|
|
11
|
+
export declare function runDepsSync(client: CrtrClient, opts: {
|
|
17
12
|
sourceArg?: string;
|
|
18
13
|
dryRun: boolean;
|
|
19
|
-
}): DepsRow[]
|
|
14
|
+
}): Promise<DepsRow[]>;
|
|
20
15
|
export declare const sysSyncDepsLeaf: import("../../core/command.js").LeafDef;
|
|
21
16
|
export {};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
var
|
|
1
|
+
var le=Object.defineProperty;var p=(s,n)=>le(s,"name",{value:n,configurable:!0});import{dirname as W,join as w,relative as F,resolve as X,sep as z}from"node:path";import{defineLeaf as pe}from"../../core/command.js";import{usage as D}from"../../core/errors.js";import{parseFrontmatterGeneric as Q}from"../../core/frontmatter.js";import{pathExists as M,readJsonIfExists as Y,readText as I,walkFiles as ee}from"../../core/fs-utils.js";import{cliClient as ue}from"../api-client.js";import{normalizedName as ne,putDoc as se,repoOwner as me,routeFromDescription as he,scalarString as fe,writeFailure as te}from"./sync-shared.js";import{isRecord as E}from"../../shared/predicates.js";import{readdirSync as ge}from"node:fs";const L="crtr sys sync deps";function f(s){throw D(`--deps: invalid package.json crtr.sync.deps.exclude: ${s}`)}p(f,"invalidDepsConfig");function ke(s){const n=Y(w(s,"package.json"));E(n)||f("package.json must contain an object");const o=n.crtr;if(o===void 0)return[];E(o)||f("crtr must be an object");const r=o.sync;if(r===void 0)return[];E(r)||f("crtr.sync must be an object");const t=r.deps;if(t===void 0)return[];E(t)||f("crtr.sync.deps must be an object");const i=t.exclude;if(i===void 0)return[];Array.isArray(i)||f("exclude must be an array of {package, version, skill} selectors");const m=new Set;return i.map((k,g)=>{E(k)||f(`exclude[${g}] must be an object with exactly package, version, and skill`),Object.keys(k).sort().join(",")!=="package,skill,version"&&f(`exclude[${g}] must contain exactly package, version, and skill`);const u=k.package,v=k.version,h=k.skill;(typeof u!="string"||!ye.test(u))&&f(`exclude[${g}].package must be one exact npm package name`),(typeof v!="string"||!$e.test(v))&&f(`exclude[${g}].version must be one exact installed semver version`),(typeof h!="string"||h===""||h!=="."&&(h.startsWith("/")||h.split("/").some(x=>x===""||x==="."||x==="..")||/[\\*?[\]{}]/.test(h)))&&f(`exclude[${g}].skill must be one exact POSIX path relative to the package skills/ directory (use . for a root SKILL.md)`);const $={package:u,version:v,skill:h},S=`${u}\0${v}\0${h}`;return m.has(S)&&f(`exclude[${g}] duplicates ${u}@${v} skill ${h}`),m.add(S),$})}p(ke,"readDepsExclusions");const ye=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/,oe="(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)",$e=new RegExp(`^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-${oe}(?:\\.${oe})*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$`);function _(s,n,o){return`${s}\0${n}\0${o}`}p(_,"exclusionKey");function be(s,n,o){return s.has(_(n.pkg,n.version,o))}p(be,"isExcluded");function we(s){if(s!==void 0)return X(s);let n=X(process.cwd());for(;;){if(M(w(n,"package.json")))return n;const o=W(n);if(o===n)throw D("--deps: no package.json found from cwd upward; run inside a Node project or pass --source <project-dir>");n=o}}p(we,"depsProjectDir");function ve(s){const n=[];for(const r of re(s))if(!r.startsWith("."))if(r.startsWith("@"))for(const t of re(w(s,r)))n.push(w(s,r,t));else n.push(w(s,r));const o=[];for(const r of n.sort()){const t=w(r,"skills");if(!M(t))continue;const i=Y(w(r,"package.json"));o.push({pkg:i?.name??F(s,r).split(z).join("/"),version:i?.version??"",skillsRoot:t})}return o}p(ve,"skillsPackages");function re(s){try{return ge(s)}catch{return[]}}p(re,"listDirNames");function xe(s,n){return n.find(o=>s===o||s.startsWith(`${o}${z}`))}p(xe,"owningBundle");function de(s,n=220){const o=s.replace(/\s+/g," ").trim(),r=o.split(/(?<=[.!?])\s+/)[0]??o,t=r.length>=30?r:o;if(t.length<=n)return t;const i=t.slice(0,n),m=i.lastIndexOf(" ");return`${i.slice(0,m>80?m:n).trimEnd()}\u2026`}p(de,"condenseDescription");function je(s){const n=s.match(/^#{1,6}\s+(.+)$/m);return n?n[1].trim():void 0}p(je,"firstHeading");async function Re(s,n){const o=we(n.sourceArg),r=w(o,"node_modules");if(!M(r))throw D(`sys sync deps: ${r} does not exist; install dependencies first (npm ci / npm install), then re-run`);const t=await me(s,o),i=[...t.existing].filter(e=>e.startsWith("deps/"));if(i.length>0||t.existing.has("deps")){const e=t.existing.has("deps")?await s.objects.read(`${t.handle}/deps`):null;if(!(e!==null&&e.state==="object"&&e.type==="document"&&e.bodies.some(c=>c.includes(L))))throw D(`--deps: repo ${t.handle} already has documents named deps/\u2026 but its \`deps\` document does not carry the "${L}" marker; they may be hand-written \u2014 move or delete them (\`crtr doc move\` / \`crtr doc delete\`) before vendoring dependency docs there`)}const m=ke(o),k=new Set(m.map(e=>_(e.package,e.version,e.skill))),g=new Map(m.map(e=>[_(e.package,e.version,e.skill),0])),y=new Map,u=[],v=ve(r),h=[];for(const e of v){const d=[],c=new Set;for(const a of ee(e.skillsRoot,l=>l==="SKILL.md",l=>l==="node_modules"||l===".git")){const l=W(a);d.push(l);const b=W(F(e.skillsRoot,a).split(z).join("/"));if(!be(k,e,b))continue;const j=_(e.pkg,e.version,b);g.set(j,(g.get(j)??0)+1),c.add(l),u.push({source:a,name:`${e.pkg}@${e.version}:${b}`,status:"excluded",reason:"matched package.json crtr.sync.deps.exclude"})}h.push({...e,bundleRoots:d.sort((a,l)=>l.length-a.length),excludedBundleRoots:c})}for(const e of m){const d=_(e.package,e.version,e.skill),c=g.get(d);if(c!==1)throw D(`--deps: package.json crtr.sync.deps.exclude selector ${e.package}@${e.version}:${e.skill} ${c===0?"does not match an installed dependency skill bundle":`matches ${c} installed dependency skill bundles`}; update or remove the selector before syncing`)}for(const e of h){const d=e.bundleRoots??[],c=e.excludedBundleRoots??new Set;for(const a of ee(e.skillsRoot,l=>l.toLowerCase().endsWith(".md"),l=>l==="node_modules"||l===".git")){const l=xe(a,d);if(l===void 0||c.has(l))continue;const b=F(e.skillsRoot,a).split(z).join("/");let j,R;if(b==="SKILL.md"||b.endsWith("/SKILL.md")){const V=W(b),H=ne(V==="."?e.pkg.split("/").pop()??e.pkg:V);R=H;let J={},P="";try{const U=Q(I(a));J=U.data??{},P=U.body}catch{P=I(a)}j={kind:"skill",sourceAbs:a,pkg:e.pkg,version:e.version,bundleRel:H,body:P,description:fe(J.description)??""}}else R=ne(b),j={kind:"sidecar-md",sourceAbs:a,pkg:e.pkg,version:e.version};if(R==="")continue;const q=y.get(R);if(q){j.kind==="skill"&&u.push({source:a,name:`${t.handle}/deps/${R}`,status:"skipped",reason:`collides with same-named document from ${q.pkg}`});continue}y.set(R,j)}}const $=[...y.entries()].filter(e=>e[1].kind==="skill"),S=$.map(([,e])=>e.bundleRel).sort((e,d)=>d.length-e.length),x=new Map;for(const[e,d]of y){if(d.kind==="skill")continue;const c=S.find(a=>e.startsWith(`${a}/`));c&&x.set(c,(x.get(c)??0)+1)}const C=new Set($.map(([,e])=>`${e.pkg}@${e.version}`)),O=`generated catalog of ${$.length} docs from ${C.size} package${C.size===1?"":"s"}`,B=p((e,d)=>{if(d.kind!=="skill")return;const c=x.get(d.bundleRel)??0;return c>0?`+${c} sidecar doc${c===1?"":"s"}`:void 0},"reasonFor"),G=i.filter(e=>!y.has(e.slice(5)));if(n.dryRun){for(const[e,d]of y){const c=B(e,d);u.push({source:d.sourceAbs,name:`${t.handle}/deps/${e}`,status:"would-import",...c?{reason:c}:{}})}for(const e of G)u.push({source:"\u2014",name:`${t.handle}/${e}`,status:"would-delete",reason:"no dependency ships it any more"});return u.push({source:r,name:`${t.handle}/deps`,status:"would-import",reason:O}),u}const T="regenerated by crtr sys sync deps";for(const[e,d]of y){const c=d.kind==="skill"?Se(e,d):Ae(e,d,S,t.handle);try{const a=await se(s,t,c,T),l=B(e,d);u.push({source:d.sourceAbs,name:a.name,status:a.changed?"imported":"unchanged",...l?{reason:l}:{}})}catch(a){u.push({source:d.sourceAbs,name:`${t.handle}/deps/${e}`,status:"skipped",reason:te(a)})}}for(const e of G)await s.docs.delete(`${t.handle}/${e}`),u.push({source:"\u2014",name:`${t.handle}/${e}`,status:"deleted",reason:"no dependency ships it any more"});const A=`${t.handle}/deps`,Z=[...new Set($.map(([,e])=>e.pkg))],ce=Z.slice(0,6).join(", ")+(Z.length>6?", \u2026":""),N=new Map;for(const[,e]of $){const d=`${e.pkg}@${e.version}`,c=N.get(d)??[],a=e.description!==""?` \u2014 ${de(e.description,180)}`:"";c.push(`- [[${A}/${e.bundleRel}]]${a}`),N.set(d,c)}const ie=[...N.entries()].map(([e,d])=>`## ${e}
|
|
2
2
|
|
|
3
|
-
${
|
|
3
|
+
${d.sort().join(`
|
|
4
4
|
`)}`).join(`
|
|
5
5
|
|
|
6
|
-
`),
|
|
6
|
+
`),K=$.length===0,ae={name:"deps",kind:"knowledge",preview:K?"When deciding whether dependency-shipped agent docs are available in this project, read this because no dependency guides are currently vendored.":`When writing code against this project's dependencies (${ce}), read this because those packages ship their own agent guides, vendored as documents readable with \`crtr canvas read ${A}/<name>\`.`,summary:K?"No dependency-shipped agent docs are currently vendored.":"Generated catalog of the agent docs shipped inside this project's npm dependencies.",rules:[{on:"boot",deliver:"preview"}],body:K?`# Dependency-shipped agent docs (generated)
|
|
7
7
|
|
|
8
|
-
No dependency agent docs are currently vendored. \`
|
|
8
|
+
No dependency agent docs are currently vendored. \`${L}\` found no included Agent Skill bundles.
|
|
9
9
|
`:`# Dependency-shipped agent docs (generated)
|
|
10
10
|
|
|
11
|
-
Generated by \`
|
|
11
|
+
Generated by \`${L}\` from the Agent Skill bundles inside this project's node_modules. Do not hand-edit: every \`${A}/\u2026\` document is rewritten on every run \u2014 re-run after dependencies change. Read any entry with \`crtr canvas read ${A}/<name>\`.
|
|
12
12
|
|
|
13
|
-
`+
|
|
14
|
-
`)
|
|
15
|
-
`)}u(Ae,"renderDepsSummary");const Te=me({name:"deps",description:"vendor Agent Skill bundles shipped inside npm dependencies as derived crouter memory docs",whenToUse:"vendoring Agent Skill bundles shipped inside a project's installed npm dependencies (node_modules/<pkg>/skills/**/SKILL.md) into that project's own .crouter/memory/deps/ as derived, regenerated-per-run memory docs, so agents get first-party dependency guidance without touching node_modules directly.",help:{name:"sys sync deps",summary:"vendor npm-dependency Agent Skill bundles into <project>/.crouter/memory/deps/ (wholly derived, regenerated every run)",params:[{kind:"flag",name:"source",type:"string",required:!1,constraint:"The project directory whose dependencies to vendor. Default: the nearest ancestor of cwd with a package.json. node_modules must already be installed there, and its repository-root `.crouter/memory/INDEX.md` must declare a `namespace:`."},{kind:"flag",name:"dry-run",type:"bool",required:!1,constraint:"Report what would be vendored without writing anything."}],output:[{name:"results",type:"object[]",required:!0,constraint:"Each: {source,target,name,scope,status,reason?}; status is one of imported, would-import, skipped, excluded. `name` is the full canonical name the vendored doc answers at (`<namespace>/deps/<bundle>`), except on an excluded row, which names the `<package>@<version>:<skill>` selector. An excluded row is a dependency bundle rejected before its files enter the vendoring planner."}],outputKind:"object",effects:["Wipes and regenerates <project>/.crouter/memory/deps/ from installed dependency skills, except bundles selected by exact {package,version,skill} entries in package.json crtr.sync.deps.exclude. Each included SKILL.md becomes a system-name/file-none deps/<bundle>/INDEX.md answering at <namespace>/deps/<bundle> (relative sidecar links keep resolving), Markdown sidecar docs are vendored alongside at the same rungs, other sidecar assets are copied verbatim, and a system-preview/file-none deps/INDEX.md catalog answering at <namespace>/deps plus a self-ignoring .gitignore are written. Excluded bundles and their sidecars do not enter the catalog.","Refuses a project store whose repository root declares no namespace, naming `crtr sys migrate --dir <repositoryRoot>` as the remedy; it never declares one itself.","With --dry-run: read-only; writes nothing."]},run:u(async s=>{const n=s.source,o=s.dryRun??!1;return{results:De({sourceArg:n,dryRun:o})}},"run"),render:u(s=>Ae(s.results),"render")});export{T as DEPS_GENERATED_MARKER,De as runDepsSync,Te as sysSyncDepsLeaf};
|
|
13
|
+
`+ie};try{const e=await se(s,t,ae,T);u.push({source:r,name:e.name,status:e.changed?"imported":"unchanged",reason:O})}catch(e){u.push({source:r,name:A,status:"skipped",reason:te(e)})}return u}p(Re,"runDepsSync");function Se(s,n){return{name:`deps/${s}`,kind:"knowledge",preview:he(n.description,"knowledge"),summary:n.description!==""?de(n.description):`Vendored agent doc shipped by ${n.pkg}@${n.version}.`,rules:[{on:"boot",deliver:"name"}],body:n.body}}p(Se,"skillDoc");function Ae(s,n,o,r){let t;try{t=Q(I(n.sourceAbs)).body}catch{t=I(n.sourceAbs)}const i=o.find(k=>s.startsWith(`${k}/`)),m=i?`${r}/deps/${i}`:`a ${r}/deps document`;return{name:`deps/${s}`,kind:"knowledge",preview:`When ${m} links to this file, read this because it carries the linked supporting reference.`,summary:je(t)??`Supporting reference vendored from ${n.pkg}@${n.version}.`,rules:[{on:"boot",deliver:"name"}],body:t}}p(Ae,"sidecarDoc");function De(s){const n=p(i=>s.filter(m=>m.status===i).length,"count"),o=n("would-import")>0?`crtr sys sync deps \u2014 dry run: ${n("would-import")} would import, ${n("would-delete")} would delete, ${n("skipped")} skipped, ${n("excluded")} excluded`:`crtr sys sync deps \u2014 ${n("imported")} imported, ${n("unchanged")} unchanged, ${n("deleted")} deleted, ${n("skipped")} skipped, ${n("excluded")} excluded`,r=s.map(i=>{const m=i.reason?` (${i.reason})`:"";return`| ${i.status} | ${i.name||"\u2014"} | ${i.source}${m} |`}),t=r.length===0?["No sync candidates."]:["| status | document | source |","| --- | --- | --- |",...r];return[o,"",...t].join(`
|
|
14
|
+
`)}p(De,"renderDepsSummary");const Me=pe({name:"deps",description:"vendor Agent Skill bundles shipped inside npm dependencies as documents owned by the project's repo",whenToUse:"vendoring Agent Skill bundles shipped inside a project's installed npm dependencies (node_modules/<pkg>/skills/**/SKILL.md) as documents owned by that project's repo, named under `deps/` and rewritten on every run, so agents get first-party dependency guidance without touching node_modules directly.",help:{name:"sys sync deps",summary:"vendor npm-dependency Agent Skill bundles as the repo's `deps/\u2026` documents (rewritten every run)",params:[{kind:"flag",name:"source",type:"string",required:!1,constraint:"The project directory whose dependencies to vendor. Default: the nearest ancestor of cwd with a package.json. node_modules must already be installed there, and the directory must be inside a repo."},{kind:"flag",name:"dry-run",type:"bool",required:!1,constraint:"Report what would be vendored without writing anything."}],output:[{name:"results",type:"object[]",required:!0,constraint:"Each: {source,name,status,reason?}; status is one of imported, unchanged, would-import, deleted, would-delete, skipped, excluded. `name` is the document's full name (`<repo>/deps/<bundle>`), except on an excluded row, which names the `<package>@<version>:<skill>` selector. An excluded row is a dependency bundle rejected before its files are planned."}],outputKind:"object",effects:["Writes the repo's documents from installed dependency skills, except bundles selected by exact {package,version,skill} entries in package.json crtr.sync.deps.exclude: each included SKILL.md becomes `<repo>/deps/<bundle>` and each Markdown sidecar `<repo>/deps/<bundle>/<path>`, both with a boot rule at name; the `<repo>/deps` catalog carries a boot rule at preview. Other sidecar files are not vendored. Repo documents sync to everyone working in the repo.","Deletes `<repo>/deps/\u2026` documents no installed dependency ships any more.",`Refuses when \`<repo>/deps/\u2026\` documents exist and \`<repo>/deps\` does not carry the "${L}" marker.`,"With --dry-run: read-only; writes nothing."]},run:p(async s=>{const n=s.source,o=s.dryRun??!1;return{results:await Re(ue(),{sourceArg:n,dryRun:o})}},"run"),render:p(s=>De(s.results),"render")});export{L as DEPS_GENERATED_MARKER,Re as runDepsSync,Me as sysSyncDepsLeaf};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)){const
|
|
3
|
-
`)
|
|
4
|
-
`)
|
|
1
|
+
var N=Object.defineProperty;var c=(r,t)=>N(r,"name",{value:t,configurable:!0});import{envProfileId as x}from"../../shared/env.js";import{existsSync as y,readdirSync as T,statSync as v}from"node:fs";import{basename as L,join as g,relative as F,resolve as f}from"node:path";import{defineLeaf as W}from"../../core/command.js";import{parseFrontmatterGeneric as $}from"../../core/frontmatter.js";import{readText as D,realpathOrSelf as S,walkFiles as G}from"../../core/fs-utils.js";import{identifyCheckout as M}from"../../core/graph/repo-sync/identity.js";import{loadProfileManifest as O}from"../../core/profiles/manifest.js";import{CRTR_DIR_NAME as P}from"../../types.js";import{cliClient as _}from"../api-client.js";import{normalizedName as j,putDoc as U,repoOwner as I,routeFromDescription as q,rulesFromLegacyFrontmatter as z,scalarString as w,writeFailure as J}from"./sync-shared.js";const K=new Set(["node_modules",".git",".venv","venv","dist","build",".next",".cache",".yalc",".sisyphus",P]),B=["AGENTS.md","CLAUDE.md"];function H(r){if(r!==void 0)return[f(r)];const t=[f(process.cwd())],e=x();if(e!==void 0&&e!=="")try{const{manifest:s}=O(e);for(const o of s.projects){const n=f(o.path);t.includes(n)||t.push(n)}}catch{}return t}c(H,"projectDocRoots");function Q(r){const t=[];if(!y(r)||!v(r).isDirectory())return t;const e=f(r),s=[e];for(;s.length>0;){const o=s.pop();for(const a of B){const d=g(o,a);if(y(d)&&v(d).isFile()){t.push({kind:"agents",path:d,sourceDir:o,walkRoot:e});break}}const n=g(o,".claude","rules");if(y(n))for(const a of G(n,d=>d.endsWith(".md")))t.push({kind:"rule",path:a,sourceDir:o,walkRoot:e});let i;try{i=T(o,{withFileTypes:!0})}catch{continue}for(const a of i)a.isDirectory()&&!K.has(a.name)&&s.push(g(o,a.name))}return t}c(Q,"collectProjectDocCandidates");function me(r){for(const t of r.split(`
|
|
2
|
+
`)){const e=t.replace(/^#+\s*/,"").replace(/\s+/g," ").trim();if(e!=="")return e.length>200?`${e.slice(0,197)}...`:e}return"Migrated project guidance."}c(me,"synthesizeShortForm");function E(r){const t=[];let e=0,s="";for(const o of r){if(o==="{"?e+=1:o==="}"&&(e=Math.max(0,e-1)),o===","&&e===0){t.push(s),s="";continue}s+=o}return t.push(s),t.map(o=>o.trim()).filter(o=>o!=="")}c(E,"splitTopLevelCommas");function V(r){return typeof r=="string"?E(r):Array.isArray(r)?r.filter(t=>typeof t=="string").flatMap(E):[]}c(V,"normalizeRulePaths");function R(r,t){let e=r.trim();return e.includes("/")&&!e.startsWith("/")&&!e.startsWith("**")&&!e.startsWith("./")&&(e=`./${e}`),!e.startsWith("./")||t===""?e:`./${t}/${e.slice(2)}`}c(R,"anchorReadGlob");function k(r){for(const t of r.split(`
|
|
3
|
+
`)){const e=t.replace(/^#+\s*/,"").replace(/\s+/g," ").trim();if(e!=="")return e.length>200?`${e.slice(0,197)}...`:e}return"Migrated project guidance."}c(k,"firstNonEmptyLine");function C(r,t){return j(F(S(r.cwd),S(t)))}c(C,"folderName");function X(r,t){const e=$(D(r.path)),s=e.data??{},o=C(t,r.sourceDir);if(o==="")return{candidate:r,owner:t,doc:{name:"index",kind:"knowledge",preview:`When working in ${t.handle}, read this because it is the project's operating guide.`,summary:k(e.body),rules:[{on:"workspace-open",deliver:"content"},{on:"file-read",match:["./**"],deliver:"content"}],body:e.body}};const n=z(s).filter(a=>a.on==="file-read"),i=w(s["when-and-why-to-read"])?.trim();return{candidate:r,owner:t,doc:{name:o,kind:"knowledge",preview:i!==void 0&&i!==""?i:`When working under ${o} in ${t.handle}, read this because it carries that folder's guidance.`,summary:k(e.body),rules:n.length>0?n.map(a=>a.match?{...a,match:a.match.map(d=>R(d,o))}:a):[{on:"file-read",match:[`./${o}/**`],deliver:"content"}],body:e.body}}}c(X,"prepareAgents");function Y(r,t){const e=$(D(r.path)),s=e.data??{},o=C(t,r.sourceDir),n=w(s.name),i=j(n!==void 0&&n.trim()!==""?n:L(r.path)),a=o===""?i:`${o}/${i}`,d=w(s.description)??"",p=V(s.paths).map(l=>R(l,o)),u={on:"file-read",match:p.length>0?p:[o===""?"./**":`./${o}/**`],deliver:"content"};return{candidate:r,owner:t,doc:{name:a,kind:"knowledge",preview:d!==""?q(d,"knowledge"):`When working under ${o===""?t.handle:`${o} in ${t.handle}`}, read this because it is migrated project rule guidance.`,summary:d!==""?d.replace(/\s+/g," ").trim():k(e.body),rules:[u],body:e.body}}}c(Y,"prepareRule");async function Z(r,t,e){const{owner:s,doc:o}=t,n={source:t.candidate.path,name:`${s.handle}/${o.name}`};if(s.existing.has(o.name)&&!e.overwrite)return{...n,status:"skipped",reason:"a document with this name already exists; re-run with --overwrite to replace it"};if(e.dryRun)return{...n,status:"would-import"};try{const i=await U(r,s,o,"migrated by crtr sys sync project-guidance");return{...n,name:i.name,status:i.changed?"imported":"unchanged"}}catch(i){return{...n,status:"skipped",reason:J(i)}}}c(Z,"convertProjectDoc");function ee(r){const t=c(n=>r.filter(i=>i.status===n).length,"count"),e=t("would-import")>0?`crtr sys sync project-guidance \u2014 dry run: ${t("would-import")} would import, ${t("skipped")} skipped`:`crtr sys sync project-guidance \u2014 ${t("imported")} imported, ${t("unchanged")} unchanged, ${t("skipped")} skipped`,s=r.map(n=>{const i=n.reason?` (${n.reason})`:"";return`| ${n.status} | ${n.name||"\u2014"} | ${n.source}${i} |`}),o=s.length===0?["No sync candidates."]:["| status | document | source |","| --- | --- | --- |",...s];return[e,"",...o].join(`
|
|
4
|
+
`)}c(ee,"renderSummary");const fe=W({name:"project-guidance",description:"migrate repository guidance into documents owned by the repo",whenToUse:"migrating a repository's CLAUDE.md/AGENTS.md/.claude/rules into documents owned by that repo: one-way copy. Only the repository-root guide becomes the workspace front door (`<repo>/index`); nested guides and rules load when files under their folder are read. Never exports documents back to these source files.",help:{name:"sys sync project-guidance",summary:"one-way migration: CLAUDE.md/AGENTS.md/.claude/rules \u2192 documents owned by the repo",params:[{kind:"flag",name:"source",type:"string",required:!1,constraint:"The root to walk recursively for CLAUDE.md/AGENTS.md/.claude/rules files. Default: cwd plus every project in the current profile's purview (when one is selected)."},{kind:"flag",name:"dry-run",type:"bool",required:!1,constraint:"Show what would be migrated without writing documents."},{kind:"flag",name:"overwrite",type:"bool",required:!1,constraint:"Replace the body and fields of an existing document of the same name (a new revision). Default: skip it."}],output:[{name:"results",type:"object[]",required:!0,constraint:"Each: {source,name,status,reason?}; status is one of imported, unchanged, skipped, would-import. `name` is the document's full name."}],outputKind:"object",effects:["Copies the repository-root CLAUDE.md/AGENTS.md into `<repo>/index` with a workspace-open rule and a file-read rule over the whole repo, both at content. Copies a nested guide into `<repo>/<folder>` with a file-read rule over that folder. Copies each .claude/rules/*.md into `<repo>/<folder>/<rule name>` with a file-read rule over its `paths` (placed under the folder when relative), or over the folder when it declares none. Originals are left untouched; a source outside any repo is skipped. Repo documents sync to everyone working in the repo.","Skips existing documents unless --overwrite is present.","With --dry-run: read-only; writes nothing."]},run:c(async r=>{const t=r.source,e=r.dryRun??!1,s=r.overwrite??!1,o=_(),n=[],i=new Set,a=new Map,d=[];for(const p of H(t))for(const u of Q(p)){if(i.has(u.path))continue;i.add(u.path);const l=M(u.sourceDir);if(!l.ok){n.push({source:u.path,name:"",status:"skipped",reason:`not inside a repo: ${l.reason}`});continue}let m=a.get(l.root);m===void 0&&(m=I(o,l.root),a.set(l.root,m));const b=await m;try{d.push(u.kind==="agents"?X(u,b):Y(u,b))}catch(h){const A=(h instanceof Error?h.message:String(h)).split(`
|
|
5
|
+
`)[0];n.push({source:u.path,name:"",status:"skipped",reason:`unparseable source frontmatter: ${A} \u2014 fix the source file and re-run`})}}for(const p of d)n.push(await Z(o,p,{dryRun:e,overwrite:s}));return{results:n}},"run"),render:c(r=>ee(r.results),"render")});export{fe as sysSyncProjectGuidanceLeaf};
|
|
@@ -1,7 +1,44 @@
|
|
|
1
|
+
import { type CrtrClient } from '../../api/index.js';
|
|
2
|
+
import type { DeliveryRuleDTO, DocKindName } from '../../api/dto/docs.js';
|
|
3
|
+
import type { PrivacyName } from '../../api/dto/objects.js';
|
|
1
4
|
export declare function scalarString(value: unknown): string | undefined;
|
|
2
5
|
export declare function routeFromDescription(description: string, kind: string): string;
|
|
3
|
-
/** Slugify a raw name/path
|
|
4
|
-
*
|
|
5
|
-
* `[a-z0-9._-]`. Shared by the skills lane (bundle names) and the
|
|
6
|
-
* project-guidance lane (project/subdir labels). */
|
|
6
|
+
/** Slugify a raw name/path into a document name: lowercase, `.md` stripped,
|
|
7
|
+
* path separators normalized to `/`, each segment reduced to `[a-z0-9_-]`. */
|
|
7
8
|
export declare function normalizedName(raw: string): string;
|
|
9
|
+
/** A document a sync lane converts, in `/v1/docs` terms. */
|
|
10
|
+
export interface SyncDoc {
|
|
11
|
+
name: string;
|
|
12
|
+
body: string;
|
|
13
|
+
preview: string;
|
|
14
|
+
summary?: string;
|
|
15
|
+
kind: DocKindName;
|
|
16
|
+
privacy?: PrivacyName;
|
|
17
|
+
rules: DeliveryRuleDTO[];
|
|
18
|
+
}
|
|
19
|
+
/** Legacy `surfaces`/`gate`/`slash` frontmatter as `/v1/docs` rules. */
|
|
20
|
+
export declare function rulesFromLegacyFrontmatter(fm: Record<string, unknown>): DeliveryRuleDTO[];
|
|
21
|
+
/** Where a lane's documents go: the repo enclosing `cwd`, or the person. */
|
|
22
|
+
export interface SyncOwner {
|
|
23
|
+
owner: 'repo' | 'user';
|
|
24
|
+
/** Sent with every write so `--owner repo` resolves this repo. */
|
|
25
|
+
cwd: string;
|
|
26
|
+
/** The owner's handle; for an owner not yet on the canvas, the handle it is expected to get. */
|
|
27
|
+
handle: string;
|
|
28
|
+
/** Local names of the owner's existing documents. */
|
|
29
|
+
existing: Set<string>;
|
|
30
|
+
}
|
|
31
|
+
/** The repo enclosing `dir`. Throws when `dir` is in no repo. */
|
|
32
|
+
export declare function repoOwner(client: CrtrClient, dir: string): Promise<SyncOwner>;
|
|
33
|
+
/** The person on this runtime. */
|
|
34
|
+
export declare function userOwner(client: CrtrClient): Promise<SyncOwner>;
|
|
35
|
+
/** Write `doc` as a new document, or replace an existing one's body and fields
|
|
36
|
+
* (read first, as every edit requires). Answers the document's full name and
|
|
37
|
+
* whether anything changed. The first write under an owner that was not yet
|
|
38
|
+
* on the canvas corrects `owner.handle` from the name the daemon answers. */
|
|
39
|
+
export declare function putDoc(client: CrtrClient, owner: SyncOwner, doc: SyncDoc, rationale: string): Promise<{
|
|
40
|
+
name: string;
|
|
41
|
+
changed: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
/** One line for a failed write, for a lane's `skipped` row. */
|
|
44
|
+
export declare function writeFailure(err: unknown): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var s=(n,e)=>l(n,"name",{value:e,configurable:!0});import{ApiError as f}from"../../api/index.js";import{identifyCheckout as h}from"../../core/graph/repo-sync/identity.js";import{rulesFromFrontmatter as p}from"../../core/graph/rules.js";import{usage as w}from"../../core/errors.js";function _(n){if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n)}s(_,"scalarString");function c(n){let e=n.replace(/\s+/g," ").trim();return e=e.replace(/^[,;:.\s]+/,"").replace(/[,;:.\s]+$/,""),/^[A-Z][a-z]/.test(e)&&(e=e.charAt(0).toLowerCase()+e.slice(1)),e}s(c,"cleanClause");const g=/\b(?:use\s+this\s+skill\s+when|use\s+this\s+when|this\s+skill\s+should\s+be\s+used\s+when|used\s+when|use\s+when)\b\s*/i;function S(n,e){const t=n.replace(/\s+/g," ").trim();if(t==="")return`When this migrated ${e} applies, this ${e} should be read.`;const r=t.match(g);if(r&&r.index!==void 0){const a=c(t.slice(0,r.index)),o=c(t.slice(r.index+r[0].length));if(o!==""){let i=`When ${o}, this ${e} should be read`;return a!==""&&(i+=` because ${a}`),`${i}.`}}return`When ${c(t)}, this ${e} should be read.`}s(S,"routeFromDescription");function v(n){return n.replace(/\\/g,"/").replace(/\.md$/i,"").split("/").map(t=>t.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")).filter(Boolean).join("/")}s(v,"normalizedName");function C(n){return p(n).map(e=>({on:e.on,deliver:e.deliver,...e.match!==void 0?{match:e.match}:{},...e.matchFrontmatter!==void 0?{match_frontmatter:e.matchFrontmatter}:{},...e.if!==void 0?{if:e.if}:{}}))}s(C,"rulesFromLegacyFrontmatter");async function m(n,e,t){let r;do{const a=await n.objects.list({type:e,limit:100,...r?{cursor:r}:{}});for(const o of a.items){const i=await n.objects.read(o.id);if(i.state==="object"&&"identity"in i&&i.identity.external_id===t)return i.handle}r=a.next_cursor??void 0}while(r);return null}s(m,"ownerByIdentity");async function d(n,e){const t=new Set;let r;do{const a=await n.objects.list({type:"document",owner:e,limit:100,...r?{cursor:r}:{}});for(const o of a.items)t.add(o.name);r=a.next_cursor??void 0}while(r);return t}s(d,"documentNames");async function E(n,e){const t=h(e);if(!t.ok)throw w(`${e} is not inside a repo: ${t.reason}`);const r=await m(n,"repo",t.externalId);return{owner:"repo",cwd:t.root,handle:r??t.handleHint,existing:r?await d(n,r):new Set}}s(E,"repoOwner");async function W(n){const e=await m(n,"person","user:local");return{owner:"user",cwd:process.cwd(),handle:e??"user",existing:e?await d(n,e):new Set}}s(W,"userOwner");async function k(n,e,t,r){const a={preview:t.preview,...t.summary!==void 0&&t.summary!==""?{summary:t.summary}:{},...t.privacy!==void 0?{privacy:t.privacy}:{},rules:t.rules};if(!e.existing.has(t.name)){const u=await n.docs.write({name:t.name,body:t.body,kind:t.kind,owner:e.owner,cwd:e.cwd,...a});return e.handle=u.name.slice(0,u.name.length-t.name.length-1),e.existing.add(t.name),{name:u.name,changed:!0}}const o=`${e.handle}/${t.name}`,i=await n.objects.read(o);return i.state==="object"&&i.type==="document"&&i.bodies.length===1&&i.bodies[0]===t.body&&i.object.preview===t.preview?{name:o,changed:!1}:{name:(await n.docs.edit(o,{body:t.body,rationale:r,...a})).name,changed:!0}}s(k,"putDoc");function z(n){if(n instanceof f)return n.message;throw n}s(z,"writeFailure");export{v as normalizedName,k as putDoc,E as repoOwner,S as routeFromDescription,C as rulesFromLegacyFrontmatter,_ as scalarString,W as userOwner,z as writeFailure};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}
|
|
1
|
+
var _=Object.defineProperty;var i=(e,o)=>_(e,"name",{value:o,configurable:!0});import{existsSync as j}from"node:fs";import{homedir as C}from"node:os";import{basename as R,dirname as k,join as f,relative as E,resolve as h,sep as N}from"node:path";import{defineLeaf as O}from"../../core/command.js";import{usage as L}from"../../core/errors.js";import{parseFrontmatterGeneric as q}from"../../core/frontmatter.js";import{readJsonIfExists as P,readText as D,walkFiles as M,writeJson as T}from"../../core/fs-utils.js";import{identifyCheckout as J}from"../../core/graph/repo-sync/identity.js";import{runtimeRoot as W}from"../../core/layout.js";import{piAgentDir as G}from"../../core/runtime/package-health.js";import{CRTR_DIR_NAME as H}from"../../types.js";import{cliClient as U}from"../api-client.js";import{normalizedName as x,putDoc as z,repoOwner as B,routeFromDescription as V,rulesFromLegacyFrontmatter as X,scalarString as S,userOwner as Y,writeFailure as Q}from"./sync-shared.js";const Z="<!-- crtr-boot-skill v",$="SKILL.md",y="skill-import-ignore.json",ee=new Set(["node_modules",".git",".venv","venv","dist","build",".next",".cache",".yalc",".sisyphus",H]);function oe(){const e=J(process.cwd());return e.ok?e.root:null}i(oe,"projectDir");function w(){return f(W(),y)}i(w,"ignoreFilePath");function te(){const e=[{label:"claude-user",root:f(C(),".claude","skills"),defaultScope:"user"},{label:"pi-user",root:f(G(),"skills"),defaultScope:"user"}],o=oe();return o&&(e.push({label:"claude-project",root:f(o,".claude","skills"),defaultScope:"project"}),e.push({label:"pi-project",root:f(o,".pi","agent","skills"),defaultScope:"project"})),e}i(te,"defaultSourceRoots");function re(e,o){if(e===void 0)return te();const r=h(e);if(o!==void 0&&o!=="user"&&o!=="project")throw L(`invalid --scope: ${o} (expected user|project)`);return[{label:"source",root:r,defaultScope:o??"user"}]}i(re,"sourceRootsFromArg");function ne(e){const o=e.root;if(!j(o))return[];const r=h(o),t=[];if(R(r)===$)return t.push({path:r,root:k(r),source:e.label,defaultScope:e.defaultScope}),t;const n=f(r,$);if(j(n))return t.push({path:n,root:k(r),source:e.label,defaultScope:e.defaultScope}),t;for(const a of M(r,c=>c===$,c=>ee.has(c)))t.push({path:a,root:r,source:e.label,defaultScope:e.defaultScope});return t}i(ne,"collectCandidates");function se(e,o){const r=S(o?.name);if(r&&r.trim()!=="")return x(r);const t=E(e.root,k(e.path)).split(N).join("/");return x(t||R(k(e.path)))}i(se,"nameForCandidate");function ie(e){const o=new Map;return r=>{let t=o.get(r);return t===void 0&&(t=r==="user"?Y(e):B(e,process.cwd()),o.set(r,t)),t}}i(ie,"ownerResolver");function ce(){let e;try{e=P(w())}catch(r){throw L(`invalid JSON in ${w()}: ${r instanceof Error?r.message:String(r)}`)}if(e===null)return{version:1,ignored:[]};if(typeof e!="object"||e===null||e.version!==1||!Array.isArray(e.ignored))throw L(`malformed ${w()}: expected {"version":1,"ignored":[...]}`);const o=[];for(const r of e.ignored){if(typeof r!="object"||r===null)continue;const t=r;typeof t.source=="string"&&typeof t.name=="string"&&(t.scope==="user"||t.scope==="project")&&typeof t.ignoredAt=="string"&&o.push({source:h(t.source),name:t.name,scope:t.scope,ignoredAt:t.ignoredAt})}return{version:1,ignored:o}}i(ce,"readIgnoreState");function ae(e){T(w(),e)}i(ae,"writeIgnoreState");function F(e,o){const r=h(e.candidate.path);return o.ignored.some(t=>t.source===r||t.scope===e.scope&&t.name===e.name)}i(F,"isIgnored");function ue(e,o){return F(e,o)?!1:(o.ignored.push({source:h(e.candidate.path),name:e.name,scope:e.scope,ignoredAt:new Date().toISOString()}),o.ignored.sort((r,t)=>`${r.scope}/${r.name}`.localeCompare(`${t.scope}/${t.name}`)),!0)}i(ue,"rememberIgnored");function K(e,o,r){return{source:e.path,name:"",scope:o,status:"skipped",reason:r}}i(K,"skipResult");async function de(e,o,r){const t=D(e.path),n=r??e.defaultScope;if(t.includes(Z))return K(e,n,"legacy generated crtr boot skill is pruned by host exports, not imported");const a=q(t),c=a.data??{},u=c.kind==="preference"?"preference":"knowledge",d=se(e,c);if(d==="")return K(e,n,"could not derive a document name");const p=await o(n);return{candidate:e,raw:t,parsed:a,sourceFm:c,kind:u,localName:d,name:`${p.handle}/${d}`,scope:n,owner:p}}i(de,"prepareCandidate");const le=["public","friends","private"];async function pe(e,o,r){const t={source:o.candidate.path,name:o.name,scope:o.scope};if(o.owner.existing.has(o.localName)&&!r.overwrite)return{...t,status:"skipped",reason:"a document with this name already exists; re-run with --overwrite to replace it"};if(r.dryRun)return{...t,status:"would-import"};const n=o.sourceFm,a=S(n.description)??"",c=S(n["when-and-why-to-read"])?.trim(),u=S(n["short-form"])?.trim(),d=X(n),p=le.find(m=>m===n.privacy),s={name:o.localName,kind:o.kind,preview:(c!==void 0&&c!==""?c:V(a,o.kind)).replace(/\s+/g," "),summary:u!==void 0&&u!==""?u:a.replace(/\s+/g," ").trim(),...p!==void 0?{privacy:p}:{},rules:Array.isArray(n.surfaces)?d:[{on:"boot",deliver:"preview"}],body:o.parsed.body};try{const m=await z(e,o.owner,s,"imported by crtr sys sync skills");return{...t,name:m.name,status:m.changed?"imported":"unchanged"}}catch(m){return{...t,status:"skipped",reason:Q(m)}}}i(pe,"convertPrepared");function A(e,o,r){return{source:e.candidate.path,name:e.name,scope:e.scope,status:r?"would-ignore":"ignored",reason:o}}i(A,"ignoreResult");function me(e,o){const r=e.filter(s=>s.status==="imported").length,t=e.filter(s=>s.status==="would-import").length,n=e.filter(s=>s.status==="skipped").length,a=e.filter(s=>s.status==="ignored").length,c=e.filter(s=>s.status==="would-ignore").length;let u;o?u=`crtr sys sync skills \u2014 ${c>0?`${c} would ignore`:`${a} ignored`}, ${n} skipped`:t>0?u=`crtr sys sync skills \u2014 dry run: ${t} would import, ${n} skipped, ${a} ignored`:u=`crtr sys sync skills \u2014 ${r} imported, ${n} skipped, ${a} ignored`;const d=e.map(s=>{const m=s.reason?` (${s.reason})`:"";return`| ${s.status} | ${s.name||"\u2014"} | ${s.source}${m} |`}),p=d.length===0?["No sync candidates."]:["| status | document | source |","| --- | --- | --- |",...d];return[u,"",...p].join(`
|
|
2
|
+
`)}i(me,"renderSummary");const xe=O({name:"skills",description:"import host Agent Skill (SKILL.md) bundles as documents",whenToUse:"migrating legacy host-native Agent Skill bundles (SKILL.md \u2014 Claude/pi user or project skill roots, or an explicit bundle/root via --source) into documents. One-way: crouter never re-exports documents back to SKILL.md, and stops reading the originals unconditionally once migrated.",help:{name:"sys sync skills",summary:"one-way import: host SKILL.md bundles \u2192 documents owned by you or the repo",params:[{kind:"flag",name:"source",type:"string",required:!1,constraint:"A SKILL.md file, a single skill bundle dir containing SKILL.md, or a skills root to scan recursively. Default: the user/project Claude and pi skill roots that exist."},{kind:"flag",name:"scope",type:"enum",choices:["user","project"],required:!1,constraint:"Owner of the imported documents. `user` \u2014 you, the person; `project` \u2014 the repo of the working directory (a repo owns only public documents). Default: user for user host roots and project for project host roots; an explicit value applies to every selected source."},{kind:"flag",name:"dry-run",type:"bool",required:!1,constraint:"Show what would be imported without writing documents."},{kind:"flag",name:"overwrite",type:"bool",required:!1,constraint:"Replace the body and fields of an existing document of the same name (a new revision). Default: skip it."},{kind:"flag",name:"ignore",type:"bool",required:!1,constraint:`Permanently ignore every selected SKILL.md source by recording it in ~/.crouter/${y}. Honors --source/--scope; with no --source, ignores every currently discovered default host skill candidate.`},{kind:"flag",name:"include-ignored",type:"bool",required:!1,constraint:"Include ignored candidates in the report without making sync read-only. Pair with --dry-run to audit the full candidate set without importing non-ignored skills."}],output:[{name:"results",type:"object[]",required:!0,constraint:"Each: {source,target,name,scope,status,reason?}; status is one of imported, unchanged, skipped, would-import, ignored, would-ignore. `name` is the document's full name, `<owner handle>/<bundle name>`."}],outputKind:"object",effects:["Writes the document `<owner handle>/<bundle name>` with the SKILL.md body; its preview comes from the skill description, and it carries a boot rule at preview unless the source declares its own `surfaces`.","Skips existing documents unless --overwrite is present.","Skips marker-bearing generated crtr boot skills; host exports prune those legacy artifacts instead.",`With --ignore: writes ~/.crouter/${y} and does not import the selected sources.`,"With --dry-run: read-only; writes nothing."]},run:i(async e=>{const o=e.source,r=e.scope,t=e.dryRun??!1,n=e.overwrite??!1,a=e.ignore??!1,c=e.includeIgnored??!1,u=re(o,r),d=new Set,p=[];for(const I of u)for(const l of ne(I))d.has(l.path)||(d.add(l.path),p.push(l));const s=U(),m=ie(s),b=ce(),g=[];let v=!1;for(const I of p){const l=await de(I,m,r);if("status"in l){g.push(l);continue}if(a){t||(v=ue(l,b)||v),g.push(A(l,t?"would record permanent ignore":`recorded in ~/.crouter/${y}`,t));continue}if(F(l,b)){c&&g.push(A(l,`matched ~/.crouter/${y}`,!1));continue}g.push(await pe(s,l,{dryRun:t,overwrite:n}))}return v&&ae(b),{results:g,ignoreFile:w(),ignoreMode:a}},"run"),render:i(e=>me(e.results,e.ignoreMode===!0),"render")});export{xe as sysSyncSkillsLeaf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineBranch as e}from"../../core/command.js";import{sysSyncSkillsLeaf as
|
|
1
|
+
import{defineBranch as e}from"../../core/command.js";import{sysSyncSkillsLeaf as n}from"./sync-skills.js";import{sysSyncProjectGuidanceLeaf as o}from"./sync-project-guidance.js";import{sysSyncDepsLeaf as s}from"./sync-deps.js";const c=e({name:"sync",description:"migrate non-crouter guidance surfaces into documents",whenToUse:"importing or migrating an external guidance source \u2014 host Agent Skill bundles, project CLAUDE.md/AGENTS.md/.claude/rules, or npm-dependency-shipped Agent Skill bundles \u2014 into documents",help:{name:"sys sync",summary:"migrate external guidance sources into documents",model:"Three independent one-way conversion lanes, none of which ever export documents back to their source: skills imports host-native SKILL.md bundles as documents owned by you or by the working directory's repo; project-guidance migrates a repo's own CLAUDE.md/AGENTS.md/.claude/rules into documents owned by that repo; deps vendors Agent Skill bundles shipped inside installed npm dependencies as the repo's `deps/\u2026` documents, rewritten on every run."},children:[n,o,s]});export{c as sysSyncBranch};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const MAX_BACKGROUND_BASH_LOG_BYTES: number;
|
|
2
2
|
export declare const BACKGROUND_BASH_LOG_TRUNCATION_MARKER = "\n[background bash job output truncated at 10 MiB; remaining output discarded]\n";
|
|
3
|
-
/** File-backed command supervisor.
|
|
4
|
-
*
|
|
5
|
-
* remains the owner of delivery. $12 selects that direct Mac path. */
|
|
3
|
+
/** File-backed command supervisor. It writes the exit code to job.exit and, for a foreground
|
|
4
|
+
* command, claims job.done; the daemon reads job.exit of a backgrounded job and publishes `exited`. */
|
|
6
5
|
export declare const BASH_JOB_SUPERVISOR_SCRIPT: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const t=10485760,
|
|
1
|
+
const t=10485760,n=`
|
|
2
2
|
[background bash job output truncated at 10 MiB; remaining output discarded]
|
|
3
|
-
`,
|
|
4
|
-
`);export{
|
|
3
|
+
`,e=['const fs = require("node:fs");',"const cap = 10485760;",`const marker = Buffer.from(${JSON.stringify(n)});`,"const prefixCap = cap - marker.length;",'const fd = fs.openSync(process.argv[1], "w");',"let written = 0;","let truncated = false;",'process.stdin.on("data", (chunk) => {'," if (truncated) return;"," const available = prefixCap - written;"," if (available > 0) {"," const prefix = chunk.subarray(0, available);"," fs.writeSync(fd, prefix);"," written += prefix.length;"," if (prefix.length === chunk.length) return;"," }"," fs.writeSync(fd, marker);"," truncated = true;","});",'process.stdin.on("end", () => fs.closeSync(fd));'].join(" "),r=["n=$(command -v nice)",'${n:+"$n" -n "$7"} "$6" "$1" 2>&1 | "$8" -e '+JSON.stringify(e)+' "$2"','echo "${PIPESTATUS[0]}" > "$3"','mv "$4" "$5" 2>/dev/null || true'].join(`
|
|
4
|
+
`);export{n as BACKGROUND_BASH_LOG_TRUNCATION_MARKER,r as BASH_JOB_SUPERVISOR_SCRIPT,t as MAX_BACKGROUND_BASH_LOG_BYTES};
|
package/dist/core/bash-jobs.d.ts
CHANGED
|
@@ -152,11 +152,6 @@ export declare function activeBackgroundBashJobs(contextDir: string, includeFore
|
|
|
152
152
|
/** Every live background job for this node whose auto-cancel deadline has
|
|
153
153
|
* passed at `now`. The daemon's deadline lane stops exactly these. A job with
|
|
154
154
|
* no deadline (deliberate handoff, or one the node claimed) never appears. */
|
|
155
|
-
export declare function completedBackgroundBashJobs(contextDir: string): Array<{
|
|
156
|
-
jobId: string;
|
|
157
|
-
exitCode: number;
|
|
158
|
-
startedAtMs: number;
|
|
159
|
-
}>;
|
|
160
155
|
export declare function expiredAutoBackgroundBashJobs(contextDir: string, now: number): BashJobStatus[];
|
|
161
156
|
/** Credit every armed auto-cancel deadline for an interval the node was not
|
|
162
157
|
* permitted to run. A profile pause stops the owning node, so without this the
|