@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,489 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { basename, dirname, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { excludeFromGit } from '../app/project.js';
|
|
4
|
+
function git(cwd, ...args) {
|
|
5
|
+
return execFileSync('git', args, {
|
|
6
|
+
cwd,
|
|
7
|
+
encoding: 'utf8',
|
|
8
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
9
|
+
}).trim();
|
|
10
|
+
}
|
|
11
|
+
// A commit object git writes only to chain merges in memory of the repo (never a ref): it needs an
|
|
12
|
+
// identity, which a fresh clone or a CI runner may not have.
|
|
13
|
+
const SCRATCH_IDENTITY = {
|
|
14
|
+
GIT_AUTHOR_NAME: 'otea',
|
|
15
|
+
GIT_AUTHOR_EMAIL: 'otea@localhost',
|
|
16
|
+
GIT_COMMITTER_NAME: 'otea',
|
|
17
|
+
GIT_COMMITTER_EMAIL: 'otea@localhost',
|
|
18
|
+
};
|
|
19
|
+
// The branch checked out in the repo at cwd, even before its first commit; throws outside a repo
|
|
20
|
+
// or on a detached HEAD.
|
|
21
|
+
export function currentBranch(cwd) {
|
|
22
|
+
try {
|
|
23
|
+
return git(cwd, 'symbolic-ref', '--short', 'HEAD');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('no branch checked out here; name it with --branch <name>');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// The branch checked out in the repo at cwd; undefined outside a repo or on a detached HEAD (a
|
|
30
|
+
// rebase under way), where git names none.
|
|
31
|
+
export function checkedOutBranch(cwd) {
|
|
32
|
+
try {
|
|
33
|
+
return git(cwd, 'symbolic-ref', '--short', '--quiet', 'HEAD') || undefined;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// How many commits `branch` holds over the first of `bases` the repo at cwd has: the branch as it
|
|
40
|
+
// is here, or else on origin. Undefined when the repo has neither, or cwd is no repo.
|
|
41
|
+
export function commitsOver(cwd, branch, bases) {
|
|
42
|
+
const tip = commitOf(cwd, `refs/heads/${branch}`) ?? commitOf(cwd, `refs/remotes/origin/${branch}`);
|
|
43
|
+
if (!tip)
|
|
44
|
+
return undefined;
|
|
45
|
+
for (const base of bases) {
|
|
46
|
+
if (base === branch || base === `origin/${branch}`)
|
|
47
|
+
continue;
|
|
48
|
+
const from = commitOf(cwd, base);
|
|
49
|
+
if (!from)
|
|
50
|
+
continue;
|
|
51
|
+
try {
|
|
52
|
+
return { base, count: Number(git(cwd, 'rev-list', '--count', `${from}..${tip}`)) };
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
// The local branches of the repo at cwd; throws outside a repo.
|
|
61
|
+
export function localBranches(cwd) {
|
|
62
|
+
const listed = git(cwd, 'for-each-ref', '--format=%(refname:short)', 'refs/heads');
|
|
63
|
+
return listed.split('\n').filter(Boolean);
|
|
64
|
+
}
|
|
65
|
+
// The commit a ref names in the repo at cwd, or undefined when it names none (a ref the repo does
|
|
66
|
+
// not have, or the all-zero id git gives a branch that is created or deleted).
|
|
67
|
+
function commitOf(cwd, ref) {
|
|
68
|
+
if (ref === '' || /^0+$/.test(ref))
|
|
69
|
+
return undefined;
|
|
70
|
+
try {
|
|
71
|
+
return git(cwd, 'rev-parse', '--verify', '--quiet', `${ref}^{commit}`) || undefined;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Whether a push from `from` (what the remote has of the branch) to `to` rewrites it rather than
|
|
78
|
+
// adding to it: `from` is not in the history of `to` (a force push after a rebase or an amend), or
|
|
79
|
+
// this clone never had it. A branch the push creates or deletes rewrites nothing.
|
|
80
|
+
export function rewritesRemote(cwd, from, to) {
|
|
81
|
+
if (/^0+$/.test(from) || /^0+$/.test(to))
|
|
82
|
+
return false;
|
|
83
|
+
const tip = commitOf(cwd, to);
|
|
84
|
+
if (!tip)
|
|
85
|
+
return false;
|
|
86
|
+
const remote = commitOf(cwd, from);
|
|
87
|
+
return remote === undefined || !isAncestor(cwd, remote, tip);
|
|
88
|
+
}
|
|
89
|
+
// Whether the repo at cwd has the commit a ref names (false outside a repo).
|
|
90
|
+
export function hasCommit(cwd, ref) {
|
|
91
|
+
return commitOf(cwd, ref) !== undefined;
|
|
92
|
+
}
|
|
93
|
+
export function branchesBrought(cwd, to, from) {
|
|
94
|
+
const tip = commitOf(cwd, to);
|
|
95
|
+
if (!tip)
|
|
96
|
+
return { branches: [], unpushed: [] };
|
|
97
|
+
const base = from === undefined ? undefined : commitOf(cwd, from);
|
|
98
|
+
const args = ['for-each-ref', '--format=%(refname)', `--merged=${tip}`];
|
|
99
|
+
if (base)
|
|
100
|
+
args.push(`--no-merged=${base}`);
|
|
101
|
+
const refs = git(cwd, ...args, 'refs/heads', 'refs/remotes')
|
|
102
|
+
.split(/\r?\n/)
|
|
103
|
+
.filter(Boolean);
|
|
104
|
+
const remotes = git(cwd, 'remote').split(/\r?\n/).filter(Boolean);
|
|
105
|
+
const local = refs.flatMap((ref) => ref.startsWith('refs/heads/') ? [ref.slice('refs/heads/'.length)] : []);
|
|
106
|
+
const fromRemotes = refs.flatMap((ref) => {
|
|
107
|
+
if (!ref.startsWith('refs/remotes/'))
|
|
108
|
+
return [];
|
|
109
|
+
const short = ref.slice('refs/remotes/'.length);
|
|
110
|
+
const remote = remotes.find((name) => short.startsWith(`${name}/`));
|
|
111
|
+
const branch = remote === undefined ? undefined : short.slice(remote.length + 1);
|
|
112
|
+
return branch === undefined || branch === 'HEAD' ? [] : [branch];
|
|
113
|
+
});
|
|
114
|
+
const unpushed = local.flatMap((branch) => {
|
|
115
|
+
const remote = remoteName(cwd, branch);
|
|
116
|
+
if (remote === undefined)
|
|
117
|
+
return [];
|
|
118
|
+
return isAncestor(cwd, `refs/heads/${branch}`, remote)
|
|
119
|
+
? []
|
|
120
|
+
: [{ branch, remote, push: pushRemote(cwd, branch) }];
|
|
121
|
+
});
|
|
122
|
+
const brought = { branches: [...new Set([...local, ...fromRemotes])], unpushed };
|
|
123
|
+
// With nothing on the remote to start from, the whole history would count as brought in: only a
|
|
124
|
+
// push onto a branch the remote has is asked which commits ride along.
|
|
125
|
+
if (base)
|
|
126
|
+
brought.outside = (held, tips = []) => commitsOutside(cwd, tip, base, held, refs, remotes, tips);
|
|
127
|
+
brought.landsAs = (landing, onto) => {
|
|
128
|
+
const start = onto === undefined ? base : (commitOf(cwd, remoteOf(cwd, onto)) ?? commitOf(cwd, onto));
|
|
129
|
+
return landsAs(cwd, tip, start, landing);
|
|
130
|
+
};
|
|
131
|
+
return brought;
|
|
132
|
+
}
|
|
133
|
+
// Whether `tip` holds exactly what was approved of the branches it lands, merged onto `start` (the
|
|
134
|
+
// base as the remote has it): each branch at the commit the person approved (`tip`), or, when none
|
|
135
|
+
// was recorded, as it stands here. The approved commit itself always passes; so does any other
|
|
136
|
+
// commit with the same tree as that merge (a rebase, or a merge commit with nothing of its own). A
|
|
137
|
+
// merge with conflicts is never what was approved: its resolution was never reviewed.
|
|
138
|
+
function landsAs(cwd, tip, start, landing) {
|
|
139
|
+
const [only] = landing;
|
|
140
|
+
if (landing.length === 1 && only?.tip?.commit === tip)
|
|
141
|
+
return true;
|
|
142
|
+
const commits = [];
|
|
143
|
+
for (const { branch, tip: approved } of landing) {
|
|
144
|
+
const commit = approved
|
|
145
|
+
? commitOf(cwd, approved.commit)
|
|
146
|
+
: (commitOf(cwd, `refs/heads/${branch}`) ?? commitOf(cwd, remoteOf(cwd, branch)));
|
|
147
|
+
// An approved commit this checkout never got can only be matched by its tree.
|
|
148
|
+
if (!commit)
|
|
149
|
+
return landing.length === 1 && approved !== undefined && treeOf(cwd, tip) === approved.tree;
|
|
150
|
+
commits.push(commit);
|
|
151
|
+
}
|
|
152
|
+
let at = start;
|
|
153
|
+
let tree = start === undefined ? undefined : treeOf(cwd, start);
|
|
154
|
+
for (const commit of commits) {
|
|
155
|
+
if (at === undefined) {
|
|
156
|
+
at = commit;
|
|
157
|
+
tree = treeOf(cwd, commit);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
tree = git(cwd, 'merge-tree', '--write-tree', at, commit).split(/\r?\n/)[0];
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
if (commit === commits.at(-1))
|
|
167
|
+
break;
|
|
168
|
+
at = execFileSync('git', ['commit-tree', String(tree), '-p', at, '-p', commit, '-m', 'otea'], {
|
|
169
|
+
cwd,
|
|
170
|
+
encoding: 'utf8',
|
|
171
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
172
|
+
env: { ...process.env, ...SCRATCH_IDENTITY },
|
|
173
|
+
}).trim();
|
|
174
|
+
}
|
|
175
|
+
return tree !== undefined && tree === treeOf(cwd, tip);
|
|
176
|
+
}
|
|
177
|
+
// Runs git, giving back its output, or when it failed the first error line it wrote to stderr.
|
|
178
|
+
function tried(cwd, ...args) {
|
|
179
|
+
try {
|
|
180
|
+
return {
|
|
181
|
+
out: execFileSync('git', args, {
|
|
182
|
+
cwd,
|
|
183
|
+
encoding: 'utf8',
|
|
184
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
185
|
+
}).trim(),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
const lines = String(error.stderr ?? '')
|
|
190
|
+
.split(/\r?\n/)
|
|
191
|
+
.map((text) => text.trim())
|
|
192
|
+
.filter(Boolean);
|
|
193
|
+
const line = lines.find((text) => /^(fatal|error): /.test(text)) ?? lines[0] ?? '';
|
|
194
|
+
return { error: line.replace(/^(fatal|error): /, '') || `git ${args[0]} failed` };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// What a merge of the approved branch takes, as its remote has it right now (P3C-R3-1): a forge
|
|
198
|
+
// merges the branch there, which a clone without Otea's hook may have pushed to since the person
|
|
199
|
+
// approved it. The branch and the base it merges into are fetched from the remote the branch is
|
|
200
|
+
// pushed to; a repo with no such remote, or a remote with no branch of that name, merges the branch
|
|
201
|
+
// as this checkout has it. `given` is a commit the merge names (--commits), checked as well. Held
|
|
202
|
+
// when each is the approved commit, or a rebase of it onto the base with the same result; never
|
|
203
|
+
// throws: what git cannot tell is `unknown`, for the gate to refuse.
|
|
204
|
+
export function mergeTake(cwd, tip, base, given) {
|
|
205
|
+
try {
|
|
206
|
+
const { branch } = tip;
|
|
207
|
+
const remote = pushRemote(cwd, branch);
|
|
208
|
+
const remotes = git(cwd, 'remote').split(/\r?\n/).filter(Boolean);
|
|
209
|
+
const takes = [];
|
|
210
|
+
let start;
|
|
211
|
+
if (remotes.includes(remote)) {
|
|
212
|
+
const heads = [branch, ...(base ? [base] : [])].map((name) => `refs/heads/${name}`);
|
|
213
|
+
const listed = tried(cwd, 'ls-remote', '--heads', remote, ...heads);
|
|
214
|
+
if ('error' in listed)
|
|
215
|
+
return { unknown: `git could not reach ${remote} (${listed.error})` };
|
|
216
|
+
const there = new Map(listed.out
|
|
217
|
+
.split(/\r?\n/)
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.map((line) => {
|
|
220
|
+
const [commit = '', ref = ''] = line.split('\t');
|
|
221
|
+
return [ref.slice('refs/heads/'.length), commit];
|
|
222
|
+
}));
|
|
223
|
+
const fetch = [...there.keys()]
|
|
224
|
+
.filter((name) => commitOf(cwd, there.get(name) ?? '') === undefined)
|
|
225
|
+
.map((name) => `+refs/heads/${name}:refs/remotes/${remote}/${name}`);
|
|
226
|
+
if (fetch.length > 0) {
|
|
227
|
+
const fetched = tried(cwd, 'fetch', '--quiet', '--no-tags', remote, ...fetch);
|
|
228
|
+
if ('error' in fetched)
|
|
229
|
+
return { unknown: `git could not fetch it from ${remote} (${fetched.error})` };
|
|
230
|
+
}
|
|
231
|
+
const at = there.get(branch);
|
|
232
|
+
const here = commitOf(cwd, `refs/heads/${branch}`);
|
|
233
|
+
if (at)
|
|
234
|
+
takes.push({ ref: `${remote}/${branch}`, at });
|
|
235
|
+
else if (here)
|
|
236
|
+
takes.push({ ref: branch, at: here });
|
|
237
|
+
else
|
|
238
|
+
return { unknown: `${remote} has no branch ${branch}, and neither has this checkout` };
|
|
239
|
+
const onto = base ? there.get(base) : undefined;
|
|
240
|
+
start = onto ?? (base ? commitOf(cwd, remoteOf(cwd, base)) : undefined);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
const ref = remoteName(cwd, branch) ?? branch;
|
|
244
|
+
const at = commitOf(cwd, ref);
|
|
245
|
+
if (!at)
|
|
246
|
+
return { unknown: `this checkout has no branch ${branch}` };
|
|
247
|
+
takes.push({ ref, at });
|
|
248
|
+
start = base ? (commitOf(cwd, remoteOf(cwd, base)) ?? commitOf(cwd, base)) : undefined;
|
|
249
|
+
}
|
|
250
|
+
if (given !== undefined) {
|
|
251
|
+
const at = commitOf(cwd, given);
|
|
252
|
+
if (!at)
|
|
253
|
+
return { unknown: `${given} is not in this repository; fetch first` };
|
|
254
|
+
takes.push({ ref: given, at });
|
|
255
|
+
}
|
|
256
|
+
for (const { ref, at } of takes) {
|
|
257
|
+
if (landsAs(cwd, at, start, [{ branch, tip }]))
|
|
258
|
+
continue;
|
|
259
|
+
return {
|
|
260
|
+
held: false,
|
|
261
|
+
ref,
|
|
262
|
+
commit: at.slice(0, 7),
|
|
263
|
+
added: commitsAddedSince(cwd, tip, at, start),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return { held: true };
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
return { unknown: error instanceof Error ? error.message : String(error) };
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// The commits `at` holds that the approved tip and the base do not, a rebased copy of an approved
|
|
273
|
+
// one aside, each by short id with its author, oldest first; none when this checkout lacks the
|
|
274
|
+
// approved commit.
|
|
275
|
+
export function commitsAddedSince(cwd, tip, at, start) {
|
|
276
|
+
const approved = commitOf(cwd, tip.commit);
|
|
277
|
+
if (!approved)
|
|
278
|
+
return [];
|
|
279
|
+
const listed = tried(cwd, 'log', '--no-merges', '--cherry-pick', '--right-only', '--reverse', '--format=%h%x09%an', '--abbrev=7', `${approved}...${at}`, ...(start ? [`^${start}`] : []));
|
|
280
|
+
if ('error' in listed)
|
|
281
|
+
return [];
|
|
282
|
+
return listed.out
|
|
283
|
+
.split(/\r?\n/)
|
|
284
|
+
.filter(Boolean)
|
|
285
|
+
.map((line) => {
|
|
286
|
+
const [commit = '', author = ''] = line.split('\t');
|
|
287
|
+
return { commit, author };
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function treeOf(cwd, commit) {
|
|
291
|
+
try {
|
|
292
|
+
return git(cwd, 'rev-parse', '--verify', '--quiet', `${commit}^{tree}`) || undefined;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Whether all that `commit` changes is in `base` already: merging it in leaves the base's tree as
|
|
299
|
+
// it is, as once a forge squash-merged or rebased it there (P3C-R3-10). False when this checkout
|
|
300
|
+
// lacks either commit, or the merge conflicts.
|
|
301
|
+
export function landedIn(cwd, commit, base) {
|
|
302
|
+
const tip = commitOf(cwd, commit);
|
|
303
|
+
const onto = commitOf(cwd, base);
|
|
304
|
+
if (!tip || !onto)
|
|
305
|
+
return false;
|
|
306
|
+
try {
|
|
307
|
+
const tree = git(cwd, 'merge-tree', '--write-tree', onto, tip).split(/\r?\n/)[0];
|
|
308
|
+
return tree !== undefined && tree === treeOf(cwd, onto);
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// What an agent hands a branch off at: its commit and tree, for the gate to hold the landing to
|
|
315
|
+
// what the person approved. The remote's branch when it has one (the review reads what was
|
|
316
|
+
// pushed), else the local one; `local` first for a branch never pushed before its approval (the
|
|
317
|
+
// base itself, on a board that works straight on it). Undefined when this checkout has neither.
|
|
318
|
+
export function tipOf(cwd, branch, local = false) {
|
|
319
|
+
const here = commitOf(cwd, `refs/heads/${branch}`);
|
|
320
|
+
const remote = remoteName(cwd, branch);
|
|
321
|
+
const there = remote === undefined ? undefined : commitOf(cwd, remote);
|
|
322
|
+
const commit = local ? (here ?? there) : (there ?? here);
|
|
323
|
+
const tree = commit === undefined ? undefined : treeOf(cwd, commit);
|
|
324
|
+
return commit === undefined || tree === undefined ? undefined : { branch, commit, tree };
|
|
325
|
+
}
|
|
326
|
+
// The commits in `tip` and not in `base` that none of the `held` branches holds, nor any of the
|
|
327
|
+
// `tips` (commits that hold the history under them; one this checkout lacks holds nothing), oldest
|
|
328
|
+
// first, each by its full id with its subject, merge commits aside; `refs` are the refs the push
|
|
329
|
+
// brings in, a branch counting by its local ref and by the remote's alike.
|
|
330
|
+
function commitsOutside(cwd, tip, base, held, refs, remotes, tips = []) {
|
|
331
|
+
const holding = refs.filter((ref) => held.some((name) => ref === `refs/heads/${name}` ||
|
|
332
|
+
remotes.some((remote) => ref === `refs/remotes/${remote}/${name}`)));
|
|
333
|
+
const under = tips.flatMap((commit) => commitOf(cwd, commit) ?? []);
|
|
334
|
+
const listed = git(cwd, 'log', '--no-merges', '--reverse', '--format=%H%x09%s', tip, `^${base}`, ...holding.map((ref) => `^${ref}`), ...under.map((commit) => `^${commit}`), '--');
|
|
335
|
+
return listed
|
|
336
|
+
.split(/\r?\n/)
|
|
337
|
+
.filter(Boolean)
|
|
338
|
+
.map((line) => {
|
|
339
|
+
const [commit = '', ...subject] = line.split('\t');
|
|
340
|
+
return { commit, subject: subject.join('\t') };
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// The remote branch a local one is pushed to, by name (origin/feat/x): the remote-tracking branch
|
|
344
|
+
// of the same name, on the remote its upstream names or else on origin; only when the remote has
|
|
345
|
+
// none of that name, its upstream. git switch -c feat/x origin/main gives feat/x the upstream
|
|
346
|
+
// origin/main, yet what the review saw is what was pushed to origin/feat/x (P1-R2-1). Undefined
|
|
347
|
+
// when the remote has neither.
|
|
348
|
+
function remoteName(cwd, branch) {
|
|
349
|
+
const same = sameNameRemote(cwd, branch);
|
|
350
|
+
if (same)
|
|
351
|
+
return same;
|
|
352
|
+
try {
|
|
353
|
+
return git(cwd, 'rev-parse', '--abbrev-ref', `${branch}@{upstream}`) || undefined;
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// The remote the branch is pushed to: the one its upstream names, else origin.
|
|
360
|
+
function pushRemote(cwd, branch) {
|
|
361
|
+
const named = configured(cwd, `branch.${branch}.remote`);
|
|
362
|
+
return named === undefined || named === '.' ? 'origin' : named;
|
|
363
|
+
}
|
|
364
|
+
// The remote-tracking branch of the same name, on the remote its upstream names or else on origin.
|
|
365
|
+
function sameNameRemote(cwd, branch) {
|
|
366
|
+
for (const remote of new Set([pushRemote(cwd, branch), 'origin'])) {
|
|
367
|
+
if (commitOf(cwd, `refs/remotes/${remote}/${branch}`))
|
|
368
|
+
return `${remote}/${branch}`;
|
|
369
|
+
}
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
export function pushState(cwd, branch) {
|
|
373
|
+
try {
|
|
374
|
+
git(cwd, 'rev-parse', '--git-dir');
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
const here = commitOf(cwd, `refs/heads/${branch}`);
|
|
380
|
+
const remote = sameNameRemote(cwd, branch);
|
|
381
|
+
const push = pushRemote(cwd, branch);
|
|
382
|
+
if (!here) {
|
|
383
|
+
if (remote)
|
|
384
|
+
return { kind: 'pushed' };
|
|
385
|
+
const on = checkedOutBranch(cwd);
|
|
386
|
+
return on === undefined ? { kind: 'missing' } : { kind: 'missing', on };
|
|
387
|
+
}
|
|
388
|
+
if (remote) {
|
|
389
|
+
return isAncestor(cwd, here, remote) ? { kind: 'pushed' } : { kind: 'ahead', remote, push };
|
|
390
|
+
}
|
|
391
|
+
const remotes = git(cwd, 'remote').split(/\r?\n/).filter(Boolean);
|
|
392
|
+
return remotes.length === 0 ? { kind: 'local' } : { kind: 'unpushed', push };
|
|
393
|
+
}
|
|
394
|
+
// A git config value, or undefined when it is not set.
|
|
395
|
+
function configured(cwd, key) {
|
|
396
|
+
try {
|
|
397
|
+
return git(cwd, 'config', '--get', key) || undefined;
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function isAncestor(cwd, ancestor, of) {
|
|
404
|
+
try {
|
|
405
|
+
git(cwd, 'merge-base', '--is-ancestor', ancestor, of);
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export function mergedInto(cwd, branch, base) {
|
|
413
|
+
const tip = commitOf(cwd, `refs/heads/${branch}`) ?? commitOf(cwd, `refs/remotes/origin/${branch}`);
|
|
414
|
+
if (!tip)
|
|
415
|
+
return undefined;
|
|
416
|
+
const remote = remoteOf(cwd, base);
|
|
417
|
+
const holds = (ref) => commitOf(cwd, ref) !== undefined && isAncestor(cwd, tip, ref);
|
|
418
|
+
if (holds(`refs/remotes/${remote}`))
|
|
419
|
+
return { merged: true };
|
|
420
|
+
if (!holds(`refs/heads/${base}`))
|
|
421
|
+
return undefined;
|
|
422
|
+
const remotes = git(cwd, 'remote').split(/\r?\n/).filter(Boolean);
|
|
423
|
+
if (remotes.length === 0)
|
|
424
|
+
return { merged: true };
|
|
425
|
+
return { merged: false, remote, push: pushRemote(cwd, base) };
|
|
426
|
+
}
|
|
427
|
+
// What the remote has of a branch, as this checkout last saw it: the remote branch it is pushed
|
|
428
|
+
// to (remoteName), or else origin/<branch>.
|
|
429
|
+
export function remoteOf(cwd, branch) {
|
|
430
|
+
return remoteName(cwd, branch) ?? `origin/${branch}`;
|
|
431
|
+
}
|
|
432
|
+
// Whether cwd is in a repo's main checkout, not one of its linked worktrees (git worktree add);
|
|
433
|
+
// false outside a repo.
|
|
434
|
+
export function inMainCheckout(cwd) {
|
|
435
|
+
try {
|
|
436
|
+
const dir = resolve(cwd, git(cwd, 'rev-parse', '--git-dir'));
|
|
437
|
+
const common = resolve(cwd, git(cwd, 'rev-parse', '--git-common-dir'));
|
|
438
|
+
return dir === common;
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
// The top folder of the checkout at cwd (a linked worktree's own, not the main checkout's), or
|
|
445
|
+
// undefined outside a repo.
|
|
446
|
+
export function checkoutRoot(cwd) {
|
|
447
|
+
try {
|
|
448
|
+
return resolve(git(cwd, 'rev-parse', '--show-toplevel'));
|
|
449
|
+
}
|
|
450
|
+
catch {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// The top folder of the repo at cwd, or cwd itself outside a repo.
|
|
455
|
+
export function repoRoot(cwd) {
|
|
456
|
+
return checkoutRoot(cwd) ?? resolve(cwd);
|
|
457
|
+
}
|
|
458
|
+
// Where the repo at cwd keeps a path of its git dir, following its config (core.hooksPath for
|
|
459
|
+
// hooks/); throws outside a repo.
|
|
460
|
+
export function gitPath(cwd, path) {
|
|
461
|
+
return resolve(cwd, git(cwd, 'rev-parse', '--git-path', path));
|
|
462
|
+
}
|
|
463
|
+
export function keepOutOfGit(file) {
|
|
464
|
+
let top;
|
|
465
|
+
try {
|
|
466
|
+
top = git(dirname(file), 'rev-parse', '--show-toplevel');
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
return 'outside';
|
|
470
|
+
}
|
|
471
|
+
const path = relative(top, file).split(sep).join('/');
|
|
472
|
+
try {
|
|
473
|
+
git(top, 'ls-files', '--error-unmatch', '--', path);
|
|
474
|
+
return 'tracked';
|
|
475
|
+
}
|
|
476
|
+
catch { }
|
|
477
|
+
excludeFromGit(resolve(top, git(top, 'rev-parse', '--git-common-dir')), `/${path}`);
|
|
478
|
+
return 'excluded';
|
|
479
|
+
}
|
|
480
|
+
// What a command says after the file it wrote, by how it stands with git.
|
|
481
|
+
export function keptOutNote(file, kept) {
|
|
482
|
+
if (kept === 'excluded') {
|
|
483
|
+
return "kept out of git through .git/info/exclude: it names this machine's path to Otea";
|
|
484
|
+
}
|
|
485
|
+
if (kept === 'tracked') {
|
|
486
|
+
return `${basename(file)} is tracked by git: it now names this machine's path to Otea, so keep that change out of your commits`;
|
|
487
|
+
}
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
package/dist/cli/help.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AGENT_COMMANDS } from '../mcp/commands.js';
|
|
2
|
+
import { usageOf } from './command.js';
|
|
3
|
+
import { COMMANDS } from './commands.js';
|
|
4
|
+
import { EXIT_CODES } from './exit-codes.js';
|
|
5
|
+
import { columns, indent } from './format.js';
|
|
6
|
+
const GLOBAL_OPTIONS = [
|
|
7
|
+
['--json', 'Print JSON to stdout; errors go to stderr as {"error":{"code","message"}}'],
|
|
8
|
+
[
|
|
9
|
+
'--as <name>',
|
|
10
|
+
'Your agent name, recorded on writes and holding leases (or $OTEA_AGENT); agent commands need one, unique among the agents working now',
|
|
11
|
+
],
|
|
12
|
+
['-h, --help', 'Show help'],
|
|
13
|
+
];
|
|
14
|
+
function exitCodeRows() {
|
|
15
|
+
const names = new Map();
|
|
16
|
+
for (const [name, code] of Object.entries(EXIT_CODES)) {
|
|
17
|
+
names.set(code, [...(names.get(code) ?? []), name]);
|
|
18
|
+
}
|
|
19
|
+
return [...names].map(([code, group]) => [String(code), group.join(', ')]);
|
|
20
|
+
}
|
|
21
|
+
export const HELP_HINT = 'Run "otea help" for usage.';
|
|
22
|
+
// The words `otea help` takes after it: `all` for the whole reference, or a command's name.
|
|
23
|
+
export const HELP_ALL = 'all';
|
|
24
|
+
// A command's summary cut to its first clause, for a line of the short help.
|
|
25
|
+
const LINE = 90;
|
|
26
|
+
function shortSummary(summary) {
|
|
27
|
+
const clause = summary.split(/[;:(]|\. /)[0]?.trim() ?? summary;
|
|
28
|
+
return clause.length <= LINE ? clause : `${clause.slice(0, LINE - 1).trimEnd()}…`;
|
|
29
|
+
}
|
|
30
|
+
// A list of words wrapped to the width of the help, each line indented.
|
|
31
|
+
function wrapped(words, width = 98) {
|
|
32
|
+
const lines = [];
|
|
33
|
+
let line = '';
|
|
34
|
+
for (const word of words) {
|
|
35
|
+
const next = line === '' ? word : `${line} ${word}`;
|
|
36
|
+
if (next.length > width && line !== '') {
|
|
37
|
+
lines.push(line);
|
|
38
|
+
line = word;
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
line = next;
|
|
42
|
+
}
|
|
43
|
+
if (line !== '')
|
|
44
|
+
lines.push(line);
|
|
45
|
+
return indent(lines.join('\n'));
|
|
46
|
+
}
|
|
47
|
+
// What `otea help` prints: short, since every agent reads it first. The agent commands a line each,
|
|
48
|
+
// the rest by name, and where the whole reference is.
|
|
49
|
+
export function shortHelp() {
|
|
50
|
+
const agent = new Set(AGENT_COMMANDS);
|
|
51
|
+
const rows = COMMANDS.filter(({ name }) => agent.has(name)).map((command) => [
|
|
52
|
+
usageOf(command)
|
|
53
|
+
.replace(/^otea /, '')
|
|
54
|
+
.replace(/ \[--?[^\]]*\]| --[\w-]+ <[^>]*>/g, ''),
|
|
55
|
+
shortSummary(command.summary),
|
|
56
|
+
]);
|
|
57
|
+
const others = COMMANDS.filter(({ name }) => !agent.has(name)).map(({ name }) => name);
|
|
58
|
+
return [
|
|
59
|
+
'Usage: otea <command> [options]',
|
|
60
|
+
'',
|
|
61
|
+
'An agent starts with otea board (the guide and the boards), then otea next (what to take now), and names itself on every command with --as <name>.',
|
|
62
|
+
'',
|
|
63
|
+
'Agent commands (the same as MCP tools):',
|
|
64
|
+
indent(columns(rows)),
|
|
65
|
+
'',
|
|
66
|
+
"Setup and the person's commands:",
|
|
67
|
+
wrapped(others.map((name, index) => (index < others.length - 1 ? `${name},` : name))),
|
|
68
|
+
'',
|
|
69
|
+
`otea <command> --help (or otea help <command>) prints a command's options; otea help ${HELP_ALL} prints every command in full, the global options and the exit codes.`,
|
|
70
|
+
].join('\n');
|
|
71
|
+
}
|
|
72
|
+
export function generalHelp() {
|
|
73
|
+
return [
|
|
74
|
+
'Usage: otea <command> [options]',
|
|
75
|
+
'',
|
|
76
|
+
'Commands:',
|
|
77
|
+
...COMMANDS.map((command) => indent(`${usageOf(command)}\n${indent(command.summary)}`)),
|
|
78
|
+
'',
|
|
79
|
+
'Global options:',
|
|
80
|
+
indent(columns(GLOBAL_OPTIONS)),
|
|
81
|
+
'',
|
|
82
|
+
'Exit codes:',
|
|
83
|
+
indent(columns(exitCodeRows())),
|
|
84
|
+
].join('\n');
|
|
85
|
+
}
|
|
86
|
+
// A group's commands (otea topic --help): each one's usage and what it does.
|
|
87
|
+
export function groupHelp(group) {
|
|
88
|
+
const commands = COMMANDS.filter(({ name }) => name.startsWith(`${group} `));
|
|
89
|
+
if (commands.length === 0)
|
|
90
|
+
return undefined;
|
|
91
|
+
return [
|
|
92
|
+
`Usage: otea ${group} <command> [options]`,
|
|
93
|
+
'',
|
|
94
|
+
'Commands:',
|
|
95
|
+
...commands.map((command) => indent(`${usageOf(command)}\n${indent(command.summary)}`)),
|
|
96
|
+
].join('\n');
|
|
97
|
+
}
|
|
98
|
+
export function commandHelp(command) {
|
|
99
|
+
const details = command.details === undefined ? '' : `\n\n${command.details}`;
|
|
100
|
+
return `Usage: ${usageOf(command)}\n\n${command.summary}${details}`;
|
|
101
|
+
}
|