@nowline/cli 0.0.0-dev.20261105234842.g537765c → 0.0.0-dev.20261106000822.g2041c05

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.
@@ -2,12 +2,13 @@ import type { ParsedArgs } from '../cli/args.js';
2
2
  /**
3
3
  * `nowline --mcp` handler.
4
4
  *
5
- * Starts a Model Context Protocol server sharing the same @nowline/mcp
6
- * server factory as `npx @nowline/mcp`.
5
+ * Starts the Model Context Protocol server through the same `startMcpServer`
6
+ * that `npx @nowline/mcp` calls, so `--root` (expansion and the binary-export
7
+ * delivery default), `--port` and the reported version behave identically.
7
8
  *
8
9
  * Transport selection:
9
10
  * stdio (default) — when --port is absent.
10
- * Streamable HTTP — when --port <N> is supplied; listens on localhost:<N>.
11
+ * Streamable HTTP — when --port <N> is supplied; listens on 127.0.0.1:<N>.
11
12
  *
12
13
  * Runs until the process receives SIGINT/SIGTERM or the client closes stdin.
13
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkC9E"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAc9E"}
@@ -1,45 +1,32 @@
1
- import { createServer } from 'node:http';
2
- import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
3
- import { createMcpHttpHandler } from '@nowline/mcp/http';
4
- import { createMcpServer } from '@nowline/mcp/server';
1
+ import { InvalidPortError, startMcpServer } from '@nowline/mcp/start';
2
+ import { CliError, ExitCode } from '../io/exit-codes.js';
5
3
  import { createLog } from '../io/log.js';
6
4
  /**
7
5
  * `nowline --mcp` handler.
8
6
  *
9
- * Starts a Model Context Protocol server sharing the same @nowline/mcp
10
- * server factory as `npx @nowline/mcp`.
7
+ * Starts the Model Context Protocol server through the same `startMcpServer`
8
+ * that `npx @nowline/mcp` calls, so `--root` (expansion and the binary-export
9
+ * delivery default), `--port` and the reported version behave identically.
11
10
  *
12
11
  * Transport selection:
13
12
  * stdio (default) — when --port is absent.
14
- * Streamable HTTP — when --port <N> is supplied; listens on localhost:<N>.
13
+ * Streamable HTTP — when --port <N> is supplied; listens on 127.0.0.1:<N>.
15
14
  *
16
15
  * Runs until the process receives SIGINT/SIGTERM or the client closes stdin.
17
16
  */
