@north-light/crouter 0.3.197 → 0.3.199
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 +19 -19
- package/dist/api/client.js +29 -37
- package/dist/api/dto/broker-ops.d.ts +3 -1
- package/dist/api/dto/broker.d.ts +13 -2
- package/dist/api/dto/broker.js +4 -4
- package/dist/api/dto/human.d.ts +6 -5
- package/dist/api/dto/inbox.d.ts +126 -33
- package/dist/api/dto/nodes.d.ts +8 -2
- package/dist/api/dto/profiles.d.ts +23 -0
- package/dist/api/dto/profiles.js +2 -2
- package/dist/api/dto/worktree.d.ts +3 -5
- package/dist/api/routes.d.ts +3 -5
- package/dist/api/routes.js +4 -6
- package/dist/builtin-memory/00-runtime-base.md +8 -8
- package/dist/builtin-memory/01-spine/01-no-manager.md +1 -1
- package/dist/builtin-memory/02-lifecycle/00-terminal.md +3 -3
- package/dist/builtin-memory/04-orchestration-kernel.md +6 -6
- package/dist/builtin-memory/05-kinds/design/00-base.md +1 -1
- package/dist/builtin-memory/05-kinds/plan/reviewers/security.md +2 -2
- package/dist/builtin-memory/05-kinds/review/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/review/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/spec/01-orchestrator.md +1 -1
- package/dist/builtin-memory/insights/capture.md +2 -2
- package/dist/builtin-memory/insights/init.md +3 -3
- package/dist/builtin-memory/internal/INDEX.md +1 -1
- package/dist/builtin-memory/internal/memory-loading.md +1 -1
- package/dist/builtin-memory/internal/nodes-and-canvas.md +3 -3
- package/dist/builtin-memory/internal/plugins.md +59 -2
- package/dist/builtin-memory/internal/storage-tiers.md +3 -1
- package/dist/builtin-memory/spec/roadmap.md +2 -2
- package/dist/builtin-memory/testing.md +1 -1
- package/dist/builtin-memory/wedged-child-on-runaway-bash.md +1 -1
- package/dist/clients/attach/chrome/bash-jobs.js +3 -3
- package/dist/clients/attach/render/chat-view.d.ts +29 -9
- package/dist/clients/attach/render/chat-view.js +64 -35
- package/dist/clients/attach/render/markdown-source.js +0 -6
- package/dist/clients/attach/render/page-block.d.ts +34 -0
- package/dist/clients/attach/render/page-block.js +226 -0
- package/dist/clients/attach/render/tool-calls.js +16 -2
- package/dist/clients/attach/session/whip.d.ts +2 -0
- package/dist/clients/attach/session/whip.js +2 -0
- package/dist/clients/attach/viewer.js +1419 -982
- package/dist/clients/conversation/projection.js +18 -3
- package/dist/clients/inbox/__tests__/serial/inbox-controller.test.js +9 -6
- package/dist/clients/inbox/__tests__/serial/mount-panel.test.js +13 -14
- package/dist/clients/inbox/controller.js +10 -16
- package/dist/clients/inbox/page-adapter.d.ts +3 -4
- package/dist/clients/inbox/page-adapter.js +3 -4
- package/dist/clients/inbox/resolve.d.ts +1 -1
- package/dist/clients/inbox/resolve.js +3 -3
- package/dist/clients/inbox/review/document-surface.js +3 -1
- package/dist/clients/inbox/review/state.d.ts +2 -1
- package/dist/clients/inbox/review/state.js +5 -16
- package/dist/clients/inbox/tui/input.js +37 -19
- package/dist/clients/inbox/tui/panel.js +5 -31
- package/dist/clients/inbox/tui/render.d.ts +11 -0
- package/dist/clients/inbox/tui/render.js +101 -36
- package/dist/clients/inbox/tui/slots.d.ts +4 -4
- package/dist/clients/inbox/tui/slots.js +19 -44
- package/dist/clients/inbox/tui/types.d.ts +6 -10
- package/dist/clients/inbox/tui.js +2 -2
- package/dist/commands/__tests__/human.test.js +118 -24
- package/dist/commands/__tests__/node-message.test.js +14 -0
- package/dist/commands/attention.js +4 -4
- package/dist/commands/canvas-browse.js +1 -1
- package/dist/commands/canvas-snapshot.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/human/{doc.d.ts → components.d.ts} +1 -1
- package/dist/commands/human/components.js +77 -0
- package/dist/commands/human/feedback.d.ts +2 -0
- package/dist/commands/human/feedback.js +108 -0
- package/dist/commands/human/prompts.d.ts +17 -8
- package/dist/commands/human/prompts.js +217 -226
- package/dist/commands/human/queue.js +57 -88
- package/dist/commands/human/shared.d.ts +4 -15
- package/dist/commands/human/shared.js +19 -61
- package/dist/commands/human.js +32 -19
- package/dist/commands/memory/origin.js +2 -2
- package/dist/commands/node/bash.js +4 -4
- package/dist/commands/node/inspect.js +3 -3
- package/dist/commands/node/lifecycle.js +1 -1
- package/dist/commands/node/message.js +2 -2
- package/dist/commands/node-worktree.js +8 -8
- package/dist/commands/pkg/browse.js +1 -1
- package/dist/commands/pkg/plugin-manage.js +129 -10
- package/dist/commands/profile/delete.js +41 -15
- package/dist/commands/profile.js +1 -1
- package/dist/commands/push.js +1 -1
- package/dist/commands/surface/node/focus.js +29 -14
- package/dist/commands/surface-edit.js +3 -3
- package/dist/commands/surface-inbox.d.ts +2 -0
- package/dist/commands/{human/inbox.js → surface-inbox.js} +14 -18
- package/dist/commands/surface.js +2 -1
- package/dist/commands/sys/doctor.js +60 -3
- package/dist/commands/sys/feedback.js +79 -25
- package/dist/commands/sys/settings.js +1 -1
- package/dist/core/__tests__/cron-broker-capacity.test.js +1 -1
- package/dist/core/__tests__/daemon-boot.test.js +7 -4
- package/dist/core/__tests__/dead-node-policy-table.test.js +20 -36
- package/dist/core/__tests__/extension-abort.test.js +5 -2
- package/dist/core/__tests__/fixtures/fake-engine.d.ts +13 -2
- package/dist/core/__tests__/fixtures/fake-engine.js +47 -3
- package/dist/core/__tests__/human-cancel-guard.test.js +31 -10
- package/dist/core/__tests__/human-deliver.test.js +41 -45
- package/dist/core/__tests__/human-node-not-supervised.test.js +1 -1
- package/dist/core/__tests__/plugin-page-components.test.js +157 -0
- package/dist/core/__tests__/seam/broker-crash-teardown.test.js +13 -11
- package/dist/core/__tests__/seam/dormancy-release.test.js +103 -4
- package/dist/core/__tests__/serial/flagship-lifecycle.test.js +2 -2
- package/dist/core/__tests__/serial/human-deliver-e2e.test.js +12 -16
- package/dist/core/__tests__/serial/live-mutation.test.js +1 -1
- package/dist/core/__tests__/serial/tmux-surface.test.js +4 -2
- package/dist/core/__tests__/serial/worktree.test.js +24 -198
- package/dist/core/__tests__/session-cycles.test.js +22 -0
- package/dist/core/__tests__/stop-guard.test.js +4 -4
- package/dist/core/__tests__/watchdog-abort-arms-retry.test.js +19 -4
- package/dist/core/bash-jobs.d.ts +6 -0
- package/dist/core/bash-jobs.js +10 -0
- package/dist/core/canvas/__tests__/attention.test.js +8 -5
- package/dist/core/canvas/__tests__/render-remote.test.js +5 -5
- package/dist/core/canvas/attention.js +8 -6
- package/dist/core/canvas/browse/app.d.ts +1 -1
- package/dist/core/canvas/browse/app.js +21 -3
- package/dist/core/canvas/browse/model.d.ts +8 -2
- package/dist/core/canvas/browse/model.js +11 -4
- package/dist/core/canvas/browse/render.d.ts +4 -0
- package/dist/core/canvas/browse/render.js +5 -1
- package/dist/core/canvas/canvas.d.ts +33 -0
- package/dist/core/canvas/canvas.js +92 -0
- package/dist/core/canvas/crons.d.ts +9 -0
- package/dist/core/canvas/crons.js +51 -0
- package/dist/core/canvas/node-order.d.ts +22 -1
- package/dist/core/canvas/node-order.js +26 -1
- package/dist/core/canvas/render-source.d.ts +5 -0
- package/dist/core/canvas/render-source.js +1 -0
- package/dist/core/canvas/types.d.ts +9 -3
- package/dist/core/command-plugins/bundle.d.ts +6 -1
- package/dist/core/command-plugins/bundle.js +26 -13
- package/dist/core/command.js +8 -12
- package/dist/core/config.d.ts +47 -1
- package/dist/core/config.js +138 -4
- package/dist/core/help.d.ts +3 -0
- package/dist/core/help.js +1 -1
- package/dist/core/human/__tests__/page-catalog.test.d.ts +1 -0
- package/dist/core/human/__tests__/page-catalog.test.js +20 -0
- package/dist/core/human/__tests__/page-tickets.test.js +68 -34
- package/dist/core/human/__tests__/page.test.js +60 -119
- package/dist/core/human/__tests__/serial/inbox-core.test.js +6 -16
- package/dist/core/human/answer-text.d.ts +3 -0
- package/dist/core/human/answer-text.js +98 -0
- package/dist/core/human/answer.d.ts +53 -0
- package/dist/core/human/answer.js +119 -0
- package/dist/core/human/component-docs.d.ts +18 -0
- package/dist/core/human/component-docs.js +434 -0
- package/dist/core/human/convention.d.ts +17 -3
- package/dist/core/human/convention.js +36 -5
- package/dist/core/human/feedback-companion.d.ts +20 -0
- package/dist/core/human/feedback-companion.js +98 -0
- package/dist/core/human/feedback.d.ts +65 -0
- package/dist/core/human/feedback.js +116 -0
- package/dist/core/human/page-catalog.d.ts +56 -5
- package/dist/core/human/page-catalog.js +151 -22
- package/dist/core/human/page-errors.d.ts +4 -0
- package/dist/core/human/page-errors.js +7 -0
- package/dist/core/human/page-eval.d.ts +20 -0
- package/dist/core/human/page-eval.js +123 -0
- package/dist/core/human/page-schema.d.ts +48 -116
- package/dist/core/human/page-schema.js +100 -72
- package/dist/core/human/page-synth.d.ts +2 -4
- package/dist/core/human/page-synth.js +20 -7
- package/dist/core/human/page.d.ts +13 -21
- package/dist/core/human/page.js +147 -391
- package/dist/core/human/review-schema.d.ts +1 -0
- package/dist/core/human/review-schema.js +1 -1
- package/dist/core/human/root.d.ts +6 -2
- package/dist/core/human/root.js +12 -4
- package/dist/core/human/scan.d.ts +3 -3
- package/dist/core/human/scan.js +21 -21
- package/dist/core/human/summary.d.ts +2 -6
- package/dist/core/human/summary.js +3 -59
- package/dist/core/human/tickets.d.ts +22 -15
- package/dist/core/human/tickets.js +90 -28
- package/dist/core/human/types.d.ts +14 -2
- package/dist/core/keybindings/catalog.d.ts +2 -2
- package/dist/core/keybindings/catalog.js +1 -0
- package/dist/core/preview-registry.js +8 -10
- package/dist/core/profiles/default-binding.d.ts +4 -0
- package/dist/core/profiles/default-binding.js +24 -0
- package/dist/core/profiles/deletion-reservation.d.ts +8 -0
- package/dist/core/profiles/deletion-reservation.js +38 -0
- package/dist/core/profiles/manifest.d.ts +3 -0
- package/dist/core/profiles/manifest.js +12 -0
- package/dist/core/profiles/select.js +2 -2
- package/dist/core/review/realize.js +12 -4
- package/dist/core/review/store.d.ts +6 -0
- package/dist/core/review/store.js +31 -0
- package/dist/core/runtime/bearings.d.ts +0 -4
- package/dist/core/runtime/bearings.js +4 -62
- package/dist/core/runtime/bin-contributions.d.ts +44 -0
- package/dist/core/runtime/bin-contributions.js +186 -0
- package/dist/core/runtime/boot-root.js +6 -1
- package/dist/core/runtime/broker/client-registry.d.ts +4 -0
- package/dist/core/runtime/broker/client-registry.js +13 -1
- package/dist/core/runtime/broker/extension-abort.d.ts +1 -1
- package/dist/core/runtime/broker/extension-abort.js +4 -2
- package/dist/core/runtime/broker/fault-retry.js +4 -0
- package/dist/core/runtime/broker/frame-dispatch.d.ts +3 -1
- package/dist/core/runtime/broker/frame-dispatch.js +5 -6
- package/dist/core/runtime/broker/read-ops.d.ts +1 -1
- package/dist/core/runtime/broker/read-ops.js +2 -2
- package/dist/core/runtime/broker/rebind.d.ts +1 -0
- package/dist/core/runtime/broker/rebind.js +6 -1
- package/dist/core/runtime/broker-extension-render.js +19 -0
- package/dist/core/runtime/broker-protocol.d.ts +14 -0
- package/dist/core/runtime/broker.d.ts +1 -1
- package/dist/core/runtime/broker.js +25 -12
- package/dist/core/runtime/busy.d.ts +4 -3
- package/dist/core/runtime/busy.js +4 -3
- package/dist/core/runtime/front-door-env.d.ts +5 -0
- package/dist/core/runtime/front-door-env.js +16 -0
- package/dist/core/runtime/front-door.d.ts +1 -5
- package/dist/core/runtime/front-door.js +2 -5
- package/dist/core/runtime/host.d.ts +1 -1
- package/dist/core/runtime/invocation.d.ts +6 -0
- package/dist/core/runtime/invocation.js +10 -0
- package/dist/core/runtime/kickoff.js +34 -0
- package/dist/core/runtime/launch.d.ts +2 -6
- package/dist/core/runtime/node-read.js +4 -1
- package/dist/core/runtime/nodes.js +2 -0
- package/dist/core/runtime/promote.d.ts +1 -0
- package/dist/core/runtime/promote.js +3 -1
- package/dist/core/runtime/session-cycles.d.ts +6 -0
- package/dist/core/runtime/session-cycles.js +15 -1
- package/dist/core/runtime/session-visibility.d.ts +17 -8
- package/dist/core/runtime/session-visibility.js +19 -10
- package/dist/core/runtime/spawn-env.d.ts +9 -1
- package/dist/core/runtime/spawn-env.js +62 -2
- package/dist/core/runtime/spawn.js +4 -4
- package/dist/core/runtime/stop-guard.d.ts +2 -2
- package/dist/core/runtime/stop-guard.js +2 -2
- package/dist/core/runtime/stop-signals.d.ts +1 -1
- package/dist/core/runtime/stop-signals.js +2 -2
- package/dist/core/runtime/tmux-bindings.js +1 -1
- package/dist/core/session-model/session-state.d.ts +4 -3
- package/dist/core/session-model/session-state.js +14 -1
- package/dist/core/user-settings.d.ts +36 -2
- package/dist/core/user-settings.js +56 -14
- package/dist/core/worktree.d.ts +15 -45
- package/dist/core/worktree.js +59 -261
- package/dist/daemon/api/__tests__/seam/profile-delete.test.d.ts +1 -0
- package/dist/daemon/api/__tests__/seam/profile-delete.test.js +386 -0
- package/dist/daemon/api/handlers/bash-jobs.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +9 -5
- package/dist/daemon/api/handlers/feedback-comments.d.ts +2 -0
- package/dist/daemon/api/handlers/feedback-comments.js +207 -0
- package/dist/daemon/api/handlers/human.js +24 -20
- package/dist/daemon/api/handlers/inbox.d.ts +10 -0
- package/dist/daemon/api/handlers/inbox.js +48 -109
- package/dist/daemon/api/handlers/profiles.js +11 -29
- package/dist/daemon/api/map.d.ts +6 -1
- package/dist/daemon/api/map.js +23 -0
- package/dist/daemon/api/server.js +3 -1
- package/dist/daemon/companion-retire.d.ts +2 -0
- package/dist/daemon/companion-retire.js +33 -0
- package/dist/daemon/cron-run.js +29 -17
- package/dist/daemon/crtrd.js +1 -1
- package/dist/daemon/fleet.d.ts +22 -10
- package/dist/daemon/fleet.js +43 -24
- package/dist/daemon/human/finish.d.ts +12 -6
- package/dist/daemon/human/finish.js +134 -54
- package/dist/daemon/human/sweep.js +9 -3
- package/dist/daemon/profile-delete.d.ts +7 -0
- package/dist/daemon/profile-delete.js +306 -0
- package/dist/daemon/reconcilers/broker-supervision.js +14 -9
- package/dist/daemon/reconcilers/dormant-inbox.js +11 -6
- package/dist/daemon/reconcilers/live-obligation.d.ts +21 -1
- package/dist/daemon/reconcilers/live-obligation.js +30 -2
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +5 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +28 -1
- package/dist/daemon/review/deliver.js +3 -3
- package/dist/daemon/review/finish.d.ts +0 -2
- package/dist/daemon/review/finish.js +1 -29
- package/dist/daemon/review/sweep.js +12 -1
- package/dist/pi-extensions/__tests__/canvas-bash-valve.test.js +56 -1
- package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +4 -4
- package/dist/pi-extensions/canvas-bash-valve.d.ts +9 -1
- package/dist/pi-extensions/canvas-bash-valve.js +31 -13
- package/dist/pi-extensions/canvas-inbox-watcher.js +1 -1
- package/dist/pi-extensions/canvas-review-boundary.d.ts +4 -0
- package/dist/pi-extensions/canvas-review-boundary.js +18 -9
- package/dist/pi-extensions/canvas-stophook.js +4 -4
- package/dist/shared/generated-context.js +2 -2
- package/dist/types.d.ts +61 -5
- package/dist/types.js +8 -2
- package/package.json +4 -4
- package/runtime.lock.json +5 -33
- package/scripts/install-runtime.mjs +19 -24
- package/dist/builtin-memory/init.md +0 -38
- package/dist/builtin-memory/plan.md +0 -19
- package/dist/builtin-memory/spec.md +0 -19
- package/dist/clients/attach/render/html-markdown.d.ts +0 -13
- package/dist/clients/attach/render/html-markdown.js +0 -206
- package/dist/commands/human/doc.js +0 -144
- package/dist/commands/human/inbox.d.ts +0 -2
- package/dist/core/human/__tests__/page-render.test.js +0 -49
- package/dist/core/human/markdown-html.d.ts +0 -8
- package/dist/core/human/markdown-html.js +0 -581
- package/dist/core/human/page-render.d.ts +0 -3
- package/dist/core/human/page-render.js +0 -131
- package/dist/pages/bundle.css +0 -1
- package/dist/pages/bundle.js +0 -1347
- package/dist/pages/comments.d.ts +0 -43
- package/dist/pages/comments.js +0 -125
- package/dist/pages/elements/cards.d.ts +0 -17
- package/dist/pages/elements/cards.js +0 -802
- package/dist/pages/elements/chart.js +0 -648
- package/dist/pages/elements/options.d.ts +0 -21
- package/dist/pages/elements/options.js +0 -629
- package/dist/pages/elements/pages.d.ts +0 -24
- package/dist/pages/elements/pages.js +0 -355
- package/dist/pages/elements/slot.d.ts +0 -21
- package/dist/pages/elements/slot.js +0 -105
- package/dist/pages/elements/table.d.ts +0 -19
- package/dist/pages/elements/table.js +0 -935
- package/dist/pages/elements/text.d.ts +0 -25
- package/dist/pages/elements/text.js +0 -968
- package/dist/pages/entry.d.ts +0 -8
- package/dist/pages/entry.js +0 -8
- package/dist/pages/host.d.ts +0 -158
- package/dist/pages/host.js +0 -182
- package/dist/pages/register.d.ts +0 -2
- package/dist/pages/register.js +0 -3
- package/dist/pages/slot-config.d.ts +0 -36
- package/dist/pages/slot-config.js +0 -50
- package/dist/pages/types.d.ts +0 -98
- package/dist/pages/types.js +0 -23
- /package/dist/{core/human/__tests__/page-render.test.d.ts → commands/__tests__/node-message.test.d.ts} +0 -0
- /package/dist/{pages/elements/chart.d.ts → core/__tests__/plugin-page-components.test.d.ts} +0 -0
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join, resolve } from 'node:path';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { defineBranch, defineLeaf } from '../../core/command.js';
|
|
5
|
-
import { InputError } from '../../core/io.js';
|
|
6
|
-
import { readConfig } from '../../core/config.js';
|
|
7
|
-
import { derivePageManifest } from '../../core/human/page.js';
|
|
8
|
-
import { checkMarkdown, renderMarkdown } from '../../core/termrender/termrender.js';
|
|
9
|
-
function documentSource(input, context) {
|
|
10
|
-
const path = input['path'];
|
|
11
|
-
const body = input['body'];
|
|
12
|
-
const stdinProvided = context?.providedParams.has('body') === true;
|
|
13
|
-
if (path === undefined && !stdinProvided) {
|
|
14
|
-
throw new InputError({
|
|
15
|
-
error: 'missing_parameter',
|
|
16
|
-
message: 'provide exactly one document source: PATH or stdin',
|
|
17
|
-
next: 'Run `crtr human doc check -h` or `crtr human doc render -h` and provide a path or pipe a document on stdin.',
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
if (path !== undefined && path !== '-' && stdinProvided && body.trim() !== '') {
|
|
21
|
-
throw new InputError({
|
|
22
|
-
error: 'bad_invocation',
|
|
23
|
-
message: 'both a positional path and piped stdin were provided',
|
|
24
|
-
field: 'path, body',
|
|
25
|
-
next: 'Pass exactly one document source: either PATH or piped stdin, not both.',
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (path === undefined || path === '-')
|
|
29
|
-
return { body };
|
|
30
|
-
const abs = resolve(path);
|
|
31
|
-
if (!existsSync(abs)) {
|
|
32
|
-
throw new InputError({
|
|
33
|
-
error: 'file_not_found',
|
|
34
|
-
message: `file not found: ${abs}`,
|
|
35
|
-
field: 'path',
|
|
36
|
-
next: 'Provide a path to an existing markdown or HTML file, or pipe a document on stdin.',
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return { body: readFileSync(abs, 'utf8'), path: abs };
|
|
40
|
-
}
|
|
41
|
-
function markdownSource(input, context) {
|
|
42
|
-
return documentSource(input, context).body;
|
|
43
|
-
}
|
|
44
|
-
function pageDialect(source) {
|
|
45
|
-
const extension = source.path?.toLowerCase();
|
|
46
|
-
if (extension?.endsWith('.html') || extension?.endsWith('.htm'))
|
|
47
|
-
return 'html';
|
|
48
|
-
if (/^\s*<!doctype\b/i.test(source.body) || /^\s*<html(?:\s|>)/i.test(source.body))
|
|
49
|
-
return 'html';
|
|
50
|
-
if (source.body.startsWith('---'))
|
|
51
|
-
return 'md';
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
function checkPage(source, dialect) {
|
|
55
|
-
const config = readConfig('user');
|
|
56
|
-
if (dialect === 'html' && !config.html_pages) {
|
|
57
|
-
return { ok: false, error: 'HTML page validation requires the user-scope html_pages capability flag to be enabled (html_pages is false).' };
|
|
58
|
-
}
|
|
59
|
-
let tempDir;
|
|
60
|
-
try {
|
|
61
|
-
const sourcePath = source.path ?? (() => {
|
|
62
|
-
tempDir = mkdtempSync(join(tmpdir(), 'crtr-human-doc-'));
|
|
63
|
-
const path = join(tempDir, dialect === 'html' ? 'page.html' : 'page.md');
|
|
64
|
-
writeFileSync(path, source.body, 'utf8');
|
|
65
|
-
return path;
|
|
66
|
-
})();
|
|
67
|
-
derivePageManifest(sourcePath, dialect, config.page_components);
|
|
68
|
-
return { ok: true };
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
if (tempDir !== undefined)
|
|
75
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const humanDocCheck = defineLeaf({
|
|
79
|
-
name: 'check',
|
|
80
|
-
description: 'validate a directive-flavored markdown body or page source',
|
|
81
|
-
whenToUse: 'validating a page source or review body before submitting it.',
|
|
82
|
-
help: {
|
|
83
|
-
name: 'human doc check',
|
|
84
|
-
summary: 'validate directive-flavored markdown or a page through the managed renderer and page schemas',
|
|
85
|
-
guide: 'Plain markdown is checked by the pinned renderer. A file with page front matter or an HTML document is parsed as a page; HTML page validation requires the user-scope html_pages capability flag.',
|
|
86
|
-
params: [
|
|
87
|
-
{ kind: 'positional', name: 'path', type: 'path', required: false, constraint: 'Markdown or HTML file to validate. Files ending in .html/.htm, HTML documents beginning with a doctype or <html, and markdown beginning with --- front matter are checked as pages. Provide exactly one of PATH or stdin; use - to read stdin.' },
|
|
88
|
-
{ kind: 'stdin', name: 'body', required: false, constraint: 'Markdown or HTML to validate. Provide exactly one of piped stdin or PATH.' },
|
|
89
|
-
],
|
|
90
|
-
output: [
|
|
91
|
-
{ name: 'ok', type: 'boolean', required: true, constraint: 'True when the markdown is valid.' },
|
|
92
|
-
{ name: 'error', type: 'string', required: false, constraint: 'The renderer or page-parser validation error when ok is false.' },
|
|
93
|
-
],
|
|
94
|
-
outputKind: 'object',
|
|
95
|
-
effects: ['Read-only: invokes the private managed renderer or page parser to validate the supplied document.'],
|
|
96
|
-
},
|
|
97
|
-
run: async (input, context) => {
|
|
98
|
-
const source = documentSource(input, context);
|
|
99
|
-
const dialect = pageDialect(source);
|
|
100
|
-
if (dialect !== undefined)
|
|
101
|
-
return checkPage(source, dialect);
|
|
102
|
-
return checkMarkdown(source.body);
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
const humanDocRender = defineLeaf({
|
|
106
|
-
name: 'render',
|
|
107
|
-
description: 'render a directive-flavored markdown body',
|
|
108
|
-
whenToUse: 'previewing how a page or review body renders before submitting it.',
|
|
109
|
-
help: {
|
|
110
|
-
name: 'human doc render',
|
|
111
|
-
summary: 'render directive-flavored markdown through the pinned managed renderer',
|
|
112
|
-
guide: 'The pinned renderer runs from a private managed venv and is not on PATH, so this is the only way to render a page or review body before submitting it.',
|
|
113
|
-
params: [
|
|
114
|
-
{ kind: 'positional', name: 'path', type: 'path', required: false, constraint: 'Markdown file to render. Provide exactly one of PATH or stdin; use - to read stdin.' },
|
|
115
|
-
{ kind: 'stdin', name: 'body', required: false, constraint: 'Markdown to render. Provide exactly one of piped stdin or PATH.' },
|
|
116
|
-
{ kind: 'flag', name: 'width', type: 'int', required: false, default: process.stdout.columns || 100, constraint: 'Render width in columns. Default: current stdout width, or 100.' },
|
|
117
|
-
{ kind: 'flag', name: 'color', type: 'bool', required: false, default: true, constraint: 'Emit ANSI color. Default true; false strips ANSI escape sequences.' },
|
|
118
|
-
],
|
|
119
|
-
output: [
|
|
120
|
-
{ name: 'lines', type: 'string[]', required: true, constraint: 'Rendered terminal lines in display order.' },
|
|
121
|
-
{ name: 'width', type: 'integer', required: true, constraint: 'The render width in columns.' },
|
|
122
|
-
],
|
|
123
|
-
outputKind: 'object',
|
|
124
|
-
effects: ['Read-only: invokes the private managed renderer to render the supplied body.'],
|
|
125
|
-
},
|
|
126
|
-
run: async (input, context) => {
|
|
127
|
-
const width = input['width'];
|
|
128
|
-
const color = input['color'];
|
|
129
|
-
const lines = renderMarkdown(markdownSource(input, context), width);
|
|
130
|
-
return { lines: color ? lines : lines.map((line) => line.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '')), width };
|
|
131
|
-
},
|
|
132
|
-
render: (result) => result['lines'].join('\n'),
|
|
133
|
-
});
|
|
134
|
-
export const humanDoc = defineBranch({
|
|
135
|
-
name: 'doc',
|
|
136
|
-
description: 'validate or render directive-flavored markdown bodies',
|
|
137
|
-
whenToUse: 'validating or previewing a directive-flavored markdown body before submitting it.',
|
|
138
|
-
help: {
|
|
139
|
-
name: 'human doc',
|
|
140
|
-
summary: 'validate and render directive-flavored markdown bodies',
|
|
141
|
-
model: 'Both leaves read exactly one body from a path or stdin through the private managed renderer.',
|
|
142
|
-
},
|
|
143
|
-
children: [humanDocCheck, humanDocRender],
|
|
144
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Two properties of the default page template whose absence would be SILENT —
|
|
2
|
-
// every ordinary page still renders and still looks right when either breaks.
|
|
3
|
-
// Nothing else about rendering is pinned here; prose shape is the renderer's
|
|
4
|
-
// own business and a change there is visible the moment anyone looks at a page.
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import test from 'node:test';
|
|
10
|
-
import { derivePageManifest } from '../page.js';
|
|
11
|
-
import { renderPageHtml } from '../page-render.js';
|
|
12
|
-
function render(name, source) {
|
|
13
|
-
const dir = mkdtempSync(join(tmpdir(), 'crtr-page-render-test-'));
|
|
14
|
-
try {
|
|
15
|
-
const path = join(dir, name);
|
|
16
|
-
writeFileSync(path, source);
|
|
17
|
-
return renderPageHtml(derivePageManifest(path, name.endsWith('.md') ? 'md' : 'html'), readFileSync(path, 'utf8'));
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
rmSync(dir, { recursive: true, force: true });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
test('a config value carrying script markup cannot end its own <script> element', () => {
|
|
24
|
-
const html = render('page.md', [
|
|
25
|
-
'---', 'title: Escaping', '---', '',
|
|
26
|
-
'Pick one.', '',
|
|
27
|
-
'```slot:options',
|
|
28
|
-
'{"id":"esc","mode":"single","options":[{"id":"a","label":"</script><script>x</script>"},{"id":"b","label":"<!-- c -->"}]}',
|
|
29
|
-
'```', '',
|
|
30
|
-
].join('\n'));
|
|
31
|
-
const config = /<crtr-options slot-id="esc"><script type="application\/json">([\s\S]*?)<\/script>/.exec(html)?.[1];
|
|
32
|
-
assert.ok(config !== undefined, `no options config in payload:\n${html}`);
|
|
33
|
-
// The mutation this catches: dropping the `<` escape for a plain JSON.stringify.
|
|
34
|
-
assert.ok(!config.includes('<'), `config text still carries a raw "<": ${config}`);
|
|
35
|
-
assert.equal(JSON.parse(config).options[0].label, '</script><script>x</script>');
|
|
36
|
-
});
|
|
37
|
-
test('an authored html slot id is mirrored to the slot-id the runtime reads', () => {
|
|
38
|
-
const html = render('page.html', [
|
|
39
|
-
'<!doctype html><html><head><meta name="crtr-page-title" content="Sign-off"></head><body>',
|
|
40
|
-
'<crtr-pages><crtr-page label="Window">',
|
|
41
|
-
'<crtr-options id="window"><script type="application/json">{"mode":"single","options":[{"id":"sat","label":"Saturday"}]}</script></crtr-options>',
|
|
42
|
-
'</crtr-page></crtr-pages>',
|
|
43
|
-
'</body></html>',
|
|
44
|
-
].join('\n'));
|
|
45
|
-
// Without this, every element mounts and renders and no response ever
|
|
46
|
-
// reaches the host, because `src/pages` keys responses by `slot-id`.
|
|
47
|
-
assert.match(html, /<crtr-options id="window" slot-id="window">/);
|
|
48
|
-
assert.match(html, /<crtr-page label="Window">/);
|
|
49
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Escape text for an HTML text node. */
|
|
2
|
-
export declare function escapeHtmlText(raw: string): string;
|
|
3
|
-
/** Escape a value for a double-quoted HTML attribute. */
|
|
4
|
-
export declare function escapeHtmlAttribute(raw: string): string;
|
|
5
|
-
/** Render one markdown document fragment as HTML. */
|
|
6
|
-
export declare function renderMarkdownToHtml(markdown: string): string;
|
|
7
|
-
/** Render inline markdown. Exported for callers rendering a single line. */
|
|
8
|
-
export declare function renderInline(source: string): string;
|