@lukawi/toporealm 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 +21 -0
- package/README.en.md +113 -0
- package/README.md +115 -0
- package/dist/cli/index.d.ts +46 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +276 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +48 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +40 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/store.d.ts +27 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +390 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +108 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/validate.d.ts +16 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +32 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/distribution/hosts.d.ts +12 -0
- package/dist/distribution/hosts.d.ts.map +1 -0
- package/dist/distribution/hosts.js +122 -0
- package/dist/distribution/hosts.js.map +1 -0
- package/dist/distribution/index.d.ts +4 -0
- package/dist/distribution/index.d.ts.map +1 -0
- package/dist/distribution/index.js +4 -0
- package/dist/distribution/index.js.map +1 -0
- package/dist/distribution/installer.d.ts +23 -0
- package/dist/distribution/installer.d.ts.map +1 -0
- package/dist/distribution/installer.js +179 -0
- package/dist/distribution/installer.js.map +1 -0
- package/dist/distribution/skills.d.ts +11 -0
- package/dist/distribution/skills.d.ts.map +1 -0
- package/dist/distribution/skills.js +20 -0
- package/dist/distribution/skills.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/skills/toporealm/SKILL.md +19 -0
- package/dist/integrations/skills/toporealm/agents/openai.yaml +6 -0
- package/dist/integrations/skills/toporealm-design/SKILL.md +14 -0
- package/dist/integrations/skills/toporealm-design/agents/openai.yaml +6 -0
- package/dist/integrations/skills/toporealm-grilling/SKILL.md +26 -0
- package/dist/integrations/skills/toporealm-grilling/agents/openai.yaml +6 -0
- package/dist/integrations/skills/toporealm-join/SKILL.md +18 -0
- package/dist/integrations/skills/toporealm-join/agents/openai.yaml +6 -0
- package/dist/mcp/index.d.ts +31 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +128 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/module-sdk/actions.d.ts +33 -0
- package/dist/module-sdk/actions.d.ts.map +1 -0
- package/dist/module-sdk/actions.js +56 -0
- package/dist/module-sdk/actions.js.map +1 -0
- package/dist/module-sdk/index.d.ts +47 -0
- package/dist/module-sdk/index.d.ts.map +1 -0
- package/dist/module-sdk/index.js +7 -0
- package/dist/module-sdk/index.js.map +1 -0
- package/dist/module-sdk/registry.d.ts +81 -0
- package/dist/module-sdk/registry.d.ts.map +1 -0
- package/dist/module-sdk/registry.js +294 -0
- package/dist/module-sdk/registry.js.map +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +168 -0
- package/dist/server/index.js.map +1 -0
- package/dist/web/index.d.ts +26 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +107 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web-assets/assets/index-BUAvvLwY.js +35 -0
- package/dist/web-assets/assets/index-DtKFY9Hh.css +1 -0
- package/dist/web-assets/index.html +175 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LUKAWI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# TopoRealm
|
|
2
|
+
|
|
3
|
+
**An extensible, visual, agent-friendly local graph workspace.**
|
|
4
|
+
|
|
5
|
+
TopoRealm provides a stable foundation for graph storage, versioned mutations, CLI, MCP, and a Web UI. Domain behavior arrives through modules that users install explicitly. It is for people who want humans and agents to share one local source of truth without baking task, research, or learning semantics into Core.
|
|
6
|
+
|
|
7
|
+
> `0.1.0` is a public Preview. The graph and module protocols are frozen at v1, but the npm package ships with no domain modules. `research`, `exploration`, and `workflow` currently exist only as non-release test fixtures. They will be developed independently after v0.1 and must pass standalone connection tests and multi-module composition tests before release.
|
|
8
|
+
|
|
9
|
+
[中文](README.md) · [Architecture boundary](docs/architecture/FOUNDATION.md) · [Module contract](docs/architecture/module-contract.md) · [Release checklist](docs/releases/v0.1.0-preview.md)
|
|
10
|
+
|
|
11
|
+
## What is included
|
|
12
|
+
|
|
13
|
+
- **Core:** local YAML graphs, stable IDs, revisions, atomic mutations, conflict handling, undo/redo, and base/full validation.
|
|
14
|
+
- **Web UI:** canvas, search, graph switching, generic editing, history, module status, and declarative module styling and forms.
|
|
15
|
+
- **CLI and stdio MCP:** humans and agents use the same Core; MCP exposes fixed graph, validation, history, module, and action entry points.
|
|
16
|
+
- **Module ecosystem:** install, bind, activate per graph, registry snapshots, lossless reads without a module, `MutationPlan` actions, and uninstall.
|
|
17
|
+
- **Four base Skills:** `toporealm`, `toporealm-design`, `toporealm-join`, and `toporealm-grilling`.
|
|
18
|
+
- **Three host projections:** directly usable manifests, Skills, MCP configuration, and read-only onboarding hooks for Codex, Claude Code, and Pi.
|
|
19
|
+
|
|
20
|
+
## Start in five minutes
|
|
21
|
+
|
|
22
|
+
Node.js 20 or newer is required.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install --global @lukawi/toporealm@preview
|
|
26
|
+
|
|
27
|
+
mkdir my-realm
|
|
28
|
+
cd my-realm
|
|
29
|
+
toporealm init demo
|
|
30
|
+
toporealm status
|
|
31
|
+
toporealm serve --open
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`serve` prints the local URL. Without `--open`, open that URL manually. TopoRealm discovers `.toporealm/` by walking upward; `--root <directory>` and `--graph <graph-id>` select targets explicitly.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
toporealm list
|
|
38
|
+
toporealm switch demo
|
|
39
|
+
toporealm read
|
|
40
|
+
toporealm validate
|
|
41
|
+
toporealm validate --complete
|
|
42
|
+
toporealm undo
|
|
43
|
+
toporealm redo
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Connect an agent through MCP
|
|
47
|
+
|
|
48
|
+
Any stdio MCP host can launch TopoRealm with:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"toporealm": {
|
|
54
|
+
"type": "stdio",
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "@lukawi/toporealm@0.1.0", "mcp"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Inside a workspace, `toporealm mcp` starts the same server directly. Its fixed tools are `graph_list`, `graph_read`, `graph_create`, `graph_select`, `graph_validate`, `graph_apply`, `graph_undo`, `graph_redo`, `module_status`, `action_list`, and `action_execute`.
|
|
63
|
+
|
|
64
|
+
## Install modules and sync hosts
|
|
65
|
+
|
|
66
|
+
Modules are independent npm packages, not hidden built-ins:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
toporealm module add <npm-package-or-local-path>
|
|
70
|
+
toporealm module list
|
|
71
|
+
toporealm host sync
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`host sync` creates TopoRealm-owned assets under `.codex/`, `.claude/`, and `.pi/` in the current workspace and preserves user files without a TopoRealm ownership marker. If a module is removed, its data remains losslessly readable, but domain-level full validation is unavailable.
|
|
75
|
+
|
|
76
|
+
### Module trust boundary
|
|
77
|
+
|
|
78
|
+
v0.1 loads only trusted local code that the user explicitly installs. It does not provide a third-party code sandbox or remote module marketplace. A module may provide domain operation implementations invoked by Core, but it has no graph-storage write access. Every graph change must be returned to Core as a `MutationPlan` for validation and commit. Core is the only component allowed to write graph facts through the supported contract.
|
|
79
|
+
|
|
80
|
+
## Base Skills
|
|
81
|
+
|
|
82
|
+
| Skill | Purpose |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `toporealm` | Identifies the workspace, graph, and modules, then routes the request to the foundation or a module Skill. |
|
|
85
|
+
| `toporealm-design` | Designs domain-neutral objects, relations, capability composition, layers, and readability. |
|
|
86
|
+
| `toporealm-join` | Gives a new session a read-only view of scope, modules, key objects, and recent changes. |
|
|
87
|
+
| `toporealm-grilling` | Aligns requirements and intent, asking one focused question at a time when a critical product or protocol ambiguity remains. |
|
|
88
|
+
|
|
89
|
+
These Skills do not decide domain objects, lifecycles, or completion rules on behalf of a domain module.
|
|
90
|
+
|
|
91
|
+
## Use TopoRealm as a library
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { GraphStore } from "@lukawi/toporealm/core";
|
|
95
|
+
import type { MutationPlan } from "@lukawi/toporealm/module-sdk";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Public subpaths also include `cli`, `mcp`, `server`, `web`, and `distribution`. See [CONTEXT.md](CONTEXT.md) for the shared vocabulary and the [v1 freeze](docs/architecture/v1-freeze.md) for stable contracts.
|
|
99
|
+
|
|
100
|
+
## Develop and verify
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npm install
|
|
104
|
+
npm --prefix web-ui install
|
|
105
|
+
npm run verify
|
|
106
|
+
git diff --check
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`npm run verify` covers type checking, Core/CLI/MCP/module/host tests, Web type and component tests, and CLI/MCP/Web smoke tests from an installed npm tarball. CI runs the same gate on Node.js 20 across Windows, macOS, and Linux.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
[MIT](LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# TopoRealm|拓境
|
|
2
|
+
|
|
3
|
+
**一个可扩展、可视化、对 agent 友好的本地图工作空间。**
|
|
4
|
+
|
|
5
|
+
TopoRealm 把图存储、版本化变更、CLI、MCP 和 Web UI 做成稳定基座,再让用户按需安装领域模块。它适合希望用同一份本地数据连接人、agent 与不同工作方法,同时又不愿把任务流、研究流或学习流写死在 Core 里的用户。
|
|
6
|
+
|
|
7
|
+
> `0.1.0` 是公开 Preview:图格式和模块协议已冻结为 v1,但 npm 包不内置任何领域模块。`research`、`exploration`、`workflow` 目前仅作为非发布测试 fixture;它们将在 v0.1 发布后独立开发,并分别完成连接测试和多模块组合测试。
|
|
8
|
+
|
|
9
|
+
[English](README.en.md) · [架构边界](docs/architecture/FOUNDATION.md) · [模块协议](docs/architecture/module-contract.md) · [发布清单](docs/releases/v0.1.0-preview.md)
|
|
10
|
+
|
|
11
|
+
## 你得到什么
|
|
12
|
+
|
|
13
|
+
- **Core**:本地 YAML 图、稳定 ID、revision、原子变更、并发冲突、撤销/重做、基础与完整校验。
|
|
14
|
+
- **Web UI**:画布、搜索、图切换、通用编辑、历史、模块状态,以及模块声明式贡献的样式和表单。
|
|
15
|
+
- **CLI 与 stdio MCP**:人和 agent 通过同一 Core 读写图;MCP 固定提供图、校验、历史、模块和动作入口。
|
|
16
|
+
- **模块生态**:安装、绑定、图级启用、注册快照、缺失模块无损读取、`MutationPlan` 动作和卸载。
|
|
17
|
+
- **四个基础 Skills**:`toporealm`、`toporealm-design`、`toporealm-join`、`toporealm-grilling`。
|
|
18
|
+
- **三宿主投影**:为 Codex、Claude Code 与 Pi 生成各自可直接使用的 manifest、Skills、MCP 配置和只读入场钩子。
|
|
19
|
+
|
|
20
|
+
## 5 分钟开始
|
|
21
|
+
|
|
22
|
+
需要 Node.js 20 或更高版本。
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install --global @lukawi/toporealm@preview
|
|
26
|
+
|
|
27
|
+
mkdir my-realm
|
|
28
|
+
cd my-realm
|
|
29
|
+
toporealm init demo
|
|
30
|
+
toporealm status
|
|
31
|
+
toporealm serve --open
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`serve` 会输出本地地址;不使用 `--open` 时可以手动在浏览器打开。工作区通过向上查找 `.toporealm/` 自动识别,也可以显式传入 `--root <目录>` 和 `--graph <图 ID>`。
|
|
35
|
+
|
|
36
|
+
常用命令:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
toporealm list
|
|
40
|
+
toporealm switch demo
|
|
41
|
+
toporealm read
|
|
42
|
+
toporealm validate
|
|
43
|
+
toporealm validate --complete
|
|
44
|
+
toporealm undo
|
|
45
|
+
toporealm redo
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 给 agent 接入 MCP
|
|
49
|
+
|
|
50
|
+
任何支持 stdio MCP 的宿主都可以启动:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"toporealm": {
|
|
56
|
+
"type": "stdio",
|
|
57
|
+
"command": "npx",
|
|
58
|
+
"args": ["-y", "@lukawi/toporealm@0.1.0", "mcp"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
也可以先进入工作区,再直接运行 `toporealm mcp`。固定工具包括 `graph_list`、`graph_read`、`graph_create`、`graph_select`、`graph_validate`、`graph_apply`、`graph_undo`、`graph_redo`、`module_status`、`action_list` 和 `action_execute`。
|
|
65
|
+
|
|
66
|
+
## 安装模块与同步宿主
|
|
67
|
+
|
|
68
|
+
模块是独立 npm 包,而不是 Core 的隐藏内置功能:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
toporealm module add <npm-package-or-local-path>
|
|
72
|
+
toporealm module list
|
|
73
|
+
toporealm host sync
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`host sync` 在当前工作区的 `.codex/`、`.claude/`、`.pi/` 下生成 TopoRealm 所有的宿主资产,并保留没有 TopoRealm 所有权标记的用户文件。模块卸载后,缺少模块的图仍能无损读取原有数据,但不能声称完成领域级完整校验。
|
|
77
|
+
|
|
78
|
+
### 模块信任边界
|
|
79
|
+
|
|
80
|
+
v0.1 只加载用户主动安装的可信本地代码,不提供第三方代码沙箱或远程模块市场。模块可以提供由 Core 调用的领域操作实现,但没有图存储写权限;所有图变更只能以 `MutationPlan` 形式交给 Core 校验并提交。Core 是受支持契约中唯一写入图事实来源的组件。
|
|
81
|
+
|
|
82
|
+
## 基础 Skills
|
|
83
|
+
|
|
84
|
+
| Skill | 作用 |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `toporealm` | 识别当前工作区、图和模块,把请求路由到基座或合适的模块 Skill。 |
|
|
87
|
+
| `toporealm-design` | 设计领域中立的对象、关系、能力组合、图层与可读性。 |
|
|
88
|
+
| `toporealm-join` | 新会话只读了解图的范围、模块、主要对象和近期变化。 |
|
|
89
|
+
| `toporealm-grilling` | 与用户对齐需求、识别真实意图,并在关键产品或协议歧义处逐问收敛。 |
|
|
90
|
+
|
|
91
|
+
这些 Skills 不替代领域模块决定业务对象、生命周期或完成规则。
|
|
92
|
+
|
|
93
|
+
## 作为库使用
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { GraphStore } from "@lukawi/toporealm/core";
|
|
97
|
+
import type { MutationPlan } from "@lukawi/toporealm/module-sdk";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
公开子路径还包括 `cli`、`mcp`、`server`、`web` 和 `distribution`。完整术语见 [CONTEXT.md](CONTEXT.md),稳定契约见 [v1 冻结清单](docs/architecture/v1-freeze.md)。
|
|
101
|
+
|
|
102
|
+
## 开发与验证
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm install
|
|
106
|
+
npm --prefix web-ui install
|
|
107
|
+
npm run verify
|
|
108
|
+
git diff --check
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`npm run verify` 覆盖类型检查、Core/CLI/MCP/模块/宿主测试、Web 类型与组件测试,以及从真实 npm tarball 安装后的 CLI、MCP 和 Web smoke。CI 在 Windows、macOS、Linux 的 Node.js 20 上运行同一套门禁。
|
|
112
|
+
|
|
113
|
+
## 许可证
|
|
114
|
+
|
|
115
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GraphStore, type GraphManifest, type MutationPlan } from "../core/index.js";
|
|
2
|
+
import { type HostSyncOptions, type InstallOptions } from "../distribution/index.js";
|
|
3
|
+
export declare const cliSurface: {
|
|
4
|
+
readonly name: "cli";
|
|
5
|
+
readonly coreFormat: "toporealm.graph/v1";
|
|
6
|
+
};
|
|
7
|
+
export interface ResolverEnvironment {
|
|
8
|
+
TOPOREALM_ROOT?: string;
|
|
9
|
+
TOPOREALM_GRAPH?: string;
|
|
10
|
+
TOPOREALM_HOME?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CliExecutionResult {
|
|
13
|
+
exitCode: 0 | 1 | 2;
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function resolveWorkspaceRoot(options?: {
|
|
18
|
+
cwd?: string | undefined;
|
|
19
|
+
explicitRoot?: string | undefined;
|
|
20
|
+
env?: ResolverEnvironment | undefined;
|
|
21
|
+
allowCreate?: boolean;
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function listGraphs(workspaceRoot: string): Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare function resolveGraphTarget(workspaceRoot: string, options?: {
|
|
28
|
+
explicitGraph?: string | undefined;
|
|
29
|
+
env?: ResolverEnvironment | undefined;
|
|
30
|
+
}): string;
|
|
31
|
+
export declare function selectGraph(workspaceRoot: string, graphId: string): void;
|
|
32
|
+
export declare function openGraph(workspaceRoot: string, graphId: string): GraphStore;
|
|
33
|
+
export declare function readGraph(workspaceRoot: string, graphId: string): import("../core/types.js").GraphSnapshot;
|
|
34
|
+
export declare function applyGraphPlan(workspaceRoot: string, graphId: string, plan: MutationPlan): import("../core/types.js").MutationResult;
|
|
35
|
+
export declare function undoGraph(workspaceRoot: string, graphId: string, expectedRevision?: number): import("../core/types.js").MutationResult;
|
|
36
|
+
export declare function redoGraph(workspaceRoot: string, graphId: string, expectedRevision?: number): import("../core/types.js").MutationResult;
|
|
37
|
+
export declare function initGraph(workspaceRoot: string, graphId: string, manifest: GraphManifest): import("../core/types.js").GraphSnapshot;
|
|
38
|
+
export declare function addModule(spec: string, options: InstallOptions): import("../distribution/installer.js").InstalledModule;
|
|
39
|
+
export declare function syncHostProjections(options: HostSyncOptions): readonly import("../distribution/hosts.js").HostSyncResult[];
|
|
40
|
+
/** Synchronous command seam. Long-running serve/mcp processes are wired by the executable entrypoint. */
|
|
41
|
+
export declare function runCli(argv: readonly string[], cwd?: string, env?: ResolverEnvironment): string;
|
|
42
|
+
export declare function executeCli(argv: readonly string[], options?: {
|
|
43
|
+
cwd?: string;
|
|
44
|
+
env?: ResolverEnvironment;
|
|
45
|
+
}): CliExecutionResult;
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,UAAU,EAGV,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAGlC,eAAO,MAAM,UAAU;;;CAAgE,CAAC;AAExF,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAoCD,wBAAgB,oBAAoB,CAAC,OAAO,GAAE;IAC5C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,GAAG,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACtC,WAAW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SAAS,MAAM,EAAE,EAAE,GAAG,SAAgB,EAAE,GAAG,GAAE,mBAAiC,GAAG,MAAM,CA6EnH;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,mBAAmB,CAAA;CAAO,GAAG,kBAAkB,CASjI"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { CoreError, GRAPH_FORMAT, GraphStore, coreSurface, validateGraph, } from "../core/index.js";
|
|
4
|
+
import { installModule, listInstalledModules, syncHosts, uninstallModule, } from "../distribution/index.js";
|
|
5
|
+
import { GraphActivator, WorkspaceModuleResolver } from "../module-sdk/index.js";
|
|
6
|
+
export const cliSurface = { name: "cli", coreFormat: coreSurface.graphFormat };
|
|
7
|
+
class CliUsageError extends Error {
|
|
8
|
+
code = "CLI_USAGE";
|
|
9
|
+
}
|
|
10
|
+
const HELP = `TopoRealm CLI
|
|
11
|
+
|
|
12
|
+
用法:toporealm [--root <目录>] [--graph <图 ID>] <命令>
|
|
13
|
+
|
|
14
|
+
命令:
|
|
15
|
+
init <图 ID> 初始化工作区和图
|
|
16
|
+
list 列出工作区中的图
|
|
17
|
+
switch <图 ID> 设置当前图
|
|
18
|
+
status 查看当前图状态
|
|
19
|
+
read 读取图快照
|
|
20
|
+
apply <MutationPlan JSON> 提交图变更
|
|
21
|
+
undo [revision] 撤销
|
|
22
|
+
redo [revision] 重做
|
|
23
|
+
validate [--complete] 基础或完整校验
|
|
24
|
+
serve 启动 Web Server
|
|
25
|
+
mcp 启动 stdio MCP Server
|
|
26
|
+
module add|remove|list 管理模块
|
|
27
|
+
host sync 同步 Codex、Claude、Pi 宿主资产
|
|
28
|
+
help 显示帮助
|
|
29
|
+
|
|
30
|
+
环境变量:TOPOREALM_ROOT、TOPOREALM_GRAPH、TOPOREALM_HOME`;
|
|
31
|
+
function workspaceMarker(root) {
|
|
32
|
+
return join(root, ".toporealm");
|
|
33
|
+
}
|
|
34
|
+
function isWorkspace(root) {
|
|
35
|
+
return existsSync(workspaceMarker(root));
|
|
36
|
+
}
|
|
37
|
+
export function resolveWorkspaceRoot(options = {}) {
|
|
38
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
39
|
+
const explicit = options.explicitRoot ?? options.env?.TOPOREALM_ROOT;
|
|
40
|
+
if (explicit) {
|
|
41
|
+
const root = resolve(cwd, explicit);
|
|
42
|
+
if (!options.allowCreate && !isWorkspace(root)) {
|
|
43
|
+
throw new CoreError({ code: "WORKSPACE_NOT_FOUND", message: `指定目录不是 TopoRealm 工作区:${root}` });
|
|
44
|
+
}
|
|
45
|
+
return root;
|
|
46
|
+
}
|
|
47
|
+
let candidate = cwd;
|
|
48
|
+
while (true) {
|
|
49
|
+
if (isWorkspace(candidate))
|
|
50
|
+
return candidate;
|
|
51
|
+
const parent = dirname(candidate);
|
|
52
|
+
if (parent === candidate)
|
|
53
|
+
break;
|
|
54
|
+
candidate = parent;
|
|
55
|
+
}
|
|
56
|
+
if (options.allowCreate)
|
|
57
|
+
return cwd;
|
|
58
|
+
throw new CoreError({ code: "WORKSPACE_NOT_FOUND", message: `从 ${cwd} 向上找不到 .toporealm 工作区。` });
|
|
59
|
+
}
|
|
60
|
+
export function listGraphs(workspaceRoot) {
|
|
61
|
+
const graphsRoot = join(workspaceRoot, ".toporealm", "graphs");
|
|
62
|
+
if (!existsSync(graphsRoot))
|
|
63
|
+
return [];
|
|
64
|
+
return readdirSync(graphsRoot, { withFileTypes: true })
|
|
65
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(graphsRoot, entry.name, "graph.yaml")))
|
|
66
|
+
.map((entry) => {
|
|
67
|
+
const snapshot = GraphStore.fromWorkspace(workspaceRoot, entry.name).read();
|
|
68
|
+
const item = { id: entry.name };
|
|
69
|
+
if (snapshot.manifest.label !== undefined)
|
|
70
|
+
item.label = snapshot.manifest.label;
|
|
71
|
+
return item;
|
|
72
|
+
})
|
|
73
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
74
|
+
}
|
|
75
|
+
function assertGraphExists(workspaceRoot, graphId, source) {
|
|
76
|
+
if (!existsSync(join(workspaceRoot, ".toporealm", "graphs", graphId, "graph.yaml"))) {
|
|
77
|
+
throw new CoreError({ code: "GRAPH_NOT_FOUND", message: `${source}指定的图不存在:${graphId}` });
|
|
78
|
+
}
|
|
79
|
+
return graphId;
|
|
80
|
+
}
|
|
81
|
+
export function resolveGraphTarget(workspaceRoot, options = {}) {
|
|
82
|
+
if (options.explicitGraph)
|
|
83
|
+
return assertGraphExists(workspaceRoot, options.explicitGraph, "--graph ");
|
|
84
|
+
if (options.env?.TOPOREALM_GRAPH)
|
|
85
|
+
return assertGraphExists(workspaceRoot, options.env.TOPOREALM_GRAPH, "TOPOREALM_GRAPH ");
|
|
86
|
+
const activePath = join(workspaceRoot, ".toporealm", "active");
|
|
87
|
+
if (existsSync(activePath)) {
|
|
88
|
+
const active = readFileSync(activePath, "utf8").trim();
|
|
89
|
+
if (active)
|
|
90
|
+
return assertGraphExists(workspaceRoot, active, "当前图 ");
|
|
91
|
+
}
|
|
92
|
+
const graphs = listGraphs(workspaceRoot);
|
|
93
|
+
if (graphs.some((graph) => graph.id === "default"))
|
|
94
|
+
return "default";
|
|
95
|
+
if (graphs.length === 1 && graphs[0])
|
|
96
|
+
return graphs[0].id;
|
|
97
|
+
throw new CoreError({ code: "GRAPH_REQUIRED", message: "无法唯一确定目标图;请使用 --graph、TOPOREALM_GRAPH 或 switch。" });
|
|
98
|
+
}
|
|
99
|
+
export function selectGraph(workspaceRoot, graphId) {
|
|
100
|
+
assertGraphExists(workspaceRoot, graphId, "");
|
|
101
|
+
writeFileSync(join(workspaceRoot, ".toporealm", "active"), `${graphId}\n`, "utf8");
|
|
102
|
+
}
|
|
103
|
+
export function openGraph(workspaceRoot, graphId) {
|
|
104
|
+
return GraphStore.fromWorkspace(workspaceRoot, graphId);
|
|
105
|
+
}
|
|
106
|
+
export function readGraph(workspaceRoot, graphId) {
|
|
107
|
+
return openGraph(workspaceRoot, graphId).read();
|
|
108
|
+
}
|
|
109
|
+
export function applyGraphPlan(workspaceRoot, graphId, plan) {
|
|
110
|
+
return openGraph(workspaceRoot, graphId).apply(plan);
|
|
111
|
+
}
|
|
112
|
+
export function undoGraph(workspaceRoot, graphId, expectedRevision) {
|
|
113
|
+
return openGraph(workspaceRoot, graphId).undo(expectedRevision);
|
|
114
|
+
}
|
|
115
|
+
export function redoGraph(workspaceRoot, graphId, expectedRevision) {
|
|
116
|
+
return openGraph(workspaceRoot, graphId).redo(expectedRevision);
|
|
117
|
+
}
|
|
118
|
+
export function initGraph(workspaceRoot, graphId, manifest) {
|
|
119
|
+
return openGraph(workspaceRoot, graphId).initialize(manifest);
|
|
120
|
+
}
|
|
121
|
+
export function addModule(spec, options) {
|
|
122
|
+
return installModule(spec, options);
|
|
123
|
+
}
|
|
124
|
+
export function syncHostProjections(options) {
|
|
125
|
+
return syncHosts(options);
|
|
126
|
+
}
|
|
127
|
+
function parseCli(argv) {
|
|
128
|
+
const parsed = { args: [], complete: false, global: false, open: false };
|
|
129
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
130
|
+
const value = argv[index];
|
|
131
|
+
if (value === "--root" || value === "--graph" || value === "--host" || value === "--port") {
|
|
132
|
+
const option = argv[index + 1];
|
|
133
|
+
if (!option)
|
|
134
|
+
throw new CliUsageError(`${value} 需要一个值。`);
|
|
135
|
+
if (value === "--root")
|
|
136
|
+
parsed.root = option;
|
|
137
|
+
else if (value === "--graph")
|
|
138
|
+
parsed.graph = option;
|
|
139
|
+
else if (value === "--host")
|
|
140
|
+
parsed.host = option;
|
|
141
|
+
else {
|
|
142
|
+
const port = Number(option);
|
|
143
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
144
|
+
throw new CliUsageError(`--port 无效:${option}`);
|
|
145
|
+
parsed.port = port;
|
|
146
|
+
}
|
|
147
|
+
index += 1;
|
|
148
|
+
}
|
|
149
|
+
else if (value === "--complete")
|
|
150
|
+
parsed.complete = true;
|
|
151
|
+
else if (value === "--global")
|
|
152
|
+
parsed.global = true;
|
|
153
|
+
else if (value === "--open")
|
|
154
|
+
parsed.open = true;
|
|
155
|
+
else if (value !== undefined)
|
|
156
|
+
parsed.args.push(value);
|
|
157
|
+
}
|
|
158
|
+
return parsed;
|
|
159
|
+
}
|
|
160
|
+
function required(value, usage) {
|
|
161
|
+
if (!value)
|
|
162
|
+
throw new CliUsageError(`用法:${usage}`);
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
function parseRevision(value) {
|
|
166
|
+
if (value === undefined)
|
|
167
|
+
return undefined;
|
|
168
|
+
const revision = Number(value);
|
|
169
|
+
if (!Number.isInteger(revision) || revision < 0)
|
|
170
|
+
throw new CliUsageError(`revision 必须是非负整数:${value}`);
|
|
171
|
+
return revision;
|
|
172
|
+
}
|
|
173
|
+
/** Synchronous command seam. Long-running serve/mcp processes are wired by the executable entrypoint. */
|
|
174
|
+
export function runCli(argv, cwd = process.cwd(), env = process.env) {
|
|
175
|
+
const parsed = parseCli(argv);
|
|
176
|
+
const [command, first, second] = parsed.args;
|
|
177
|
+
if (!command || command === "help" || command === "--help" || command === "-h")
|
|
178
|
+
return HELP;
|
|
179
|
+
const commands = new Set(["init", "list", "switch", "status", "read", "apply", "undo", "redo", "validate", "serve", "mcp", "module", "host"]);
|
|
180
|
+
if (!commands.has(command))
|
|
181
|
+
throw new CliUsageError(`未知命令:${command}`);
|
|
182
|
+
if (command === "init") {
|
|
183
|
+
const graphId = parsed.graph ?? required(first, "toporealm init <图 ID>");
|
|
184
|
+
const root = resolveWorkspaceRoot({ cwd, explicitRoot: parsed.root, env, allowCreate: true });
|
|
185
|
+
mkdirSync(join(root, ".toporealm", "graphs"), { recursive: true });
|
|
186
|
+
const snapshot = initGraph(root, graphId, {
|
|
187
|
+
format: GRAPH_FORMAT,
|
|
188
|
+
id: graphId,
|
|
189
|
+
sources: { objects: "objects/*.yaml", relations: "relations/*.yaml" },
|
|
190
|
+
});
|
|
191
|
+
if (!existsSync(join(root, ".toporealm", "active")))
|
|
192
|
+
selectGraph(root, graphId);
|
|
193
|
+
return JSON.stringify(snapshot);
|
|
194
|
+
}
|
|
195
|
+
const root = resolveWorkspaceRoot({ cwd, explicitRoot: parsed.root, env });
|
|
196
|
+
if (command === "list") {
|
|
197
|
+
let currentId;
|
|
198
|
+
try {
|
|
199
|
+
currentId = resolveGraphTarget(root, { explicitGraph: parsed.graph, env });
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
currentId = undefined;
|
|
203
|
+
}
|
|
204
|
+
return JSON.stringify({ currentId, graphs: listGraphs(root) });
|
|
205
|
+
}
|
|
206
|
+
if (command === "switch") {
|
|
207
|
+
const graphId = parsed.graph ?? required(first, "toporealm switch <图 ID>");
|
|
208
|
+
selectGraph(root, graphId);
|
|
209
|
+
return JSON.stringify({ currentId: graphId });
|
|
210
|
+
}
|
|
211
|
+
if (command === "module") {
|
|
212
|
+
const action = required(first, "toporealm module add|remove|list");
|
|
213
|
+
const options = { workspaceRoot: root, scope: parsed.global ? "global" : "workspace" };
|
|
214
|
+
if (env.TOPOREALM_HOME)
|
|
215
|
+
options.globalHome = env.TOPOREALM_HOME;
|
|
216
|
+
if (action === "list")
|
|
217
|
+
return JSON.stringify({ modules: listInstalledModules(options) });
|
|
218
|
+
if (action === "add")
|
|
219
|
+
return JSON.stringify(addModule(required(second, "toporealm module add <npm-spec>"), options));
|
|
220
|
+
if (action === "remove") {
|
|
221
|
+
const id = required(second, "toporealm module remove <module-id>");
|
|
222
|
+
uninstallModule(id, options);
|
|
223
|
+
return JSON.stringify({ removed: id, scope: options.scope });
|
|
224
|
+
}
|
|
225
|
+
throw new CliUsageError(`未知 module 子命令:${action}`);
|
|
226
|
+
}
|
|
227
|
+
if (command === "host") {
|
|
228
|
+
if (first !== "sync")
|
|
229
|
+
throw new CliUsageError("用法:toporealm host sync");
|
|
230
|
+
return JSON.stringify(syncHostProjections({
|
|
231
|
+
workspaceRoot: root,
|
|
232
|
+
hostRoots: { codex: join(root, ".codex"), claude: join(root, ".claude"), pi: join(root, ".pi") },
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
if (command === "serve" || command === "mcp") {
|
|
236
|
+
return JSON.stringify({ command, workspaceRoot: root, graphId: resolveGraphTarget(root, { explicitGraph: parsed.graph, env }), host: parsed.host ?? "127.0.0.1", port: parsed.port ?? 0, open: parsed.open });
|
|
237
|
+
}
|
|
238
|
+
let legacyGraph;
|
|
239
|
+
let payload = first;
|
|
240
|
+
if (!parsed.graph && ["read", "apply"].includes(command) && first && !first.startsWith("{")) {
|
|
241
|
+
legacyGraph = first;
|
|
242
|
+
payload = second;
|
|
243
|
+
}
|
|
244
|
+
const graphId = resolveGraphTarget(root, { explicitGraph: parsed.graph ?? legacyGraph, env });
|
|
245
|
+
const store = openGraph(root, graphId);
|
|
246
|
+
if (command === "read")
|
|
247
|
+
return JSON.stringify(store.read());
|
|
248
|
+
if (command === "status") {
|
|
249
|
+
const snapshot = store.read();
|
|
250
|
+
return JSON.stringify({ graphId, revision: snapshot.revision, objects: snapshot.objects.length, relations: snapshot.relations.length, history: store.historyStatus() });
|
|
251
|
+
}
|
|
252
|
+
if (command === "apply")
|
|
253
|
+
return JSON.stringify(store.apply(JSON.parse(required(payload, "toporealm apply <MutationPlan JSON>"))));
|
|
254
|
+
if (command === "undo")
|
|
255
|
+
return JSON.stringify(store.undo(parseRevision(first)));
|
|
256
|
+
if (command === "redo")
|
|
257
|
+
return JSON.stringify(store.redo(parseRevision(first)));
|
|
258
|
+
if (command === "validate") {
|
|
259
|
+
const snapshot = store.read();
|
|
260
|
+
const registry = parsed.complete ? new GraphActivator(new WorkspaceModuleResolver(root)).activate(snapshot) : undefined;
|
|
261
|
+
return JSON.stringify(validateGraph(snapshot, registry));
|
|
262
|
+
}
|
|
263
|
+
throw new CliUsageError(`未知命令:${command}`);
|
|
264
|
+
}
|
|
265
|
+
export function executeCli(argv, options = {}) {
|
|
266
|
+
try {
|
|
267
|
+
return { exitCode: 0, stdout: `${runCli(argv, options.cwd, options.env)}\n`, stderr: "" };
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
const usage = error instanceof CliUsageError;
|
|
271
|
+
const code = error instanceof CoreError ? error.code : usage ? error.code : "CLI_ERROR";
|
|
272
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
273
|
+
return { exitCode: usage ? 2 : 1, stdout: "", stderr: `${JSON.stringify({ error: { code, message } })}\n` };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,GAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,WAAW,EAAW,CAAC;AAcxF,MAAM,aAAc,SAAQ,KAAK;IACtB,IAAI,GAAG,WAAW,CAAC;CAC7B;AAED,MAAM,IAAI,GAAG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K,CAAC,CAAC;QACvE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;IAC9G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":""}
|
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { executeCli, runCli } from "./index.js";
|
|
3
|
+
import { startToporealmMcpStdio } from "../mcp/index.js";
|
|
4
|
+
import { GraphStore } from "../core/index.js";
|
|
5
|
+
import { listenToporealmServer } from "../server/index.js";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
function openBrowser(url) {
|
|
8
|
+
const command = process.platform === "win32" ? "cmd" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
9
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
10
|
+
spawn(command, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
11
|
+
}
|
|
12
|
+
const argv = process.argv.slice(2);
|
|
13
|
+
if (argv.includes("mcp")) {
|
|
14
|
+
try {
|
|
15
|
+
const target = JSON.parse(runCli(argv));
|
|
16
|
+
await startToporealmMcpStdio(target);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
20
|
+
process.exitCode = 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (argv.includes("serve")) {
|
|
24
|
+
try {
|
|
25
|
+
const target = JSON.parse(runCli(argv));
|
|
26
|
+
const server = await listenToporealmServer(GraphStore.fromWorkspace(target.workspaceRoot, target.graphId), target.port, target.host);
|
|
27
|
+
const address = server.address();
|
|
28
|
+
if (!address || typeof address === "string")
|
|
29
|
+
throw new Error("Web Server 未获得 TCP 地址。");
|
|
30
|
+
const url = `http://${target.host}:${address.port}/`;
|
|
31
|
+
process.stdout.write(`${JSON.stringify({ url, graphId: target.graphId })}\n`);
|
|
32
|
+
if (target.open)
|
|
33
|
+
openBrowser(url);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const result = executeCli(argv);
|
|
42
|
+
if (result.stdout)
|
|
43
|
+
process.stdout.write(result.stdout);
|
|
44
|
+
if (result.stderr)
|
|
45
|
+
process.stderr.write(result.stderr);
|
|
46
|
+
process.exitCode = result.exitCode;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=main.js.map
|