18
17
  export async function mcpHandler({ args }) {
19
- // Without --root the server follows the client's MCP roots, else cwd.
20
- const root = args.root;
21
- const portStr = args.port;
22
- if (portStr !== undefined) {
23
- const port = parseInt(portStr, 10);
24
- if (!Number.isFinite(port) || port < 1 || port > 65535) {
25
- throw new Error(`nowline: --port must be a number between 1 and 65535 (got ${portStr}).`);
26
- }
27
- const httpServer = createServer(createMcpHttpHandler(() => createMcpServer({ allowedRoot: root })));
28
- await new Promise((resolve) => {
29
- httpServer.listen(port, '127.0.0.1', () => {
30
- createLog(args.logLevel).notice(`nowline: MCP Streamable HTTP listening on http://127.0.0.1:${port}`);
31
- });
32
- httpServer.on('close', resolve);
33
- process.on('SIGINT', () => httpServer.close());
34
- process.on('SIGTERM', () => httpServer.close());
18
+ try {
19
+ await startMcpServer({
20
+ root: args.root,
21
+ port: args.port,
22
+ onListening: (url) => createLog(args.logLevel).notice(`nowline: MCP Streamable HTTP listening on ${url}`),
35
23
  });
36
24
  }
37
- else {
38
- const transport = new StdioServerTransport();
39
- await createMcpServer({ allowedRoot: root }).connect(transport);
40
- await new Promise((resolve) => {
41
- transport.onclose = resolve;
42
- });
25
+ catch (err) {
26
+ if (err instanceof InvalidPortError) {
27
+ throw new CliError(ExitCode.InputError, `nowline: ${err.message}`);
28
+ }
29
+ throw err;
43
30
  }
44
31
  }
45
32
  //# sourceMappingURL=mcp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAE,IAAI,EAAwB;IAC3D,sEAAsE;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CACX,6DAA6D,OAAO,IAAI,CAC3E,CAAC;QACN,CAAC;QAED,MAAM,UAAU,GAAG,YAAY,CAC3B,oBAAoB,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CACrE,CAAC;QAEF,MAAM,IAA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YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CACjB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,6CAA6C,GAAG,EAAE,CAAC;SAC1F,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;YAClC,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,GAAG,CAAC;IACd,CAAC;AACL,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const CLI_VERSION = "0.0.0-dev.20261105234842.g537765c";
1
+ export declare const CLI_VERSION = "0.0.0-dev.20261106000822.g2041c05";
2
2
  export interface CliBuild {
3
3
  /** Short git SHA at build time, or empty when not in a git checkout. */
4
4
  readonly sha: string;
@@ -1,7 +1,7 @@
1
1
  // Auto-generated by scripts/bundle-templates.mjs. Do not edit by hand.
2
- export const CLI_VERSION = "0.0.0-dev.20261105234842.g537765c";
2
+ export const CLI_VERSION = "0.0.0-dev.20261106000822.g2041c05";
3
3
  export const CLI_BUILD = {
4
- "sha": "537765c",
4
+ "sha": "2041c05",
5
5
  "isRelease": false,
6
6
  "isDirty": true
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowline/cli",
3
- "version": "0.0.0-dev.20261105234842.g537765c",
3
+ "version": "0.0.0-dev.20261106000822.g2041c05",
4
4
  "description": "Command-line tool to check, convert, and create Nowline roadmaps.",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -33,19 +33,19 @@
33
33
  "@babel/code-frame": "^8.0.6",
34
34
  "@clack/prompts": "^1.8.1",
35
35
  "@modelcontextprotocol/server": "^2.3.1",
36
- "@nowline/config": "0.0.0-dev.20261105234842.g537765c",
37
- "@nowline/core": "0.0.0-dev.20261105234842.g537765c",
38
- "@nowline/export": "0.0.0-dev.20261105234842.g537765c",
39
- "@nowline/export-core": "0.0.0-dev.20261105234842.g537765c",
40
- "@nowline/export-html": "0.0.0-dev.20261105234842.g537765c",
41
- "@nowline/export-mermaid": "0.0.0-dev.20261105234842.g537765c",
42
- "@nowline/export-msproj": "0.0.0-dev.20261105234842.g537765c",
43
- "@nowline/export-pdf": "0.0.0-dev.20261105234842.g537765c",
44
- "@nowline/export-png": "0.0.0-dev.20261105234842.g537765c",
45
- "@nowline/export-xlsx": "0.0.0-dev.20261105234842.g537765c",
46
- "@nowline/layout": "0.0.0-dev.20261105234842.g537765c",
47
- "@nowline/mcp": "0.0.0-dev.20261105234842.g537765c",
48
- "@nowline/renderer": "0.0.0-dev.20261105234842.g537765c",
36
+ "@nowline/config": "0.0.0-dev.20261106000822.g2041c05",
37
+ "@nowline/core": "0.0.0-dev.20261106000822.g2041c05",
38
+ "@nowline/export": "0.0.0-dev.20261106000822.g2041c05",
39
+ "@nowline/export-core": "0.0.0-dev.20261106000822.g2041c05",
40
+ "@nowline/export-html": "0.0.0-dev.20261106000822.g2041c05",
41
+ "@nowline/export-mermaid": "0.0.0-dev.20261106000822.g2041c05",
42
+ "@nowline/export-msproj": "0.0.0-dev.20261106000822.g2041c05",
43
+ "@nowline/export-pdf": "0.0.0-dev.20261106000822.g2041c05",
44
+ "@nowline/export-png": "0.0.0-dev.20261106000822.g2041c05",
45
+ "@nowline/export-xlsx": "0.0.0-dev.20261106000822.g2041c05",
46
+ "@nowline/layout": "0.0.0-dev.20261106000822.g2041c05",
47
+ "@nowline/mcp": "0.0.0-dev.20261106000822.g2041c05",
48
+ "@nowline/renderer": "0.0.0-dev.20261106000822.g2041c05",
49
49
  "chalk": "^6.0.1",
50
50
  "citty": "^0.2.2",
51
51
  "consola": "^3.4.2",
@@ -1,54 +1,33 @@
1
- import { createServer } from 'node:http';
2
- import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
3
- import { createMcpHttpHandler } from '@nowline/mcp/http';
4
- import { createMcpServer } from '@nowline/mcp/server';
1
+ import { InvalidPortError, startMcpServer } from '@nowline/mcp/start';
5
2
  import type { ParsedArgs } from '../cli/args.js';
3
+ import { CliError, ExitCode } from '../io/exit-codes.js';
6
4
  import { createLog } from '../io/log.js';
7
5
 
8
6
  /**
9
7
  * `nowline --mcp` handler.
10
8
  *
11
- * Starts a Model Context Protocol server sharing the same @nowline/mcp
12
- * server factory as `npx @nowline/mcp`.
9
+ * Starts the Model Context Protocol server through the same `startMcpServer`
10
+ * that `npx @nowline/mcp` calls, so `--root` (expansion and the binary-export
11
+ * delivery default), `--port` and the reported version behave identically.
13
12
  *
14
13
  * Transport selection:
15
14
  * stdio (default) — when --port is absent.
16
- * Streamable HTTP — when --port <N> is supplied; listens on localhost:<N>.
15
+ * Streamable HTTP — when --port <N> is supplied; listens on 127.0.0.1:<N>.
17
16
  *
18
17
  * Runs until the process receives SIGINT/SIGTERM or the client closes stdin.
19
18
  */
20
19
  export async function mcpHandler({ args }: { args: ParsedArgs }): Promise<void> {
21
- // Without --root the server follows the client's MCP roots, else cwd.
22
- const root = args.root;
23
-
24
- const portStr = args.port;
25
- if (portStr !== undefined) {
26
- const port = parseInt(portStr, 10);
27
- if (!Number.isFinite(port) || port < 1 || port > 65535) {
28
- throw new Error(
29
- `nowline: --port must be a number between 1 and 65535 (got ${portStr}).`,
30
- );
31
- }
32
-
33
- const httpServer = createServer(
34
- createMcpHttpHandler(() => createMcpServer({ allowedRoot: root })),
35
- );
36
-
37
- await new Promise<void>((resolve) => {
38
- httpServer.listen(port, '127.0.0.1', () => {
39
- createLog(args.logLevel).notice(
40
- `nowline: MCP Streamable HTTP listening on http://127.0.0.1:${port}`,
41
- );
42
- });
43
- httpServer.on('close', resolve);
44
- process.on('SIGINT', () => httpServer.close());
45
- process.on('SIGTERM', () => httpServer.close());
46
- });
47
- } else {
48
- const transport = new StdioServerTransport();
49
- await createMcpServer({ allowedRoot: root }).connect(transport);
50
- await new Promise<void>((resolve) => {
51
- transport.onclose = resolve;
20
+ try {
21
+ await startMcpServer({
22
+ root: args.root,
23
+ port: args.port,
24
+ onListening: (url) =>
25
+ createLog(args.logLevel).notice(`nowline: MCP Streamable HTTP listening on ${url}`),
52
26
  });
27
+ } catch (err) {
28
+ if (err instanceof InvalidPortError) {
29
+ throw new CliError(ExitCode.InputError, `nowline: ${err.message}`);
30
+ }
31
+ throw err;
53
32
  }
54
33
  }
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by scripts/bundle-templates.mjs. Do not edit by hand.
2
2
 
3
- export const CLI_VERSION = "0.0.0-dev.20261105234842.g537765c";
3
+ export const CLI_VERSION = "0.0.0-dev.20261106000822.g2041c05";
4
4
 
5
5
  export interface CliBuild {
6
6
  /** Short git SHA at build time, or empty when not in a git checkout. */
@@ -12,7 +12,7 @@ export interface CliBuild {
12
12
  }
13
13
 
14
14
  export const CLI_BUILD: CliBuild = {
15
- "sha": "537765c",
15
+ "sha": "2041c05",
16
16
  "isRelease": false,
17
17
  "isDirty": true
18
18
  };