@otea/cli 0.0.1 → 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 +251 -3
- 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 +72 -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,221 @@
|
|
|
1
|
+
import { listDevices } from '../app/devices.js';
|
|
2
|
+
import { oteaHome } from '../app/home.js';
|
|
3
|
+
import { openMachine } from '../app/machine.js';
|
|
4
|
+
import { choosePhoneTransport, lanOpen, phoneSettings, phoneStatus, RELAY_UNAVAILABLE, setLanOpen, switchToTailscale, } from '../app/phone.js';
|
|
5
|
+
import { lanAddresses, localName } from '../server/lan.js';
|
|
6
|
+
import { sessionCookie } from '../server/session.js';
|
|
7
|
+
import { readUiToken } from '../server/token.js';
|
|
8
|
+
import { CommandFailure, UsageError } from './command.js';
|
|
9
|
+
import { portToOpen } from './ports.js';
|
|
10
|
+
import { readServeFile } from './serve-file.js';
|
|
11
|
+
// otea phone: how a phone reaches the desk. The local network is the default; Tailscale is set up
|
|
12
|
+
// here; the Otea relay is a seam for later. See app/phone.ts.
|
|
13
|
+
// Phone access is the computer's, not a project's: one pairing and one door for every project its
|
|
14
|
+
// otea serve serves, kept in the machine store of the Otea home (app/machine.ts).
|
|
15
|
+
async function withMachine(use) {
|
|
16
|
+
const machine = openMachine();
|
|
17
|
+
try {
|
|
18
|
+
return await use(machine);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
machine.close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const LEDGER_NOTE = "Note: Tailscale's HTTPS certificate is public: this computer's name on the tailnet (<machine>.<tailnet>.ts.net) is listed in the Certificate Transparency logs.";
|
|
25
|
+
const PHONE_STEPS = [
|
|
26
|
+
'On the phone: install the Tailscale app, log in with the same account, then scan the pairing code.',
|
|
27
|
+
'The code is in the UI under Settings > Phone > Pair a phone (otea serve prints one when it starts).',
|
|
28
|
+
];
|
|
29
|
+
// What stops Tailscale, and what the person does about it; Otea never installs or logs in for them.
|
|
30
|
+
export function tailscaleProblem(check) {
|
|
31
|
+
switch (check.state) {
|
|
32
|
+
case 'missing':
|
|
33
|
+
return [
|
|
34
|
+
'Tailscale is not installed. Otea does not install it; install it yourself:',
|
|
35
|
+
...check.install.commands.map((command) => ` ${command}`),
|
|
36
|
+
` or download it from ${check.install.link}`,
|
|
37
|
+
'Then log in, and run otea phone tailscale again.',
|
|
38
|
+
].join('\n');
|
|
39
|
+
case 'logged_out':
|
|
40
|
+
if (check.stopped)
|
|
41
|
+
return 'Tailscale is stopped on this computer. Run: tailscale up';
|
|
42
|
+
return [
|
|
43
|
+
'Tailscale is installed but not logged in. Run: tailscale up',
|
|
44
|
+
...(check.authUrl ? [` or open ${check.authUrl}`] : []),
|
|
45
|
+
'and log in once in the browser it opens (or run otea phone tailscale --login to start it from here).',
|
|
46
|
+
].join('\n');
|
|
47
|
+
case 'no_magic_dns':
|
|
48
|
+
return `MagicDNS is off on your tailnet. Turn it on at ${check.settings} (it is on by default on new tailnets), then run otea phone tailscale again.`;
|
|
49
|
+
case 'no_https':
|
|
50
|
+
return `HTTPS certificates are off on your tailnet. Turn them on at ${check.settings} (under HTTPS Certificates), then run otea phone tailscale again.`;
|
|
51
|
+
case 'taken':
|
|
52
|
+
return `https://${check.host}/ already forwards to ${check.target}. Free it with: tailscale serve --https=443 off, then run otea phone tailscale again.`;
|
|
53
|
+
case 'failed':
|
|
54
|
+
return check.message;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function lanUrls(port) {
|
|
58
|
+
const addresses = lanAddresses();
|
|
59
|
+
return localName(addresses).then((name) => [...(name ? [name] : []), ...addresses].map((host) => `http://${host}:${port}`));
|
|
60
|
+
}
|
|
61
|
+
function statusText(status, { running, devices, open }) {
|
|
62
|
+
const lines = [];
|
|
63
|
+
const tailscale = status.transport === 'tailscale';
|
|
64
|
+
lines.push(`Transport: ${tailscale ? 'Tailscale' : 'local network'}`);
|
|
65
|
+
lines.push(`Open to the local network: ${open ? 'yes' : 'no (otea phone lan --open)'}`);
|
|
66
|
+
lines.push(`URL: ${status.url ?? 'none (this computer has no private network address)'}`);
|
|
67
|
+
const reach = status.reachable === null
|
|
68
|
+
? 'nothing to try'
|
|
69
|
+
: status.reachable
|
|
70
|
+
? 'yes'
|
|
71
|
+
: tailscale
|
|
72
|
+
? 'no (run otea phone tailscale)'
|
|
73
|
+
: 'no (open it with otea phone lan --open, or in Settings > Phone)';
|
|
74
|
+
lines.push(`Reachable: ${reach}`);
|
|
75
|
+
lines.push(running === undefined ? 'Otea: not running (otea serve)' : `Otea: running on port ${running}`);
|
|
76
|
+
lines.push(`Paired devices: ${devices}`);
|
|
77
|
+
if (status.tailscale && status.tailscale.state !== 'ready') {
|
|
78
|
+
lines.push(tailscaleProblem(status.tailscale));
|
|
79
|
+
}
|
|
80
|
+
if (tailscale)
|
|
81
|
+
lines.push(LEDGER_NOTE);
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
const phoneStatusCommand = {
|
|
85
|
+
name: 'phone status',
|
|
86
|
+
summary: 'Show how a phone reaches this computer: the transport (local network or Tailscale), its URL, whether Otea answers there, and the paired devices',
|
|
87
|
+
args: [],
|
|
88
|
+
options: { port: {} },
|
|
89
|
+
execute: ({ option, tailscale, probe }) => withMachine(async (machine) => {
|
|
90
|
+
const port = portToOpen(option('port'));
|
|
91
|
+
const running = readServeFile(oteaHome())?.port;
|
|
92
|
+
const urls = phoneSettings(machine).transport === 'lan' ? await lanUrls(port) : [];
|
|
93
|
+
const status = await phoneStatus(machine, { port, lanUrls: urls, tailscale, probe });
|
|
94
|
+
const devices = listDevices(machine).length;
|
|
95
|
+
const open = lanOpen(machine);
|
|
96
|
+
return {
|
|
97
|
+
data: { ...status, lanOpen: open, port, running: running !== undefined, devices },
|
|
98
|
+
text: statusText(status, { running, devices, open }),
|
|
99
|
+
};
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
// Opens or closes the local network on the otea serve running on `port`, as Settings › Phone
|
|
103
|
+
// does: from this computer, signed in with the server's key. It keeps the choice itself. Says
|
|
104
|
+
// 'down' when nothing answers there (a serve file left behind), so the choice is kept here instead.
|
|
105
|
+
async function tellRunning(port, open) {
|
|
106
|
+
const token = readUiToken(oteaHome());
|
|
107
|
+
if (!token)
|
|
108
|
+
return 'down';
|
|
109
|
+
const base = `http://127.0.0.1:${port}`;
|
|
110
|
+
let response;
|
|
111
|
+
try {
|
|
112
|
+
response = await fetch(`${base}/api/lan/${open ? 'open' : 'close'}`, {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
headers: {
|
|
115
|
+
cookie: `${sessionCookie(port)}=${token}`,
|
|
116
|
+
origin: base,
|
|
117
|
+
'content-type': 'application/json',
|
|
118
|
+
},
|
|
119
|
+
body: '{}',
|
|
120
|
+
signal: AbortSignal.timeout(10_000),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return 'down';
|
|
125
|
+
}
|
|
126
|
+
if (response.ok) {
|
|
127
|
+
await response.body?.cancel();
|
|
128
|
+
return 'done';
|
|
129
|
+
}
|
|
130
|
+
const body = (await response.json().catch(() => undefined));
|
|
131
|
+
throw new CommandFailure('transport_unavailable', `The otea serve on port ${port} could not ${open ? 'open' : 'close'} the local network: ${body?.error?.message ?? `HTTP ${response.status}`}`);
|
|
132
|
+
}
|
|
133
|
+
// Keeps the choice, on the running otea serve when there is one; says where it stands.
|
|
134
|
+
async function keepLan(machine, open) {
|
|
135
|
+
const running = readServeFile(oteaHome())?.port;
|
|
136
|
+
const told = running === undefined ? 'down' : await tellRunning(running, open);
|
|
137
|
+
if (told === 'done') {
|
|
138
|
+
return open
|
|
139
|
+
? `The otea serve on port ${running} is open to it now, for every project it serves, and it starts open from now on.`
|
|
140
|
+
: `The otea serve on port ${running} stopped listening on the network.`;
|
|
141
|
+
}
|
|
142
|
+
setLanOpen(machine, open);
|
|
143
|
+
return open
|
|
144
|
+
? 'Otea is not running: the next otea serve starts open to it.'
|
|
145
|
+
: 'Otea is not running; the next otea serve answers this computer only.';
|
|
146
|
+
}
|
|
147
|
+
const phoneLan = {
|
|
148
|
+
name: 'phone lan',
|
|
149
|
+
summary: 'Pair phones over the local network (the default): plain HTTP to this computer; --open opens it to phones now and for every otea serve after (the same as Settings > Phone), --close closes it again',
|
|
150
|
+
args: [],
|
|
151
|
+
options: { open: { flag: true }, close: { flag: true } },
|
|
152
|
+
execute: ({ flag }) => withMachine(async (machine) => {
|
|
153
|
+
if (flag('open') && flag('close')) {
|
|
154
|
+
throw new UsageError('--open cannot be combined with --close');
|
|
155
|
+
}
|
|
156
|
+
if (flag('close')) {
|
|
157
|
+
const lines = [
|
|
158
|
+
'Otea is closed to the local network.',
|
|
159
|
+
await keepLan(machine, false),
|
|
160
|
+
'Paired phones stay paired; they reach Otea again once it is open.',
|
|
161
|
+
];
|
|
162
|
+
return { data: { ...phoneSettings(machine), lanOpen: false }, text: lines.join('\n') };
|
|
163
|
+
}
|
|
164
|
+
const was = phoneSettings(machine);
|
|
165
|
+
const settings = choosePhoneTransport(machine, { transport: 'lan', tailscaleHost: null });
|
|
166
|
+
const kept = flag('open') ? await keepLan(machine, true) : undefined;
|
|
167
|
+
const open = lanOpen(machine);
|
|
168
|
+
const lines = [
|
|
169
|
+
open
|
|
170
|
+
? 'Phones now pair over the local network, and Otea is open to it.'
|
|
171
|
+
: 'Phones now pair over the local network. Open Otea to it with otea phone lan --open, or in Settings > Phone.',
|
|
172
|
+
...(kept === undefined ? [] : [kept]),
|
|
173
|
+
...(kept !== undefined && process.platform === 'win32'
|
|
174
|
+
? ['Windows may ask once to let Otea through its firewall; Otea never changes it itself.']
|
|
175
|
+
: []),
|
|
176
|
+
...(was.tailscaleHost
|
|
177
|
+
? [
|
|
178
|
+
`tailscale serve may still forward https://${was.tailscaleHost} to this computer; Otea no longer answers through it. Stop it with: tailscale serve --https=443 off`,
|
|
179
|
+
]
|
|
180
|
+
: []),
|
|
181
|
+
];
|
|
182
|
+
return { data: { ...settings, lanOpen: open }, text: lines.join('\n') };
|
|
183
|
+
}),
|
|
184
|
+
};
|
|
185
|
+
const phoneTailscale = {
|
|
186
|
+
name: 'phone tailscale',
|
|
187
|
+
summary: 'Pair phones through Tailscale: checks the tailscale CLI, its login, MagicDNS and HTTPS certificates, then runs tailscale serve so https://<machine>.<tailnet>.ts.net reaches Otea from your own devices anywhere; installs nothing, --login runs tailscale up',
|
|
188
|
+
args: [],
|
|
189
|
+
options: { port: {}, login: { flag: true } },
|
|
190
|
+
execute: ({ option, flag, tailscale }) => withMachine(async (machine) => {
|
|
191
|
+
const port = portToOpen(option('port'));
|
|
192
|
+
const check = await switchToTailscale(machine, tailscale, port, { login: flag('login') });
|
|
193
|
+
if (check.state !== 'ready') {
|
|
194
|
+
throw new CommandFailure('transport_unavailable', tailscaleProblem(check));
|
|
195
|
+
}
|
|
196
|
+
const running = readServeFile(oteaHome())?.port;
|
|
197
|
+
const lines = [
|
|
198
|
+
`Tailscale ready: ${check.url} forwards to Otea on port ${port} (tailscale serve: your tailnet only, never funnel).`,
|
|
199
|
+
'Phones now pair through Tailscale; the pairing code, device tokens and what a phone may do are the same.',
|
|
200
|
+
...PHONE_STEPS,
|
|
201
|
+
...(running === port ? [] : [`Start otea serve --port ${port} for the phone to reach it.`]),
|
|
202
|
+
LEDGER_NOTE,
|
|
203
|
+
];
|
|
204
|
+
return { data: { transport: 'tailscale', url: check.url, port }, text: lines.join('\n') };
|
|
205
|
+
}),
|
|
206
|
+
};
|
|
207
|
+
const phoneRelay = {
|
|
208
|
+
name: 'phone relay',
|
|
209
|
+
summary: 'Pair phones through the Otea relay, a future service: not available yet',
|
|
210
|
+
args: [],
|
|
211
|
+
options: {},
|
|
212
|
+
execute: () => {
|
|
213
|
+
throw new CommandFailure('transport_unavailable', RELAY_UNAVAILABLE);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
export const PHONE_COMMANDS = [
|
|
217
|
+
phoneStatusCommand,
|
|
218
|
+
phoneLan,
|
|
219
|
+
phoneTailscale,
|
|
220
|
+
phoneRelay,
|
|
221
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { oteaHome } from '../app/home.js';
|
|
2
|
+
import { DEFAULT_PORT } from '../server/hosts.js';
|
|
3
|
+
import { UsageError } from './command.js';
|
|
4
|
+
import { readServeFile } from './serve-file.js';
|
|
5
|
+
const PORT_PATTERN = /^\d{1,5}$/;
|
|
6
|
+
export function portFrom(value) {
|
|
7
|
+
if (value === undefined)
|
|
8
|
+
return DEFAULT_PORT;
|
|
9
|
+
const port = Number(value);
|
|
10
|
+
if (!PORT_PATTERN.test(value) || port > 65535) {
|
|
11
|
+
throw new UsageError('--port must be an integer between 0 and 65535');
|
|
12
|
+
}
|
|
13
|
+
return port;
|
|
14
|
+
}
|
|
15
|
+
// The port of this computer's otea serve (one per Otea home), unless --port names another.
|
|
16
|
+
export function portToOpen(option, env = process.env) {
|
|
17
|
+
if (option !== undefined)
|
|
18
|
+
return portFrom(option);
|
|
19
|
+
return readServeFile(oteaHome(env))?.port ?? DEFAULT_PORT;
|
|
20
|
+
}
|
|
21
|
+
// A project's page on the server at that port: every project has its own path on the one server.
|
|
22
|
+
export function projectPage(port, id) {
|
|
23
|
+
return `http://127.0.0.1:${port}/p/${id}/`;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Whether the server at a sign-in link is this Otea home's: it takes the token and sends the browser
|
|
2
|
+
// on to a page of its own (a project's, or `/`); another home's server refuses the token.
|
|
3
|
+
export async function probeSignIn(signInUrl) {
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(signInUrl, {
|
|
6
|
+
redirect: 'manual',
|
|
7
|
+
signal: AbortSignal.timeout(2000),
|
|
8
|
+
});
|
|
9
|
+
await response.body?.cancel();
|
|
10
|
+
const location = response.headers.get('location') ?? '';
|
|
11
|
+
if (response.status === 302 && location.startsWith('/'))
|
|
12
|
+
return 'ours';
|
|
13
|
+
return response.status === 401 ? 'other' : 'down';
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return 'down';
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { pathLauncher } from '../app/launcher.js';
|
|
4
|
+
import { CLI_HARNESS } from '../app/presence.js';
|
|
5
|
+
import { NO_TAILSCALE } from '../app/tailscale.js';
|
|
6
|
+
import { agentActor, readerActor } from '../core/item.js';
|
|
7
|
+
import { errorData, failureCode, UsageError, usageOf, } from './command.js';
|
|
8
|
+
import { COMMANDS, findCommand } from './commands.js';
|
|
9
|
+
import { EXIT_CODES } from './exit-codes.js';
|
|
10
|
+
import { NO_FORGE } from './forge.js';
|
|
11
|
+
import { commandHelp, generalHelp, groupHelp, HELP_ALL, HELP_HINT, shortHelp } from './help.js';
|
|
12
|
+
import { OTEA_VERSION } from './version.js';
|
|
13
|
+
const GLOBAL_OPTIONS = {
|
|
14
|
+
json: { type: 'boolean' },
|
|
15
|
+
as: { type: 'string' },
|
|
16
|
+
help: { type: 'boolean', short: 'h' },
|
|
17
|
+
version: { type: 'boolean', short: 'v' },
|
|
18
|
+
};
|
|
19
|
+
const PARSE_OPTIONS = Object.assign({}, GLOBAL_OPTIONS, ...COMMANDS.flatMap((command) => Object.entries(command.options).map(([name, spec]) => ({
|
|
20
|
+
[name]: spec.flag
|
|
21
|
+
? { type: 'boolean' }
|
|
22
|
+
: { type: 'string', multiple: spec.multiple ?? false },
|
|
23
|
+
}))));
|
|
24
|
+
const OPTIONAL_VALUES = new Set(COMMANDS.flatMap((command) => Object.entries(command.options).flatMap(([name, spec]) => spec.optionalValue ? [`--${name}`] : [])));
|
|
25
|
+
// An option whose value is optional, given without one, reads as an empty value.
|
|
26
|
+
function withOptionalValues(argv) {
|
|
27
|
+
return argv.map((token, index) => {
|
|
28
|
+
const next = argv[index + 1];
|
|
29
|
+
const bare = next === undefined || next.startsWith('-');
|
|
30
|
+
return OPTIONAL_VALUES.has(token) && bare ? `${token}=` : token;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function parse(argv) {
|
|
34
|
+
try {
|
|
35
|
+
const args = withOptionalValues(argv);
|
|
36
|
+
return parseArgs({ args, options: PARSE_OPTIONS, allowPositionals: true, strict: true });
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
40
|
+
// Agents reach for --field <name> --value <value>: say how a field is given instead.
|
|
41
|
+
if (/^Unknown option '--value'/.test(message)) {
|
|
42
|
+
throw new UsageError('There is no --value: give a field as --field "<name>=<value>", or a long one from a file with --field-file "<name>=<file>"');
|
|
43
|
+
}
|
|
44
|
+
throw new UsageError(message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// The name the agent gave: --as, or OTEA_AGENT. There is no default: an unnamed agent is refused.
|
|
48
|
+
function agentName(values, env) {
|
|
49
|
+
const given = typeof values.as === 'string' ? values.as : '';
|
|
50
|
+
return given || env.OTEA_AGENT || undefined;
|
|
51
|
+
}
|
|
52
|
+
const NAME_YOURSELF = 'pass --as <name> or set OTEA_AGENT=<name>';
|
|
53
|
+
function validate(command, values, args) {
|
|
54
|
+
for (const name of Object.keys(values)) {
|
|
55
|
+
if (!(name in GLOBAL_OPTIONS) && !(name in command.options)) {
|
|
56
|
+
throw new UsageError(`Unknown option --${name} for "otea ${command.name}"`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const [name, spec] of Object.entries(command.options)) {
|
|
60
|
+
const value = values[name];
|
|
61
|
+
if (typeof value === 'string' && spec.choices && !spec.choices.includes(value)) {
|
|
62
|
+
throw new UsageError(`--${name} must be one of ${spec.choices.join(', ')}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const rest = command.args.at(-1)?.endsWith('...') ?? false;
|
|
66
|
+
// A last name ending in `?` (`name?`) is an argument that may be left out.
|
|
67
|
+
const optional = command.args.at(-1)?.endsWith('?') ?? false;
|
|
68
|
+
const fewest = optional ? command.args.length - 1 : command.args.length;
|
|
69
|
+
const fits = rest
|
|
70
|
+
? args.length >= command.args.length
|
|
71
|
+
: args.length >= fewest && args.length <= command.args.length;
|
|
72
|
+
if (!fits) {
|
|
73
|
+
throw new UsageError(`"otea ${command.name}" expects ${command.args.length} argument(s)`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// What a command reads as a path, which Git Bash's conversion leaves a real path of.
|
|
77
|
+
const PATH_OPTIONS = new Set(['file', 'log', 'join', 'field-file']);
|
|
78
|
+
const PATH_ARGS = new Set(['path', 'path?', 'file', 'old', 'new']);
|
|
79
|
+
// Git Bash (MSYSTEM set) hands a Windows program an argument that starts with / as a path under
|
|
80
|
+
// its own folder: "/deploy fails" arrives as "C:/Program Files/Git/deploy fails", and so does the
|
|
81
|
+
// value of "key=/value". Text given to Otea (a title, a field, a note) gets its slash back.
|
|
82
|
+
export function undoGitBashPath(env) {
|
|
83
|
+
if (!env.MSYSTEM || !env.EXEPATH)
|
|
84
|
+
return (value) => value;
|
|
85
|
+
const root = env.EXEPATH.replaceAll('\\', '/').replace(/\/((mingw(32|64)|usr)\/)?bin\/?$/i, '');
|
|
86
|
+
const prefix = `${root}/`;
|
|
87
|
+
return (value) => {
|
|
88
|
+
if (value.startsWith(prefix))
|
|
89
|
+
return `/${value.slice(prefix.length)}`;
|
|
90
|
+
const equals = value.indexOf('=');
|
|
91
|
+
if (equals > 0 && value.startsWith(prefix, equals + 1)) {
|
|
92
|
+
return `${value.slice(0, equals + 1)}/${value.slice(equals + 1 + prefix.length)}`;
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function inputFor(command, values, args, io, json) {
|
|
98
|
+
const text = undoGitBashPath(io.env);
|
|
99
|
+
const option = (name) => {
|
|
100
|
+
const value = values[name];
|
|
101
|
+
if (typeof value !== 'string')
|
|
102
|
+
return undefined;
|
|
103
|
+
return PATH_OPTIONS.has(name) ? value : text(value);
|
|
104
|
+
};
|
|
105
|
+
const options = (name) => {
|
|
106
|
+
const value = values[name];
|
|
107
|
+
if (!Array.isArray(value))
|
|
108
|
+
return [];
|
|
109
|
+
return value.map((each) => (PATH_OPTIONS.has(name) ? String(each) : text(String(each))));
|
|
110
|
+
};
|
|
111
|
+
const given = args.map((arg, index) => {
|
|
112
|
+
const name = command.args[Math.min(index, command.args.length - 1)] ?? '';
|
|
113
|
+
return PATH_ARGS.has(name) ? arg : text(arg);
|
|
114
|
+
});
|
|
115
|
+
const agent = agentName(values, io.env);
|
|
116
|
+
return {
|
|
117
|
+
cwd: io.cwd,
|
|
118
|
+
get actor() {
|
|
119
|
+
return agentActor(agent, NAME_YOURSELF);
|
|
120
|
+
},
|
|
121
|
+
get reader() {
|
|
122
|
+
return readerActor(agent);
|
|
123
|
+
},
|
|
124
|
+
agent,
|
|
125
|
+
channel: 'cli',
|
|
126
|
+
harness: CLI_HARNESS,
|
|
127
|
+
signal: io.signal,
|
|
128
|
+
openUrl: io.openUrl,
|
|
129
|
+
tailscale: io.tailscale ?? NO_TAILSCALE,
|
|
130
|
+
probe: io.probe ?? (async () => false),
|
|
131
|
+
...(io.gh === undefined ? {} : { gh: io.gh }),
|
|
132
|
+
forge: io.forge ?? NO_FORGE,
|
|
133
|
+
...(io.env.OTEA_HOME ? { home: resolve(io.cwd, io.env.OTEA_HOME) } : {}),
|
|
134
|
+
oteaOnPath: () => pathLauncher(io.env),
|
|
135
|
+
...(io.env.OTEA_PROJECT_ID ? { pin: io.env.OTEA_PROJECT_ID } : {}),
|
|
136
|
+
terminal: io.stdout.isTTY === true,
|
|
137
|
+
warn: (message) => io.stderr.write(`otea: ${message}
|
|
138
|
+
`),
|
|
139
|
+
ask: async (question) => io.ask?.(question),
|
|
140
|
+
stdin: async () => (io.stdin ? io.stdin() : ''),
|
|
141
|
+
print: (data, text) => io.stdout.write(`${json ? JSON.stringify(data) : text}\n`),
|
|
142
|
+
args: given,
|
|
143
|
+
flag: (name) => values[name] === true,
|
|
144
|
+
option,
|
|
145
|
+
options,
|
|
146
|
+
required: (name) => {
|
|
147
|
+
const value = option(name);
|
|
148
|
+
if (value === undefined)
|
|
149
|
+
throw new UsageError(`Missing --${name} for "otea ${command.name}"`);
|
|
150
|
+
return value;
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// What some commands people look for are, in the commands there are.
|
|
155
|
+
const INSTEAD = {
|
|
156
|
+
'repos rename': 'to rename a repo, otea repos add <path> --name <name>',
|
|
157
|
+
};
|
|
158
|
+
// A group's name alone (otea projects) or with a word it does not take names the group's
|
|
159
|
+
// commands, so the group reads as there; anything else is plainly unknown.
|
|
160
|
+
function unknownCommand(positionals) {
|
|
161
|
+
const [group = '', word] = positionals;
|
|
162
|
+
const subcommands = COMMANDS.flatMap(({ name }) => {
|
|
163
|
+
const [first, ...rest] = name.split(' ');
|
|
164
|
+
return first === group && rest.length > 0 ? [rest.join(' ')] : [];
|
|
165
|
+
});
|
|
166
|
+
if (subcommands.length === 0)
|
|
167
|
+
return `Unknown command "${group}"`;
|
|
168
|
+
const list = subcommands.join(', ');
|
|
169
|
+
if (word === undefined)
|
|
170
|
+
return `"${group}" needs a command: ${list} (otea ${group} <command> --help)`;
|
|
171
|
+
const instead = INSTEAD[`${group} ${word}`];
|
|
172
|
+
return `Unknown command "${group} ${word}": otea ${group} takes ${list}${instead ? `; ${instead}` : ''}`;
|
|
173
|
+
}
|
|
174
|
+
async function dispatch(argv, io, json) {
|
|
175
|
+
const { values, positionals } = parse(argv);
|
|
176
|
+
if (positionals[0] === 'help' || (values.help && positionals.length === 0)) {
|
|
177
|
+
const [, ...words] = positionals;
|
|
178
|
+
if (words.length === 0)
|
|
179
|
+
io.stdout.write(`${shortHelp()}\n`);
|
|
180
|
+
else if (words.length === 1 && words[0] === HELP_ALL)
|
|
181
|
+
io.stdout.write(`${generalHelp()}\n`);
|
|
182
|
+
else {
|
|
183
|
+
const command = findCommand(words);
|
|
184
|
+
const group = !command && words.length === 1 ? groupHelp(words[0] ?? '') : undefined;
|
|
185
|
+
if (!command && !group)
|
|
186
|
+
throw new UsageError(unknownCommand(words));
|
|
187
|
+
io.stdout.write(`${command ? commandHelp(command) : group}\n`);
|
|
188
|
+
}
|
|
189
|
+
return EXIT_CODES.ok;
|
|
190
|
+
}
|
|
191
|
+
if (values.version && positionals.length === 0) {
|
|
192
|
+
io.stdout.write(`${OTEA_VERSION}\n`);
|
|
193
|
+
return EXIT_CODES.ok;
|
|
194
|
+
}
|
|
195
|
+
if (positionals.length === 0)
|
|
196
|
+
throw new UsageError('Missing command');
|
|
197
|
+
const command = findCommand(positionals);
|
|
198
|
+
const group = values.help && !command && positionals.length === 1
|
|
199
|
+
? groupHelp(positionals[0] ?? '')
|
|
200
|
+
: undefined;
|
|
201
|
+
if (group) {
|
|
202
|
+
io.stdout.write(`${group}\n`);
|
|
203
|
+
return EXIT_CODES.ok;
|
|
204
|
+
}
|
|
205
|
+
if (!command)
|
|
206
|
+
throw new UsageError(unknownCommand(positionals));
|
|
207
|
+
if (values.help) {
|
|
208
|
+
io.stdout.write(`${commandHelp(command)}\n`);
|
|
209
|
+
return EXIT_CODES.ok;
|
|
210
|
+
}
|
|
211
|
+
const args = positionals.slice(command.name.split(' ').length);
|
|
212
|
+
validate(command, values, args);
|
|
213
|
+
const output = await command.execute(inputFor(command, values, args, io, json));
|
|
214
|
+
if (output === undefined)
|
|
215
|
+
return EXIT_CODES.ok;
|
|
216
|
+
if (json)
|
|
217
|
+
io.stdout.write(`${JSON.stringify(output.data)}\n`);
|
|
218
|
+
else if (output.text !== '')
|
|
219
|
+
io.stdout.write(`${output.text}\n`);
|
|
220
|
+
return EXIT_CODES[output.failure ?? 'ok'];
|
|
221
|
+
}
|
|
222
|
+
function usageHint(argv) {
|
|
223
|
+
const command = findCommand(argv.filter((token) => !token.startsWith('-')));
|
|
224
|
+
return command ? `Usage: ${usageOf(command)}` : HELP_HINT;
|
|
225
|
+
}
|
|
226
|
+
function report(error, argv, io, json) {
|
|
227
|
+
const code = failureCode(error);
|
|
228
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
229
|
+
if (json) {
|
|
230
|
+
io.stderr.write(`${JSON.stringify(errorData(error))}\n`);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
const hint = EXIT_CODES[code] === EXIT_CODES.usage ? `\n${usageHint(argv)}` : '';
|
|
234
|
+
io.stderr.write(`otea: ${message}${hint}\n`);
|
|
235
|
+
}
|
|
236
|
+
return EXIT_CODES[code];
|
|
237
|
+
}
|
|
238
|
+
export async function run(argv, io) {
|
|
239
|
+
const json = argv.includes('--json');
|
|
240
|
+
try {
|
|
241
|
+
return await dispatch(argv, io, json);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
return report(error, argv, io, json);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const SERVE_FILE = 'serve.json';
|
|
5
|
+
const ServeInfo = z.object({ port: z.number().int(), pid: z.number().int() });
|
|
6
|
+
export function writeServeFile(dir, info) {
|
|
7
|
+
writeFileSync(join(dir, SERVE_FILE), `${JSON.stringify(info)}\n`);
|
|
8
|
+
}
|
|
9
|
+
export function readServeFile(dir) {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = ServeInfo.safeParse(JSON.parse(readFileSync(join(dir, SERVE_FILE), 'utf8')));
|
|
12
|
+
return parsed.success ? parsed.data : undefined;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function removeServeFile(dir, pid) {
|
|
19
|
+
if (readServeFile(dir)?.pid === pid)
|
|
20
|
+
rmSync(join(dir, SERVE_FILE), { force: true });
|
|
21
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { columns } from './format.js';
|
|
2
|
+
// otea stats as text: one row per model family and effort, its exact models and its board steps
|
|
3
|
+
// under it, indented, with the same numbers --json gives.
|
|
4
|
+
const HEAD = [
|
|
5
|
+
'model · effort',
|
|
6
|
+
'handoffs',
|
|
7
|
+
'sent back',
|
|
8
|
+
'rounds per step',
|
|
9
|
+
'items done',
|
|
10
|
+
'discards',
|
|
11
|
+
'claim to handoff',
|
|
12
|
+
];
|
|
13
|
+
const NONE = '–';
|
|
14
|
+
// A span of time, roughly: minutes under two hours, then hours under two days, then days.
|
|
15
|
+
export function spanText(ms) {
|
|
16
|
+
if (ms === null)
|
|
17
|
+
return NONE;
|
|
18
|
+
const minutes = Math.round(ms / 60_000);
|
|
19
|
+
if (minutes < 1)
|
|
20
|
+
return '<1 min';
|
|
21
|
+
if (minutes < 120)
|
|
22
|
+
return `${minutes} min`;
|
|
23
|
+
const hours = Math.round(minutes / 60);
|
|
24
|
+
if (hours < 48)
|
|
25
|
+
return `${hours} h`;
|
|
26
|
+
return `${Math.round(hours / 24)} d`;
|
|
27
|
+
}
|
|
28
|
+
function cells(label, n) {
|
|
29
|
+
const rate = n.handoffs === 0 ? 0 : Math.round((n.sentBack / n.handoffs) * 100);
|
|
30
|
+
return [
|
|
31
|
+
label,
|
|
32
|
+
String(n.handoffs),
|
|
33
|
+
n.handoffs === 0 ? NONE : `${n.sentBack} (${rate}%)`,
|
|
34
|
+
n.finishedSteps === 0 ? NONE : (n.rounds / n.finishedSteps).toFixed(1),
|
|
35
|
+
String(n.itemsFinished),
|
|
36
|
+
String(n.discards),
|
|
37
|
+
spanText(n.medianClaimToHandoffMs),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
export function statsText(view, period) {
|
|
41
|
+
const when = period === 'all' ? 'all time' : `last ${period}`;
|
|
42
|
+
const where = view.boards.length === 1 ? `board ${view.boards[0]}` : 'every board';
|
|
43
|
+
const title = `How each model performs, ${when}, ${where} (profiles as the agents declare them)`;
|
|
44
|
+
if (view.rows.length === 0) {
|
|
45
|
+
return `${title}\n\nNo handoffs yet by an agent with a declared profile.`;
|
|
46
|
+
}
|
|
47
|
+
const rows = view.rows.flatMap((row) => [
|
|
48
|
+
cells(`${row.family} · ${row.effort}`, row),
|
|
49
|
+
...(row.models.length > 1 || row.models[0]?.model !== row.family
|
|
50
|
+
? row.models.map((model) => cells(` ${model.model}`, model))
|
|
51
|
+
: []),
|
|
52
|
+
...row.steps.map((step) => cells(` ${step.board} › ${step.stepName}`, step)),
|
|
53
|
+
]);
|
|
54
|
+
return `${title}\n\n${columns([HEAD, ...rows])}`;
|
|
55
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Otea's agent guide: how an agent works a board, in one text. The MCP server gives it as its
|
|
2
|
+
// instructions on initialize, and `otea board`'s index prints it first, for an agent on the command
|
|
3
|
+
// line, where the AGENTS.md block sends it (that block holds no copy). Every agent reads it once a
|
|
4
|
+
// session, so every word costs: keep it short.
|
|
5
|
+
export const AGENT_GUIDE = [
|
|
6
|
+
"Otea's agent guide: the board is the procedure; follow it to the letter.",
|
|
7
|
+
"1. Name yourself on every call: --as <name> (MCP tools: as). A new session runs otea whoami first (MCP: whoami): reuse the name it gives back, or pick a new one when it gives none. Each agent and every subagent has its own unique name (a subagent: <your name>-<role>); never reuse your parent's.",
|
|
8
|
+
'2. Declare your model and effort: otea profile --model <id> --effort <level> (MCP: profile), each session and on any change; subagents too. Declare what this session tells you (your instructions, or what the person says); never open config files outside the project for it. Otherwise declare unknown. Never guess.',
|
|
9
|
+
'3. Start with otea next: it follows the order the person set on the Matrix (a board view weighing two fields, like effort × impact). Claim before you work: otea claim <id>, or otea next --claim. A claim lasts one step, and your otea calls keep it: claim it again at each new step, and when your lease ran out; on a long step with no call (a rebase, a test run), run otea heartbeat <id> every 10 minutes. A subagent releases what it holds before it ends: otea release <id>.',
|
|
10
|
+
'4. Every request the person makes, in chat too, goes on a board first: otea create it, then work it there. A new board or a change to one goes through rule 11, never otea create. Do what the step says: its instructions and every line of "Before you hand it off". Do not skip, reorder or add steps; never invent a procedure of your own.',
|
|
11
|
+
'5. "Sent back to you": read the note and address every point before you hand it off again.',
|
|
12
|
+
'6. Hand off with the exact command next prints under "When you finish".',
|
|
13
|
+
'7. Never relay a decision on a step you did, nor review it.',
|
|
14
|
+
'8. Never push to a branch the item\'s "Branch" lines do not allow.',
|
|
15
|
+
'9. Answer every note from the person (otea reply) before you hand off.',
|
|
16
|
+
'10. Ask the person only with otea ask <id> "<question>" (MCP: ask); an answer they give in the chat goes on it: otea answer <id> "<their words>".',
|
|
17
|
+
'11. To propose a new board, run otea board draft --new "<name>" --why "<what it is for>" --template <key> (MCP: board_draft) after asking the person one question at a time how they work; to change a published board (a field, a step), --change <board> instead of --new; the person publishes it.',
|
|
18
|
+
'12. Keep going until the person stops you: after each handoff run otea next again; when it has nothing, wait in a background shell, which keeps your chat free (the MCP wait tool holds it): $ otea wait --turn agent --unclaimed --as <name>; then otea next. Only a running wait hears the desk: after a chat reply, wait again. Stop your wait by ending its shell or with --timeout, never by killing processes by name or pattern. When the person says to leave an item for later: otea release <id> --later sets it aside for every agent; then keep waiting. Never write a polling loop of your own: otea wait is how you wait.',
|
|
19
|
+
].join('\n');
|
|
20
|
+
// Added to the guide while the project keeps side topics (app/topics.ts); never otherwise.
|
|
21
|
+
// Agents skipped the bare rule in a chat (0 of 9 side questions recorded with Haiku): it names what
|
|
22
|
+
// a side question is, when to record it, and where to look for what was said before. A recall
|
|
23
|
+
// question, a check-in and a follow-up each became a new topic (P4-R2-6, P8-R2-12, P4-R2-5): it
|
|
24
|
+
// names what is not a topic, and where a follow-up goes.
|
|
25
|
+
export const TOPICS_RULE = '13. Topics are on. Every question the person asks you that is not a request to do work (advice, an explanation, a comparison, a curiosity), even mid-task, is a topic. Before you answer it, record it: otea topic add "<their question>" (MCP: topic_add); once you answered in the chat, save your answer there: otea topic answer <id> --summary "<a line or two>" --full "<your answer as you gave it>". Not a topic: a request to do work, small talk or a check-in ("are you there?"), or a question about something said before ("what did we conclude about…?"); for that one, look in the topics first: otea topic list --search "<words>" (MCP: topic_list), then otea topic show <id>; if nothing turns up, search every project with --all-projects. A follow-up to a topic goes on it: otea topic add --to <id> "<their question>". A task you make from a topic takes --from <id>.';
|
|
26
|
+
// What next and wait remind an agent of while topics are on, between the person's messages.
|
|
27
|
+
export const TOPICS_REMINDER = 'Topics are on: record each question the person asks you off the work with otea topic add before you answer it (a follow-up: --to <id>), then otea topic answer.';
|
|
28
|
+
// The guide an agent of this project reads: with the topics rule only while topics are on.
|
|
29
|
+
export function agentGuideFor(topics) {
|
|
30
|
+
return topics ? `${AGENT_GUIDE}\n${TOPICS_RULE}` : AGENT_GUIDE;
|
|
31
|
+
}
|