lopebase 0.6.5 → 0.6.7
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/README.md +43 -1
- package/dist/lopebase.js +328 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,6 +89,35 @@ Made for web products, and fine with anything else:
|
|
|
89
89
|
| `npx lopebase mcp` | Run the LopeBase tools as a local MCP server (stdio) for any agent. |
|
|
90
90
|
| `npx lopebase adapter secret` | Print a new signing secret for [@lopebase/adapter](https://www.npmjs.com/package/@lopebase/adapter). Pipe it straight into your secret store. |
|
|
91
91
|
| `npx lopebase adapter check <url>` | Test a running adapter, local or deployed, before you connect it. |
|
|
92
|
+
| `npx lopebase blog check [dir]` | Check the blog posts LopeBase publishes to your repo. Exits 1 on any problem, for CI. `--format <preset>`, `--allow-empty`. |
|
|
93
|
+
|
|
94
|
+
## Check published blog posts in CI
|
|
95
|
+
|
|
96
|
+
When LopeBase publishes articles to your GitHub repo, add this to CI so a
|
|
97
|
+
malformed post fails the check instead of breaking your site build:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
npx lopebase blog check --format astro
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
It reads only the post files in one folder, with no network calls, and prints
|
|
104
|
+
one line per problem as `<file>: <problem>` plus a summary.
|
|
105
|
+
|
|
106
|
+
| Preset | Folder | File name |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| `markdown` (default) | `content/blog` | `<slug>.md` |
|
|
109
|
+
| `next-mdx` | `content/blog` | `<slug>.mdx` |
|
|
110
|
+
| `astro` | `src/content/blog` | `<slug>.md` |
|
|
111
|
+
| `hugo` | `content/posts` | `<slug>.md` |
|
|
112
|
+
| `jekyll` | `_posts` | `YYYY-MM-DD-<slug>.md` |
|
|
113
|
+
|
|
114
|
+
Pass a folder to check somewhere else. For each post it checks the front
|
|
115
|
+
matter (required fields, quoted strings, dates, tag and image lists), that the
|
|
116
|
+
slug is lowercase words joined by hyphens and matches the file name, that the
|
|
117
|
+
body has at least one `##` heading, does not open with a `#` heading, and has
|
|
118
|
+
no raw HTML outside code, and that no two posts share a slug. A missing or
|
|
119
|
+
empty folder fails too, unless you pass `--allow-empty` (useful before the
|
|
120
|
+
first post lands).
|
|
92
121
|
|
|
93
122
|
## What it reads, and what it keeps
|
|
94
123
|
|
|
@@ -103,10 +132,23 @@ Made for web products, and fine with anything else:
|
|
|
103
132
|
- **Keeps** one thing: an agent token in `~/.config/lopebase/auth.json`,
|
|
104
133
|
readable only by you. It lasts 30 days, acts as the workspace admin who
|
|
105
134
|
approved it, is limited to what that admin allowed, and can be revoked any
|
|
106
|
-
time under
|
|
135
|
+
time under Agents, Access.
|
|
107
136
|
- `LOPEBASE_TOKEN` and `LOPEBASE_URL` override the saved values, for CI or
|
|
108
137
|
another machine.
|
|
109
138
|
|
|
139
|
+
## Run it from an agent or CI
|
|
140
|
+
|
|
141
|
+
Setup and `npx lopebase login` ask questions, so they need an interactive
|
|
142
|
+
terminal. Started without one (a coding agent's shell, CI, a pipe), they stop
|
|
143
|
+
with an error and list what works instead:
|
|
144
|
+
|
|
145
|
+
- `npx lopebase prompt` prints the setup prompt with this project's scan.
|
|
146
|
+
- `npx lopebase scan --json` prints the scan.
|
|
147
|
+
- Add `https://app.lopebase.com/api/mcp` to your agent as a remote MCP server;
|
|
148
|
+
it opens a browser page for you to approve.
|
|
149
|
+
- Or set `LOPEBASE_TOKEN` to an agent token (Agents, Access in LopeBase) and
|
|
150
|
+
register `npx -y lopebase mcp` as a stdio MCP server.
|
|
151
|
+
|
|
110
152
|
## Use it with any agent
|
|
111
153
|
|
|
112
154
|
`npx lopebase` sets this up for you. To add the tools by hand, register this
|
package/dist/lopebase.js
CHANGED
|
@@ -502,7 +502,7 @@ var require_cross_spawn = __commonJS(function(exports, module) {
|
|
|
502
502
|
|
|
503
503
|
// bin/lopebase.ts
|
|
504
504
|
import { spawn as spawn2 } from "node:child_process";
|
|
505
|
-
import { readFileSync as
|
|
505
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
506
506
|
|
|
507
507
|
// ../../node_modules/.bun/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
|
|
508
508
|
import { stripVTControlCharacters as S2 } from "node:util";
|
|
@@ -1665,12 +1665,275 @@ function installedAgents() {
|
|
|
1665
1665
|
return AGENTS.filter((a) => isInstalled(a.bin));
|
|
1666
1666
|
}
|
|
1667
1667
|
|
|
1668
|
+
// src/blog-check.ts
|
|
1669
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
1670
|
+
import { join } from "node:path";
|
|
1671
|
+
// ../lopebase-blog/src/contract.ts
|
|
1672
|
+
var shared = {
|
|
1673
|
+
title: { kind: "string", required: !0, role: "title" },
|
|
1674
|
+
description: { kind: "string", required: !0, role: "description" },
|
|
1675
|
+
author: { kind: "string", role: "author" },
|
|
1676
|
+
tags: { kind: "tags", role: "tags" }
|
|
1677
|
+
}, markdownKeys = {
|
|
1678
|
+
...shared,
|
|
1679
|
+
date: { kind: "date", required: !0, role: "date" },
|
|
1680
|
+
slug: { kind: "string", required: !0, role: "slug" },
|
|
1681
|
+
updated: { kind: "date", role: "updated" },
|
|
1682
|
+
image: { kind: "url", role: "image" },
|
|
1683
|
+
image_alt: { kind: "string", role: "imageAlt" },
|
|
1684
|
+
image_kind: { kind: "imageKind", role: "imageKind" },
|
|
1685
|
+
faq: { kind: "faq", role: "faq" }
|
|
1686
|
+
}, BLOG_PRESETS = {
|
|
1687
|
+
markdown: {
|
|
1688
|
+
dir: "content/blog",
|
|
1689
|
+
ext: ".md",
|
|
1690
|
+
keys: markdownKeys,
|
|
1691
|
+
slugKey: "slug"
|
|
1692
|
+
},
|
|
1693
|
+
"next-mdx": {
|
|
1694
|
+
dir: "content/blog",
|
|
1695
|
+
ext: ".mdx",
|
|
1696
|
+
keys: markdownKeys,
|
|
1697
|
+
slugKey: "slug"
|
|
1698
|
+
},
|
|
1699
|
+
astro: {
|
|
1700
|
+
dir: "src/content/blog",
|
|
1701
|
+
ext: ".md",
|
|
1702
|
+
keys: {
|
|
1703
|
+
...shared,
|
|
1704
|
+
pubDate: { kind: "date", required: !0, role: "date" },
|
|
1705
|
+
updatedDate: { kind: "date", role: "updated" },
|
|
1706
|
+
heroImage: { kind: "url", role: "image" }
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
hugo: {
|
|
1710
|
+
dir: "content/posts",
|
|
1711
|
+
ext: ".md",
|
|
1712
|
+
keys: {
|
|
1713
|
+
...shared,
|
|
1714
|
+
date: { kind: "datetime", required: !0, role: "date" },
|
|
1715
|
+
slug: { kind: "string", required: !0, role: "slug" },
|
|
1716
|
+
lastmod: { kind: "datetime", role: "updated" },
|
|
1717
|
+
images: { kind: "urls", role: "images" }
|
|
1718
|
+
},
|
|
1719
|
+
slugKey: "slug"
|
|
1720
|
+
},
|
|
1721
|
+
jekyll: {
|
|
1722
|
+
dir: "_posts",
|
|
1723
|
+
ext: ".md",
|
|
1724
|
+
keys: {
|
|
1725
|
+
layout: { kind: "layout", required: !0 },
|
|
1726
|
+
...shared,
|
|
1727
|
+
date: { kind: "date", required: !0, role: "date" },
|
|
1728
|
+
last_modified_at: { kind: "date", role: "updated" },
|
|
1729
|
+
image: { kind: "url", role: "image" }
|
|
1730
|
+
},
|
|
1731
|
+
datedFileKey: "date"
|
|
1732
|
+
}
|
|
1733
|
+
}, isBlogFormat = (v) => Object.hasOwn(BLOG_PRESETS, v), IMAGE_KINDS = ["title_card", "artwork"], SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/, DATE = /^(\d{4})-(\d{2})-(\d{2})$/, DATETIME = /^(\d{4})-(\d{2})-(\d{2})T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/, JEKYLL_FILE = /^(\d{4}-\d{2}-\d{2})-(.+)$/, HTML_TAG = /<\/?[A-Za-z][A-Za-z0-9-]*(?:\s[^<>]*)?\/?>|<!--/;
|
|
1734
|
+
function realDate(y, m, d) {
|
|
1735
|
+
let date = new Date(Date.UTC(+y, +m - 1, +d));
|
|
1736
|
+
return date.getUTCFullYear() === +y && date.getUTCMonth() === +m - 1 && date.getUTCDate() === +d;
|
|
1737
|
+
}
|
|
1738
|
+
function isUrl(v) {
|
|
1739
|
+
if (typeof v !== "string")
|
|
1740
|
+
return !1;
|
|
1741
|
+
try {
|
|
1742
|
+
let u = new URL(v);
|
|
1743
|
+
return u.protocol === "https:" || u.protocol === "http:";
|
|
1744
|
+
} catch {
|
|
1745
|
+
return !1;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
var filled = (v) => typeof v === "string" && v.trim() !== "";
|
|
1749
|
+
function json(raw) {
|
|
1750
|
+
try {
|
|
1751
|
+
return { ok: !0, value: JSON.parse(raw) };
|
|
1752
|
+
} catch {
|
|
1753
|
+
return { ok: !1 };
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
function checkValue(key, kind, raw) {
|
|
1757
|
+
switch (kind) {
|
|
1758
|
+
case "layout":
|
|
1759
|
+
return raw === "post" ? void 0 : `${key} must be post`;
|
|
1760
|
+
case "imageKind": {
|
|
1761
|
+
let v = json(raw);
|
|
1762
|
+
return v.ok && IMAGE_KINDS.includes(v.value) ? void 0 : `${key} must be "title_card" or "artwork"`;
|
|
1763
|
+
}
|
|
1764
|
+
case "date": {
|
|
1765
|
+
let m = DATE.exec(raw);
|
|
1766
|
+
return m && realDate(m[1], m[2], m[3]) ? void 0 : `${key} must be a date like 2026-11-05`;
|
|
1767
|
+
}
|
|
1768
|
+
case "datetime": {
|
|
1769
|
+
let m = DATETIME.exec(raw);
|
|
1770
|
+
return m && realDate(m[1], m[2], m[3]) ? void 0 : `${key} must be a date and time like 2026-11-05T15:00:00Z`;
|
|
1771
|
+
}
|
|
1772
|
+
case "string": {
|
|
1773
|
+
let v = json(raw);
|
|
1774
|
+
if (!v.ok || typeof v.value !== "string")
|
|
1775
|
+
return `${key} must be a quoted string`;
|
|
1776
|
+
return v.value.trim() ? void 0 : `${key} is empty`;
|
|
1777
|
+
}
|
|
1778
|
+
case "url": {
|
|
1779
|
+
let v = json(raw);
|
|
1780
|
+
return v.ok && isUrl(v.value) ? void 0 : `${key} must be a quoted http or https address`;
|
|
1781
|
+
}
|
|
1782
|
+
case "tags": {
|
|
1783
|
+
let v = json(raw);
|
|
1784
|
+
return v.ok && Array.isArray(v.value) && v.value.every((t) => typeof t === "string") ? void 0 : `${key} must be a list of quoted strings, like ["seo"]`;
|
|
1785
|
+
}
|
|
1786
|
+
case "urls": {
|
|
1787
|
+
let v = json(raw);
|
|
1788
|
+
return v.ok && Array.isArray(v.value) && v.value.every(isUrl) ? void 0 : `${key} must be a list of quoted http or https addresses`;
|
|
1789
|
+
}
|
|
1790
|
+
case "faq": {
|
|
1791
|
+
let v = json(raw);
|
|
1792
|
+
return v.ok && Array.isArray(v.value) && v.value.every((f) => f !== null && typeof f === "object" && filled(f.q) && filled(f.a)) ? void 0 : `${key} must be one line of JSON like [{"q": "A question?", "a": "An answer."}]`;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
function proseOnly(body) {
|
|
1797
|
+
let out = [], fence;
|
|
1798
|
+
for (let line of body.split(`
|
|
1799
|
+
`)) {
|
|
1800
|
+
let open = /^\s{0,3}(`{3,}|~{3,})/.exec(line);
|
|
1801
|
+
if (fence) {
|
|
1802
|
+
if (open && open[1][0] === fence[0] && open[1].length >= fence.length)
|
|
1803
|
+
fence = void 0;
|
|
1804
|
+
continue;
|
|
1805
|
+
}
|
|
1806
|
+
if (open) {
|
|
1807
|
+
fence = open[1];
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
out.push(line.replace(/(`+)[^`]*?\1/g, ""));
|
|
1811
|
+
}
|
|
1812
|
+
return out;
|
|
1813
|
+
}
|
|
1814
|
+
function inspectPost(fileName, text, format) {
|
|
1815
|
+
let preset = BLOG_PRESETS[format], problems = [], base = fileName.endsWith(preset.ext) ? fileName.slice(0, fileName.length - preset.ext.length) : fileName.replace(/\.[^.]*$/, ""), fileSlug = base, fileDate;
|
|
1816
|
+
if (preset.datedFileKey) {
|
|
1817
|
+
let m = JEKYLL_FILE.exec(base);
|
|
1818
|
+
if (m)
|
|
1819
|
+
fileDate = m[1], fileSlug = m[2];
|
|
1820
|
+
else
|
|
1821
|
+
problems.push("file name must look like YYYY-MM-DD-<slug>.md");
|
|
1822
|
+
}
|
|
1823
|
+
if (!SLUG.test(fileSlug))
|
|
1824
|
+
problems.push(`file name slug "${fileSlug}" must be lowercase words joined by hyphens`);
|
|
1825
|
+
let lines = text.replace(/^/, "").split(/\r?\n/), end = lines[0] === "---" ? lines.indexOf("---", 1) : -1;
|
|
1826
|
+
if (end < 0)
|
|
1827
|
+
return problems.push("front matter must open and close with --- lines at the top"), { slug: fileSlug, problems };
|
|
1828
|
+
let raws = /* @__PURE__ */ new Map;
|
|
1829
|
+
for (let line of lines.slice(1, end)) {
|
|
1830
|
+
if (!line.trim())
|
|
1831
|
+
continue;
|
|
1832
|
+
let m = /^([A-Za-z_][A-Za-z0-9_]*):\s*(.*)$/.exec(line);
|
|
1833
|
+
if (!m) {
|
|
1834
|
+
problems.push(`front matter line is not "key: value": ${line.trim()}`);
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
if (raws.has(m[1]))
|
|
1838
|
+
problems.push(`${m[1]} appears more than once`);
|
|
1839
|
+
raws.set(m[1], m[2].trim());
|
|
1840
|
+
}
|
|
1841
|
+
let values = {};
|
|
1842
|
+
for (let [key, spec] of Object.entries(preset.keys)) {
|
|
1843
|
+
let raw = raws.get(key);
|
|
1844
|
+
if (raw === void 0 || raw === "") {
|
|
1845
|
+
if (spec.required)
|
|
1846
|
+
problems.push(`missing ${key}`);
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
let problem = checkValue(key, spec.kind, raw);
|
|
1850
|
+
if (problem)
|
|
1851
|
+
problems.push(problem);
|
|
1852
|
+
else if (spec.role)
|
|
1853
|
+
values[spec.role] = spec.kind === "date" || spec.kind === "datetime" ? raw : JSON.parse(raw);
|
|
1854
|
+
}
|
|
1855
|
+
let slug = fileSlug;
|
|
1856
|
+
if (preset.slugKey) {
|
|
1857
|
+
let v = json(raws.get(preset.slugKey) ?? "");
|
|
1858
|
+
if (v.ok && typeof v.value === "string" && v.value) {
|
|
1859
|
+
if (!SLUG.test(v.value))
|
|
1860
|
+
problems.push(`${preset.slugKey} "${v.value}" must be lowercase words joined by hyphens`);
|
|
1861
|
+
else if (v.value !== fileSlug)
|
|
1862
|
+
problems.push(`${preset.slugKey} "${v.value}" does not match the file name "${fileSlug}"`);
|
|
1863
|
+
slug = v.value;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
if (preset.datedFileKey && fileDate) {
|
|
1867
|
+
let date = raws.get(preset.datedFileKey);
|
|
1868
|
+
if (date && DATE.test(date) && date !== fileDate)
|
|
1869
|
+
problems.push(`${preset.datedFileKey} ${date} does not match the file name date ${fileDate}`);
|
|
1870
|
+
}
|
|
1871
|
+
let body = lines.slice(end + 1).join(`
|
|
1872
|
+
`), fields = { slug, values, body };
|
|
1873
|
+
if (!body.trim())
|
|
1874
|
+
return problems.push("the post has no body"), { slug, problems, fields };
|
|
1875
|
+
let prose = proseOnly(body), first = body.split(`
|
|
1876
|
+
`).find((l) => l.trim());
|
|
1877
|
+
if (first && /^\s{0,3}#(?:\s|$)/.test(first))
|
|
1878
|
+
problems.push("the body starts with a # heading; the title comes from front matter");
|
|
1879
|
+
if (!prose.some((l) => /^\s{0,3}## /.test(l)))
|
|
1880
|
+
problems.push("the body needs at least one ## heading");
|
|
1881
|
+
if (prose.some((l) => HTML_TAG.test(l)))
|
|
1882
|
+
problems.push("the body has raw HTML outside code; use Markdown instead");
|
|
1883
|
+
return { slug, problems, fields };
|
|
1884
|
+
}
|
|
1885
|
+
function checkPost(fileName, text, format) {
|
|
1886
|
+
let { slug, problems } = inspectPost(fileName, text, format);
|
|
1887
|
+
return { slug, problems };
|
|
1888
|
+
}
|
|
1889
|
+
// src/blog-check.ts
|
|
1890
|
+
function checkBlog(opts) {
|
|
1891
|
+
let format = opts.format ?? "markdown", preset = BLOG_PRESETS[format], dir = (opts.dir ?? preset.dir).replace(/\\/g, "/").replace(/\/+$/, ""), abs = join(opts.cwd, dir), problems = [], names;
|
|
1892
|
+
try {
|
|
1893
|
+
if (!statSync(abs).isDirectory())
|
|
1894
|
+
return {
|
|
1895
|
+
dir,
|
|
1896
|
+
posts: 0,
|
|
1897
|
+
problems: [{ file: dir, problem: "is not a folder" }]
|
|
1898
|
+
};
|
|
1899
|
+
names = readdirSync(abs, { withFileTypes: !0 }).filter((e) => e.isFile() && e.name.endsWith(preset.ext)).map((e) => e.name).sort();
|
|
1900
|
+
} catch {
|
|
1901
|
+
return {
|
|
1902
|
+
dir,
|
|
1903
|
+
posts: 0,
|
|
1904
|
+
problems: opts.allowEmpty ? [] : [{ file: dir, problem: "folder not found (pass --allow-empty)" }]
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
if (!names.length && !opts.allowEmpty)
|
|
1908
|
+
problems.push({
|
|
1909
|
+
file: dir,
|
|
1910
|
+
problem: `no ${preset.ext} posts found (pass --allow-empty)`
|
|
1911
|
+
});
|
|
1912
|
+
let seen = /* @__PURE__ */ new Map;
|
|
1913
|
+
for (let name of names) {
|
|
1914
|
+
let file = `${dir}/${name}`, res = checkPost(name, readFileSync(join(abs, name), "utf8"), format);
|
|
1915
|
+
for (let problem of res.problems)
|
|
1916
|
+
problems.push({ file, problem });
|
|
1917
|
+
if (res.slug) {
|
|
1918
|
+
let other = seen.get(res.slug);
|
|
1919
|
+
if (other)
|
|
1920
|
+
problems.push({
|
|
1921
|
+
file,
|
|
1922
|
+
problem: `slug "${res.slug}" is also used by ${other}`
|
|
1923
|
+
});
|
|
1924
|
+
else
|
|
1925
|
+
seen.set(res.slug, file);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
return { dir, posts: names.length, problems };
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1668
1931
|
// src/config.ts
|
|
1669
1932
|
import {
|
|
1670
1933
|
chmodSync,
|
|
1671
1934
|
existsSync,
|
|
1672
1935
|
mkdirSync,
|
|
1673
|
-
readFileSync,
|
|
1936
|
+
readFileSync as readFileSync2,
|
|
1674
1937
|
writeFileSync
|
|
1675
1938
|
} from "node:fs";
|
|
1676
1939
|
import os from "node:os";
|
|
@@ -1716,7 +1979,7 @@ function loadAuth() {
|
|
|
1716
1979
|
if (!existsSync(authFile()))
|
|
1717
1980
|
return null;
|
|
1718
1981
|
try {
|
|
1719
|
-
let a = JSON.parse(
|
|
1982
|
+
let a = JSON.parse(readFileSync2(authFile(), "utf8"));
|
|
1720
1983
|
if (!a.token)
|
|
1721
1984
|
return null;
|
|
1722
1985
|
return { url: envUrl || a.url || DEFAULT_URL, token: a.token };
|
|
@@ -2439,6 +2702,25 @@ async function pollDeviceLogin(url, start, opts = {}) {
|
|
|
2439
2702
|
};
|
|
2440
2703
|
}
|
|
2441
2704
|
|
|
2705
|
+
// src/headless.ts
|
|
2706
|
+
function canPrompt(stdin = process.stdin, stdout = process.stdout) {
|
|
2707
|
+
return Boolean(stdin.isTTY && stdout.isTTY);
|
|
2708
|
+
}
|
|
2709
|
+
function headlessHelp() {
|
|
2710
|
+
return `npx lopebase needs an interactive terminal to sign in, and this one is not (no TTY).
|
|
2711
|
+
|
|
2712
|
+
For a coding agent or a script:
|
|
2713
|
+
npx lopebase prompt print the setup prompt, with this project's scan
|
|
2714
|
+
npx lopebase scan --json print the scan as JSON
|
|
2715
|
+
Add the MCP server https://app.lopebase.com/api/mcp to your agent. It opens
|
|
2716
|
+
a browser page for the person to approve.
|
|
2717
|
+
Or set LOPEBASE_TOKEN to an agent token (Agents, Access in LopeBase) and
|
|
2718
|
+
register "npx -y lopebase mcp" as a stdio MCP server.
|
|
2719
|
+
|
|
2720
|
+
To connect this computer, a person runs "npx lopebase login" in their own terminal.
|
|
2721
|
+
More: https://lopebase.com/docs/npx-lopebase#headless`;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2442
2724
|
// src/mcp-proxy.ts
|
|
2443
2725
|
import { createInterface as createInterface2 } from "node:readline";
|
|
2444
2726
|
async function runMcpProxy(auth, fetchImpl = fetch) {
|
|
@@ -2541,7 +2823,7 @@ function onboardingPrompt(input) {
|
|
|
2541
2823
|
}
|
|
2542
2824
|
|
|
2543
2825
|
// src/scan.ts
|
|
2544
|
-
import { existsSync as existsSync2, readdirSync, readFileSync as
|
|
2826
|
+
import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
2545
2827
|
import path2 from "node:path";
|
|
2546
2828
|
var MONOREPO_DIRS = ["apps", "packages", "services", "sites", "web", "site"], SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
2547
2829
|
"node_modules",
|
|
@@ -2599,7 +2881,7 @@ var MONOREPO_DIRS = ["apps", "packages", "services", "sites", "web", "site"], SK
|
|
|
2599
2881
|
], EXAMPLE_ENV = /^(\.env\.(example|sample|template|dist|local\.example|development\.example|production\.example)|example\.env|\.dev\.vars\.example)$/;
|
|
2600
2882
|
function readText(file) {
|
|
2601
2883
|
try {
|
|
2602
|
-
return
|
|
2884
|
+
return readFileSync3(file, "utf8");
|
|
2603
2885
|
} catch {
|
|
2604
2886
|
return null;
|
|
2605
2887
|
}
|
|
@@ -2616,14 +2898,14 @@ function readJson(file) {
|
|
|
2616
2898
|
}
|
|
2617
2899
|
function isDir(p) {
|
|
2618
2900
|
try {
|
|
2619
|
-
return
|
|
2901
|
+
return statSync2(p).isDirectory();
|
|
2620
2902
|
} catch {
|
|
2621
2903
|
return !1;
|
|
2622
2904
|
}
|
|
2623
2905
|
}
|
|
2624
2906
|
function listDir(dir) {
|
|
2625
2907
|
try {
|
|
2626
|
-
return
|
|
2908
|
+
return readdirSync2(dir);
|
|
2627
2909
|
} catch {
|
|
2628
2910
|
return [];
|
|
2629
2911
|
}
|
|
@@ -3041,11 +3323,11 @@ function watchRows(items) {
|
|
|
3041
3323
|
}
|
|
3042
3324
|
|
|
3043
3325
|
// src/update.ts
|
|
3044
|
-
import { readFileSync as
|
|
3326
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
3045
3327
|
import path3 from "node:path";
|
|
3046
3328
|
var readJson2 = (file) => {
|
|
3047
3329
|
try {
|
|
3048
|
-
return JSON.parse(
|
|
3330
|
+
return JSON.parse(readFileSync4(file, "utf8"));
|
|
3049
3331
|
} catch {
|
|
3050
3332
|
return null;
|
|
3051
3333
|
}
|
|
@@ -3099,6 +3381,8 @@ ${import_picocolors4.default.bold("Usage")}
|
|
|
3099
3381
|
npx lopebase mcp run the LopeBase tools as a stdio MCP server
|
|
3100
3382
|
npx lopebase adapter secret print a new @lopebase/adapter signing secret
|
|
3101
3383
|
npx lopebase adapter check <url> test a running adapter (reads LOPEBASE_SIGNING_SECRET)
|
|
3384
|
+
npx lopebase blog check [dir] check the blog posts LopeBase publishes to your repo
|
|
3385
|
+
(--format <preset>, --allow-empty)
|
|
3102
3386
|
|
|
3103
3387
|
${import_picocolors4.default.bold("Options")}
|
|
3104
3388
|
--print print the agent prompt instead of starting an agent
|
|
@@ -3114,7 +3398,7 @@ ${import_picocolors4.default.bold("Learn more")}
|
|
|
3114
3398
|
}, cwd = process.cwd(), motion = motionAllowed(), TAGLINE = "Every product, one place.", PAGEVIEWS = "LopeBase pageviews";
|
|
3115
3399
|
function version() {
|
|
3116
3400
|
try {
|
|
3117
|
-
return JSON.parse(
|
|
3401
|
+
return JSON.parse(readFileSync5(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
3118
3402
|
} catch {
|
|
3119
3403
|
return;
|
|
3120
3404
|
}
|
|
@@ -3122,6 +3406,11 @@ function version() {
|
|
|
3122
3406
|
function bail(message) {
|
|
3123
3407
|
xe(message), process.exit(1);
|
|
3124
3408
|
}
|
|
3409
|
+
function requireTerminal() {
|
|
3410
|
+
if (canPrompt())
|
|
3411
|
+
return;
|
|
3412
|
+
console.error(headlessHelp()), process.exit(1);
|
|
3413
|
+
}
|
|
3125
3414
|
function guard(value) {
|
|
3126
3415
|
if (pD(value))
|
|
3127
3416
|
bail("Stopped. Run lopebase again any time.");
|
|
@@ -3202,10 +3491,10 @@ async function askWorkspace() {
|
|
|
3202
3491
|
})));
|
|
3203
3492
|
}
|
|
3204
3493
|
async function pasteLogin(url) {
|
|
3205
|
-
let settings = `${url}/
|
|
3494
|
+
let settings = `${url}/agents?tab=access`;
|
|
3206
3495
|
Me([
|
|
3207
3496
|
"1. Sign in (or sign up) in the browser tab we open.",
|
|
3208
|
-
`2. Under
|
|
3497
|
+
`2. Under Agents, Access, press ${import_picocolors4.default.bold("Create agent access")}.`,
|
|
3209
3498
|
"3. Copy the token and paste it here. It is saved on this computer only."
|
|
3210
3499
|
].join(`
|
|
3211
3500
|
`), "Get an agent token"), openBrowser(settings), M2.info(import_picocolors4.default.dim(settings));
|
|
@@ -3269,7 +3558,7 @@ function registerMcp(agent) {
|
|
|
3269
3558
|
return res.status === 0 || /already exists/i.test(`${res.stderr}${res.stdout}`);
|
|
3270
3559
|
}
|
|
3271
3560
|
async function init() {
|
|
3272
|
-
if (console.clear(), await showLogo({ tagline: TAGLINE, version: version(), motion }), await horizon({ motion }), Ie(`${badge("LopeBase")} set up this project`), await noticeNewerCli(), Me(planLines().join(`
|
|
3561
|
+
if (requireTerminal(), console.clear(), await showLogo({ tagline: TAGLINE, version: version(), motion }), await horizon({ motion }), Ie(`${badge("LopeBase")} set up this project`), await noticeNewerCli(), Me(planLines().join(`
|
|
3273
3562
|
`), "Here is what happens"), !guard(await ye({
|
|
3274
3563
|
message: `Scan ${import_picocolors4.default.bold(cwd)}?`,
|
|
3275
3564
|
initialValue: !0
|
|
@@ -3411,6 +3700,29 @@ The adapter is in: ${where}. If you have the lopebase MCP tools, call get_onboar
|
|
|
3411
3700
|
` ${brand("3.")} run the adapter check and your tests`
|
|
3412
3701
|
]);
|
|
3413
3702
|
}
|
|
3703
|
+
var BLOG_USAGE = `Usage:
|
|
3704
|
+
lopebase blog check [dir] [--format <preset>] [--allow-empty]
|
|
3705
|
+
|
|
3706
|
+
Presets: ${Object.entries(BLOG_PRESETS).map(([name, preset]) => `${name} (${preset.dir})`).join(", ")}. Default: markdown.`;
|
|
3707
|
+
function blog() {
|
|
3708
|
+
if (rest[0] !== "check")
|
|
3709
|
+
return console.log(BLOG_USAGE), process.exit(rest[0] ? 1 : 0);
|
|
3710
|
+
let format = option("format") ?? "markdown";
|
|
3711
|
+
if (!isBlogFormat(format))
|
|
3712
|
+
return console.error(`Unknown format "${format}".
|
|
3713
|
+
|
|
3714
|
+
${BLOG_USAGE}`), process.exit(1);
|
|
3715
|
+
let dir = rest.slice(1).find((a, i, args) => !a.startsWith("--") && args[i - 1] !== "--format"), res = checkBlog({
|
|
3716
|
+
cwd,
|
|
3717
|
+
format,
|
|
3718
|
+
dir,
|
|
3719
|
+
allowEmpty: flag("allow-empty")
|
|
3720
|
+
});
|
|
3721
|
+
for (let { file, problem } of res.problems)
|
|
3722
|
+
console.log(`${file}: ${problem}`);
|
|
3723
|
+
let posts = `${res.posts} ${res.posts === 1 ? "post" : "posts"}`;
|
|
3724
|
+
console.log(res.problems.length ? import_picocolors4.default.red(`${res.problems.length} ${res.problems.length === 1 ? "problem" : "problems"} in ${posts} in ${res.dir}.`) : import_picocolors4.default.green(`Checked ${posts} in ${res.dir}. All good.`)), process.exit(res.problems.length ? 1 : 0);
|
|
3725
|
+
}
|
|
3414
3726
|
async function main() {
|
|
3415
3727
|
switch (command) {
|
|
3416
3728
|
case "init":
|
|
@@ -3419,7 +3731,7 @@ async function main() {
|
|
|
3419
3731
|
case "upgrade":
|
|
3420
3732
|
return update();
|
|
3421
3733
|
case "login":
|
|
3422
|
-
return await showLogo({ tagline: TAGLINE, version: version(), motion }), Ie(`${badge("LopeBase")} sign in`), await login(), Se("Ready. Run lopebase in any project.");
|
|
3734
|
+
return requireTerminal(), await showLogo({ tagline: TAGLINE, version: version(), motion }), Ie(`${badge("LopeBase")} sign in`), await login(), Se("Ready. Run lopebase in any project.");
|
|
3423
3735
|
case "scan": {
|
|
3424
3736
|
let facts = scanProject(cwd), detection = detectStack(facts);
|
|
3425
3737
|
if (flag("json"))
|
|
@@ -3452,6 +3764,8 @@ async function main() {
|
|
|
3452
3764
|
lopebase adapter secret print a new signing secret
|
|
3453
3765
|
lopebase adapter check <base-url> test a running adapter (reads LOPEBASE_SIGNING_SECRET)`), process.exit(sub ? 1 : 0);
|
|
3454
3766
|
}
|
|
3767
|
+
case "blog":
|
|
3768
|
+
return blog();
|
|
3455
3769
|
case "mcp": {
|
|
3456
3770
|
let auth = loadAuth();
|
|
3457
3771
|
if (!auth)
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lopebase",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Set up LopeBase from your project's folder: scan your stack, connect your workspace, and let your coding agent do the rest.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lopebase": "dist/lopebase.js"
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./src/index.ts",
|
|
11
10
|
"./detect": "./src/detect.ts",
|
|
12
11
|
"./releases": "./src/releases.ts"
|
|
13
12
|
},
|
|
@@ -28,6 +27,7 @@
|
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@clack/prompts": "^0.11.0",
|
|
30
29
|
"@lopebase/adapter": "workspace:*",
|
|
30
|
+
"@lopebase/blog": "workspace:*",
|
|
31
31
|
"@types/cross-spawn": "^6.0.6",
|
|
32
32
|
"@types/node": "^22.0.0",
|
|
33
33
|
"cross-spawn": "^7.0.6",
|