nx-kv 0.46.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +10 -4
- package/bin/kv.mjs +41 -0
- package/package.json +23 -11
- package/src/core/atomic-file.ts +46 -0
- package/src/core/attachmentdb/docs.ts +124 -0
- package/src/core/attachmentdb/ids.ts +112 -0
- package/src/core/attachmentdb/query.ts +230 -0
- package/src/core/attachmentdb/relations.ts +221 -0
- package/src/core/attachmentdb/resources.ts +260 -0
- package/src/core/attachstore.ts +360 -0
- package/src/core/command-table.ts +33 -0
- package/src/core/config.ts +212 -0
- package/src/core/db/bootstrap.ts +507 -0
- package/src/core/db/driver.ts +408 -0
- package/src/core/db/errors.ts +149 -0
- package/src/core/db/import-json/data.ts +193 -0
- package/src/core/db/import-json/extras.ts +77 -0
- package/src/core/db/import-json/links.ts +161 -0
- package/src/core/db/import-json/refs.ts +207 -0
- package/src/core/db/import-json/repos.ts +190 -0
- package/src/core/db/import-json/scan.ts +50 -0
- package/src/core/db/import-json/tasks.ts +366 -0
- package/src/core/db/import-json.ts +206 -0
- package/src/core/db/index.ts +147 -0
- package/src/core/db/migrations/index.ts +138 -0
- package/src/core/db/migrations/v2-data.ts +177 -0
- package/src/core/db/migrations/v4-data.ts +221 -0
- package/src/core/db/migrator.ts +233 -0
- package/src/core/db/quiet.ts +23 -0
- package/src/core/db/seed-templates.ts +266 -0
- package/src/core/db/settings.ts +61 -0
- package/src/core/db/time.ts +98 -0
- package/src/core/db/tx.ts +209 -0
- package/src/core/db/verify.ts +317 -0
- package/src/core/db/version.ts +72 -0
- package/src/core/errors.ts +105 -0
- package/src/core/fileapi.ts +267 -0
- package/src/core/frontmatter.ts +70 -0
- package/src/core/fstree.ts +87 -0
- package/src/core/instruction-template.ts +357 -0
- package/src/core/keys.ts +32 -0
- package/src/core/kvapi.ts +237 -0
- package/src/core/localatt.ts +179 -0
- package/src/core/open.ts +26 -0
- package/src/core/paths.ts +101 -0
- package/src/core/prompt.ts +60 -0
- package/src/core/serve-port.ts +165 -0
- package/src/core/topic-key.ts +43 -0
- package/src/core/workflow/edges.ts +28 -0
- package/src/core/workflow/layout.ts +118 -0
- package/src/core/workflow/lifecycle.ts +57 -0
- package/src/core/workflow/plugin-registry.ts +50 -0
- package/src/core/workflow/project.ts +108 -0
- package/src/core/workflow/readiness.ts +218 -0
- package/src/core/workflow/types.ts +175 -0
- package/src/core/zip.ts +178 -0
- package/src/index.js +11 -9
- package/src/index.ts +10 -0
- package/src/modules/auth/actions/_manifest.generated.ts +26 -0
- package/src/modules/auth/actions/auth-login.ts +24 -0
- package/src/modules/auth/actions/auth-logout.ts +28 -0
- package/src/modules/auth/actions/auth-me.ts +28 -0
- package/src/modules/auth/actions/auth-status.ts +36 -0
- package/src/modules/auth/index.ts +24 -0
- package/src/modules/auth/schemas.ts +27 -0
- package/src/modules/auth/support.ts +28 -0
- package/src/modules/bundled/actions/_manifest.generated.ts +26 -0
- package/src/modules/bundled/actions/bundled-get.ts +29 -0
- package/src/modules/bundled/actions/bundled-groups.ts +33 -0
- package/src/modules/bundled/actions/bundled-install.ts +43 -0
- package/src/modules/bundled/actions/bundled-list.ts +37 -0
- package/src/modules/bundled/index.ts +24 -0
- package/src/modules/bundled/schemas.ts +32 -0
- package/src/modules/bundled/service.ts +377 -0
- package/src/modules/bundled/support.ts +70 -0
- package/src/modules/db/actions/_manifest.generated.ts +26 -0
- package/src/modules/db/actions/db-backup.ts +24 -0
- package/src/modules/db/actions/db-migrate.ts +24 -0
- package/src/modules/db/actions/db-status.ts +24 -0
- package/src/modules/db/actions/db-verify.ts +24 -0
- package/src/modules/db/index.ts +24 -0
- package/src/modules/db/schemas.ts +27 -0
- package/src/modules/db/service.ts +340 -0
- package/src/modules/docs/actions/_manifest.generated.ts +56 -0
- package/src/modules/docs/actions/doc-add.ts +30 -0
- package/src/modules/docs/actions/doc-attach-note.ts +25 -0
- package/src/modules/docs/actions/doc-attach.ts +25 -0
- package/src/modules/docs/actions/doc-attachments.ts +27 -0
- package/src/modules/docs/actions/doc-detach.ts +25 -0
- package/src/modules/docs/actions/doc-get.ts +27 -0
- package/src/modules/docs/actions/doc-list.ts +26 -0
- package/src/modules/docs/actions/doc-remove.ts +25 -0
- package/src/modules/docs/actions/doc-update.ts +30 -0
- package/src/modules/docs/actions/docs-bind.ts +26 -0
- package/src/modules/docs/actions/docs-index.ts +24 -0
- package/src/modules/docs/actions/docs-link.ts +27 -0
- package/src/modules/docs/actions/docs-notebind.ts +27 -0
- package/src/modules/docs/actions/docs-seed.ts +26 -0
- package/src/modules/docs/attach.ts +299 -0
- package/src/modules/docs/brief.ts +142 -0
- package/src/modules/docs/docref.ts +109 -0
- package/src/modules/docs/index.ts +25 -0
- package/src/modules/docs/knowledge.ts +628 -0
- package/src/modules/docs/links.ts +45 -0
- package/src/modules/docs/paths.ts +104 -0
- package/src/modules/docs/refs.ts +275 -0
- package/src/modules/docs/render.ts +85 -0
- package/src/modules/docs/repos-bridge.ts +13 -0
- package/src/modules/docs/schemas.ts +107 -0
- package/src/modules/docs/seed.ts +160 -0
- package/src/modules/docs/service.ts +255 -0
- package/src/modules/docs/store.ts +262 -0
- package/src/modules/file/actions/_manifest.generated.ts +38 -0
- package/src/modules/file/actions/file-content.ts +28 -0
- package/src/modules/file/actions/file-get.ts +25 -0
- package/src/modules/file/actions/file-list.ts +24 -0
- package/src/modules/file/actions/file-orphans.ts +24 -0
- package/src/modules/file/actions/file-prune.ts +24 -0
- package/src/modules/file/actions/file-remove.ts +25 -0
- package/src/modules/file/actions/file-sync.ts +24 -0
- package/src/modules/file/actions/file-upload.ts +24 -0
- package/src/modules/file/index.ts +24 -0
- package/src/modules/file/schemas.ts +61 -0
- package/src/modules/file/service.ts +449 -0
- package/src/modules/localtask/action-render.ts +203 -0
- package/src/modules/localtask/actions/_manifest.generated.ts +113 -0
- package/src/modules/localtask/actions/localtask-add.ts +48 -0
- package/src/modules/localtask/actions/localtask-attach-note.ts +29 -0
- package/src/modules/localtask/actions/localtask-attach.ts +38 -0
- package/src/modules/localtask/actions/localtask-attachments.ts +25 -0
- package/src/modules/localtask/actions/localtask-cancel.ts +26 -0
- package/src/modules/localtask/actions/localtask-cancelMany.ts +34 -0
- package/src/modules/localtask/actions/localtask-chain.ts +26 -0
- package/src/modules/localtask/actions/localtask-claim.ts +34 -0
- package/src/modules/localtask/actions/localtask-clone.ts +25 -0
- package/src/modules/localtask/actions/localtask-closeMany.ts +41 -0
- package/src/modules/localtask/actions/localtask-config.ts +64 -0
- package/src/modules/localtask/actions/localtask-detach.ts +31 -0
- package/src/modules/localtask/actions/localtask-done.ts +36 -0
- package/src/modules/localtask/actions/localtask-events.ts +31 -0
- package/src/modules/localtask/actions/localtask-fork.ts +25 -0
- package/src/modules/localtask/actions/localtask-get.ts +33 -0
- package/src/modules/localtask/actions/localtask-importRemote.ts +40 -0
- package/src/modules/localtask/actions/localtask-list.ts +26 -0
- package/src/modules/localtask/actions/localtask-presence.ts +28 -0
- package/src/modules/localtask/actions/localtask-preview.ts +45 -0
- package/src/modules/localtask/actions/localtask-prune.ts +28 -0
- package/src/modules/localtask/actions/localtask-remove.ts +27 -0
- package/src/modules/localtask/actions/localtask-removeMany.ts +32 -0
- package/src/modules/localtask/actions/localtask-reopen.ts +39 -0
- package/src/modules/localtask/actions/localtask-reorder.ts +33 -0
- package/src/modules/localtask/actions/localtask-task-restore.ts +27 -0
- package/src/modules/localtask/actions/localtask-timegoalLog.ts +37 -0
- package/src/modules/localtask/actions/localtask-topic-add.ts +26 -0
- package/src/modules/localtask/actions/localtask-topic-remove.ts +25 -0
- package/src/modules/localtask/actions/localtask-topic-removeMany.ts +26 -0
- package/src/modules/localtask/actions/localtask-update.ts +60 -0
- package/src/modules/localtask/actions/localtask-wait.ts +32 -0
- package/src/modules/localtask/actions/task-move.ts +50 -0
- package/src/modules/localtask/board-target.ts +190 -0
- package/src/modules/localtask/bus/index.ts +44 -0
- package/src/modules/localtask/deletion.ts +169 -0
- package/src/modules/localtask/engine.ts +59 -0
- package/src/modules/localtask/events.ts +250 -0
- package/src/modules/localtask/index.ts +25 -0
- package/src/modules/localtask/move-prims.ts +170 -0
- package/src/modules/localtask/move.ts +174 -0
- package/src/modules/localtask/mutator/index.ts +184 -0
- package/src/modules/localtask/mutator/validate.ts +59 -0
- package/src/modules/localtask/panel-guard.ts +199 -0
- package/src/modules/localtask/panel-presence.ts +361 -0
- package/src/modules/localtask/paths.ts +101 -0
- package/src/modules/localtask/remote-import.ts +159 -0
- package/src/modules/localtask/repo/goals.ts +186 -0
- package/src/modules/localtask/repo/links.ts +172 -0
- package/src/modules/localtask/repo/open.ts +74 -0
- package/src/modules/localtask/repo/presence.ts +126 -0
- package/src/modules/localtask/repo/rows.ts +204 -0
- package/src/modules/localtask/repo/settings.ts +402 -0
- package/src/modules/localtask/repo/snapshot.ts +173 -0
- package/src/modules/localtask/repo/tasks.ts +394 -0
- package/src/modules/localtask/repo/topics.ts +336 -0
- package/src/modules/localtask/repo-ctx.ts +33 -0
- package/src/modules/localtask/scheduler/index.ts +68 -0
- package/src/modules/localtask/scheduler/state-drive.ts +38 -0
- package/src/modules/localtask/schemas.ts +310 -0
- package/src/modules/localtask/service.ts +62 -0
- package/src/modules/localtask/store/file-adapter.ts +55 -0
- package/src/modules/localtask/store/index.ts +111 -0
- package/src/modules/localtask/store/memory-adapter.ts +37 -0
- package/src/modules/localtask/store-io.ts +77 -0
- package/src/modules/localtask/task-lifecycle.ts +461 -0
- package/src/modules/localtask/task-ops.ts +494 -0
- package/src/modules/localtask/task-remove.ts +366 -0
- package/src/modules/localtask/task-templates.ts +84 -0
- package/src/modules/localtask/task-view.ts +474 -0
- package/src/modules/localtask/topics.ts +197 -0
- package/src/modules/localtask/waiters.ts +86 -0
- package/src/modules/localtask/waiting.ts +82 -0
- package/src/modules/localtask/writes.ts +153 -0
- package/src/modules/repos/actions/_manifest.generated.ts +146 -0
- package/src/modules/repos/actions/board-add.ts +25 -0
- package/src/modules/repos/actions/board-assign.ts +27 -0
- package/src/modules/repos/actions/board-export.ts +24 -0
- package/src/modules/repos/actions/board-get.ts +27 -0
- package/src/modules/repos/actions/board-import.ts +40 -0
- package/src/modules/repos/actions/board-list.ts +26 -0
- package/src/modules/repos/actions/board-note.ts +27 -0
- package/src/modules/repos/actions/board-prefix.ts +27 -0
- package/src/modules/repos/actions/board-prune.ts +29 -0
- package/src/modules/repos/actions/board-rekey.ts +28 -0
- package/src/modules/repos/actions/board-remove.ts +25 -0
- package/src/modules/repos/actions/board-update.ts +25 -0
- package/src/modules/repos/actions/repo-add.ts +29 -0
- package/src/modules/repos/actions/repo-bind-topics.ts +36 -0
- package/src/modules/repos/actions/repo-bind.ts +27 -0
- package/src/modules/repos/actions/repo-clone.ts +25 -0
- package/src/modules/repos/actions/repo-detect.ts +33 -0
- package/src/modules/repos/actions/repo-doc-add.ts +25 -0
- package/src/modules/repos/actions/repo-doc-list.ts +34 -0
- package/src/modules/repos/actions/repo-doc-remove.ts +25 -0
- package/src/modules/repos/actions/repo-export.ts +32 -0
- package/src/modules/repos/actions/repo-get.ts +27 -0
- package/src/modules/repos/actions/repo-import-diff.ts +28 -0
- package/src/modules/repos/actions/repo-import.ts +35 -0
- package/src/modules/repos/actions/repo-key-migrate.ts +24 -0
- package/src/modules/repos/actions/repo-key-refresh.ts +25 -0
- package/src/modules/repos/actions/repo-key-set.ts +33 -0
- package/src/modules/repos/actions/repo-knowledge.ts +43 -0
- package/src/modules/repos/actions/repo-list.ts +26 -0
- package/src/modules/repos/actions/repo-open.ts +25 -0
- package/src/modules/repos/actions/repo-ref-add.ts +25 -0
- package/src/modules/repos/actions/repo-ref-backfill.ts +27 -0
- package/src/modules/repos/actions/repo-ref-check.ts +26 -0
- package/src/modules/repos/actions/repo-ref-clone.ts +36 -0
- package/src/modules/repos/actions/repo-ref-note.ts +25 -0
- package/src/modules/repos/actions/repo-ref-of.ts +27 -0
- package/src/modules/repos/actions/repo-ref-sync.ts +27 -0
- package/src/modules/repos/actions/repo-remote-check.ts +28 -0
- package/src/modules/repos/actions/repo-remote-list.ts +32 -0
- package/src/modules/repos/actions/repo-remote-pick.ts +25 -0
- package/src/modules/repos/actions/repo-remote.ts +38 -0
- package/src/modules/repos/actions/repo-remove.ts +25 -0
- package/src/modules/repos/actions/repo-scan.ts +41 -0
- package/src/modules/repos/actions/repo-update.ts +33 -0
- package/src/modules/repos/boards/core.ts +366 -0
- package/src/modules/repos/boards/docs.ts +82 -0
- package/src/modules/repos/boards/members.ts +306 -0
- package/src/modules/repos/boards/transfer.ts +214 -0
- package/src/modules/repos/cli/render.ts +184 -0
- package/src/modules/repos/git.ts +223 -0
- package/src/modules/repos/index.ts +25 -0
- package/src/modules/repos/keys.ts +262 -0
- package/src/modules/repos/ref-backfill.ts +219 -0
- package/src/modules/repos/ref.ts +680 -0
- package/src/modules/repos/remote.ts +262 -0
- package/src/modules/repos/repo/open.ts +93 -0
- package/src/modules/repos/repo/refs.ts +186 -0
- package/src/modules/repos/repo/repos.ts +242 -0
- package/src/modules/repos/repo/rows.ts +260 -0
- package/src/modules/repos/schemas.ts +310 -0
- package/src/modules/repos/service/bind-topics.ts +124 -0
- package/src/modules/repos/service/context.ts +229 -0
- package/src/modules/repos/service/crud.ts +404 -0
- package/src/modules/repos/service/identity.ts +212 -0
- package/src/modules/repos/service/store.ts +278 -0
- package/src/modules/repos/transfer/diff.ts +208 -0
- package/src/modules/repos/transfer/export.ts +287 -0
- package/src/modules/repos/transfer/import.ts +424 -0
- package/src/modules/repos/transfer/layout.ts +193 -0
- package/src/modules/repos/transfer/render.ts +75 -0
- package/src/modules/setting/actions/_manifest.generated.ts +20 -0
- package/src/modules/setting/actions/setting-get.ts +24 -0
- package/src/modules/setting/actions/setting-set.ts +24 -0
- package/src/modules/setting/index.ts +24 -0
- package/src/modules/setting/schemas.ts +18 -0
- package/src/modules/setting/service.ts +75 -0
- package/src/modules/system/actions/_manifest.generated.ts +23 -0
- package/src/modules/system/actions/bootstrap.ts +74 -0
- package/src/modules/system/actions/health.ts +57 -0
- package/src/modules/system/actions/routes.ts +26 -0
- package/src/modules/system/index.ts +29 -0
- package/src/modules/system/routes.ts +67 -0
- package/src/modules/system/schemas.ts +29 -0
- package/src/modules/tasktool/actions/_manifest.generated.ts +38 -0
- package/src/modules/tasktool/actions/timegoal-check.ts +30 -0
- package/src/modules/tasktool/actions/timegoal-clear.ts +25 -0
- package/src/modules/tasktool/actions/timegoal-list.ts +25 -0
- package/src/modules/tasktool/actions/timegoal-log.ts +37 -0
- package/src/modules/tasktool/actions/timegoal-prune.ts +28 -0
- package/src/modules/tasktool/actions/timegoal-set.ts +25 -0
- package/src/modules/tasktool/actions/timegoal-show.ts +28 -0
- package/src/modules/tasktool/actions/timegoal-update.ts +25 -0
- package/src/modules/tasktool/add.ts +129 -0
- package/src/modules/tasktool/attach-resource.ts +312 -0
- package/src/modules/tasktool/attach-template.ts +266 -0
- package/src/modules/tasktool/attach.ts +497 -0
- package/src/modules/tasktool/delivery-template.ts +222 -0
- package/src/modules/tasktool/delivery-text.ts +36 -0
- package/src/modules/tasktool/doc-inline.ts +85 -0
- package/src/modules/tasktool/facade/get.ts +54 -0
- package/src/modules/tasktool/facade/submit.ts +61 -0
- package/src/modules/tasktool/get.ts +46 -0
- package/src/modules/tasktool/group-store.ts +28 -0
- package/src/modules/tasktool/groupctx.ts +167 -0
- package/src/modules/tasktool/index.ts +24 -0
- package/src/modules/tasktool/panel-escort.ts +134 -0
- package/src/modules/tasktool/params.ts +34 -0
- package/src/modules/tasktool/plugins/base.ts +68 -0
- package/src/modules/tasktool/plugins/blockgoal.ts +24 -0
- package/src/modules/tasktool/plugins/container.ts +42 -0
- package/src/modules/tasktool/plugins/discover.ts +55 -0
- package/src/modules/tasktool/plugins/goal-template.ts +98 -0
- package/src/modules/tasktool/plugins/runtime.ts +73 -0
- package/src/modules/tasktool/plugins/taskgoal-store.ts +183 -0
- package/src/modules/tasktool/plugins/taskgoal.ts +17 -0
- package/src/modules/tasktool/plugins/timegoal-core-store.ts +161 -0
- package/src/modules/tasktool/plugins/timegoal-cwd-store.ts +455 -0
- package/src/modules/tasktool/plugins/timegoal-store.ts +81 -0
- package/src/modules/tasktool/plugins/timegoal-task-store.ts +356 -0
- package/src/modules/tasktool/plugins/timegoal.ts +51 -0
- package/src/modules/tasktool/plugins/waitgoal-config.ts +118 -0
- package/src/modules/tasktool/plugins/waitgoal.ts +77 -0
- package/src/modules/tasktool/preview.ts +105 -0
- package/src/modules/tasktool/schemas.ts +52 -0
- package/src/modules/tasktool/support.ts +100 -0
- package/src/modules/tasktool/system-blocks.ts +112 -0
- package/src/modules/tasktool/update.ts +79 -0
- package/src/modules/tasktool/wait.ts +574 -0
- package/src/modules/templates/actions/_manifest.generated.ts +29 -0
- package/src/modules/templates/actions/templates-add.ts +39 -0
- package/src/modules/templates/actions/templates-default.ts +39 -0
- package/src/modules/templates/actions/templates-list.ts +27 -0
- package/src/modules/templates/actions/templates-remove.ts +26 -0
- package/src/modules/templates/actions/templates-update.ts +34 -0
- package/src/modules/templates/index.ts +24 -0
- package/src/modules/templates/repo/open.ts +72 -0
- package/src/modules/templates/repo/templates.ts +155 -0
- package/src/modules/templates/schemas.ts +50 -0
- package/src/modules/templates/scope.ts +113 -0
- package/src/modules/templates/service.ts +359 -0
- package/src/modules/templates/support.ts +47 -0
- package/src/modules/todo/actions/_manifest.generated.ts +89 -0
- package/src/modules/todo/actions/group-add.ts +28 -0
- package/src/modules/todo/actions/group-current.ts +31 -0
- package/src/modules/todo/actions/group-get.ts +38 -0
- package/src/modules/todo/actions/group-list.ts +36 -0
- package/src/modules/todo/actions/group-members.ts +36 -0
- package/src/modules/todo/actions/group-remove.ts +39 -0
- package/src/modules/todo/actions/group-update.ts +30 -0
- package/src/modules/todo/actions/group-use.ts +38 -0
- package/src/modules/todo/actions/prompt-get.ts +25 -0
- package/src/modules/todo/actions/prompt-remove.ts +25 -0
- package/src/modules/todo/actions/prompt-set.ts +25 -0
- package/src/modules/todo/actions/todo-add.ts +27 -0
- package/src/modules/todo/actions/todo-archive.ts +27 -0
- package/src/modules/todo/actions/todo-attach.ts +24 -0
- package/src/modules/todo/actions/todo-attachments.ts +25 -0
- package/src/modules/todo/actions/todo-done.ts +24 -0
- package/src/modules/todo/actions/todo-freeze.ts +24 -0
- package/src/modules/todo/actions/todo-get.ts +25 -0
- package/src/modules/todo/actions/todo-list.ts +25 -0
- package/src/modules/todo/actions/todo-remove.ts +24 -0
- package/src/modules/todo/actions/todo-unfreeze.ts +26 -0
- package/src/modules/todo/actions/todo-update.ts +31 -0
- package/src/modules/todo/actions/topic-add.ts +25 -0
- package/src/modules/todo/actions/topic-list.ts +30 -0
- package/src/modules/todo/actions/topic-remove.ts +30 -0
- package/src/modules/todo/attachments.ts +194 -0
- package/src/modules/todo/group.ts +207 -0
- package/src/modules/todo/index.ts +26 -0
- package/src/modules/todo/locate.ts +103 -0
- package/src/modules/todo/schemas.ts +177 -0
- package/src/modules/todo/service.ts +476 -0
- package/src/modules/todo/store.ts +176 -0
- package/src/modules/todo/support.ts +93 -0
- package/src/runtime/action-base.ts +14 -0
- package/src/runtime/action-decorator.ts +187 -0
- package/src/runtime/api.ts +146 -0
- package/src/runtime/cli.ts +497 -0
- package/src/runtime/codegen.ts +250 -0
- package/src/runtime/container.ts +53 -0
- package/src/runtime/cors.ts +132 -0
- package/src/runtime/help.ts +77 -0
- package/src/runtime/registry.ts +140 -0
- package/src/runtime/server.ts +144 -0
- package/src/runtime/spec.ts +288 -0
- package/src/runtime/types/module.ts +47 -0
- package/src/runtime/zod-bridge.ts +212 -0
- package/src/shared/attach.ts +105 -0
- package/src/shared/doc-title.ts +65 -0
- package/src/shared/feedback-text.ts +261 -0
- package/src/shared/frontmatter.ts +107 -0
- package/src/shared/graph.ts +36 -0
- package/src/shared/prompt-blocks.ts +438 -0
- package/src/shared/repo-key.ts +57 -0
- package/src/shared/task-status.ts +108 -0
- package/src/shared/wikilink.ts +77 -0
- package/src/web/frontend/App.tsx +571 -0
- package/src/web/frontend/api/cli-tree.json +2602 -0
- package/src/web/frontend/api/client.generated.ts +1734 -0
- package/src/web/frontend/api/client.ts +57 -0
- package/src/web/frontend/app-context.tsx +56 -0
- package/src/web/frontend/components/Introduction/docs-modal.tsx +338 -0
- package/src/web/frontend/components/Introduction/index.tsx +65 -0
- package/src/web/frontend/components/Introduction/rail.tsx +169 -0
- package/src/web/frontend/components/Introduction/use-intro.ts +311 -0
- package/src/web/frontend/components/board/member-picker.tsx +290 -0
- package/src/web/frontend/components/button/index.tsx +150 -0
- package/src/web/frontend/components/cloud/editor.tsx +254 -0
- package/src/web/frontend/components/cloud/group-popup.tsx +198 -0
- package/src/web/frontend/components/cloud/markdown.tsx +60 -0
- package/src/web/frontend/components/cloud/upload.ts +157 -0
- package/src/web/frontend/components/doc/doc-head.tsx +269 -0
- package/src/web/frontend/components/icons.tsx +188 -0
- package/src/web/frontend/components/layout/breadcrumb.tsx +58 -0
- package/src/web/frontend/components/layout/crumbs.ts +155 -0
- package/src/web/frontend/components/layout/route-crumb.tsx +33 -0
- package/src/web/frontend/components/layout/route-history.ts +27 -0
- package/src/web/frontend/components/layout/side-resizer.tsx +126 -0
- package/src/web/frontend/components/layout/tabs.tsx +76 -0
- package/src/web/frontend/components/md/ack-rail.tsx +318 -0
- package/src/web/frontend/components/md/attach-area.tsx +430 -0
- package/src/web/frontend/components/md/attach-bar.tsx +31 -0
- package/src/web/frontend/components/md/attach-common.ts +222 -0
- package/src/web/frontend/components/md/attach-modal.tsx +491 -0
- package/src/web/frontend/components/md/attach-picker.tsx +367 -0
- package/src/web/frontend/components/md/attachments.ts +122 -0
- package/src/web/frontend/components/md/composer-launch.ts +105 -0
- package/src/web/frontend/components/md/composer-panel.tsx +369 -0
- package/src/web/frontend/components/md/find-bar.tsx +51 -0
- package/src/web/frontend/components/md/live-block.tsx +153 -0
- package/src/web/frontend/components/md/md-panes-helpers.ts +166 -0
- package/src/web/frontend/components/md/md-panes-keys.ts +212 -0
- package/src/web/frontend/components/md/md-panes-root.tsx +198 -0
- package/src/web/frontend/components/md/md-panes.tsx +528 -0
- package/src/web/frontend/components/md/sel-menu.tsx +106 -0
- package/src/web/frontend/components/md/shortcut-sheet.tsx +66 -0
- package/src/web/frontend/components/md/slash-menu.tsx +136 -0
- package/src/web/frontend/components/md/status-bar.tsx +60 -0
- package/src/web/frontend/components/md/task-chain.tsx +98 -0
- package/src/web/frontend/components/md/template-editor.tsx +129 -0
- package/src/web/frontend/components/md/tool-bar.tsx +331 -0
- package/src/web/frontend/components/md/use-live-preview.ts +304 -0
- package/src/web/frontend/components/md/use-slash-menu.ts +89 -0
- package/src/web/frontend/components/md/use-source-editor.ts +342 -0
- package/src/web/frontend/components/migrate/dialog.tsx +120 -0
- package/src/web/frontend/components/migrate/undo.tsx +73 -0
- package/src/web/frontend/components/migrate/use-move.ts +137 -0
- package/src/web/frontend/components/pager.tsx +90 -0
- package/src/web/frontend/components/popup/dismiss.ts +41 -0
- package/src/web/frontend/components/popup/index.tsx +350 -0
- package/src/web/frontend/components/repos/desc-modal.tsx +293 -0
- package/src/web/frontend/components/repos/get-loop-modal.tsx +292 -0
- package/src/web/frontend/components/repos/transfer-panel.tsx +521 -0
- package/src/web/frontend/components/sidebar/drag.ts +87 -0
- package/src/web/frontend/components/sidebar/index.tsx +407 -0
- package/src/web/frontend/components/sidebar/model.ts +253 -0
- package/src/web/frontend/components/sidebar/panel.tsx +213 -0
- package/src/web/frontend/components/sidebar/queue-nav.ts +56 -0
- package/src/web/frontend/components/sidebar/rescue-fab.tsx +84 -0
- package/src/web/frontend/components/sidebar/row-menu.tsx +136 -0
- package/src/web/frontend/components/sidebar/side-state.ts +58 -0
- package/src/web/frontend/components/sidebar/task-children.tsx +103 -0
- package/src/web/frontend/components/status-tag/index.tsx +43 -0
- package/src/web/frontend/components/status-tag/model.ts +61 -0
- package/src/web/frontend/components/task-panel/index.tsx +48 -0
- package/src/web/frontend/components/task-panel/layout.tsx +82 -0
- package/src/web/frontend/components/task-panel/page-shell.tsx +49 -0
- package/src/web/frontend/components/task-panel/task-row.tsx +227 -0
- package/src/web/frontend/components/toast/index.tsx +59 -0
- package/src/web/frontend/components/tool-acts/bar.tsx +174 -0
- package/src/web/frontend/components/tool-acts/dnd.ts +70 -0
- package/src/web/frontend/components/tool-acts/layout-panel.tsx +320 -0
- package/src/web/frontend/components/tool-acts/modules.ts +215 -0
- package/src/web/frontend/components/tool-acts/use-layout.ts +37 -0
- package/src/web/frontend/components/ui.tsx +119 -0
- package/src/web/frontend/index.html +1 -1
- package/src/web/frontend/main.tsx +20 -0
- package/src/web/frontend/modules/board/ack-nodes.ts +150 -0
- package/src/web/frontend/modules/board/ack-rail-pos.ts +73 -0
- package/src/web/frontend/modules/board/board-view.ts +302 -0
- package/src/web/frontend/modules/board/reopen-text.ts +90 -0
- package/src/web/frontend/modules/md/attach-mention.ts +81 -0
- package/src/web/frontend/modules/md/doc-store.ts +100 -0
- package/src/web/frontend/modules/md/lightbox.ts +114 -0
- package/src/web/frontend/modules/md/md-blocks.ts +260 -0
- package/src/web/frontend/modules/md/md-edit-ops.ts +435 -0
- package/src/web/frontend/modules/md/md-history.ts +129 -0
- package/src/web/frontend/modules/md/md-parse.ts +133 -0
- package/src/web/frontend/modules/md/md-render.ts +304 -0
- package/src/web/frontend/modules/md/progress-chain.ts +34 -0
- package/src/web/frontend/modules/md/progress-search.ts +117 -0
- package/src/web/frontend/modules/md/use-templates.ts +175 -0
- package/src/web/frontend/modules/prompts/placeholders.ts +106 -0
- package/src/web/frontend/modules/prompts/prompt-editor.tsx +174 -0
- package/src/web/frontend/page/cloud/index.tsx +535 -0
- package/src/web/frontend/page/dag/edges.ts +79 -0
- package/src/web/frontend/page/dag/head-bar.tsx +78 -0
- package/src/web/frontend/page/dag/index.tsx +520 -0
- package/src/web/frontend/page/dag/layout.ts +97 -0
- package/src/web/frontend/page/dag/model.ts +128 -0
- package/src/web/frontend/page/dag/node-card.tsx +156 -0
- package/src/web/frontend/page/dag/use-interactions.ts +155 -0
- package/src/web/frontend/page/dir/dag-editor.tsx +206 -0
- package/src/web/frontend/page/dir/deleted-panel.tsx +77 -0
- package/src/web/frontend/page/dir/index.tsx +557 -0
- package/src/web/frontend/page/dir/landing.tsx +463 -0
- package/src/web/frontend/page/dir/task-ack.ts +46 -0
- package/src/web/frontend/page/dir/task-actions.ts +450 -0
- package/src/web/frontend/page/dir/task-beside-header.tsx +22 -0
- package/src/web/frontend/page/dir/task-board-section.tsx +49 -0
- package/src/web/frontend/page/dir/task-chain.ts +190 -0
- package/src/web/frontend/page/dir/task-derived-ctx.ts +61 -0
- package/src/web/frontend/page/dir/task-dock-panel.tsx +283 -0
- package/src/web/frontend/page/dir/task-dock.ts +97 -0
- package/src/web/frontend/page/dir/task-feedback.ts +247 -0
- package/src/web/frontend/page/dir/task-goal-section.tsx +78 -0
- package/src/web/frontend/page/dir/task-goal.ts +51 -0
- package/src/web/frontend/page/dir/task-history-view.tsx +54 -0
- package/src/web/frontend/page/dir/task-not-found.tsx +34 -0
- package/src/web/frontend/page/dir/task-preview-modal.tsx +104 -0
- package/src/web/frontend/page/dir/task-sel-menu.ts +59 -0
- package/src/web/frontend/page/dir/task-status-bar.tsx +77 -0
- package/src/web/frontend/page/dir/task-utils.ts +257 -0
- package/src/web/frontend/page/dir/task.tsx +575 -0
- package/src/web/frontend/page/doc/index.tsx +632 -0
- package/src/web/frontend/page/group/index.tsx +698 -0
- package/src/web/frontend/page/overview/index.tsx +326 -0
- package/src/web/frontend/page/progress/index.tsx +545 -0
- package/src/web/frontend/page/refs/index.tsx +157 -0
- package/src/web/frontend/page/repos/bind-modals.tsx +138 -0
- package/src/web/frontend/page/repos/board-admin.tsx +246 -0
- package/src/web/frontend/page/repos/board-refs.tsx +108 -0
- package/src/web/frontend/page/repos/doc-search-modal.tsx +269 -0
- package/src/web/frontend/page/repos/filters-bar.tsx +54 -0
- package/src/web/frontend/page/repos/index.tsx +615 -0
- package/src/web/frontend/page/repos/pending-section.tsx +169 -0
- package/src/web/frontend/page/repos/ref-panel.tsx +441 -0
- package/src/web/frontend/page/repos/remote-modal.tsx +142 -0
- package/src/web/frontend/page/repos/repo-form-modal.tsx +252 -0
- package/src/web/frontend/page/repos/repo-table.tsx +411 -0
- package/src/web/frontend/page/settings/index.tsx +234 -0
- package/src/web/frontend/page/settings/prompt-template-params.ts +296 -0
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +473 -0
- package/src/web/frontend/page/settings/sidebar-section.tsx +75 -0
- package/src/web/frontend/page/settings/task-templates-section.tsx +124 -0
- package/src/web/frontend/page/templates/index.tsx +280 -0
- package/src/web/frontend/page/templates/scope-chips.tsx +237 -0
- package/src/web/frontend/panels.tsx +248 -0
- package/src/web/frontend/prefs.ts +77 -0
- package/src/web/frontend/registry.ts +36 -0
- package/src/web/frontend/route-map.ts +47 -0
- package/src/web/frontend/routes/dir.ts +54 -0
- package/src/web/frontend/routes/doc-ref.ts +36 -0
- package/src/web/frontend/routes/doc.ts +45 -0
- package/src/web/frontend/routes/group.ts +37 -0
- package/src/web/frontend/routes/index.ts +40 -0
- package/src/web/frontend/routes/keys.ts +3 -0
- package/src/web/frontend/routes/static.ts +21 -0
- package/src/web/frontend/routes/templates.ts +65 -0
- package/src/web/frontend/routes/types.ts +43 -0
- package/src/web/frontend/store.tsx +96 -0
- package/src/web/frontend/styles-v2/views.css +24 -0
- package/src/web/frontend/types.ts +170 -0
- package/src/web/frontend/workspace/areas.ts +62 -0
- package/src/web/frontend/workspace/layout.ts +433 -0
- package/src/web/frontend/workspace/open.ts +284 -0
- package/src/web/frontend/workspace/panels.ts +447 -0
- package/src/web/public/assets/Introduction-aQCeCLrV.js +6 -0
- package/src/web/public/assets/app-context-BASCGAA-.js +1 -0
- package/src/web/public/assets/bar-B9WWmCpt.js +1 -0
- package/src/web/public/assets/board-view-DABoVkaA.js +1 -0
- package/src/web/public/assets/cloud-C4b8SU7C.js +3 -0
- package/src/web/public/assets/composer-launch-mK9Nr6mZ.js +1 -0
- package/src/web/public/assets/composer-panel-ByezS8Xv.js +1 -0
- package/src/web/public/assets/dag-jvrjx4i7.js +1 -0
- package/src/web/public/assets/deleted-panel-BcbtctNF.js +1 -0
- package/src/web/public/assets/dir-B82XBb1J.js +5 -0
- package/src/web/public/assets/frontmatter-CLLxCmTv.js +2 -0
- package/src/web/public/assets/graph-BTEfvFz6.js +1 -0
- package/src/web/public/assets/group-BPUOO_QM.js +2 -0
- package/src/web/public/assets/index-D8MvtVAm.js +2 -0
- package/src/web/public/assets/index-DP3qBv1o.css +1 -0
- package/src/web/public/assets/md-history-BqZvzWiD.js +39 -0
- package/src/web/public/assets/md-parse-b6GY5eBl.js +13 -0
- package/src/web/public/assets/member-picker-B5I7KuOR.js +1 -0
- package/src/web/public/assets/model-Bn2fG6CC.js +2 -0
- package/src/web/public/assets/overview-DMihuyzh.js +1 -0
- package/src/web/public/assets/progress-D-rMgz3w.js +3 -0
- package/src/web/public/assets/prompt-blocks-BovFd039.js +8 -0
- package/src/web/public/assets/refs-D21jmrn6.js +1 -0
- package/src/web/public/assets/repos-B94tMDGs.js +15 -0
- package/src/web/public/assets/route-crumb-CWVu80du.js +1 -0
- package/src/web/public/assets/settings-DgTt4JG5.js +1 -0
- package/src/web/public/assets/status-tag-DRl9E2Os.js +1 -0
- package/src/web/public/assets/task-B2x5GoV3.js +11 -0
- package/src/web/public/assets/task-status-DSrx0i66.js +1 -0
- package/src/web/public/assets/task-utils-By8gLpHY.js +12 -0
- package/src/web/public/assets/templates-Df__0k-F.js +1 -0
- package/src/web/public/assets/tool-bar-Cv7f6p4v.js +1 -0
- package/src/web/public/assets/upload-BcMhRsMn.js +1 -0
- package/src/web/public/assets/workspace-4tw7trV7.js +28 -0
- package/src/web/public/index.html +9 -9
- package/bin/cli.mjs +0 -27
- package/src/core/atomic-file.js +0 -45
- package/src/core/attachmentdb/docs.js +0 -116
- package/src/core/attachmentdb/ids.js +0 -96
- package/src/core/attachmentdb/query.js +0 -189
- package/src/core/attachmentdb/relations.js +0 -170
- package/src/core/attachmentdb/resources.js +0 -225
- package/src/core/attachstore.js +0 -312
- package/src/core/command-table.js +0 -22
- package/src/core/config.js +0 -193
- package/src/core/db/bootstrap.js +0 -424
- package/src/core/db/driver.js +0 -359
- package/src/core/db/errors.js +0 -144
- package/src/core/db/import-json/data.js +0 -140
- package/src/core/db/import-json/extras.js +0 -69
- package/src/core/db/import-json/links.js +0 -147
- package/src/core/db/import-json/refs.js +0 -183
- package/src/core/db/import-json/repos.js +0 -180
- package/src/core/db/import-json/scan.js +0 -35
- package/src/core/db/import-json/tasks.js +0 -317
- package/src/core/db/import-json.js +0 -194
- package/src/core/db/index.js +0 -122
- package/src/core/db/migrations/index.js +0 -110
- package/src/core/db/migrations/v2-data.js +0 -149
- package/src/core/db/migrations/v4-data.js +0 -193
- package/src/core/db/migrator.js +0 -203
- package/src/core/db/quiet.js +0 -19
- package/src/core/db/seed-templates.js +0 -265
- package/src/core/db/settings.js +0 -54
- package/src/core/db/time.js +0 -96
- package/src/core/db/tx.js +0 -188
- package/src/core/db/verify.js +0 -295
- package/src/core/db/version.js +0 -65
- package/src/core/errors.js +0 -88
- package/src/core/fileapi.js +0 -243
- package/src/core/frontmatter.js +0 -65
- package/src/core/fstree.js +0 -74
- package/src/core/instruction-template.js +0 -341
- package/src/core/keys.js +0 -33
- package/src/core/kvapi.js +0 -203
- package/src/core/localatt.js +0 -156
- package/src/core/open.js +0 -26
- package/src/core/paths.js +0 -92
- package/src/core/prompt.js +0 -60
- package/src/core/serve-port.js +0 -139
- package/src/core/topic-key.js +0 -43
- package/src/core/workflow/edges.js +0 -31
- package/src/core/workflow/layout.js +0 -119
- package/src/core/workflow/lifecycle.js +0 -58
- package/src/core/workflow/plugin-registry.js +0 -47
- package/src/core/workflow/project.js +0 -112
- package/src/core/workflow/readiness.js +0 -226
- package/src/core/workflow/types.js +0 -190
- package/src/core/zip.js +0 -163
- package/src/modules/auth/index.js +0 -99
- package/src/modules/bundled/index.js +0 -187
- package/src/modules/bundled/service.js +0 -312
- package/src/modules/db/index.js +0 -54
- package/src/modules/db/service.js +0 -273
- package/src/modules/docs/attach.js +0 -226
- package/src/modules/docs/brief.js +0 -125
- package/src/modules/docs/docref.js +0 -94
- package/src/modules/docs/index.js +0 -228
- package/src/modules/docs/knowledge.js +0 -520
- package/src/modules/docs/links.js +0 -43
- package/src/modules/docs/paths.js +0 -103
- package/src/modules/docs/refs.js +0 -237
- package/src/modules/docs/render.js +0 -84
- package/src/modules/docs/repos-bridge.js +0 -11
- package/src/modules/docs/seed.js +0 -147
- package/src/modules/docs/service.js +0 -204
- package/src/modules/docs/store.js +0 -231
- package/src/modules/file/index.js +0 -123
- package/src/modules/file/service.js +0 -348
- package/src/modules/localtask/action-attach.js +0 -113
- package/src/modules/localtask/action-lifecycle.js +0 -207
- package/src/modules/localtask/action-maintenance.js +0 -130
- package/src/modules/localtask/action-move.js +0 -58
- package/src/modules/localtask/action-query.js +0 -46
- package/src/modules/localtask/action-remove.js +0 -116
- package/src/modules/localtask/action-render.js +0 -200
- package/src/modules/localtask/action-submit.js +0 -186
- package/src/modules/localtask/action-topics.js +0 -46
- package/src/modules/localtask/action-waiting.js +0 -95
- package/src/modules/localtask/board-target.js +0 -161
- package/src/modules/localtask/bus/index.js +0 -41
- package/src/modules/localtask/deletion.js +0 -133
- package/src/modules/localtask/engine.js +0 -49
- package/src/modules/localtask/events.js +0 -216
- package/src/modules/localtask/index.js +0 -60
- package/src/modules/localtask/move-prims.js +0 -128
- package/src/modules/localtask/move.js +0 -165
- package/src/modules/localtask/mutator/index.js +0 -153
- package/src/modules/localtask/mutator/validate.js +0 -53
- package/src/modules/localtask/panel-guard.js +0 -155
- package/src/modules/localtask/panel-presence.js +0 -322
- package/src/modules/localtask/paths.js +0 -87
- package/src/modules/localtask/remote-import.js +0 -137
- package/src/modules/localtask/repo/goals.js +0 -153
- package/src/modules/localtask/repo/links.js +0 -136
- package/src/modules/localtask/repo/open.js +0 -71
- package/src/modules/localtask/repo/presence.js +0 -117
- package/src/modules/localtask/repo/rows.js +0 -162
- package/src/modules/localtask/repo/settings.js +0 -384
- package/src/modules/localtask/repo/snapshot.js +0 -154
- package/src/modules/localtask/repo/tasks.js +0 -374
- package/src/modules/localtask/repo/topics.js +0 -293
- package/src/modules/localtask/repo-ctx.js +0 -23
- package/src/modules/localtask/scheduler/index.js +0 -55
- package/src/modules/localtask/scheduler/state-drive.js +0 -30
- package/src/modules/localtask/service.js +0 -62
- package/src/modules/localtask/store/file-adapter.js +0 -51
- package/src/modules/localtask/store/index.js +0 -99
- package/src/modules/localtask/store/memory-adapter.js +0 -26
- package/src/modules/localtask/store-io.js +0 -71
- package/src/modules/localtask/task-lifecycle.js +0 -448
- package/src/modules/localtask/task-ops.js +0 -444
- package/src/modules/localtask/task-remove.js +0 -313
- package/src/modules/localtask/task-templates.js +0 -84
- package/src/modules/localtask/task-view.js +0 -446
- package/src/modules/localtask/topics.js +0 -170
- package/src/modules/localtask/waiters.js +0 -63
- package/src/modules/localtask/waiting.js +0 -73
- package/src/modules/localtask/writes.js +0 -130
- package/src/modules/repos/boards/core.js +0 -255
- package/src/modules/repos/boards/docs.js +0 -53
- package/src/modules/repos/boards/members.js +0 -228
- package/src/modules/repos/boards/transfer.js +0 -159
- package/src/modules/repos/cli/board-actions.js +0 -177
- package/src/modules/repos/cli/ref-actions.js +0 -157
- package/src/modules/repos/cli/remote-actions.js +0 -141
- package/src/modules/repos/cli/render.js +0 -168
- package/src/modules/repos/cli/repo-actions.js +0 -199
- package/src/modules/repos/cli/transfer-actions.js +0 -105
- package/src/modules/repos/git.js +0 -0
- package/src/modules/repos/index.js +0 -47
- package/src/modules/repos/keys.js +0 -221
- package/src/modules/repos/ref-backfill.js +0 -172
- package/src/modules/repos/ref.js +0 -535
- package/src/modules/repos/remote.js +0 -175
- package/src/modules/repos/repo/open.js +0 -84
- package/src/modules/repos/repo/refs.js +0 -165
- package/src/modules/repos/repo/repos.js +0 -213
- package/src/modules/repos/repo/rows.js +0 -178
- package/src/modules/repos/service/bind-topics.js +0 -97
- package/src/modules/repos/service/context.js +0 -189
- package/src/modules/repos/service/crud.js +0 -345
- package/src/modules/repos/service/identity.js +0 -188
- package/src/modules/repos/service/store.js +0 -274
- package/src/modules/repos/transfer/diff.js +0 -126
- package/src/modules/repos/transfer/export.js +0 -223
- package/src/modules/repos/transfer/import.js +0 -377
- package/src/modules/repos/transfer/layout.js +0 -135
- package/src/modules/repos/transfer/render.js +0 -72
- package/src/modules/setting/index.js +0 -34
- package/src/modules/setting/service.js +0 -58
- package/src/modules/system/index.js +0 -96
- package/src/modules/system/routes.js +0 -71
- package/src/modules/tasktool/add.js +0 -107
- package/src/modules/tasktool/attach-resource.js +0 -296
- package/src/modules/tasktool/attach-template.js +0 -266
- package/src/modules/tasktool/attach.js +0 -451
- package/src/modules/tasktool/delivery-template.js +0 -213
- package/src/modules/tasktool/delivery-text.js +0 -28
- package/src/modules/tasktool/doc-inline.js +0 -84
- package/src/modules/tasktool/facade/get.js +0 -46
- package/src/modules/tasktool/facade/submit.js +0 -49
- package/src/modules/tasktool/get.js +0 -38
- package/src/modules/tasktool/group-store.js +0 -28
- package/src/modules/tasktool/groupctx.js +0 -124
- package/src/modules/tasktool/index.js +0 -250
- package/src/modules/tasktool/panel-escort.js +0 -121
- package/src/modules/tasktool/params.js +0 -34
- package/src/modules/tasktool/plugins/base.js +0 -92
- package/src/modules/tasktool/plugins/blockgoal.js +0 -23
- package/src/modules/tasktool/plugins/container.js +0 -47
- package/src/modules/tasktool/plugins/discover.js +0 -45
- package/src/modules/tasktool/plugins/goal-template.js +0 -86
- package/src/modules/tasktool/plugins/runtime.js +0 -69
- package/src/modules/tasktool/plugins/taskgoal-store.js +0 -160
- package/src/modules/tasktool/plugins/taskgoal.js +0 -17
- package/src/modules/tasktool/plugins/timegoal-core-store.js +0 -151
- package/src/modules/tasktool/plugins/timegoal-cwd-store.js +0 -438
- package/src/modules/tasktool/plugins/timegoal-store.js +0 -81
- package/src/modules/tasktool/plugins/timegoal-task-store.js +0 -323
- package/src/modules/tasktool/plugins/timegoal.js +0 -51
- package/src/modules/tasktool/plugins/waitgoal-config.js +0 -84
- package/src/modules/tasktool/plugins/waitgoal.js +0 -75
- package/src/modules/tasktool/preview.js +0 -91
- package/src/modules/tasktool/system-blocks.js +0 -78
- package/src/modules/tasktool/update.js +0 -70
- package/src/modules/tasktool/wait.js +0 -532
- package/src/modules/templates/index.js +0 -189
- package/src/modules/templates/repo/open.js +0 -65
- package/src/modules/templates/repo/templates.js +0 -155
- package/src/modules/templates/scope.js +0 -107
- package/src/modules/templates/service.js +0 -311
- package/src/modules/todo/attachments.js +0 -149
- package/src/modules/todo/group.js +0 -194
- package/src/modules/todo/index.js +0 -365
- package/src/modules/todo/locate.js +0 -82
- package/src/modules/todo/service.js +0 -381
- package/src/modules/todo/store.js +0 -158
- package/src/runtime/api.js +0 -101
- package/src/runtime/cli.js +0 -417
- package/src/runtime/cors.js +0 -125
- package/src/runtime/registry.js +0 -89
- package/src/runtime/server.js +0 -103
- package/src/runtime/spec.js +0 -192
- package/src/shared/attach.js +0 -96
- package/src/shared/doc-title.js +0 -71
- package/src/shared/feedback-text.js +0 -245
- package/src/shared/frontmatter.js +0 -107
- package/src/shared/graph.js +0 -40
- package/src/shared/prompt-blocks.js +0 -374
- package/src/shared/repo-key.js +0 -57
- package/src/shared/task-status.js +0 -105
- package/src/shared/wikilink.js +0 -64
- package/src/web/frontend/App.jsx +0 -530
- package/src/web/frontend/api/client.js +0 -39
- package/src/web/frontend/app-context.jsx +0 -13
- package/src/web/frontend/components/Introduction/docs-modal.jsx +0 -306
- package/src/web/frontend/components/Introduction/index.jsx +0 -62
- package/src/web/frontend/components/Introduction/rail.jsx +0 -141
- package/src/web/frontend/components/Introduction/use-intro.js +0 -225
- package/src/web/frontend/components/board/member-picker.jsx +0 -262
- package/src/web/frontend/components/button/index.jsx +0 -118
- package/src/web/frontend/components/cloud/editor.jsx +0 -229
- package/src/web/frontend/components/cloud/group-popup.jsx +0 -173
- package/src/web/frontend/components/cloud/markdown.jsx +0 -53
- package/src/web/frontend/components/cloud/upload.js +0 -108
- package/src/web/frontend/components/doc/doc-head.jsx +0 -226
- package/src/web/frontend/components/icons.jsx +0 -176
- package/src/web/frontend/components/layout/breadcrumb.jsx +0 -49
- package/src/web/frontend/components/layout/crumbs.js +0 -132
- package/src/web/frontend/components/layout/route-crumb.jsx +0 -33
- package/src/web/frontend/components/layout/route-history.js +0 -27
- package/src/web/frontend/components/layout/side-resizer.jsx +0 -102
- package/src/web/frontend/components/layout/tabs.jsx +0 -58
- package/src/web/frontend/components/md/ack-rail.jsx +0 -273
- package/src/web/frontend/components/md/attach-area.jsx +0 -366
- package/src/web/frontend/components/md/attach-bar.jsx +0 -25
- package/src/web/frontend/components/md/attach-common.js +0 -108
- package/src/web/frontend/components/md/attach-modal.jsx +0 -429
- package/src/web/frontend/components/md/attach-picker.jsx +0 -304
- package/src/web/frontend/components/md/attachments.js +0 -106
- package/src/web/frontend/components/md/composer-launch.js +0 -68
- package/src/web/frontend/components/md/composer-panel.jsx +0 -354
- package/src/web/frontend/components/md/find-bar.jsx +0 -38
- package/src/web/frontend/components/md/live-block.jsx +0 -129
- package/src/web/frontend/components/md/md-panes-helpers.js +0 -95
- package/src/web/frontend/components/md/md-panes-keys.js +0 -193
- package/src/web/frontend/components/md/md-panes-root.jsx +0 -158
- package/src/web/frontend/components/md/md-panes.jsx +0 -471
- package/src/web/frontend/components/md/sel-menu.jsx +0 -88
- package/src/web/frontend/components/md/shortcut-sheet.jsx +0 -60
- package/src/web/frontend/components/md/slash-menu.jsx +0 -83
- package/src/web/frontend/components/md/status-bar.jsx +0 -46
- package/src/web/frontend/components/md/task-chain.jsx +0 -72
- package/src/web/frontend/components/md/template-editor.jsx +0 -120
- package/src/web/frontend/components/md/tool-bar.jsx +0 -262
- package/src/web/frontend/components/md/use-live-preview.js +0 -279
- package/src/web/frontend/components/md/use-slash-menu.js +0 -80
- package/src/web/frontend/components/md/use-source-editor.js +0 -297
- package/src/web/frontend/components/migrate/dialog.jsx +0 -90
- package/src/web/frontend/components/migrate/undo.jsx +0 -58
- package/src/web/frontend/components/migrate/use-move.js +0 -86
- package/src/web/frontend/components/pager.jsx +0 -71
- package/src/web/frontend/components/popup/dismiss.js +0 -32
- package/src/web/frontend/components/popup/index.jsx +0 -270
- package/src/web/frontend/components/repos/desc-modal.jsx +0 -250
- package/src/web/frontend/components/repos/get-loop-modal.jsx +0 -181
- package/src/web/frontend/components/repos/transfer-panel.jsx +0 -450
- package/src/web/frontend/components/sidebar/drag.js +0 -70
- package/src/web/frontend/components/sidebar/index.jsx +0 -362
- package/src/web/frontend/components/sidebar/model.js +0 -193
- package/src/web/frontend/components/sidebar/panel.jsx +0 -195
- package/src/web/frontend/components/sidebar/queue-nav.js +0 -40
- package/src/web/frontend/components/sidebar/rescue-fab.jsx +0 -78
- package/src/web/frontend/components/sidebar/row-menu.jsx +0 -103
- package/src/web/frontend/components/sidebar/side-state.js +0 -49
- package/src/web/frontend/components/sidebar/task-children.jsx +0 -89
- package/src/web/frontend/components/status-tag/index.jsx +0 -30
- package/src/web/frontend/components/status-tag/model.js +0 -53
- package/src/web/frontend/components/task-panel/index.jsx +0 -36
- package/src/web/frontend/components/task-panel/layout.jsx +0 -64
- package/src/web/frontend/components/task-panel/page-shell.jsx +0 -38
- package/src/web/frontend/components/task-panel/task-row.jsx +0 -170
- package/src/web/frontend/components/toast/index.jsx +0 -40
- package/src/web/frontend/components/tool-acts/bar.jsx +0 -156
- package/src/web/frontend/components/tool-acts/dnd.js +0 -59
- package/src/web/frontend/components/tool-acts/layout-panel.jsx +0 -289
- package/src/web/frontend/components/tool-acts/modules.js +0 -188
- package/src/web/frontend/components/tool-acts/use-layout.js +0 -27
- package/src/web/frontend/components/ui.jsx +0 -95
- package/src/web/frontend/main.jsx +0 -19
- package/src/web/frontend/modules/board/ack-nodes.js +0 -137
- package/src/web/frontend/modules/board/ack-rail-pos.js +0 -50
- package/src/web/frontend/modules/board/board-view.js +0 -255
- package/src/web/frontend/modules/board/reopen-text.js +0 -80
- package/src/web/frontend/modules/md/attach-mention.js +0 -59
- package/src/web/frontend/modules/md/doc-store.js +0 -78
- package/src/web/frontend/modules/md/lightbox.js +0 -97
- package/src/web/frontend/modules/md/md-blocks.js +0 -248
- package/src/web/frontend/modules/md/md-edit-ops.js +0 -367
- package/src/web/frontend/modules/md/md-history.js +0 -79
- package/src/web/frontend/modules/md/md-parse.js +0 -122
- package/src/web/frontend/modules/md/md-render.js +0 -281
- package/src/web/frontend/modules/md/progress-chain.js +0 -29
- package/src/web/frontend/modules/md/progress-search.js +0 -110
- package/src/web/frontend/modules/md/use-templates.js +0 -143
- package/src/web/frontend/modules/prompts/placeholders.js +0 -85
- package/src/web/frontend/modules/prompts/prompt-editor.jsx +0 -154
- package/src/web/frontend/page/cloud/index.jsx +0 -476
- package/src/web/frontend/page/dag/edges.js +0 -55
- package/src/web/frontend/page/dag/head-bar.jsx +0 -46
- package/src/web/frontend/page/dag/index.jsx +0 -497
- package/src/web/frontend/page/dag/layout.js +0 -83
- package/src/web/frontend/page/dag/model.js +0 -47
- package/src/web/frontend/page/dag/node-card.jsx +0 -123
- package/src/web/frontend/page/dag/use-interactions.js +0 -135
- package/src/web/frontend/page/dir/dag-editor.jsx +0 -171
- package/src/web/frontend/page/dir/deleted-panel.jsx +0 -63
- package/src/web/frontend/page/dir/index.jsx +0 -540
- package/src/web/frontend/page/dir/landing.jsx +0 -365
- package/src/web/frontend/page/dir/task-ack.js +0 -38
- package/src/web/frontend/page/dir/task-actions.js +0 -387
- package/src/web/frontend/page/dir/task-beside-header.jsx +0 -18
- package/src/web/frontend/page/dir/task-board-section.jsx +0 -38
- package/src/web/frontend/page/dir/task-chain.js +0 -172
- package/src/web/frontend/page/dir/task-derived-ctx.js +0 -46
- package/src/web/frontend/page/dir/task-dock-panel.jsx +0 -227
- package/src/web/frontend/page/dir/task-dock.js +0 -79
- package/src/web/frontend/page/dir/task-feedback.js +0 -207
- package/src/web/frontend/page/dir/task-goal-section.jsx +0 -55
- package/src/web/frontend/page/dir/task-goal.js +0 -41
- package/src/web/frontend/page/dir/task-history-view.jsx +0 -44
- package/src/web/frontend/page/dir/task-not-found.jsx +0 -23
- package/src/web/frontend/page/dir/task-preview-modal.jsx +0 -82
- package/src/web/frontend/page/dir/task-sel-menu.js +0 -54
- package/src/web/frontend/page/dir/task-status-bar.jsx +0 -61
- package/src/web/frontend/page/dir/task-utils.js +0 -7
- package/src/web/frontend/page/dir/task.jsx +0 -540
- package/src/web/frontend/page/doc/index.jsx +0 -554
- package/src/web/frontend/page/group/index.jsx +0 -603
- package/src/web/frontend/page/overview/index.jsx +0 -295
- package/src/web/frontend/page/progress/index.jsx +0 -480
- package/src/web/frontend/page/refs/index.jsx +0 -122
- package/src/web/frontend/page/repos/bind-modals.jsx +0 -118
- package/src/web/frontend/page/repos/board-admin.jsx +0 -226
- package/src/web/frontend/page/repos/board-refs.jsx +0 -97
- package/src/web/frontend/page/repos/doc-search-modal.jsx +0 -241
- package/src/web/frontend/page/repos/filters-bar.jsx +0 -44
- package/src/web/frontend/page/repos/index.jsx +0 -586
- package/src/web/frontend/page/repos/pending-section.jsx +0 -163
- package/src/web/frontend/page/repos/ref-panel.jsx +0 -406
- package/src/web/frontend/page/repos/remote-modal.jsx +0 -112
- package/src/web/frontend/page/repos/repo-form-modal.jsx +0 -219
- package/src/web/frontend/page/repos/repo-table.jsx +0 -222
- package/src/web/frontend/page/settings/index.jsx +0 -224
- package/src/web/frontend/page/settings/prompt-template-params.js +0 -286
- package/src/web/frontend/page/settings/prompt-templates-section.jsx +0 -427
- package/src/web/frontend/page/settings/sidebar-section.jsx +0 -72
- package/src/web/frontend/page/settings/task-templates-section.jsx +0 -115
- package/src/web/frontend/page/templates/index.jsx +0 -253
- package/src/web/frontend/page/templates/scope-chips.jsx +0 -211
- package/src/web/frontend/panels.jsx +0 -230
- package/src/web/frontend/prefs.js +0 -73
- package/src/web/frontend/registry.js +0 -27
- package/src/web/frontend/route-map.js +0 -209
- package/src/web/frontend/store.jsx +0 -74
- package/src/web/frontend/workspace/areas.js +0 -59
- package/src/web/frontend/workspace/layout.js +0 -399
- package/src/web/frontend/workspace/open.js +0 -246
- package/src/web/frontend/workspace/panels.js +0 -417
- package/src/web/public/assets/Introduction-BI8Ohz1l.js +0 -6
- package/src/web/public/assets/app-context-D7HAx67n.js +0 -1
- package/src/web/public/assets/bar-Jfji2mz3.js +0 -1
- package/src/web/public/assets/board-view-CZKZsyk-.js +0 -1
- package/src/web/public/assets/button-Cmo-6aoW.js +0 -1
- package/src/web/public/assets/cloud-cFewR3CF.js +0 -3
- package/src/web/public/assets/composer-launch-Bf4rXhLs.js +0 -1
- package/src/web/public/assets/composer-panel-CcK0D4Gd.js +0 -1
- package/src/web/public/assets/dag-BBtSqd-X.js +0 -1
- package/src/web/public/assets/deleted-panel-oN8YlGvq.js +0 -1
- package/src/web/public/assets/dir-BuAtw08k.js +0 -5
- package/src/web/public/assets/frontmatter-QvrjUNzF.js +0 -2
- package/src/web/public/assets/graph-DM-zDRdL.js +0 -1
- package/src/web/public/assets/group-FRUv4mQ6.js +0 -2
- package/src/web/public/assets/index-CyF6nNWE.js +0 -2
- package/src/web/public/assets/index-DGvBoOdp.css +0 -1
- package/src/web/public/assets/md-history-DErcpXhC.js +0 -39
- package/src/web/public/assets/md-parse-awNLHAzO.js +0 -13
- package/src/web/public/assets/member-picker-BAgkj36N.js +0 -1
- package/src/web/public/assets/model-DzdWfp14.js +0 -2
- package/src/web/public/assets/overview-DZHcrz4u.js +0 -1
- package/src/web/public/assets/progress-Bx0reVYl.js +0 -3
- package/src/web/public/assets/refs-BXIwmL5W.js +0 -1
- package/src/web/public/assets/reopen-text-BylkngqC.js +0 -12
- package/src/web/public/assets/repos-DYugJZpl.js +0 -15
- package/src/web/public/assets/route-crumb-C3Ce0rzR.js +0 -1
- package/src/web/public/assets/settings-Bpazt87u.js +0 -8
- package/src/web/public/assets/status-tag-CHCpOgMP.js +0 -1
- package/src/web/public/assets/task-G58spmPC.js +0 -11
- package/src/web/public/assets/task-status-BnymQMTw.js +0 -1
- package/src/web/public/assets/templates-Dr0CunY8.js +0 -1
- package/src/web/public/assets/tool-bar-BSIlsHln.js +0 -1
- package/src/web/public/assets/upload-BIMbGcCB.js +0 -1
- package/src/web/public/assets/workspace-C_5X2gIr.js +0 -28
- /package/src/core/{attachmentdb.js → attachmentdb.ts} +0 -0
- /package/src/core/workflow/{event-names.js → event-names.ts} +0 -0
- /package/src/modules/localtask/{action-flags.js → action-flags.ts} +0 -0
- /package/src/modules/localtask/{dag.js → dag.ts} +0 -0
- /package/src/modules/localtask/repo/{index.js → index.ts} +0 -0
- /package/src/modules/localtask/store/{topic-adapter.js → topic-adapter.ts} +0 -0
- /package/src/modules/repos/{boards.js → boards.ts} +0 -0
- /package/src/modules/repos/repo/{index.js → index.ts} +0 -0
- /package/src/modules/repos/{service.js → service.ts} +0 -0
- /package/src/modules/repos/{transfer.js → transfer.ts} +0 -0
- /package/src/modules/tasktool/facade/{index.js → index.ts} +0 -0
- /package/src/modules/tasktool/facade/{wait.js → wait.ts} +0 -0
- /package/src/modules/tasktool/{getloop.js → getloop.ts} +0 -0
- /package/src/modules/tasktool/plugins/{index.js → index.ts} +0 -0
- /package/src/modules/tasktool/{taskgoal.js → taskgoal.ts} +0 -0
- /package/src/modules/tasktool/{timegoal.js → timegoal.ts} +0 -0
- /package/src/modules/templates/repo/{index.js → index.ts} +0 -0
- /package/src/web/frontend/components/md/{doc-outline-rail.jsx → doc-outline-rail.tsx} +0 -0
- /package/src/web/frontend/{workspace.js → workspace.ts} +0 -0
- /package/src/web/public/assets/{button-DA4lNJeC.css → prompt-blocks-DA4lNJeC.css} +0 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
// 附件区(任务页 / 文档页共用):关系表 task_attach / ref_attach 的呈现与操作。
|
|
2
|
+
//
|
|
3
|
+
// 与正文的关系:正文只呈现 `role=inline` 那一部分;这里按 area 分区显示
|
|
4
|
+
// 「正文内嵌 / 附件区」,不会遗漏只挂在附件区的资源(--no-embed 挂的)。
|
|
5
|
+
//
|
|
6
|
+
// 交互:拖文件进来直接登记(role=attach);「添加附件」打开共享弹窗;
|
|
7
|
+
// 图片缩略图点开大图;pdf/其它给打开/下载;task 点击跳任务;ref 点击开文档;
|
|
8
|
+
// 移除时二选一:只解除关联 / 连资源与字节一起删。
|
|
9
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
10
|
+
import type { ComponentType, DragEvent, ReactNode, Ref } from 'react';
|
|
11
|
+
import { Modal, useDialog } from '../popup/index.jsx';
|
|
12
|
+
import { useToast } from '../toast/index.jsx';
|
|
13
|
+
import { api } from '../../api/client.js';
|
|
14
|
+
import { uploadOne, droppedFiles } from '../cloud/upload.js';
|
|
15
|
+
import AttachModal from './attach-modal.jsx';
|
|
16
|
+
import {
|
|
17
|
+
AREA_LABEL,
|
|
18
|
+
badgeOf,
|
|
19
|
+
contentUrl,
|
|
20
|
+
endpointOf,
|
|
21
|
+
normAttachment,
|
|
22
|
+
} from './attach-common.js';
|
|
23
|
+
import type {
|
|
24
|
+
AttachAllow,
|
|
25
|
+
AttachHostKind,
|
|
26
|
+
Attachment,
|
|
27
|
+
DocOption,
|
|
28
|
+
NormalizedAttachment,
|
|
29
|
+
TaskOption,
|
|
30
|
+
} from './attach-common.js';
|
|
31
|
+
|
|
32
|
+
type SortBy = 'position' | 'name' | 'kind';
|
|
33
|
+
|
|
34
|
+
// popup 的 Modal 仍是 JS 模块:JSDoc 从默认值 null 推出的 footer 只能是 null,
|
|
35
|
+
// 真实契约是 ReactNode——这里重新标注一次(本文件唯一断言点)。
|
|
36
|
+
const ModalBox = Modal as unknown as ComponentType<{
|
|
37
|
+
title?: ReactNode;
|
|
38
|
+
onClose?: () => void;
|
|
39
|
+
busy?: boolean;
|
|
40
|
+
size?: string;
|
|
41
|
+
footer?: ReactNode;
|
|
42
|
+
className?: string;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
const SORTERS: Record<SortBy, (a: NormalizedAttachment, b: NormalizedAttachment) => number> = {
|
|
47
|
+
position: (a, b) => (a.position || 0) - (b.position || 0) || String(a.id).localeCompare(String(b.id)),
|
|
48
|
+
name: (a, b) => String(a.name || '').localeCompare(String(b.name || '')),
|
|
49
|
+
kind: (a, b) => String(a.kind).localeCompare(String(b.kind)) || String(a.name || '').localeCompare(String(b.name || '')),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** 附件区的对外句柄(任务页的「添加附件」按钮经 ref 唤起)。 */
|
|
53
|
+
export interface AttachAreaHandle {
|
|
54
|
+
open: () => void;
|
|
55
|
+
refresh: () => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 一条条目的动作集合(renderItem 的入参)。 */
|
|
59
|
+
interface ItemActions {
|
|
60
|
+
onRemove: (a: NormalizedAttachment) => void;
|
|
61
|
+
onPreview: (p: { src: string; name?: string }) => void;
|
|
62
|
+
key?: Attachment['id'];
|
|
63
|
+
onOpenTask?: (hit: { key?: string; seq?: number | null }) => void;
|
|
64
|
+
onOpenDoc?: (locator: string) => void;
|
|
65
|
+
onEditNote?: (a: NormalizedAttachment) => void;
|
|
66
|
+
onReplace?: (a: NormalizedAttachment) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface AttachAreaProps {
|
|
70
|
+
host?: AttachHostKind;
|
|
71
|
+
hostId?: string | number;
|
|
72
|
+
hostKey?: string;
|
|
73
|
+
hostCwd?: string;
|
|
74
|
+
refId?: string;
|
|
75
|
+
allow?: AttachAllow;
|
|
76
|
+
taskOptions?: TaskOption[];
|
|
77
|
+
docOptions?: DocOption[] | null;
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
disabledText?: string;
|
|
80
|
+
openRef?: Ref<AttachAreaHandle>;
|
|
81
|
+
/** React 19 的 ref-as-prop:页面按 `<AttachArea ref={...}>` 传句柄。
|
|
82
|
+
* 历史上本组件只认 openRef,这里保持同一行为(不接管 ref),仅让调用点类型对得上。 */
|
|
83
|
+
ref?: Ref<AttachAreaHandle>;
|
|
84
|
+
onChanged?: () => void;
|
|
85
|
+
onOpenTask?: (hit: { key?: string; seq?: number | null }) => void;
|
|
86
|
+
onOpenDoc?: (locator: string) => void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function renderItem(a: NormalizedAttachment, { onRemove, onPreview, onOpenTask, onOpenDoc, onEditNote, onReplace }: ItemActions) {
|
|
90
|
+
const src = a.kind === 'image' ? contentUrl(a.id) : '';
|
|
91
|
+
return (
|
|
92
|
+
<div className={`att-item att-kind-${a.kind}`} key={a.id}>
|
|
93
|
+
{a.kind === 'image' ? (
|
|
94
|
+
<button type="button" className="att-thumb" onClick={() => onPreview({ src, name: a.name })} title="点击看大图">
|
|
95
|
+
<img src={src} alt={a.name} loading="lazy" />
|
|
96
|
+
</button>
|
|
97
|
+
) : (
|
|
98
|
+
<span className="att-kind-badge">{badgeOf(a.kind)}</span>
|
|
99
|
+
)}
|
|
100
|
+
|
|
101
|
+
<span className="att-item-main">
|
|
102
|
+
{a.kind === 'task' ? (
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="att-link"
|
|
106
|
+
title={`跳转到任务 #${a.targetSeq ?? ''}`}
|
|
107
|
+
onClick={() => onOpenTask?.({ key: a.targetKey, seq: a.targetSeq })}
|
|
108
|
+
>
|
|
109
|
+
{a.name}
|
|
110
|
+
</button>
|
|
111
|
+
) : a.kind === 'ref' ? (
|
|
112
|
+
<button
|
|
113
|
+
type="button"
|
|
114
|
+
className="att-link"
|
|
115
|
+
title={a.locator || a.targetRef || '打开文档'}
|
|
116
|
+
onClick={() => onOpenDoc?.(a.locator || a.targetRef)}
|
|
117
|
+
>
|
|
118
|
+
{a.name}
|
|
119
|
+
</button>
|
|
120
|
+
) : a.kind === 'url' ? (
|
|
121
|
+
<a className="att-link" href={a.url} target="_blank" rel="noreferrer" title={a.url}>{a.name}</a>
|
|
122
|
+
) : (
|
|
123
|
+
<span className="att-item-name" title={a.name}>{a.name}</span>
|
|
124
|
+
)}
|
|
125
|
+
<span className="att-item-meta">
|
|
126
|
+
{a.sizeText ? <span>{a.sizeText}</span> : null}
|
|
127
|
+
{a.note ? <span className="att-note">{a.note}</span> : null}
|
|
128
|
+
</span>
|
|
129
|
+
</span>
|
|
130
|
+
|
|
131
|
+
{a.kind === 'file' || a.kind === 'image' ? (
|
|
132
|
+
<span className="att-item-acts">
|
|
133
|
+
<a className="att-act" href={contentUrl(a.id)} target="_blank" rel="noreferrer">打开</a>
|
|
134
|
+
<a className="att-act" href={contentUrl(a.id)} download={a.name}>下载</a>
|
|
135
|
+
</span>
|
|
136
|
+
) : null}
|
|
137
|
+
|
|
138
|
+
{a.kind === 'ref' ? (
|
|
139
|
+
<span className="att-item-acts">
|
|
140
|
+
<button type="button" className="att-act" title="改这条绑定的一行说明(交付清单会透出)" onClick={() => onEditNote?.(a)}>✎ 说明</button>
|
|
141
|
+
<button type="button" className="att-act" title="换成另一篇文档(替换这条绑定)" onClick={() => onReplace?.(a)}>⇄ 更换</button>
|
|
142
|
+
</span>
|
|
143
|
+
) : null}
|
|
144
|
+
|
|
145
|
+
<button type="button" className="att-x" aria-label={`移除 ${a.name}`} onClick={() => onRemove(a)}>×</button>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default function AttachArea({
|
|
151
|
+
host = 'task',
|
|
152
|
+
hostId,
|
|
153
|
+
hostKey,
|
|
154
|
+
hostCwd,
|
|
155
|
+
refId,
|
|
156
|
+
allow = { file: true, url: true, task: false, ref: false },
|
|
157
|
+
taskOptions = [],
|
|
158
|
+
docOptions,
|
|
159
|
+
disabled = false,
|
|
160
|
+
disabledText = '提交任务后可以在这里挂附件(当前是草稿)。',
|
|
161
|
+
openRef,
|
|
162
|
+
onChanged,
|
|
163
|
+
onOpenTask,
|
|
164
|
+
onOpenDoc,
|
|
165
|
+
}: AttachAreaProps) {
|
|
166
|
+
const toast = useToast();
|
|
167
|
+
const { dialog, node: dialogNode } = useDialog();
|
|
168
|
+
const [list, setList] = useState<NormalizedAttachment[]>([]);
|
|
169
|
+
const [loading, setLoading] = useState(false);
|
|
170
|
+
const [error, setError] = useState('');
|
|
171
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
172
|
+
const [dragOver, setDragOver] = useState(false);
|
|
173
|
+
const [dropping, setDropping] = useState(false);
|
|
174
|
+
const [sortBy, setSortBy] = useState<SortBy>('position');
|
|
175
|
+
const [removeOf, setRemoveOf] = useState<NormalizedAttachment | null>(null);
|
|
176
|
+
// #168:ref 条目的两个动作——改说明(✎)/ 换指向(⇄,替换成另一篇文档)
|
|
177
|
+
const [replaceOf, setReplaceOf] = useState<NormalizedAttachment | null>(null);
|
|
178
|
+
const [removing, setRemoving] = useState(false);
|
|
179
|
+
const [preview, setPreview] = useState<{ src: string; name?: string } | null>(null);
|
|
180
|
+
|
|
181
|
+
const ep = useMemo(
|
|
182
|
+
() => endpointOf(host, { hostId, hostKey, hostCwd, refId }),
|
|
183
|
+
[host, hostId, hostKey, hostCwd, refId]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const load = useCallback(async () => {
|
|
187
|
+
if (disabled) {
|
|
188
|
+
setList([]);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
setLoading(true);
|
|
192
|
+
setError('');
|
|
193
|
+
try {
|
|
194
|
+
const r = await ep.list();
|
|
195
|
+
setList((r.attachments || []).map(normAttachment));
|
|
196
|
+
} catch (e) {
|
|
197
|
+
setError(String((e as Error).message || e));
|
|
198
|
+
} finally {
|
|
199
|
+
setLoading(false);
|
|
200
|
+
}
|
|
201
|
+
}, [ep, disabled]);
|
|
202
|
+
|
|
203
|
+
useEffect(() => { load(); }, [load]);
|
|
204
|
+
|
|
205
|
+
useImperativeHandle(openRef, () => ({
|
|
206
|
+
open: () => setModalOpen(true),
|
|
207
|
+
refresh: load,
|
|
208
|
+
}), [load]);
|
|
209
|
+
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
if (!preview) return undefined;
|
|
212
|
+
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') setPreview(null); };
|
|
213
|
+
window.addEventListener('keydown', onKey);
|
|
214
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
215
|
+
}, [preview]);
|
|
216
|
+
|
|
217
|
+
const sorted = useMemo(() => [...list].sort(SORTERS[sortBy] || SORTERS.position), [list, sortBy]);
|
|
218
|
+
const inline = sorted.filter((a) => a.area === 'inline');
|
|
219
|
+
const area = sorted.filter((a) => a.area === 'area');
|
|
220
|
+
|
|
221
|
+
const dropFiles = async (files: FileList | File[] | null, e: DragEvent<HTMLDivElement>) => {
|
|
222
|
+
if (disabled) return;
|
|
223
|
+
// cloud/upload 仍是 JS 模块:droppedFiles 的返回被推成 unknown[],约定就是 File[]
|
|
224
|
+
const fs = droppedFiles(e) as File[];
|
|
225
|
+
const picked = fs.length ? fs : [...(files || [])].filter((f) => f && f.size > 0);
|
|
226
|
+
if (!picked.length) return;
|
|
227
|
+
setDropping(true);
|
|
228
|
+
let ok = 0;
|
|
229
|
+
for (const f of picked) {
|
|
230
|
+
try {
|
|
231
|
+
// 拖进附件区 = 明确要挂到附件区:上传后走 no-embed(不写正文)
|
|
232
|
+
const r = await uploadOne(f, { local: true });
|
|
233
|
+
const fileId = r.fileId || r.id;
|
|
234
|
+
if (!fileId) throw new Error('上传未返回 fileId');
|
|
235
|
+
await ep.attach({ fileId, name: r.name });
|
|
236
|
+
ok += 1;
|
|
237
|
+
} catch (err) {
|
|
238
|
+
toast(`「${f.name || '文件'}」添加失败:${(err as Error).message || err}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
setDropping(false);
|
|
242
|
+
if (ok) {
|
|
243
|
+
toast(`已挂到附件区 ${ok} 个文件`);
|
|
244
|
+
await load();
|
|
245
|
+
onChanged?.();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// #168:改一条绑定的说明(desc)——面板直改,不必重挂
|
|
250
|
+
const editNote = async (item: NormalizedAttachment | null) => {
|
|
251
|
+
if (!item) return;
|
|
252
|
+
try {
|
|
253
|
+
// useDialog 仍是 JS 模块:dialog 返回 Promise<unknown>,约定是 string(单输入)或 { value, note }
|
|
254
|
+
const res = await dialog({
|
|
255
|
+
title: `说明 · ${item.name}`,
|
|
256
|
+
input: true,
|
|
257
|
+
placeholder: '这一行里大概是什么(交付清单会透出给 agent)',
|
|
258
|
+
value: item.note || '',
|
|
259
|
+
okText: '保存说明',
|
|
260
|
+
}) as string | { value?: string; note?: string } | null;
|
|
261
|
+
if (res === null) return;
|
|
262
|
+
const note = typeof res === 'string' ? res : (res && (res.value || res.note)) || '';
|
|
263
|
+
const path = host === 'doc'
|
|
264
|
+
? `/api/docs/attach-note?ref=${encodeURIComponent(String(refId || ''))}`
|
|
265
|
+
: '/api/localtasks/attach-note';
|
|
266
|
+
const body = host === 'doc'
|
|
267
|
+
? { attachment: item.id, note }
|
|
268
|
+
: { id: Number(hostId), ...(hostKey ? { key: hostKey } : hostCwd ? { cwd: hostCwd } : {}), attachment: item.id, note };
|
|
269
|
+
await api(path, { method: 'PATCH', body });
|
|
270
|
+
toast(note ? `已保存说明:${note}` : '已清空说明');
|
|
271
|
+
await load();
|
|
272
|
+
onChanged?.();
|
|
273
|
+
} catch (e) {
|
|
274
|
+
toast(`改说明失败:${(e as Error).message || e}`);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// #168:换指向——重新打开「添加附件」弹窗(只选文档),提交后把旧绑定换掉
|
|
279
|
+
const startReplace = (item: NormalizedAttachment | null) => {
|
|
280
|
+
if (!item) return;
|
|
281
|
+
setReplaceOf(item);
|
|
282
|
+
setModalOpen(true);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const doRemove = async (purge: boolean) => {
|
|
286
|
+
const item = removeOf;
|
|
287
|
+
if (!item) return;
|
|
288
|
+
setRemoving(true);
|
|
289
|
+
try {
|
|
290
|
+
await ep.detach(item.id, !!purge);
|
|
291
|
+
setRemoveOf(null);
|
|
292
|
+
toast(purge ? `已移除并删除资源:${item.name}` : `已解除关联:${item.name}`);
|
|
293
|
+
await load();
|
|
294
|
+
onChanged?.();
|
|
295
|
+
} catch (e) {
|
|
296
|
+
toast(`移除失败:${(e as Error).message || e}`);
|
|
297
|
+
} finally {
|
|
298
|
+
setRemoving(false);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const emptyAll = !loading && !error && !list.length;
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<div
|
|
306
|
+
className={`att-area${disabled ? ' is-disabled' : ''}`}
|
|
307
|
+
// 拖放落点是**整个附件区**:空态提示写着「拖文件到这里」,落点只盖头部
|
|
308
|
+
// 一条的话提示区反而是空的(md/pdf 等文件拖上去落空,触发浏览器默认打开文件)。
|
|
309
|
+
onDragOver={(e) => {
|
|
310
|
+
if (disabled || ![...(e.dataTransfer?.types || [])].includes('Files')) return;
|
|
311
|
+
e.preventDefault();
|
|
312
|
+
setDragOver(true);
|
|
313
|
+
}}
|
|
314
|
+
onDragLeave={(e) => {
|
|
315
|
+
// DOM 事件边界:relatedTarget 声明为 EventTarget,contains 需要 Node
|
|
316
|
+
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setDragOver(false);
|
|
317
|
+
}}
|
|
318
|
+
onDrop={(e) => {
|
|
319
|
+
setDragOver(false);
|
|
320
|
+
if (disabled || ![...(e.dataTransfer?.types || [])].includes('Files')) return;
|
|
321
|
+
e.preventDefault();
|
|
322
|
+
dropFiles(null, e);
|
|
323
|
+
}}
|
|
324
|
+
>
|
|
325
|
+
{/* 「改说明」用的输入弹窗挂在这里(#168) */}
|
|
326
|
+
{dialogNode}
|
|
327
|
+
<div className={'att-area-head' + (dragOver && !disabled ? ' is-over' : '')}>
|
|
328
|
+
<span className="att-area-title">
|
|
329
|
+
附件
|
|
330
|
+
{list.length ? <span className="att-count">{list.length}</span> : null}
|
|
331
|
+
{dropping ? <span className="att-area-note">上传中…</span> : null}
|
|
332
|
+
</span>
|
|
333
|
+
<span className="att-area-acts">
|
|
334
|
+
{list.length ? (
|
|
335
|
+
<select
|
|
336
|
+
className="att-sort"
|
|
337
|
+
value={sortBy}
|
|
338
|
+
// DOM 边界:<option> 的 value 就是 SortBy 之一
|
|
339
|
+
onChange={(e) => setSortBy(e.target.value as SortBy)}
|
|
340
|
+
aria-label="附件排序"
|
|
341
|
+
>
|
|
342
|
+
<option value="position">按添加顺序</option>
|
|
343
|
+
<option value="name">按名称</option>
|
|
344
|
+
<option value="kind">按类型</option>
|
|
345
|
+
</select>
|
|
346
|
+
) : null}
|
|
347
|
+
<button type="button" className="btn ghost att-add-btn" disabled={disabled} onClick={() => setModalOpen(true)}>
|
|
348
|
+
添加附件
|
|
349
|
+
</button>
|
|
350
|
+
</span>
|
|
351
|
+
</div>
|
|
352
|
+
|
|
353
|
+
{disabled ? <div className="att-empty">{disabledText}</div> : null}
|
|
354
|
+
{loading ? <div className="att-empty">加载附件…</div> : null}
|
|
355
|
+
{error ? <div className="att-empty att-err-text">附件加载失败:{error}</div> : null}
|
|
356
|
+
{emptyAll ? (
|
|
357
|
+
<div className="att-empty">还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。</div>
|
|
358
|
+
) : null}
|
|
359
|
+
|
|
360
|
+
{inline.length ? (
|
|
361
|
+
<div className="att-section">
|
|
362
|
+
<div className="att-section-head">{AREA_LABEL.inline}<span className="att-section-hint">正文里的引用,删正文行会跟着消失</span></div>
|
|
363
|
+
{inline.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
|
|
364
|
+
</div>
|
|
365
|
+
) : null}
|
|
366
|
+
|
|
367
|
+
{area.length ? (
|
|
368
|
+
<div className="att-section">
|
|
369
|
+
<div className="att-section-head">{AREA_LABEL.area}<span className="att-section-hint">不依赖正文,删正文行也不会丢</span></div>
|
|
370
|
+
{area.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
|
|
371
|
+
</div>
|
|
372
|
+
) : null}
|
|
373
|
+
|
|
374
|
+
<AttachModal
|
|
375
|
+
open={modalOpen}
|
|
376
|
+
host={host}
|
|
377
|
+
hostId={hostId}
|
|
378
|
+
hostKey={hostKey}
|
|
379
|
+
hostCwd={hostCwd}
|
|
380
|
+
refId={refId}
|
|
381
|
+
allow={allow}
|
|
382
|
+
taskOptions={taskOptions}
|
|
383
|
+
docOptions={docOptions}
|
|
384
|
+
replaceAttachment={replaceOf ? replaceOf.id : null}
|
|
385
|
+
replaceNote={replaceOf ? replaceOf.note || '' : ''}
|
|
386
|
+
onClose={() => { setModalOpen(false); setReplaceOf(null); }}
|
|
387
|
+
onDone={async () => { setReplaceOf(null); await load(); onChanged?.(); }}
|
|
388
|
+
/>
|
|
389
|
+
|
|
390
|
+
{removeOf ? (
|
|
391
|
+
<ModalBox
|
|
392
|
+
title="移除附件"
|
|
393
|
+
size="sm"
|
|
394
|
+
busy={removing}
|
|
395
|
+
onClose={removing ? undefined : () => setRemoveOf(null)}
|
|
396
|
+
footer={
|
|
397
|
+
<div className="att-foot">
|
|
398
|
+
<button type="button" className="btn ghost" disabled={removing} onClick={() => setRemoveOf(null)}>取消</button>
|
|
399
|
+
<button type="button" className="btn" disabled={removing} onClick={() => doRemove(false)}>只解除关联</button>
|
|
400
|
+
<button type="button" className="btn danger" disabled={removing} onClick={() => doRemove(true)}>
|
|
401
|
+
{removeOf.kind === 'file' ? '连文件一起删' : '连资源一起删'}
|
|
402
|
+
</button>
|
|
403
|
+
</div>
|
|
404
|
+
}
|
|
405
|
+
>
|
|
406
|
+
<div className="att-confirm">
|
|
407
|
+
<div className="att-confirm-name">{removeOf.name}</div>
|
|
408
|
+
<div className="att-confirm-text">
|
|
409
|
+
只解除关联:从这份{host === 'task' ? '任务' : '文档'}的附件清单里移除,资源仍留在孤儿池,可被重新挂载。
|
|
410
|
+
连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。
|
|
411
|
+
</div>
|
|
412
|
+
</div>
|
|
413
|
+
</ModalBox>
|
|
414
|
+
) : null}
|
|
415
|
+
|
|
416
|
+
{preview ? (
|
|
417
|
+
<div className="att-lightbox" role="dialog" aria-label="图片预览" onMouseDown={(e) => { if (e.target === e.currentTarget) setPreview(null); }}>
|
|
418
|
+
<div className="att-lightbox-card">
|
|
419
|
+
<div className="att-lightbox-head">
|
|
420
|
+
<span className="att-lightbox-name">{preview.name}</span>
|
|
421
|
+
<a className="att-lightbox-open" href={preview.src} target="_blank" rel="noreferrer">新窗口打开</a>
|
|
422
|
+
<button type="button" className="pp-x" aria-label="关闭" onClick={() => setPreview(null)}>×</button>
|
|
423
|
+
</div>
|
|
424
|
+
<img className="att-lightbox-img" src={preview.src} alt={preview.name} />
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
) : null}
|
|
428
|
+
</div>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Icon } from '../icons.jsx';
|
|
2
|
+
import type { Attachment } from './attach-common.js';
|
|
3
|
+
|
|
4
|
+
/** 附件列表(添加入口在工具区,此处只展示/移除) */
|
|
5
|
+
interface AttachBarProps {
|
|
6
|
+
attachments?: Attachment[];
|
|
7
|
+
onRemove: (id: Attachment['id']) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function AttachBar({ attachments, onRemove }: AttachBarProps) {
|
|
11
|
+
if (!attachments?.length) return null;
|
|
12
|
+
return (
|
|
13
|
+
<div className="mdw-attach">
|
|
14
|
+
<div className="lab">附件 / 图片</div>
|
|
15
|
+
<div className="list">
|
|
16
|
+
{attachments.map((a) => (
|
|
17
|
+
<div className="att" key={a.id}>
|
|
18
|
+
{a.type === 'image' && a.url
|
|
19
|
+
? <img src={a.url} alt="" />
|
|
20
|
+
: <div className="ico">{/* icons 仍是 JS:title 被推成必填,显式 undefined 不影响渲染 */}<Icon name="list" size={14} title={undefined} /></div>}
|
|
21
|
+
<div className="meta">
|
|
22
|
+
<div className="n">{a.name}</div>
|
|
23
|
+
<div className="s">{a.size}</div>
|
|
24
|
+
</div>
|
|
25
|
+
<button type="button" className="x" aria-label="移除" onClick={() => onRemove(a.id)}>×</button>
|
|
26
|
+
</div>
|
|
27
|
+
))}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// 任务/文档共用的附件口径:归一化、展示标签、接口地址。
|
|
2
|
+
//
|
|
3
|
+
// 前端**不拼正文**:所有写入都走 `localtask attach` / `docs attach` 的
|
|
4
|
+
// `--no-embed` 路径(attachments + task_attach/ref_attach),正文由编辑器自己管。
|
|
5
|
+
import { api } from '../../api/client.js';
|
|
6
|
+
|
|
7
|
+
/** 附件分区:正文内嵌(role=inline)/ 附件区(role=attach|doc)。 */
|
|
8
|
+
export type AttachAreaKind = 'area' | 'inline';
|
|
9
|
+
|
|
10
|
+
/** 附件宿主(任务侧走 localtask.attach,文档侧走 docs.attach)。 */
|
|
11
|
+
export type AttachHostKind = 'task' | 'doc';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 一条附件:服务端两类清单(task_attach / ref_attach)与本地草稿条目共用。
|
|
15
|
+
*
|
|
16
|
+
* 按索引签名放行——这是**外部数据边界**:任务侧、文档侧字段不同,本地草稿
|
|
17
|
+
* 又是第三套(type/size/url),这里只声明各消费点真的读到的字段。
|
|
18
|
+
*/
|
|
19
|
+
export interface Attachment {
|
|
20
|
+
[k: string]: any;
|
|
21
|
+
id?: string | number;
|
|
22
|
+
name?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
kind?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
role?: string;
|
|
27
|
+
badge?: string;
|
|
28
|
+
kindLabel?: string;
|
|
29
|
+
size?: number | string;
|
|
30
|
+
sizeText?: string | number;
|
|
31
|
+
areaLabel?: string;
|
|
32
|
+
area?: AttachAreaKind;
|
|
33
|
+
/** 地址:文件/链接条目用;老数据可能是 `{ href }` 形态(normAttachment 收口) */
|
|
34
|
+
url?: any;
|
|
35
|
+
href?: string;
|
|
36
|
+
mime?: string;
|
|
37
|
+
isImage?: boolean;
|
|
38
|
+
locator?: string;
|
|
39
|
+
relPath?: string;
|
|
40
|
+
refId?: string;
|
|
41
|
+
taskId?: string | number;
|
|
42
|
+
topicKey?: string;
|
|
43
|
+
seq?: number;
|
|
44
|
+
targetSeq?: number | null;
|
|
45
|
+
targetKey?: string;
|
|
46
|
+
targetRef?: string;
|
|
47
|
+
note?: string;
|
|
48
|
+
position?: number;
|
|
49
|
+
meta?: Record<string, any>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 归一化后的展示形状:各字段已收口成一套(服务端字段差异见 normAttachment)。 */
|
|
53
|
+
export interface NormalizedAttachment extends Attachment {
|
|
54
|
+
role: string;
|
|
55
|
+
area: AttachAreaKind;
|
|
56
|
+
areaLabel: string;
|
|
57
|
+
sizeText: string;
|
|
58
|
+
href: string;
|
|
59
|
+
targetSeq: number | null;
|
|
60
|
+
targetKey: string;
|
|
61
|
+
targetRef: string;
|
|
62
|
+
locator: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 附件清单接口的出站形状(任务侧 / 文档侧同形)。 */
|
|
66
|
+
export interface AttachListData {
|
|
67
|
+
attachments?: Attachment[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 查询附件清单 / 增删绑定的取数描述(attach-common.endpointOf 的入参)。 */
|
|
71
|
+
export interface AttachHostRef {
|
|
72
|
+
hostId?: string | number;
|
|
73
|
+
hostKey?: string;
|
|
74
|
+
hostCwd?: string;
|
|
75
|
+
refId?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 一类来源的可用性(「添加附件」弹窗按它决定显示哪几块)。 */
|
|
79
|
+
export interface AttachAllow {
|
|
80
|
+
file: boolean;
|
|
81
|
+
url: boolean;
|
|
82
|
+
task: boolean;
|
|
83
|
+
ref: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 可关联的任务(本主题内):只用到编号与标题/正文首行。 */
|
|
87
|
+
export interface TaskOption {
|
|
88
|
+
id: string | number;
|
|
89
|
+
text?: string;
|
|
90
|
+
title?: string;
|
|
91
|
+
status?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** 可关联的文档(ref):弹窗自己拉一份,或由宿主传入。 */
|
|
95
|
+
export interface DocOption {
|
|
96
|
+
ref: string;
|
|
97
|
+
title?: string;
|
|
98
|
+
rel?: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 端点三件套:清单 / 挂载 / 解除。 */
|
|
103
|
+
export interface AttachEndpoint {
|
|
104
|
+
list: () => Promise<AttachListData>;
|
|
105
|
+
attach: (body: Record<string, any>) => Promise<any>;
|
|
106
|
+
detach: (attachment: string | number | undefined, purge: boolean) => Promise<any>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 待确认条目 → attach 请求体的最小形状(attachBodyOf 的入参)。 */
|
|
110
|
+
export interface AttachDraftItem {
|
|
111
|
+
source: string;
|
|
112
|
+
fileId?: string | null;
|
|
113
|
+
name?: string;
|
|
114
|
+
url?: string;
|
|
115
|
+
seq?: number | string;
|
|
116
|
+
docRef?: string;
|
|
117
|
+
note?: string;
|
|
118
|
+
inline?: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const AREA_LABEL: Record<AttachAreaKind, string> = { inline: '正文内嵌', area: '附件区' };
|
|
122
|
+
export const AREA_OF = (role: string): AttachAreaKind => (role === 'attach' || role === 'doc' ? 'area' : 'inline');
|
|
123
|
+
|
|
124
|
+
const IMG_EXT = /\.(png|jpe?g|gif|webp|bmp|svg)$/i;
|
|
125
|
+
|
|
126
|
+
export function fmtSize(n: number | string | null | undefined) {
|
|
127
|
+
const v = Number(n) || 0;
|
|
128
|
+
if (!v) return '';
|
|
129
|
+
if (v < 1024) return `${v} B`;
|
|
130
|
+
if (v < 1024 * 1024) return `${(v / 1024).toFixed(0)} KB`;
|
|
131
|
+
return `${(v / 1024 / 1024).toFixed(1)} MB`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function contentUrl(id: unknown) {
|
|
135
|
+
return `/api/file/content/${encodeURIComponent(String(id))}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** 决策文档 locator(后端存的是裸路径)→ 面板 docId(rel: / path:)。 */
|
|
139
|
+
export function docIdOfLocator(locator: unknown) {
|
|
140
|
+
const s = String(locator || '').replace(/\\/g, '/');
|
|
141
|
+
if (/^(rel|path):/.test(s)) return s;
|
|
142
|
+
if (/^\/|[A-Za-z]:\//.test(s)) return `path:${s}`;
|
|
143
|
+
return s ? `rel:${s}` : '';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** 统一展示形状:服务端两类清单字段不同,这里收口成一套。 */
|
|
147
|
+
export function normAttachment(a: Attachment): NormalizedAttachment {
|
|
148
|
+
const role = String(a.role || 'inline');
|
|
149
|
+
const isImage =
|
|
150
|
+
a.kind === 'file' &&
|
|
151
|
+
(a.isImage === true || /^image\//i.test(a.mime || '') || IMG_EXT.test(a.name || ''));
|
|
152
|
+
const urlText: string = typeof a.url === 'string' ? a.url : a.url && a.url.href ? String(a.url.href) : '';
|
|
153
|
+
return {
|
|
154
|
+
...a,
|
|
155
|
+
role,
|
|
156
|
+
area: AREA_OF(role),
|
|
157
|
+
areaLabel: AREA_LABEL[AREA_OF(role)],
|
|
158
|
+
kind: a.kind === 'file' && isImage ? 'image' : a.kind,
|
|
159
|
+
sizeText: fmtSize(a.size),
|
|
160
|
+
href: a.kind === 'file' ? contentUrl(a.id) : a.href || urlText,
|
|
161
|
+
targetSeq: a.targetSeq ?? (a.meta && a.meta.seq) ?? null,
|
|
162
|
+
targetKey: a.targetKey || (a.meta && a.meta.topicKey) || '',
|
|
163
|
+
targetRef: a.targetKey || (a.meta && a.meta.refId) || '',
|
|
164
|
+
locator: a.locator || a.relPath || (a.meta && a.meta.locator) || '',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const KIND_BADGE: Record<string, string> = { image: '图片', file: '文件', url: '链接', task: '任务', ref: '文档' };
|
|
169
|
+
export const badgeOf = (kind: string | undefined) => KIND_BADGE[kind || ''] || '附件';
|
|
170
|
+
|
|
171
|
+
/** 任务侧/文档侧的列表与关系接口(同一套字段,只换 URL)。 */
|
|
172
|
+
export function endpointOf(host: AttachHostKind | undefined, { hostId, hostKey, hostCwd, refId }: AttachHostRef): AttachEndpoint {
|
|
173
|
+
if (host === 'task') {
|
|
174
|
+
// 任务定位二选一:全局池用 key,代码目录用 cwd(后端 getTask 两种都认)。
|
|
175
|
+
const where: { key?: string; cwd?: string } = hostKey ? { key: hostKey } : hostCwd ? { cwd: hostCwd } : {};
|
|
176
|
+
const q = new URLSearchParams({ id: String(hostId) });
|
|
177
|
+
if (hostKey) q.set('key', hostKey);
|
|
178
|
+
else if (hostCwd) q.set('cwd', hostCwd);
|
|
179
|
+
return {
|
|
180
|
+
list: () => api<AttachListData>(`/api/localtasks/attachments?${q.toString()}`),
|
|
181
|
+
attach: (body) => api('/api/localtasks/attach', {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
body: { id: Number(hostId), ...where, ...body, noEmbed: true },
|
|
184
|
+
}),
|
|
185
|
+
detach: (attachment, purge) => api('/api/localtasks/attach', {
|
|
186
|
+
method: 'DELETE',
|
|
187
|
+
body: { id: Number(hostId), ...where, attachment, purge },
|
|
188
|
+
}),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const q = new URLSearchParams({ ref: String(refId || '') });
|
|
192
|
+
return {
|
|
193
|
+
list: () => api<AttachListData>(`/api/docs/attachments?${q.toString()}`),
|
|
194
|
+
attach: (body) => api('/api/docs/attach', { method: 'POST', body: { ref: refId, ...body, noEmbed: true } }),
|
|
195
|
+
detach: (attachment, purge) => api('/api/docs/attach', {
|
|
196
|
+
method: 'DELETE',
|
|
197
|
+
body: { ref: refId, attachment, purge },
|
|
198
|
+
}),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** 待确认条目 → attach 请求体(文件先上传拿到 fileId)。
|
|
203
|
+
*
|
|
204
|
+
* 文档来源的**字段名按宿主分**(#165 二轮):任务侧 action 收 `ref`
|
|
205
|
+
* (localtask.attach),文档侧收 `doc`(docs.attach)——之前两侧都发 `doc`,
|
|
206
|
+
* 面板「给任务挂文档」必然失败(未知键透传,attachToTask 收不到 ref)。
|
|
207
|
+
* `note`(绑定说明 / desc)与 `inline`(文档进原文,#162)随条目透传。
|
|
208
|
+
*/
|
|
209
|
+
export function attachBodyOf(item: AttachDraftItem, host: AttachHostKind = 'task'): Record<string, any> {
|
|
210
|
+
if (item.source === 'file') return { fileId: item.fileId, name: item.name };
|
|
211
|
+
if (item.source === 'url') return { url: item.url, name: item.name };
|
|
212
|
+
if (item.source === 'task') return { task: String(item.seq), name: item.name };
|
|
213
|
+
if (item.source === 'ref') {
|
|
214
|
+
const body: Record<string, any> = host === 'doc'
|
|
215
|
+
? { doc: item.docRef, name: item.name }
|
|
216
|
+
: { ref: item.docRef, name: item.name };
|
|
217
|
+
if (item.note) body.note = item.note;
|
|
218
|
+
if (host !== 'doc' && item.inline) body.inline = true;
|
|
219
|
+
return body;
|
|
220
|
+
}
|
|
221
|
+
return {};
|
|
222
|
+
}
|