@otea/cli 0.0.0-stage → 0.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 +661 -0
- package/README.es.md +151 -0
- package/README.md +252 -2
- package/THIRD_PARTY_NOTICES.md +114 -0
- package/bin/otea.mjs +28 -0
- package/dist/app/agent-detail.js +26 -0
- package/dist/app/agent-draft.js +429 -0
- package/dist/app/agent-prompts.js +52 -0
- package/dist/app/agents.js +77 -0
- package/dist/app/asking.js +43 -0
- package/dist/app/board-archive.js +243 -0
- package/dist/app/board-migration.js +272 -0
- package/dist/app/boards.js +870 -0
- package/dist/app/branch-owner.js +48 -0
- package/dist/app/brief.js +53 -0
- package/dist/app/choices.js +61 -0
- package/dist/app/collections.js +101 -0
- package/dist/app/context.js +1 -0
- package/dist/app/crop.js +56 -0
- package/dist/app/devices.js +62 -0
- package/dist/app/draft-request.js +82 -0
- package/dist/app/events.js +12 -0
- package/dist/app/evidence.js +287 -0
- package/dist/app/gates.js +610 -0
- package/dist/app/guide.js +37 -0
- package/dist/app/home.js +145 -0
- package/dist/app/init-boards.js +36 -0
- package/dist/app/intake.js +25 -0
- package/dist/app/item-search.js +141 -0
- package/dist/app/items.js +318 -0
- package/dist/app/keep-waiting.js +44 -0
- package/dist/app/land-order.js +107 -0
- package/dist/app/language.js +52 -0
- package/dist/app/launcher.js +56 -0
- package/dist/app/lease-take.js +54 -0
- package/dist/app/leases.js +86 -0
- package/dist/app/machine.js +39 -0
- package/dist/app/merged.js +89 -0
- package/dist/app/migrate.js +171 -0
- package/dist/app/next.js +1637 -0
- package/dist/app/notes.js +319 -0
- package/dist/app/notify-targets.js +113 -0
- package/dist/app/opened.js +25 -0
- package/dist/app/owner-only.js +34 -0
- package/dist/app/performance.js +28 -0
- package/dist/app/phone.js +97 -0
- package/dist/app/presence.js +596 -0
- package/dist/app/preset-views.js +25 -0
- package/dist/app/presets.js +129 -0
- package/dist/app/priority.js +156 -0
- package/dist/app/profile.js +86 -0
- package/dist/app/project.js +247 -0
- package/dist/app/proofs.js +179 -0
- package/dist/app/questions.js +215 -0
- package/dist/app/reader-filter.js +58 -0
- package/dist/app/relations.js +164 -0
- package/dist/app/relay.js +98 -0
- package/dist/app/repos.js +176 -0
- package/dist/app/restart.js +92 -0
- package/dist/app/set-aside.js +64 -0
- package/dist/app/system-locale.js +6 -0
- package/dist/app/tailscale-cli.js +77 -0
- package/dist/app/tailscale-testing.js +41 -0
- package/dist/app/tailscale.js +177 -0
- package/dist/app/tips.js +30 -0
- package/dist/app/topics-everywhere.js +53 -0
- package/dist/app/topics.js +453 -0
- package/dist/app/undo.js +52 -0
- package/dist/app/validate.js +131 -0
- package/dist/app/watch.js +48 -0
- package/dist/cli/command.js +44 -0
- package/dist/cli/commands.js +3303 -0
- package/dist/cli/exit-codes.js +70 -0
- package/dist/cli/forge.js +176 -0
- package/dist/cli/format.js +340 -0
- package/dist/cli/gh.js +17 -0
- package/dist/cli/gitrepo.js +489 -0
- package/dist/cli/help.js +101 -0
- package/dist/cli/hooks.js +232 -0
- package/dist/cli/main.js +37 -0
- package/dist/cli/merged-outside.js +58 -0
- package/dist/cli/names.js +154 -0
- package/dist/cli/opener.js +21 -0
- package/dist/cli/owner.js +154 -0
- package/dist/cli/phone.js +221 -0
- package/dist/cli/ports.js +24 -0
- package/dist/cli/probe.js +18 -0
- package/dist/cli/run.js +246 -0
- package/dist/cli/serve-file.js +21 -0
- package/dist/cli/stats.js +55 -0
- package/dist/cli/version.js +3 -0
- package/dist/core/agent-guide.js +31 -0
- package/dist/core/agent-prompts.js +139 -0
- package/dist/core/authority.js +94 -0
- package/dist/core/board/analysis.js +86 -0
- package/dist/core/board/choices.js +100 -0
- package/dist/core/board/compile.js +362 -0
- package/dist/core/board/engine.js +523 -0
- package/dist/core/board/hints.js +46 -0
- package/dist/core/board/history.js +146 -0
- package/dist/core/board/ids.js +87 -0
- package/dist/core/board/joins.js +30 -0
- package/dist/core/board/mentions.js +68 -0
- package/dist/core/board/merged.js +18 -0
- package/dist/core/board/model.js +135 -0
- package/dist/core/board/next.js +1116 -0
- package/dist/core/board/notes.js +298 -0
- package/dist/core/board/performance.js +218 -0
- package/dist/core/board/plan.js +299 -0
- package/dist/core/board/problems.js +232 -0
- package/dist/core/board/proofs.js +84 -0
- package/dist/core/board/questions.js +114 -0
- package/dist/core/board/reading.js +220 -0
- package/dist/core/board/readings.js +534 -0
- package/dist/core/board/schema.js +335 -0
- package/dist/core/board/shape-words.js +179 -0
- package/dist/core/board/template-words.js +23 -0
- package/dist/core/board/templates-catalogue.js +965 -0
- package/dist/core/board/templates-coverage.js +261 -0
- package/dist/core/board/templates-flows.js +779 -0
- package/dist/core/board/templates.js +586 -0
- package/dist/core/brief.js +93 -0
- package/dist/core/diagram.js +80 -0
- package/dist/core/errors.js +12 -0
- package/dist/core/evidence.js +33 -0
- package/dist/core/fields.js +129 -0
- package/dist/core/hierarchy.js +30 -0
- package/dist/core/icons.js +181 -0
- package/dist/core/image-crop.js +166 -0
- package/dist/core/item.js +49 -0
- package/dist/core/lease.js +31 -0
- package/dist/core/modules.js +318 -0
- package/dist/core/notify/planner.js +117 -0
- package/dist/core/notify/signals.js +66 -0
- package/dist/core/notify/text.js +60 -0
- package/dist/core/path-key.js +22 -0
- package/dist/core/placement.js +161 -0
- package/dist/core/preset-labels.js +66 -0
- package/dist/core/preset-notes.js +109 -0
- package/dist/core/preset.js +541 -0
- package/dist/core/profile.js +55 -0
- package/dist/core/project-id.js +20 -0
- package/dist/core/refusal.js +1 -0
- package/dist/core/relations.js +208 -0
- package/dist/core/repo.js +54 -0
- package/dist/core/samples.js +161 -0
- package/dist/core/search-words.js +68 -0
- package/dist/core/test-report.js +120 -0
- package/dist/core/time.js +8 -0
- package/dist/core/validation.js +60 -0
- package/dist/core/views.js +171 -0
- package/dist/core/workflow.js +51 -0
- package/dist/mcp/commands.js +101 -0
- package/dist/mcp/server.js +239 -0
- package/dist/mcp/words.js +95 -0
- package/dist/server/boards.js +232 -0
- package/dist/server/changes.js +42 -0
- package/dist/server/diff-tip.js +83 -0
- package/dist/server/drift.js +87 -0
- package/dist/server/errors.js +87 -0
- package/dist/server/evidence.js +82 -0
- package/dist/server/hosts.js +6 -0
- package/dist/server/hub.js +98 -0
- package/dist/server/lan-access.js +62 -0
- package/dist/server/lan.js +164 -0
- package/dist/server/listen.js +70 -0
- package/dist/server/notifier.js +156 -0
- package/dist/server/notify-api.js +151 -0
- package/dist/server/pairing.js +124 -0
- package/dist/server/projects.js +191 -0
- package/dist/server/push.js +199 -0
- package/dist/server/server.js +960 -0
- package/dist/server/session.js +43 -0
- package/dist/server/stream.js +36 -0
- package/dist/server/test-push.js +38 -0
- package/dist/server/token.js +37 -0
- package/dist/server/transports.js +54 -0
- package/dist/server/ui.js +44 -0
- package/dist/server/writes.js +361 -0
- package/dist/server/wrong-address.js +36 -0
- package/dist/store/boards.js +111 -0
- package/dist/store/database.js +45 -0
- package/dist/store/machine.js +77 -0
- package/dist/store/migrations.js +493 -0
- package/dist/store/queries.js +585 -0
- package/dist/store/registry.js +72 -0
- package/package.json +73 -4
- package/presets/architecture/playbook.md +69 -0
- package/presets/architecture/preset.yaml +80 -0
- package/presets/architecture/samples.yaml +23 -0
- package/presets/bug-triage/playbook.md +129 -0
- package/presets/bug-triage/preset.yaml +127 -0
- package/presets/bug-triage/samples/wall-slide-after.png +0 -0
- package/presets/bug-triage/samples/wall-slide-before.png +0 -0
- package/presets/bug-triage/samples.yaml +72 -0
- package/presets/change/playbook.md +115 -0
- package/presets/change/preset.yaml +141 -0
- package/presets/change/samples.yaml +62 -0
- package/presets/review/playbook.md +51 -0
- package/presets/review/preset.yaml +62 -0
- package/presets/review/samples.yaml +27 -0
- package/presets/tasks/playbook.md +78 -0
- package/presets/tasks/preset.yaml +61 -0
- package/presets/tasks/samples.yaml +46 -0
- package/schemas/board.schema.json +764 -0
- package/ui/dist/THIRD_PARTY_NOTICES.md +114 -0
- package/ui/dist/assets/dm-mono-latin-400-normal--0xN8mdc.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-400-normal-4GdczIuU.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-500-normal-CN8Miw6E.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-500-normal-DRMDZjhP.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-400-normal-1aZr6b2b.woff +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-400-normal-C2zvOubV.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-500-normal-BtRyHRi6.woff2 +0 -0
- package/ui/dist/assets/dm-mono-latin-ext-500-normal-Dw3M13d8.woff +0 -0
- package/ui/dist/assets/index-C3OzJope.js +103 -0
- package/ui/dist/assets/index-COdEjckQ.css +1 -0
- package/ui/dist/assets/newsreader-latin-ext-opsz-italic-CSPGnFdO.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-ext-opsz-normal-BQn1nviT.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-opsz-italic-kJKFiXvB.woff2 +0 -0
- package/ui/dist/assets/newsreader-latin-opsz-normal-s-izfB6B.woff2 +0 -0
- package/ui/dist/assets/newsreader-vietnamese-opsz-italic-DTr-ymY4.woff2 +0 -0
- package/ui/dist/assets/newsreader-vietnamese-opsz-normal-BjhtXyW2.woff2 +0 -0
- package/ui/dist/assets/pdf-YwugTw7Y.js +54 -0
- package/ui/dist/assets/pdf-engine-CkBopwck.js +1 -0
- package/ui/dist/assets/pdf-rELvHkft.js +56 -0
- package/ui/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/ui/dist/assets/pdf.worker.min-B7U8ptvh.js +1 -0
- package/ui/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
- package/ui/dist/assets/pdf.worker.min-UqOn5EDC.js +1 -0
- package/ui/dist/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
- package/ui/dist/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
- package/ui/dist/icons/apple-touch-icon.png +0 -0
- package/ui/dist/icons/otea-192.png +0 -0
- package/ui/dist/icons/otea-512.png +0 -0
- package/ui/dist/icons/otea-badge.png +0 -0
- package/ui/dist/icons/otea-maskable-512.png +0 -0
- package/ui/dist/index.html +25 -0
- package/ui/dist/manifest.webmanifest +24 -0
- package/ui/dist/otea-idle.svg +5 -0
- package/ui/dist/otea-working.svg +5 -0
- package/ui/dist/otea-yours-working.svg +5 -0
- package/ui/dist/otea-yours.svg +5 -0
- package/ui/dist/sw.js +1 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Tailscale as a phone transport, the steps Otea takes on this computer: find the tailscale CLI,
|
|
2
|
+
// see that it is logged in with MagicDNS and HTTPS certificates on, then have `tailscale serve`
|
|
3
|
+
// forward `https://<machine>.<tailnet>.ts.net` to Otea's port. The CLI sits behind TailscaleCli
|
|
4
|
+
// (tailscale-cli.ts runs the real one); everything here only reads what it answers, so tests fake
|
|
5
|
+
// it and never touch this computer's network.
|
|
6
|
+
export class TailscaleFailure extends Error {
|
|
7
|
+
name = 'TailscaleFailure';
|
|
8
|
+
}
|
|
9
|
+
// How to install Tailscale here; Otea never installs it itself.
|
|
10
|
+
export function installHint(platform) {
|
|
11
|
+
if (platform === 'win32') {
|
|
12
|
+
return {
|
|
13
|
+
commands: ['winget install --id tailscale.tailscale'],
|
|
14
|
+
link: 'https://tailscale.com/download/windows',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (platform === 'darwin') {
|
|
18
|
+
return {
|
|
19
|
+
commands: ['brew install --cask tailscale'],
|
|
20
|
+
link: 'https://tailscale.com/download/mac',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
commands: ['curl -fsSL https://tailscale.com/install.sh | sh'],
|
|
25
|
+
link: 'https://tailscale.com/download/linux',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Where MagicDNS and HTTPS Certificates are turned on (tailscale.com/kb/1153/enabling-https).
|
|
29
|
+
export const DNS_SETTINGS_URL = 'https://console.tailscale.com/admin/dns';
|
|
30
|
+
// The Tailscale app's store pages, as tailscale.com/download/android and /download/ios link them.
|
|
31
|
+
export const PHONE_STORES = {
|
|
32
|
+
android: 'https://play.google.com/store/apps/details?id=com.tailscale.ipn',
|
|
33
|
+
ios: 'https://apps.apple.com/us/app/tailscale/id1470499037',
|
|
34
|
+
};
|
|
35
|
+
// What Otea runs on this computer for Tailscale, shown to the person word for word first:
|
|
36
|
+
// `tailscale serve` answers https://<machine>.<tailnet>.ts.net with an automatic certificate and
|
|
37
|
+
// forwards it to Otea, for the tailnet only (serve, never funnel), and keeps it across restarts
|
|
38
|
+
// (--bg). SERVE_UNDO stops it again (tailscale.com/kb/1242/tailscale-serve).
|
|
39
|
+
export const serveCommand = (port) => `tailscale serve --bg --https=443 http://127.0.0.1:${port}`;
|
|
40
|
+
export const SERVE_UNDO = 'tailscale serve --https=443 off';
|
|
41
|
+
const record = (value) => typeof value === 'object' && value !== null ? value : {};
|
|
42
|
+
const trimDot = (name) => name.replace(/\.$/, '').toLowerCase();
|
|
43
|
+
// The systems a peer names when it is a phone or a tablet.
|
|
44
|
+
const PHONE_SYSTEMS = new Set(['android', 'iOS']);
|
|
45
|
+
// `tailscale status --json`, the parts Otea reads.
|
|
46
|
+
export function parseStatus(json) {
|
|
47
|
+
const status = record(json);
|
|
48
|
+
const self = record(status.Self);
|
|
49
|
+
const tailnet = record(status.CurrentTailnet);
|
|
50
|
+
const dns = typeof self.DNSName === 'string' && self.DNSName !== '' ? trimDot(self.DNSName) : null;
|
|
51
|
+
const certs = Array.isArray(status.CertDomains) ? status.CertDomains : [];
|
|
52
|
+
const peers = Object.values(record(status.Peer)).map(record);
|
|
53
|
+
const phones = peers.filter(({ OS }) => typeof OS === 'string' && PHONE_SYSTEMS.has(OS));
|
|
54
|
+
const online = phones.map(({ Online }) => Online).filter((on) => typeof on === 'boolean');
|
|
55
|
+
return {
|
|
56
|
+
backend: typeof status.BackendState === 'string' ? status.BackendState : 'NoState',
|
|
57
|
+
dnsName: dns,
|
|
58
|
+
magicDns: tailnet.MagicDNSEnabled === true,
|
|
59
|
+
https: certs.some((domain) => typeof domain === 'string' && domain !== ''),
|
|
60
|
+
authUrl: typeof status.AuthURL === 'string' && status.AuthURL !== '' ? status.AuthURL : null,
|
|
61
|
+
phoneOnTailnet: phones.length > 0,
|
|
62
|
+
phoneOnline: online.length === 0 ? null : online.includes(true),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// `tailscale serve status --json`: `Web` maps `<host>:<port>` to its handlers by path.
|
|
66
|
+
export function parseServeStatus(json) {
|
|
67
|
+
const routes = [];
|
|
68
|
+
for (const [hostPort, web] of Object.entries(record(record(json).Web))) {
|
|
69
|
+
const at = hostPort.lastIndexOf(':');
|
|
70
|
+
const host = trimDot(at < 0 ? hostPort : hostPort.slice(0, at));
|
|
71
|
+
const port = at < 0 ? 443 : Number(hostPort.slice(at + 1));
|
|
72
|
+
for (const [path, handler] of Object.entries(record(record(web).Handlers))) {
|
|
73
|
+
const target = record(handler).Proxy;
|
|
74
|
+
if (typeof target === 'string')
|
|
75
|
+
routes.push({ host, port, path, target });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return routes;
|
|
79
|
+
}
|
|
80
|
+
// Whether a route forwards to Otea on this port (tailscale serve writes 127.0.0.1 or localhost).
|
|
81
|
+
export function forwardsTo(route, port) {
|
|
82
|
+
const target = route.target.replace(/\/$/, '').toLowerCase();
|
|
83
|
+
return [`http://127.0.0.1:${port}`, `http://localhost:${port}`].includes(target);
|
|
84
|
+
}
|
|
85
|
+
async function orFailed(read) {
|
|
86
|
+
try {
|
|
87
|
+
return await read();
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (!(error instanceof TailscaleFailure))
|
|
91
|
+
throw error;
|
|
92
|
+
return { state: 'failed', message: error.message };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Reads where Tailscale stands without changing anything.
|
|
96
|
+
export function checkTailscale(cli, port, platform = process.platform) {
|
|
97
|
+
return orFailed(() => check(cli, port, platform));
|
|
98
|
+
}
|
|
99
|
+
async function check(cli, port, platform, read = () => cli.status()) {
|
|
100
|
+
if (cli.locate() === undefined)
|
|
101
|
+
return { state: 'missing', install: installHint(platform) };
|
|
102
|
+
const status = await read();
|
|
103
|
+
if (status.backend === 'Stopped')
|
|
104
|
+
return { state: 'logged_out', authUrl: null, stopped: true };
|
|
105
|
+
if (status.backend !== 'Running')
|
|
106
|
+
return { state: 'logged_out', authUrl: status.authUrl };
|
|
107
|
+
if (!status.magicDns || status.dnsName === null) {
|
|
108
|
+
return { state: 'no_magic_dns', settings: DNS_SETTINGS_URL };
|
|
109
|
+
}
|
|
110
|
+
if (!status.https)
|
|
111
|
+
return { state: 'no_https', settings: DNS_SETTINGS_URL };
|
|
112
|
+
const host = status.dnsName;
|
|
113
|
+
const root = (await cli.serveStatus()).find((route) => route.host === host && route.port === 443 && route.path === '/');
|
|
114
|
+
if (root && !forwardsTo(root, port))
|
|
115
|
+
return { state: 'taken', host, target: root.target };
|
|
116
|
+
return { state: 'ready', host, url: `https://${host}`, serving: root !== undefined };
|
|
117
|
+
}
|
|
118
|
+
// The guided path to Tailscale (Configuración · Teléfono), step by step, each read from this
|
|
119
|
+
// computer: done or still to do. Nothing here changes Tailscale.
|
|
120
|
+
export const GUIDE_STEPS = ['phone', 'pc', 'signIn', 'https', 'serve', 'pair'];
|
|
121
|
+
export async function readGuide(cli, port, options) {
|
|
122
|
+
const platform = options.platform ?? process.platform;
|
|
123
|
+
const installed = cli.locate() !== undefined;
|
|
124
|
+
let status = null;
|
|
125
|
+
const found = await orFailed(() => check(cli, port, platform, async () => {
|
|
126
|
+
status = await cli.status();
|
|
127
|
+
return status;
|
|
128
|
+
}));
|
|
129
|
+
const read = status;
|
|
130
|
+
const signedIn = read?.backend === 'Running';
|
|
131
|
+
const phone = read?.phoneOnTailnet === true;
|
|
132
|
+
const https = signedIn && read?.magicDns === true && read.https && read.dnsName !== null;
|
|
133
|
+
const serve = found.state === 'ready' && found.serving;
|
|
134
|
+
return {
|
|
135
|
+
done: {
|
|
136
|
+
phone,
|
|
137
|
+
pc: installed,
|
|
138
|
+
signIn: signedIn && phone,
|
|
139
|
+
https,
|
|
140
|
+
serve,
|
|
141
|
+
pair: serve && options.pairing === 'push',
|
|
142
|
+
},
|
|
143
|
+
pairing: options.pairing,
|
|
144
|
+
phoneOnline: read?.phoneOnline ?? null,
|
|
145
|
+
signedIn,
|
|
146
|
+
check: found,
|
|
147
|
+
host: signedIn ? (read?.dnsName ?? null) : null,
|
|
148
|
+
command: serveCommand(port),
|
|
149
|
+
undo: SERVE_UNDO,
|
|
150
|
+
install: installHint(platform),
|
|
151
|
+
stores: PHONE_STORES,
|
|
152
|
+
settings: DNS_SETTINGS_URL,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// Gets Tailscale ready for Otea: logs in when asked to, then points `tailscale serve` at the port.
|
|
156
|
+
export function setUpTailscale(cli, port, options = {}) {
|
|
157
|
+
const platform = options.platform ?? process.platform;
|
|
158
|
+
return orFailed(async () => {
|
|
159
|
+
let found = await check(cli, port, platform);
|
|
160
|
+
if (found.state === 'logged_out' && options.login) {
|
|
161
|
+
await cli.up();
|
|
162
|
+
found = await check(cli, port, platform);
|
|
163
|
+
}
|
|
164
|
+
if (found.state !== 'ready' || found.serving)
|
|
165
|
+
return found;
|
|
166
|
+
await cli.serve(port);
|
|
167
|
+
return { ...found, serving: true };
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// A CLI that is not installed, for wherever no real one may run (tests, a server without one).
|
|
171
|
+
export const NO_TAILSCALE = {
|
|
172
|
+
locate: () => undefined,
|
|
173
|
+
status: () => Promise.reject(new TailscaleFailure('Tailscale is not installed')),
|
|
174
|
+
serveStatus: () => Promise.reject(new TailscaleFailure('Tailscale is not installed')),
|
|
175
|
+
up: () => Promise.reject(new TailscaleFailure('Tailscale is not installed')),
|
|
176
|
+
serve: () => Promise.reject(new TailscaleFailure('Tailscale is not installed')),
|
|
177
|
+
};
|
package/dist/app/tips.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isClosed, positionOf } from '../core/board/engine.js';
|
|
2
|
+
import { selectEvents } from '../store/queries.js';
|
|
3
|
+
function isTip(value) {
|
|
4
|
+
if (value === null || typeof value !== 'object')
|
|
5
|
+
return false;
|
|
6
|
+
const { branch, commit, tree } = value;
|
|
7
|
+
return typeof branch === 'string' && typeof commit === 'string' && typeof tree === 'string';
|
|
8
|
+
}
|
|
9
|
+
// What the person approved of an item's branch: the tip its last handoff into a review recorded
|
|
10
|
+
// (P3C-R2-1). A later handoff that recorded none (made outside the repo) leaves nothing to hold the
|
|
11
|
+
// branch to, never an older round's tip; a tip of another branch holds nothing either.
|
|
12
|
+
export function approvedTipOf(ctx, id, branch) {
|
|
13
|
+
const tip = lastHandoff(ctx, id)?.data.tip;
|
|
14
|
+
return isTip(tip) && tip.branch === branch ? tip : undefined;
|
|
15
|
+
}
|
|
16
|
+
// The item's last move into a review: its last handoff.
|
|
17
|
+
function lastHandoff(ctx, id) {
|
|
18
|
+
return selectEvents(ctx.db, id)
|
|
19
|
+
.filter(({ type }) => type === 'transitioned')
|
|
20
|
+
.filter(({ data }) => {
|
|
21
|
+
const to = positionOf(String(data.to));
|
|
22
|
+
return !isClosed(to) && to.phase !== 'doing';
|
|
23
|
+
})
|
|
24
|
+
.at(-1);
|
|
25
|
+
}
|
|
26
|
+
// Whether the item was ever handed off into a review: from then on its branch on the remote holds
|
|
27
|
+
// what a review read.
|
|
28
|
+
export function handedOff(ctx, id) {
|
|
29
|
+
return lastHandoff(ctx, id) !== undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { itemHitLines, searchItems } from './item-search.js';
|
|
2
|
+
import { systemClock } from './items.js';
|
|
3
|
+
import { listTopics } from './topics.js';
|
|
4
|
+
// The topics of every project, and with a search the items found too, each with its project: this
|
|
5
|
+
// project first, then the others by name. A project that cannot be read is left out.
|
|
6
|
+
export function topicsEverywhere(served, currentId, filter, now = systemClock) {
|
|
7
|
+
const ordered = [...served].sort((a, b) => Number(b.id === currentId) - Number(a.id === currentId) ||
|
|
8
|
+
a.name.localeCompare(b.name) ||
|
|
9
|
+
a.id.localeCompare(b.id));
|
|
10
|
+
const found = { topics: [], items: [] };
|
|
11
|
+
for (const { id, name, project } of ordered) {
|
|
12
|
+
if (!project)
|
|
13
|
+
continue;
|
|
14
|
+
const ref = { id, name };
|
|
15
|
+
try {
|
|
16
|
+
for (const topic of listTopics(project, filter, now))
|
|
17
|
+
found.topics.push({ ...topic, project: ref });
|
|
18
|
+
for (const hit of searchItems(project, filter.search ?? ''))
|
|
19
|
+
found.items.push({ ...hit, project: ref });
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// A project whose data cannot be read now is left out of the others' answer.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return found;
|
|
26
|
+
}
|
|
27
|
+
const lastAnswerOf = (topic) => topic.turns.findLast((turn) => turn.kind === 'answer');
|
|
28
|
+
// One line per topic, its project first; a search gives each its last answer and lists the items
|
|
29
|
+
// found after the topics.
|
|
30
|
+
export function topicsEverywhereText(found, search) {
|
|
31
|
+
const searched = search?.trim() ?? '';
|
|
32
|
+
if (found.topics.length === 0 && found.items.length === 0)
|
|
33
|
+
return searched === ''
|
|
34
|
+
? 'No topics wait on anyone in any project.'
|
|
35
|
+
: `No topic in any project mentions "${searched}".`;
|
|
36
|
+
const blocks = [];
|
|
37
|
+
if (found.topics.length > 0)
|
|
38
|
+
blocks.push(found.topics
|
|
39
|
+
.map((topic) => {
|
|
40
|
+
const line = `${topic.project.name} ${topic.id} ${topic.state.padEnd(8)} ${topic.title}`;
|
|
41
|
+
const answer = searched === '' ? undefined : lastAnswerOf(topic);
|
|
42
|
+
return answer ? `${line}\n ${answer.text}` : line;
|
|
43
|
+
})
|
|
44
|
+
.join('\n'));
|
|
45
|
+
if (found.items.length > 0)
|
|
46
|
+
blocks.push([
|
|
47
|
+
"In the items' threads (otea show <id>, in that project):",
|
|
48
|
+
...found.items.flatMap((hit) => itemHitLines(hit, `${hit.project.name} ${hit.id} ${hit.title}`)),
|
|
49
|
+
].join('\n'));
|
|
50
|
+
if (found.topics.length > 0)
|
|
51
|
+
blocks.push('Read one with otea topic show <id> --project <project>.');
|
|
52
|
+
return blocks.join('\n\n');
|
|
53
|
+
}
|