@hanzo/dev 4.0.1 → 4.1.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/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +31 -0
- package/dist/builder/api/git.js +47 -0
- package/dist/builder/api/github.d.ts +176 -0
- package/dist/builder/api/github.js +271 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +570 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +591 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +164 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working in a folder on this computer, with no repository (hanzo-inc/app issues 309 and 310).
|
|
3
|
+
*
|
|
4
|
+
* A HOST THAT HAS THE COMPUTER says so. Hanzo Desktop can open a folder dialog and run the coding agent in a folder
|
|
5
|
+
* (`dev exec -C <folder>`), so it hands the builder a `Local` (host.tsx); a browser page has no folder of its own and
|
|
6
|
+
* hands none, and New then offers the cloud workspace and the org's machines as before. Nothing here sniffs a user
|
|
7
|
+
* agent: the host says what it has.
|
|
8
|
+
*
|
|
9
|
+
* AUTO IS THE FOLDER THE ASK IS ABOUT, ELSE THE ONE USED LAST (`route`). The folders are the ones Hanzo opened and
|
|
10
|
+
* the project folders the host found on the computer; a person who chose no folder works in the one their words
|
|
11
|
+
* name ("fix the footer in shop" goes to `shop`), and in the one they worked in most recently when their words
|
|
12
|
+
* name none. One who has no folder at all is asked for one, once, on their first send, and that folder is then
|
|
13
|
+
* the one Auto picks. Choosing a folder in the pill keeps it for the next New; choosing Auto again goes back to
|
|
14
|
+
* the rule. The pill says where the run will go as the words are typed, so a person can always say before they send.
|
|
15
|
+
*
|
|
16
|
+
* A run on this computer reads, edits and runs in its folder and nowhere else (the agent's workspace-write sandbox),
|
|
17
|
+
* and it needs no repository: a folder that is a git checkout keeps its history, and one that is not stays one.
|
|
18
|
+
*/
|
|
19
|
+
import { phrase } from '@hanzo/i18n';
|
|
20
|
+
import { english } from './say.js';
|
|
21
|
+
/** The place id New keeps for this computer. A machine's is `tgt_…` and the cloud workspace's is ''. */
|
|
22
|
+
export const HERE = 'here';
|
|
23
|
+
/** The folders, most recently used first; a folder never used goes last, in the order the host gave. */
|
|
24
|
+
export function recent(folders) {
|
|
25
|
+
return folders
|
|
26
|
+
.map((f, i) => ({ f, i }))
|
|
27
|
+
.sort((a, b) => (b.f.used ?? 0) - (a.f.used ?? 0) || a.i - b.i)
|
|
28
|
+
.map(({ f }) => f);
|
|
29
|
+
}
|
|
30
|
+
/** The folder Auto picks: the one used most recently, or null when this computer has opened none. */
|
|
31
|
+
export function auto(folders) {
|
|
32
|
+
return recent(folders)[0] ?? null;
|
|
33
|
+
}
|
|
34
|
+
/** Names a path says nowhere in particular: where people keep their projects, not which one. */
|
|
35
|
+
const COMMON = new Set([
|
|
36
|
+
'users', 'user', 'home', 'documents', 'desktop', 'downloads', 'projects', 'project', 'code', 'src', 'source', 'sources',
|
|
37
|
+
'work', 'dev', 'developer', 'repos', 'repo', 'repositories', 'github', 'git', 'workspace', 'workspaces', 'sites', 'mnt',
|
|
38
|
+
'volumes', 'data', 'the', 'and', 'for', 'new',
|
|
39
|
+
]);
|
|
40
|
+
/** The words of a text: letters and digits, lower case, accents folded; a camelCase name is two words. */
|
|
41
|
+
function wordsOf(text) {
|
|
42
|
+
return text
|
|
43
|
+
.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu, '$1 $2')
|
|
44
|
+
.normalize('NFKD')
|
|
45
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
46
|
+
.toLowerCase()
|
|
47
|
+
.split(/[^\p{L}\p{N}]+/u)
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
}
|
|
50
|
+
/** The words that tell one folder from another: not a place projects live in, and not a letter or two. */
|
|
51
|
+
const telling = (text) => wordsOf(text).filter((w) => w.length >= 3 && !COMMON.has(w));
|
|
52
|
+
/** Whether the ask says `word`, in the singular or the plural. */
|
|
53
|
+
const says = (ask, word) => ask.has(word) || ask.has(`${word}s`) || (word.endsWith('s') && ask.has(word.slice(0, -1)));
|
|
54
|
+
/**
|
|
55
|
+
* The folder an ask is about, else the one used last.
|
|
56
|
+
*
|
|
57
|
+
* A folder is named by its own name first ("shop", "my-shop"; each word of it the ask says counts, and the
|
|
58
|
+
* folder it is all of beats one it is a little of), and then by the folders it sits in (`~/work/acme/web` is
|
|
59
|
+
* about "acme"). The ask is read as words: nothing is guessed from what it means, so the same words always go to
|
|
60
|
+
* the same folder, and a tie goes to the folder used more recently. An ask that names none goes where Auto
|
|
61
|
+
* went before: the folder used last.
|
|
62
|
+
*/
|
|
63
|
+
export function route(folders, ask) {
|
|
64
|
+
const said = new Set(wordsOf(ask));
|
|
65
|
+
const phrase = ` ${[...said].join(' ')} `;
|
|
66
|
+
let best = null;
|
|
67
|
+
for (const folder of recent(folders)) {
|
|
68
|
+
const score = scored(folder, said, phrase);
|
|
69
|
+
if (score[0] > 0 && (!best || beats(score, best.score)))
|
|
70
|
+
best = { folder, score };
|
|
71
|
+
}
|
|
72
|
+
return best?.folder ?? auto(folders);
|
|
73
|
+
}
|
|
74
|
+
const beats = (a, b) => (a[0] !== b[0] ? a[0] > b[0] : a[1] !== b[1] ? a[1] > b[1] : a[2] > b[2]);
|
|
75
|
+
function scored(folder, said, phrase) {
|
|
76
|
+
const own = telling(folder.name);
|
|
77
|
+
const hits = own.filter((w) => says(said, w)).length;
|
|
78
|
+
const whole = wordsOf(folder.name).join(' ');
|
|
79
|
+
const distinct = wordsOf(folder.name).some((w) => !COMMON.has(w));
|
|
80
|
+
if (hits > 0 || (distinct && phrase.includes(` ${whole} `)))
|
|
81
|
+
return [2, own.length ? hits / own.length : 1, hits];
|
|
82
|
+
const above = telling(folder.path.replace(/[/\\]+$/, '').split(/[/\\]/).slice(0, -1).join('/')).filter((w) => says(said, w)).length;
|
|
83
|
+
return above > 0 ? [1, 0, above] : [0, 0, 0];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The folder a run goes to: the one chosen (`kept`, a path), while this computer still lists it, else the one the
|
|
87
|
+
* ask is about, else the one used last (`route`). A chosen folder the host no longer lists was removed, and is
|
|
88
|
+
* not where the next run goes.
|
|
89
|
+
*/
|
|
90
|
+
export function where(folders, kept, ask = '') {
|
|
91
|
+
const chosen = kept ? folders.find((f) => f.path === kept) : undefined;
|
|
92
|
+
if (chosen)
|
|
93
|
+
return { folder: chosen, auto: false };
|
|
94
|
+
return { folder: route(folders, ask), auto: true };
|
|
95
|
+
}
|
|
96
|
+
/** A folder's last segment, for a path the host gave no name. */
|
|
97
|
+
export function named(path) {
|
|
98
|
+
return path.replace(/[/\\]+$/, '').split(/[/\\]/).pop() || path;
|
|
99
|
+
}
|
|
100
|
+
/** What the host answers once the first-run setup a person cancelled has stopped. */
|
|
101
|
+
export const CANCELLED = /^Setup was cancelled\.?$/i;
|
|
102
|
+
/**
|
|
103
|
+
* Why a run on this computer stopped before it began, in the reader's words. The host fetches the agent itself
|
|
104
|
+
* and words what went wrong in plain sentences (no connection, a download that did not check out, a folder that
|
|
105
|
+
* is gone), so those are said as they came; a host that could not find the agent at all is told to update.
|
|
106
|
+
* What the agent itself printed is its answer, and is shown as it is.
|
|
107
|
+
*/
|
|
108
|
+
export function failed(e, say = english) {
|
|
109
|
+
const why = (e instanceof Error ? e.message : typeof e === 'string' ? e : '').trim();
|
|
110
|
+
// A person's own choice, not a fault: the host says exactly this once the setup they cancelled has stopped.
|
|
111
|
+
if (CANCELLED.test(why))
|
|
112
|
+
return say('Setup was cancelled. Send again whenever you like.');
|
|
113
|
+
if (/failed to invoke dev|no such file|os error 2|cannot find/i.test(why)) {
|
|
114
|
+
return say('Hanzo Dev is not set up on this computer yet. Update Hanzo Desktop, then send again.');
|
|
115
|
+
}
|
|
116
|
+
return why || say('The run on this computer could not start. Try again.');
|
|
117
|
+
}
|
|
118
|
+
/** Words New marks for the reader's language (`phrase`), drawn through `t`. */
|
|
119
|
+
export const WORDS = {
|
|
120
|
+
here: phrase('This computer'),
|
|
121
|
+
auto: phrase('Auto'),
|
|
122
|
+
choose: phrase('Choose folder…'),
|
|
123
|
+
pick: phrase('Choose a folder for this run'),
|
|
124
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A chip: one choice among a few, lit when chosen. */
|
|
2
|
+
export declare function Chip({ label, on, onPress }: {
|
|
3
|
+
label: string;
|
|
4
|
+
on: boolean;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function Make({ open, onClose }: {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Make something new: the Library's template picker (-/artifacts/new), fed live
|
|
4
|
+
* by gallery.hanzo.ai (api/gallery.ts). Each template shows its capture, its
|
|
5
|
+
* name and its kind; search and the kinds narrow them.
|
|
6
|
+
*
|
|
7
|
+
* Picking one makes it where its kind is made: a site is copied into a project
|
|
8
|
+
* of this org and opens in Dev (`fork`), an agent becomes the org's own and
|
|
9
|
+
* opens in Customize › Agents (`use`).
|
|
10
|
+
*
|
|
11
|
+
* The keyboard: Down (or Enter) from the search goes into the grid, the arrows
|
|
12
|
+
* move across and down it, Up from its first row goes back, Enter picks, and
|
|
13
|
+
* Escape closes. On a phone the picker is the whole screen.
|
|
14
|
+
*/
|
|
15
|
+
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
16
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
17
|
+
import { Bot, Globe, Search, X } from '@hanzogui/lucide-icons-2';
|
|
18
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
19
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import { RING } from './pane.js';
|
|
21
|
+
import { use } from './api/agents.js';
|
|
22
|
+
import { told } from './api/call.js';
|
|
23
|
+
import { APP, catalogue, KIND, KINDS, narrow } from './api/gallery.js';
|
|
24
|
+
import { fork } from './api/projects.js';
|
|
25
|
+
import { useRead } from './data.js';
|
|
26
|
+
import { useHost, useTarget } from './host.js';
|
|
27
|
+
import { copying } from './question.js';
|
|
28
|
+
import { useSpend } from './spend.js';
|
|
29
|
+
import { path } from './route.js';
|
|
30
|
+
/** A chip: one choice among a few, lit when chosen. */
|
|
31
|
+
export function Chip({ label, on, onPress }) {
|
|
32
|
+
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, height: 32, px: "$3", items: "center", rounded: "$10", shrink: 0, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', hoverStyle: { bg: on ? '$ink' : '$hover' }, cursor: "pointer", focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: label }) }));
|
|
33
|
+
}
|
|
34
|
+
/** A template's capture, 16:10 from the top of its page, or its kind's mark. */
|
|
35
|
+
function Still({ x }) {
|
|
36
|
+
const [broken, setBroken] = useState(false);
|
|
37
|
+
return (_jsx(YStack, { width: "100%", aspectRatio: 16 / 10, bg: "$raised", items: "center", justify: "center", overflow: "hidden", "aria-hidden": true, children: x.preview && !broken ? (_jsx("img", { src: x.preview, alt: "", loading: "lazy", onError: () => setBroken(true), style: { width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'top', display: 'block' } })) : (_jsx(YStack, { opacity: 0.6, children: x.kind === 'agent' ? _jsx(Bot, { size: 24 }) : _jsx(Globe, { size: 24 }) })) }));
|
|
38
|
+
}
|
|
39
|
+
/** Where a key moves from cell `i` of `n` laid out `cols` wide: a cell, -1 for Up out of the first row, or null for a key the grid does not take. */
|
|
40
|
+
function step(key, i, n, cols) {
|
|
41
|
+
const to = { ArrowRight: i + 1, ArrowLeft: i - 1, ArrowDown: i + cols, ArrowUp: i - cols, Home: 0, End: n - 1 };
|
|
42
|
+
if (!(key in to))
|
|
43
|
+
return null;
|
|
44
|
+
const v = to[key];
|
|
45
|
+
return v < 0 ? (key === 'ArrowUp' ? -1 : 0) : Math.min(v, n - 1);
|
|
46
|
+
}
|
|
47
|
+
export function Make({ open, onClose }) {
|
|
48
|
+
const { t } = useI18n();
|
|
49
|
+
const host = useHost();
|
|
50
|
+
const target = useTarget();
|
|
51
|
+
const wide = useMedia().md;
|
|
52
|
+
const read = useRead(open ? () => catalogue() : null, [], [open]);
|
|
53
|
+
const [q, setQ] = useState('');
|
|
54
|
+
const [kind, setKind] = useState('');
|
|
55
|
+
const [at, setAt] = useState(0);
|
|
56
|
+
const [busy, setBusy] = useState('');
|
|
57
|
+
const [note, setNote] = useState('');
|
|
58
|
+
const spend = useSpend();
|
|
59
|
+
const search = useRef(null);
|
|
60
|
+
const cells = useRef([]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (open)
|
|
63
|
+
setNote('');
|
|
64
|
+
}, [open]);
|
|
65
|
+
const kinds = useMemo(() => KINDS.filter((k) => read.value.some((x) => x.kind === k)), [read.value]);
|
|
66
|
+
const hits = useMemo(() => narrow(read.value, kind, q), [read.value, kind, q]);
|
|
67
|
+
useEffect(() => setAt(0), [kind, q]);
|
|
68
|
+
const pick = async (x) => {
|
|
69
|
+
if (busy)
|
|
70
|
+
return;
|
|
71
|
+
if (!host.person)
|
|
72
|
+
return host.signIn?.();
|
|
73
|
+
// A site template's copy is built and published at once: asked first. An agent template only makes the agent.
|
|
74
|
+
if (APP[x.kind] === 'dev' && !(await spend.ask(copying(x.name, t))))
|
|
75
|
+
return;
|
|
76
|
+
setBusy(x.slug);
|
|
77
|
+
setNote('');
|
|
78
|
+
try {
|
|
79
|
+
if (APP[x.kind] === 'dev') {
|
|
80
|
+
const made = await fork(target, x.slug);
|
|
81
|
+
host.go(made.slug || x.slug);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const made = await use(target, { name: x.slug, title: x.name, description: x.description, category: x.category, model: x.model, instructions: x.instructions, avatar: x.preview }, window.location.href);
|
|
85
|
+
host.go(path({ kind: 'agent', name: made.name }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
setNote(told(e, t));
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
setBusy('');
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const into = (e) => {
|
|
96
|
+
if ((e.key !== 'ArrowDown' && e.key !== 'Enter') || !hits.length)
|
|
97
|
+
return;
|
|
98
|
+
e.preventDefault?.();
|
|
99
|
+
cells.current[0]?.focus();
|
|
100
|
+
};
|
|
101
|
+
const across = (e) => {
|
|
102
|
+
const els = cells.current.slice(0, hits.length);
|
|
103
|
+
const i = els.findIndex((el) => el === document.activeElement);
|
|
104
|
+
if (i < 0)
|
|
105
|
+
return;
|
|
106
|
+
const top = els[0]?.getBoundingClientRect().top;
|
|
107
|
+
const cols = Math.max(1, els.filter((el) => el?.getBoundingClientRect().top === top).length);
|
|
108
|
+
const to = step(e.key ?? '', i, hits.length, cols);
|
|
109
|
+
if (to === null)
|
|
110
|
+
return;
|
|
111
|
+
e.preventDefault?.();
|
|
112
|
+
if (to < 0)
|
|
113
|
+
search.current?.focus();
|
|
114
|
+
else
|
|
115
|
+
els[to]?.focus();
|
|
116
|
+
};
|
|
117
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { "data-slot": "make", showCloseButton: false, p: "$4", gap: "$3", ...(wide ? { width: '100%', maxW: 960, maxH: '88vh' } : { position: 'fixed', t: 0, r: 0, b: 0, l: 0, maxW: '100%', maxH: '100%', rounded: 0, borderWidth: 0 }), children: [spend.dialog, _jsx(DialogTitle, { numberOfLines: 1, paddingInlineEnd: 40, children: t('Make something new') }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { ref: search, value: q, onChangeText: setQ, placeholder: t('Search templates'), "aria-label": t('Search templates'), onKeyDown: into }) })] }), kinds.length > 1 ? (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$1", "$platform-web": { scrollbarWidth: 'none' }, children: [_jsx(Chip, { label: t('All'), on: kind === '', onPress: () => setKind('') }), kinds.map((k) => (_jsx(Chip, { label: t(KIND[k]), on: kind === k, onPress: () => setKind(k) }, k)))] })) : null, note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: note })) : null, _jsx(YStack, { shrink: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: read.error ? (_jsxs(YStack, { gap: "$3", items: "flex-start", py: "$4", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: told(read.error, t) }), _jsx(Button, { size: "sm", variant: "outline", onPress: read.reload, children: t('Try again') })] })) : read.loading && !read.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Reading templates…') })) : !hits.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Nothing matches.') })) : (_jsx(YStack, { role: "list", "aria-label": t('Templates'), onKeyDown: across, gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 200px), 1fr))' }, children: hits.map((x, i) => (_jsx(YStack, { role: "listitem", minW: 0, children: _jsxs(YStack, { ref: (el) => {
|
|
118
|
+
cells.current[i] = el instanceof HTMLElement ? el : null;
|
|
119
|
+
}, render: "button", tabIndex: i === at ? 0 : -1, onFocus: () => setAt(i), "aria-label": t('Start from {template}', { template: x.name }), disabled: Boolean(busy), onPress: () => void pick(x), rounded: "$4", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: [_jsx(Still, { x: x }), _jsxs(YStack, { px: "$2.5", py: "$2", gap: "$0.5", minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: busy === x.slug ? t('Starting…') : [t(KIND[x.kind]), x.category].filter(Boolean).join(' · ') })] })] }) }, x.slug))) })) }), _jsx(XStack, { render: "button", "aria-label": t('Close'), position: "absolute", t: 14, insetInlineEnd: 14, width: 32, height: 32, items: "center", justify: "center", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: onClose, children: _jsx(X, { size: 16 }) })] }) }));
|
|
120
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The markdown an agent writes, read into blocks and inline pieces: paragraphs,
|
|
3
|
+
* headings, lists, quotes, rules, tables and fenced code; inline code, bold,
|
|
4
|
+
* italics and links. What prose.tsx draws, as plain values.
|
|
5
|
+
*
|
|
6
|
+
* A link keeps an address only when it is http(s); anything else, and every
|
|
7
|
+
* image, is its words.
|
|
8
|
+
*/
|
|
9
|
+
export type Block = {
|
|
10
|
+
kind: 'paragraph';
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'heading';
|
|
14
|
+
level: number;
|
|
15
|
+
text: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'code';
|
|
18
|
+
lang: string;
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'list';
|
|
22
|
+
ordered: boolean;
|
|
23
|
+
start: number;
|
|
24
|
+
items: {
|
|
25
|
+
text: string;
|
|
26
|
+
depth: number;
|
|
27
|
+
}[];
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'quote';
|
|
30
|
+
text: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'rule';
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'table';
|
|
35
|
+
head: string[];
|
|
36
|
+
rows: string[][];
|
|
37
|
+
};
|
|
38
|
+
/** The blocks of a markdown text, in order. */
|
|
39
|
+
export declare function blocks(md: string): Block[];
|
|
40
|
+
export type Span = {
|
|
41
|
+
kind: 'text' | 'code' | 'strong' | 'em';
|
|
42
|
+
text: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'link';
|
|
45
|
+
text: string;
|
|
46
|
+
href: string;
|
|
47
|
+
};
|
|
48
|
+
/** A line's inline pieces. A link to anything but http(s) is its words. */
|
|
49
|
+
export declare function spans(text: string): Span[];
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const FENCE = /^\s{0,3}(```+|~~~+)\s*([\w+#.-]*)\s*$/;
|
|
2
|
+
const HEADING = /^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
|
|
3
|
+
const ITEM = /^(\s*)([-*+]|\d{1,9}[.)])\s+(.*)$/;
|
|
4
|
+
const RULE = /^\s{0,3}([-*_])(\s*\1){2,}\s*$/;
|
|
5
|
+
const QUOTE = /^\s{0,3}>\s?(.*)$/;
|
|
6
|
+
const ROW = /^\s*\|(.*)\|\s*$/;
|
|
7
|
+
const DIVIDER = /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/;
|
|
8
|
+
/** A table row's cells. Only a line ROW matched is one. */
|
|
9
|
+
const cells = (line) => ROW.exec(line)[1].split('|').map((c) => c.trim());
|
|
10
|
+
/** The blocks of a markdown text, in order. */
|
|
11
|
+
export function blocks(md) {
|
|
12
|
+
const lines = md.replace(/\r\n?/g, '\n').split('\n');
|
|
13
|
+
const out = [];
|
|
14
|
+
let para = [];
|
|
15
|
+
const flush = () => {
|
|
16
|
+
if (para.length)
|
|
17
|
+
out.push({ kind: 'paragraph', text: para.join(' ').trim() });
|
|
18
|
+
para = [];
|
|
19
|
+
};
|
|
20
|
+
for (let i = 0; i < lines.length; i++) {
|
|
21
|
+
const line = lines[i];
|
|
22
|
+
const fence = FENCE.exec(line);
|
|
23
|
+
if (fence) {
|
|
24
|
+
flush();
|
|
25
|
+
const body = [];
|
|
26
|
+
i++;
|
|
27
|
+
while (i < lines.length && !lines[i].trim().startsWith(fence[1]))
|
|
28
|
+
body.push(lines[i++]);
|
|
29
|
+
out.push({ kind: 'code', lang: fence[2], text: body.join('\n') });
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!line.trim()) {
|
|
33
|
+
flush();
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const heading = HEADING.exec(line);
|
|
37
|
+
if (heading) {
|
|
38
|
+
flush();
|
|
39
|
+
out.push({ kind: 'heading', level: heading[1].length, text: heading[2] });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (RULE.test(line)) {
|
|
43
|
+
flush();
|
|
44
|
+
out.push({ kind: 'rule' });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (ROW.test(line) && DIVIDER.test(lines[i + 1] ?? '')) {
|
|
48
|
+
flush();
|
|
49
|
+
const head = cells(line);
|
|
50
|
+
const rows = [];
|
|
51
|
+
i += 2;
|
|
52
|
+
while (i < lines.length && ROW.test(lines[i]))
|
|
53
|
+
rows.push(cells(lines[i++]));
|
|
54
|
+
i--;
|
|
55
|
+
out.push({ kind: 'table', head, rows });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const quote = QUOTE.exec(line);
|
|
59
|
+
if (quote) {
|
|
60
|
+
flush();
|
|
61
|
+
const body = [quote[1]];
|
|
62
|
+
while (i + 1 < lines.length && QUOTE.test(lines[i + 1]))
|
|
63
|
+
body.push(QUOTE.exec(lines[++i])[1]);
|
|
64
|
+
out.push({ kind: 'quote', text: body.join(' ').trim() });
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const item = ITEM.exec(line);
|
|
68
|
+
if (item) {
|
|
69
|
+
flush();
|
|
70
|
+
const ordered = /\d/.test(item[2]);
|
|
71
|
+
const items = [];
|
|
72
|
+
const start = ordered ? parseInt(item[2], 10) : 1;
|
|
73
|
+
let j = i;
|
|
74
|
+
while (j < lines.length) {
|
|
75
|
+
const m = ITEM.exec(lines[j]);
|
|
76
|
+
if (m) {
|
|
77
|
+
items.push({ text: m[3], depth: Math.min(3, Math.floor(m[1].replace(/\t/g, ' ').length / 2)) });
|
|
78
|
+
j++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
// A line indented under an item continues it.
|
|
82
|
+
if (lines[j].trim() && /^\s{2,}/.test(lines[j])) {
|
|
83
|
+
items[items.length - 1].text += ` ${lines[j].trim()}`;
|
|
84
|
+
j++;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
out.push({ kind: 'list', ordered, start, items });
|
|
90
|
+
i = j - 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
para.push(line.trim());
|
|
94
|
+
}
|
|
95
|
+
flush();
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
const INLINE = /(`+)([^`]+?)\1|!?\[([^\]]+)\]\(((?:[^()\s]|\([^()\s]*\))+)(?:\s+"[^"]*")?\)|\*\*(.+?)\*\*|__(.+?)__|\*([^*\s](?:[^*]*[^*\s])?)\*|(?<![\w])_([^_\s](?:[^_]*[^_\s])?)_(?![\w])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g;
|
|
99
|
+
const safe = (href) => (/^https?:\/\/[^\s]+$/i.test(href) ? href : '');
|
|
100
|
+
/** A line's inline pieces. A link to anything but http(s) is its words. */
|
|
101
|
+
export function spans(text) {
|
|
102
|
+
const out = [];
|
|
103
|
+
let at = 0;
|
|
104
|
+
for (const m of text.matchAll(INLINE)) {
|
|
105
|
+
if (m.index > at)
|
|
106
|
+
out.push({ kind: 'text', text: text.slice(at, m.index) });
|
|
107
|
+
if (m[2] !== undefined)
|
|
108
|
+
out.push({ kind: 'code', text: m[2] });
|
|
109
|
+
else if (m[3] !== undefined) {
|
|
110
|
+
const href = safe(m[4]);
|
|
111
|
+
out.push(href && !m[0].startsWith('!') ? { kind: 'link', text: m[3], href } : { kind: 'text', text: m[3] });
|
|
112
|
+
}
|
|
113
|
+
else if (m[5] !== undefined || m[6] !== undefined)
|
|
114
|
+
out.push({ kind: 'strong', text: (m[5] ?? m[6]) });
|
|
115
|
+
else if (m[7] !== undefined || m[8] !== undefined)
|
|
116
|
+
out.push({ kind: 'em', text: (m[7] ?? m[8]) });
|
|
117
|
+
// What is left is the bare address, the only other thing INLINE matches.
|
|
118
|
+
else
|
|
119
|
+
out.push({ kind: 'link', text: m[9], href: m[9] });
|
|
120
|
+
at = m.index + m[0].length;
|
|
121
|
+
}
|
|
122
|
+
if (at < text.length)
|
|
123
|
+
out.push({ kind: 'text', text: text.slice(at) });
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mark of each product and place, once. The rail, a phone's bar, the sidebars,
|
|
3
|
+
* the palette and every landing page draw these and no other, so the same thing
|
|
4
|
+
* wears the same icon everywhere. `icon` is the place; `make` is its New: Chat
|
|
5
|
+
* starts a conversation (the pen), Dev a task (`</>`), Tabs a terminal; a place
|
|
6
|
+
* with nothing of its own to start draws its own icon.
|
|
7
|
+
*/
|
|
8
|
+
import { SquarePen } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
export type Mark = 'chat' | 'dev' | 'design' | 'studio' | 'tabs' | 'library' | 'scheduled' | 'customize';
|
|
10
|
+
/** An icon as the rail and the sidebars draw it. */
|
|
11
|
+
export type Icon = typeof SquarePen;
|
|
12
|
+
export declare const MARKS: Record<Mark, {
|
|
13
|
+
icon: Icon;
|
|
14
|
+
make: Icon;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mark of each product and place, once. The rail, a phone's bar, the sidebars,
|
|
3
|
+
* the palette and every landing page draw these and no other, so the same thing
|
|
4
|
+
* wears the same icon everywhere. `icon` is the place; `make` is its New: Chat
|
|
5
|
+
* starts a conversation (the pen), Dev a task (`</>`), Tabs a terminal; a place
|
|
6
|
+
* with nothing of its own to start draws its own icon.
|
|
7
|
+
*/
|
|
8
|
+
import { Clapperboard, Clock, CodeXml, Library, MessageSquare, Puzzle, SquarePen, SquareTerminal, WandSparkles } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
export const MARKS = {
|
|
10
|
+
chat: { icon: MessageSquare, make: SquarePen },
|
|
11
|
+
dev: { icon: CodeXml, make: CodeXml },
|
|
12
|
+
design: { icon: WandSparkles, make: WandSparkles },
|
|
13
|
+
studio: { icon: Clapperboard, make: Clapperboard },
|
|
14
|
+
tabs: { icon: SquareTerminal, make: SquareTerminal },
|
|
15
|
+
library: { icon: Library, make: Library },
|
|
16
|
+
scheduled: { icon: Clock, make: Clock },
|
|
17
|
+
customize: { icon: Puzzle, make: Puzzle },
|
|
18
|
+
};
|