@nera-static/mcp 1.4.0 → 1.4.1
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/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +14 -0
- package/bin/nera-mcp.js +13 -7
- package/docs/llms-full.txt +1219 -31
- package/package.json +29 -18
- package/skills/nera/SKILL.md +3 -0
- package/skills/nera/recipes/blog.md +9 -5
- package/src/catalog.js +1 -1
- package/src/hosted/app.js +4 -2
- package/src/hosted/checkout.js +46 -56
- package/src/hosted/config.js +12 -8
- package/src/hosted/consent.js +28 -23
- package/src/hosted/crypto.js +2 -1
- package/src/hosted/github.js +6 -3
- package/src/hosted/mcp.js +3 -3
- package/src/hosted/provider.js +13 -6
- package/src/hosted/repo.js +30 -16
- package/src/hosted/store.js +25 -7
- package/src/hosted/tools/publish.js +43 -17
- package/src/hosted/tools/read.js +31 -16
- package/src/hosted/tools/validate.js +10 -3
- package/src/hosted/tools/write.js +28 -9
- package/src/pages.js +21 -18
- package/src/paths.js +11 -18
- package/src/prompts.js +33 -15
- package/src/resources.js +7 -3
- package/src/runner.js +13 -11
- package/src/server-info.js +11 -0
- package/src/server.js +14 -4
- package/src/tools/cli.js +40 -22
- package/src/tools/files.js +14 -7
- package/src/tools/long-running.js +12 -31
- package/src/tools/sites.js +10 -8
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { satisfiesFloor } from '@nera-static/plugin-utils/guard'
|
|
1
2
|
import { z } from 'zod'
|
|
2
3
|
import { freePort } from '../processes.js'
|
|
3
4
|
import { ok, tool, ToolError } from '../results.js'
|
|
@@ -37,8 +38,10 @@ const ACTIONS = {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
const INSTRUCTIONS = {
|
|
40
|
-
github_sign_in: ({ code, url }) => `Ask the user to open ${url} and enter the code ${code},
|
|
41
|
-
|
|
41
|
+
github_sign_in: ({ code, url }) => `Ask the user to open ${url} and enter the code ${code}, ` +
|
|
42
|
+
'then call publish again.',
|
|
43
|
+
github_app_install: ({ url }) => `Ask the user to open ${url} and install the Nera Static app on their GitHub ` +
|
|
44
|
+
'account, then call publish again.',
|
|
42
45
|
netlify_sign_in: ({ url }) => `Ask the user to open ${url} and choose "Authorize", then call publish again.`,
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -110,31 +113,6 @@ function lastProgress(stderr) {
|
|
|
110
113
|
return last.length > PROGRESS_MAX ? `${last.slice(0, PROGRESS_MAX)}…` : last
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
/** `x.y.z` with an optional `-prerelease` (and `+build`, ignored), or null. */
|
|
114
|
-
function parseVersion(version) {
|
|
115
|
-
const match = typeof version === 'string' && version.match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/)
|
|
116
|
-
return match ? { numbers: match.slice(1, 4).map(Number), prerelease: match[4] !== undefined } : null
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Whether `version` is `floor` or later, by semver precedence: major, minor
|
|
121
|
-
* and patch compared as numbers, and a prerelease of a version (`1.27.0-beta.1`)
|
|
122
|
-
* below that version. Anything that is no `x.y.z` version is not.
|
|
123
|
-
*
|
|
124
|
-
* @param {string|null} version
|
|
125
|
-
* @param {string} floor an `x.y.z` version without a prerelease
|
|
126
|
-
* @returns {boolean}
|
|
127
|
-
*/
|
|
128
|
-
export function meetsFloor(version, floor) {
|
|
129
|
-
const have = parseVersion(version)
|
|
130
|
-
if (!have) return false
|
|
131
|
-
const need = parseVersion(floor).numbers
|
|
132
|
-
for (let i = 0; i < 3; i++) {
|
|
133
|
-
if (have.numbers[i] !== need[i]) return have.numbers[i] > need[i]
|
|
134
|
-
}
|
|
135
|
-
return !have.prerelease
|
|
136
|
-
}
|
|
137
|
-
|
|
138
116
|
/**
|
|
139
117
|
* The local address `nera dev` serves on, once Vite has printed it.
|
|
140
118
|
*
|
|
@@ -216,7 +194,8 @@ export function registerLongRunningTools(server, ctx) {
|
|
|
216
194
|
const stopped = await ctx.processes.stop(key)
|
|
217
195
|
return ok(
|
|
218
196
|
{ site: resolved.site, stopped },
|
|
219
|
-
stopped ? `Stopped the preview of "${resolved.site}".` : `No preview of "${resolved.site}"
|
|
197
|
+
stopped ? `Stopped the preview of "${resolved.site}".` : `No preview of "${resolved.site}" ` +
|
|
198
|
+
'was running.',
|
|
220
199
|
)
|
|
221
200
|
}
|
|
222
201
|
|
|
@@ -236,7 +215,8 @@ export function registerLongRunningTools(server, ctx) {
|
|
|
236
215
|
const url = previewUrl(run.stdout)
|
|
237
216
|
if (run.exited) {
|
|
238
217
|
ctx.processes.forget(key)
|
|
239
|
-
throw new ToolError(`The preview of "${resolved.site}" stopped: ${failureText(run)}\nCall validate to
|
|
218
|
+
throw new ToolError(`The preview of "${resolved.site}" stopped: ${failureText(run)}\nCall validate to ` +
|
|
219
|
+
'find the cause, fix it, then call preview again.')
|
|
240
220
|
}
|
|
241
221
|
if (!url) {
|
|
242
222
|
await ctx.processes.stop(key)
|
|
@@ -265,9 +245,10 @@ export function registerLongRunningTools(server, ctx) {
|
|
|
265
245
|
if (!run) {
|
|
266
246
|
// an older CLI announces no browser step as an event, so the user would never see the sign-in code
|
|
267
247
|
const version = neraVersion(resolved.dir)
|
|
268
|
-
if (!
|
|
248
|
+
if (!satisfiesFloor(version, PUBLISH_CLI_FLOOR)) {
|
|
269
249
|
const runs = version ? `@nera-static/nera ${version}` : 'a @nera-static/nera whose version cannot be read'
|
|
270
|
-
throw new ToolError(`Publishing "${resolved.site}" runs ${runs}; publish needs ${PUBLISH_CLI_FLOOR}
|
|
250
|
+
throw new ToolError(`Publishing "${resolved.site}" runs ${runs}; publish needs ${PUBLISH_CLI_FLOOR} ` +
|
|
251
|
+
'or later. Run `npm update` in the site, then call publish again.')
|
|
271
252
|
}
|
|
272
253
|
run = ctx.processes.start(key, 'nera', publishArgs(options), { cwd: resolved.dir })
|
|
273
254
|
}
|
package/src/tools/sites.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fs from 'node:fs/promises'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { resolveSiteModel } from '@nera-static/core'
|
|
4
|
+
import { isPluginPackage } from '@nera-static/plugin-utils/packages'
|
|
5
|
+
import { byString } from '@nera-static/plugin-utils/sort'
|
|
6
|
+
import { isInside } from '@nera-static/plugin-utils/urls'
|
|
4
7
|
import { z } from 'zod'
|
|
5
|
-
import {
|
|
8
|
+
import { resolveInRoot } from '../paths.js'
|
|
6
9
|
import { ok, tool, ToolError } from '../results.js'
|
|
7
10
|
|
|
8
11
|
const CLI_PACKAGE = '@nera-static/nera'
|
|
9
|
-
const PLUGIN_PREFIX = '@nera-static/plugin-'
|
|
10
|
-
const NOT_PLUGINS = new Set(['@nera-static/plugin-utils'])
|
|
11
12
|
/** How deep `list_sites` looks below the root (the root itself is depth 0). */
|
|
12
13
|
const MAX_SITE_DEPTH = 3
|
|
13
14
|
const SKIPPED_FOLDERS = new Set(['node_modules', 'public'])
|
|
@@ -60,8 +61,8 @@ export function neraRange(pkg) {
|
|
|
60
61
|
*/
|
|
61
62
|
export function sitePlugins(pkg) {
|
|
62
63
|
return Object.keys(allDependencies(pkg))
|
|
63
|
-
.filter(
|
|
64
|
-
.sort()
|
|
64
|
+
.filter(isPluginPackage)
|
|
65
|
+
.sort(byString)
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -85,7 +86,8 @@ export async function resolveSite(ctx, site) {
|
|
|
85
86
|
const dir = await resolveInRoot(ctx.root, site, { label: 'site' })
|
|
86
87
|
const pkg = await readPackage(dir)
|
|
87
88
|
if (!isNeraSite(pkg)) {
|
|
88
|
-
throw new ToolError(`"${site}" is not a Nera site: it has no package.json that depends on ${CLI_PACKAGE}.
|
|
89
|
+
throw new ToolError(`"${site}" is not a Nera site: it has no package.json that depends on ${CLI_PACKAGE}. ` +
|
|
90
|
+
'Call list_sites to see the sites under the root, or create_site to make one.')
|
|
89
91
|
}
|
|
90
92
|
return { dir, site: relativeTo(ctx.root, dir), pkg }
|
|
91
93
|
}
|
|
@@ -120,7 +122,7 @@ async function listPages(dir, pagesDir) {
|
|
|
120
122
|
.map((entry) => path.join(entry.parentPath, entry.name))
|
|
121
123
|
.filter((file) => isInside(pagesDir, file))
|
|
122
124
|
.map((file) => relativeTo(dir, file))
|
|
123
|
-
.sort()
|
|
125
|
+
.sort(byString)
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
/**
|
|
@@ -153,7 +155,7 @@ export async function findSites(root) {
|
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
await visit(root, 0)
|
|
156
|
-
return found.sort((a, b) => a.site
|
|
158
|
+
return found.sort((a, b) => byString(a.site, b.site))
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
/**
|