@ggui-ai/project-config 0.1.0-rc.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/LICENSE +201 -0
- package/README.md +66 -0
- package/dist/discovery.d.ts +74 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +167 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/mcp-mount-discovery.d.ts +82 -0
- package/dist/mcp-mount-discovery.d.ts.map +1 -0
- package/dist/mcp-mount-discovery.js +226 -0
- package/dist/node.d.ts +69 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +157 -0
- package/dist/primitive-discovery.d.ts +95 -0
- package/dist/primitive-discovery.d.ts.map +1 -0
- package/dist/primitive-discovery.js +281 -0
- package/dist/primitives-manifest.d.ts +106 -0
- package/dist/primitives-manifest.d.ts.map +1 -0
- package/dist/primitives-manifest.js +131 -0
- package/dist/schema.d.ts +520 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +556 -0
- package/dist/theme-loader.d.ts +104 -0
- package/dist/theme-loader.d.ts.map +1 -0
- package/dist/theme-loader.js +263 -0
- package/dist/theme.d.ts +311 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +366 -0
- package/dist/ui-manifest.d.ts +95 -0
- package/dist/ui-manifest.d.ts.map +1 -0
- package/dist/ui-manifest.js +114 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Loqu, Inc. (Guuey)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @ggui-ai/project-config
|
|
2
|
+
|
|
3
|
+
> Schema and loader for `ggui.json` — the portable app/agent manifest for the [ggui](https://github.com/ggui-ai/ggui) protocol.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@ggui-ai/project-config)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
`ggui.json` is the single source of truth for a ggui app: its identity, the agent entry point, storage, theme, primitives, and blueprints. This package owns the schema (a [Zod](https://zod.dev) document) and the loaders that read, validate, and write it.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @ggui-ai/project-config
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Two entry points
|
|
17
|
+
|
|
18
|
+
| Import | Environment | Contains |
|
|
19
|
+
| ------------------------------ | ------------ | -------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| `@ggui-ai/project-config` | browser-safe | Schema + pure parsers — no Node dependencies. |
|
|
21
|
+
| `@ggui-ai/project-config/node` | Node only | Filesystem helpers (`findGguiJson`, `loadGguiJson`, `saveGguiJson`) plus everything from the root. |
|
|
22
|
+
|
|
23
|
+
The root barrel carries no `node:fs` imports, so it can run in a browser — for example to validate a manifest pasted into a web UI.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// Browser-safe: validate a manifest object.
|
|
29
|
+
import { parseGguiJson, safeParseGguiJson } from "@ggui-ai/project-config";
|
|
30
|
+
|
|
31
|
+
const manifest = parseGguiJson(JSON.parse(rawText)); // throws on invalid input
|
|
32
|
+
|
|
33
|
+
const result = safeParseGguiJson(JSON.parse(rawText));
|
|
34
|
+
if (result.ok) {
|
|
35
|
+
// result.value is a validated GguiJsonV1
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// Node: locate and load ggui.json from disk.
|
|
41
|
+
import { findGguiJson, loadGguiJson } from "@ggui-ai/project-config/node";
|
|
42
|
+
|
|
43
|
+
const path = findGguiJson(process.cwd()); // walks up the directory tree
|
|
44
|
+
if (path) {
|
|
45
|
+
const manifest = loadGguiJson(path); // throws GguiJsonLoadError on failure
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Manifest shape
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"schema": "1",
|
|
54
|
+
"protocol": "<current PROTOCOL_VERSION>",
|
|
55
|
+
"app": { "slug": "my-app", "name": "My App" },
|
|
56
|
+
"agent": { "entry": "./agent.ts" }
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`protocol` MUST match `PROTOCOL_VERSION` exported by `@ggui-ai/protocol` in the version installed.
|
|
61
|
+
|
|
62
|
+
Optional blocks: `storage` (sessions / vectors / threads via `memory` or `sqlite`), `theme`, `primitives`, `blueprints`, `mcpMounts`, and `operator`. See the exported Zod schema for the full, authoritative shape.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
Apache 2.0
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { GguiJsonV1 } from './schema.js';
|
|
2
|
+
import { type UiManifest } from './ui-manifest.js';
|
|
3
|
+
/**
|
|
4
|
+
* One discovered UI — the stable id + absolute manifest path + the
|
|
5
|
+
* parsed manifest shape. Callers address by id; the paths are for
|
|
6
|
+
* compile lookups and for informational output.
|
|
7
|
+
*/
|
|
8
|
+
export interface DiscoveredUi {
|
|
9
|
+
id: string;
|
|
10
|
+
manifestPath: string;
|
|
11
|
+
manifest: UiManifest;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An error surfaced during discovery. Discovery never throws on a
|
|
15
|
+
* single bad manifest — one malformed UI shouldn't black-hole the
|
|
16
|
+
* rest of the project. Instead we collect issues with per-file
|
|
17
|
+
* provenance so the CLI can render them and continue serving the
|
|
18
|
+
* valid ones.
|
|
19
|
+
*/
|
|
20
|
+
export interface DiscoveryIssue {
|
|
21
|
+
/**
|
|
22
|
+
* Path of the offending manifest, relative to the project root if
|
|
23
|
+
* it was reachable, absolute if the failure happened before we
|
|
24
|
+
* could compute a sensible relative path.
|
|
25
|
+
*/
|
|
26
|
+
path: string;
|
|
27
|
+
message: string;
|
|
28
|
+
/** Underlying cause (typically a `ZodError` or `SyntaxError`). */
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** Result of a full discovery pass. */
|
|
32
|
+
export interface DiscoveryResult {
|
|
33
|
+
/** Successfully parsed UIs, in filesystem-walk order. */
|
|
34
|
+
uis: DiscoveredUi[];
|
|
35
|
+
/** Issues that should be rendered to the user; discovery still returns. */
|
|
36
|
+
issues: DiscoveryIssue[];
|
|
37
|
+
}
|
|
38
|
+
export interface DiscoverOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Absolute project root — the directory containing `ggui.json`.
|
|
41
|
+
* Globs in `blueprints.include` are resolved relative to this
|
|
42
|
+
* directory.
|
|
43
|
+
*/
|
|
44
|
+
projectRoot: string;
|
|
45
|
+
/** The parsed `ggui.json`. Only `blueprints.include` is consumed today. */
|
|
46
|
+
manifest: GguiJsonV1;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Walk `blueprints.include`, load every matched `ggui.ui.json`, and
|
|
50
|
+
* return discovered UIs plus accumulated issues.
|
|
51
|
+
*
|
|
52
|
+
* Ordering: filesystem-walk order from `tinyglobby` (currently
|
|
53
|
+
* alphabetical within each match). Callers that care about stable
|
|
54
|
+
* ordering across file renames should sort by `id` or `manifest.name`
|
|
55
|
+
* themselves.
|
|
56
|
+
*
|
|
57
|
+
* Duplicate-id handling: the first encounter wins and the rest are
|
|
58
|
+
* surfaced as {@link DiscoveryIssue} entries. Two sources with the
|
|
59
|
+
* same id would violate the registry-source identity invariant — we
|
|
60
|
+
* would rather emit a noisy conflict than silently overwrite.
|
|
61
|
+
*
|
|
62
|
+
* Glob mismatch handling: a glob pattern that matches a file whose
|
|
63
|
+
* basename isn't `ggui.ui.json` is ignored (not an error) — users
|
|
64
|
+
* sometimes cast wide `**` patterns intentionally. A glob that
|
|
65
|
+
* matches nothing at all is allowed; the manifest may exist in
|
|
66
|
+
* anticipation of UIs not authored yet.
|
|
67
|
+
*/
|
|
68
|
+
export declare function discoverLocalUis(options: DiscoverOptions): Promise<DiscoveryResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Convenience wrapper for the common "I have a `ggui.json` path, give
|
|
71
|
+
* me the UIs" flow. Resolves the project root from the manifest path.
|
|
72
|
+
*/
|
|
73
|
+
export declare function discoverFromGguiJsonPath(manifestPath: string, manifest: GguiJsonV1): Promise<DiscoveryResult>;
|
|
74
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,UAAU,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,uCAAuC;AACvC,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,GAAG,EAAE,YAAY,EAAE,CAAC;IACpB,2EAA2E;IAC3E,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,EAAE,UAAU,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,eAAe,CAAC,CA8F1B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,eAAe,CAAC,CAG1B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blueprint manifest discovery — turns a loaded `ggui.json` into the
|
|
3
|
+
* set of authored UIs the project declares via `blueprints.include`.
|
|
4
|
+
*
|
|
5
|
+
* The flow:
|
|
6
|
+
*
|
|
7
|
+
* ggui.json.blueprints.include (globs, relative to project root)
|
|
8
|
+
* → filesystem match (tinyglobby)
|
|
9
|
+
* → load each `ggui.ui.json`
|
|
10
|
+
* → parse via {@link parseUiManifest}
|
|
11
|
+
* → return `{ id, manifestPath, manifest }` tuples
|
|
12
|
+
*
|
|
13
|
+
* Per the registry-source architecture lock (plan §8.6), every UI
|
|
14
|
+
* carries a stable machine-oriented `id` that survives renames and
|
|
15
|
+
* content edits. Duplicate ids across manifests are a load-bearing
|
|
16
|
+
* error — two sources cannot share identity — so we surface them as
|
|
17
|
+
* structured issues rather than silently last-writer-wins.
|
|
18
|
+
*
|
|
19
|
+
* ## Error model
|
|
20
|
+
*
|
|
21
|
+
* Discovery never throws on a per-manifest failure. One malformed
|
|
22
|
+
* `ggui.ui.json` should not black-hole the rest of the project — the
|
|
23
|
+
* `ggui dev` hub renders the valid UIs + flags the bad ones in the
|
|
24
|
+
* UI. Each issue carries a path + message so callers can render a
|
|
25
|
+
* useful list.
|
|
26
|
+
*
|
|
27
|
+
* Callers that need fail-fast semantics (e.g. `ggui serve` boot, where
|
|
28
|
+
* continuing with a partial set is a silent deploy-time regression)
|
|
29
|
+
* inspect `result.issues` themselves and escalate to a thrown error
|
|
30
|
+
* when non-empty. This helper stays policy-neutral.
|
|
31
|
+
*
|
|
32
|
+
* ## Why `@ggui-ai/project-config/node`, not a sibling package
|
|
33
|
+
*
|
|
34
|
+
* Discovery is filesystem + parse + identity check. It is NOT HTTP,
|
|
35
|
+
* agent runtime, or registry state. Two consumers need it today:
|
|
36
|
+
*
|
|
37
|
+
* - `@ggui-ai/dev-stack`'s `LocalUiRegistry`, which powers the
|
|
38
|
+
* `ggui dev` hub's compile-on-demand view.
|
|
39
|
+
* - `@ggui-ai/mcp-server` at `ggui serve` boot time — so the OSS
|
|
40
|
+
* MCP server's blueprint-read handlers actually consume the
|
|
41
|
+
* declared capability surface instead of returning the empty
|
|
42
|
+
* pre-manifest placeholder.
|
|
43
|
+
*
|
|
44
|
+
* Housing it in `@ggui-ai/project-config/node` (the schema-owner's
|
|
45
|
+
* Node subpath) keeps one source of truth and avoids a dev-stack →
|
|
46
|
+
* mcp-server import edge (dev-stack pulls HTTP / Vite / SSE runtime
|
|
47
|
+
* infrastructure that has no business booting inside a pure MCP
|
|
48
|
+
* server).
|
|
49
|
+
*/
|
|
50
|
+
import { readFile } from 'node:fs/promises';
|
|
51
|
+
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
52
|
+
import { glob } from 'tinyglobby';
|
|
53
|
+
import { GGUI_UI_JSON_FILENAME, parseUiManifest, } from './ui-manifest.js';
|
|
54
|
+
/**
|
|
55
|
+
* Walk `blueprints.include`, load every matched `ggui.ui.json`, and
|
|
56
|
+
* return discovered UIs plus accumulated issues.
|
|
57
|
+
*
|
|
58
|
+
* Ordering: filesystem-walk order from `tinyglobby` (currently
|
|
59
|
+
* alphabetical within each match). Callers that care about stable
|
|
60
|
+
* ordering across file renames should sort by `id` or `manifest.name`
|
|
61
|
+
* themselves.
|
|
62
|
+
*
|
|
63
|
+
* Duplicate-id handling: the first encounter wins and the rest are
|
|
64
|
+
* surfaced as {@link DiscoveryIssue} entries. Two sources with the
|
|
65
|
+
* same id would violate the registry-source identity invariant — we
|
|
66
|
+
* would rather emit a noisy conflict than silently overwrite.
|
|
67
|
+
*
|
|
68
|
+
* Glob mismatch handling: a glob pattern that matches a file whose
|
|
69
|
+
* basename isn't `ggui.ui.json` is ignored (not an error) — users
|
|
70
|
+
* sometimes cast wide `**` patterns intentionally. A glob that
|
|
71
|
+
* matches nothing at all is allowed; the manifest may exist in
|
|
72
|
+
* anticipation of UIs not authored yet.
|
|
73
|
+
*/
|
|
74
|
+
export async function discoverLocalUis(options) {
|
|
75
|
+
const { projectRoot, manifest } = options;
|
|
76
|
+
if (!isAbsolute(projectRoot)) {
|
|
77
|
+
throw new Error(`discoverLocalUis: projectRoot must be absolute, got ${projectRoot}`);
|
|
78
|
+
}
|
|
79
|
+
const patterns = manifest.blueprints.include;
|
|
80
|
+
const uis = [];
|
|
81
|
+
const issues = [];
|
|
82
|
+
const seenIds = new Map(); // id → manifestPath
|
|
83
|
+
if (patterns.length === 0) {
|
|
84
|
+
return { uis, issues };
|
|
85
|
+
}
|
|
86
|
+
const matches = await glob(patterns, {
|
|
87
|
+
cwd: projectRoot,
|
|
88
|
+
absolute: true,
|
|
89
|
+
onlyFiles: true,
|
|
90
|
+
// Symlink-following off by default — matches the usual "source
|
|
91
|
+
// is in the repo" expectation and keeps discovery cheap.
|
|
92
|
+
followSymbolicLinks: false,
|
|
93
|
+
// No dot-file expansion unless the user explicitly opted in via
|
|
94
|
+
// a pattern starting with `.`; stays consistent with most git /
|
|
95
|
+
// tooling defaults.
|
|
96
|
+
dot: false,
|
|
97
|
+
});
|
|
98
|
+
for (const absolutePath of matches) {
|
|
99
|
+
const relPath = relative(projectRoot, absolutePath);
|
|
100
|
+
const displayPath = relPath === '' ? absolutePath : relPath;
|
|
101
|
+
// Skip files whose basename doesn't look like a per-UI manifest.
|
|
102
|
+
// `blueprints.include` is intentionally glob-based; users
|
|
103
|
+
// sometimes write `ui/**/*.json` and pick up README JSONs etc.
|
|
104
|
+
if (!absolutePath.endsWith(`/${GGUI_UI_JSON_FILENAME}`)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
let raw;
|
|
108
|
+
try {
|
|
109
|
+
raw = await readFile(absolutePath, 'utf-8');
|
|
110
|
+
}
|
|
111
|
+
catch (cause) {
|
|
112
|
+
issues.push({
|
|
113
|
+
path: displayPath,
|
|
114
|
+
message: `Could not read ${GGUI_UI_JSON_FILENAME}: ${errorMessage(cause)}`,
|
|
115
|
+
cause,
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
let decoded;
|
|
120
|
+
try {
|
|
121
|
+
decoded = JSON.parse(raw);
|
|
122
|
+
}
|
|
123
|
+
catch (cause) {
|
|
124
|
+
issues.push({
|
|
125
|
+
path: displayPath,
|
|
126
|
+
message: `${GGUI_UI_JSON_FILENAME} is not valid JSON: ${errorMessage(cause)}`,
|
|
127
|
+
cause,
|
|
128
|
+
});
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
let parsed;
|
|
132
|
+
try {
|
|
133
|
+
parsed = parseUiManifest(decoded);
|
|
134
|
+
}
|
|
135
|
+
catch (cause) {
|
|
136
|
+
issues.push({
|
|
137
|
+
path: displayPath,
|
|
138
|
+
message: `${GGUI_UI_JSON_FILENAME} failed schema validation: ${errorMessage(cause)}`,
|
|
139
|
+
cause,
|
|
140
|
+
});
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const prior = seenIds.get(parsed.id);
|
|
144
|
+
if (prior !== undefined) {
|
|
145
|
+
issues.push({
|
|
146
|
+
path: displayPath,
|
|
147
|
+
message: `Duplicate id "${parsed.id}" — already declared by ${prior}. ` +
|
|
148
|
+
`Every ggui.ui.json#id must be unique across the project (registry-source identity).`,
|
|
149
|
+
});
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
seenIds.set(parsed.id, displayPath);
|
|
153
|
+
uis.push({ id: parsed.id, manifestPath: absolutePath, manifest: parsed });
|
|
154
|
+
}
|
|
155
|
+
return { uis, issues };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Convenience wrapper for the common "I have a `ggui.json` path, give
|
|
159
|
+
* me the UIs" flow. Resolves the project root from the manifest path.
|
|
160
|
+
*/
|
|
161
|
+
export async function discoverFromGguiJsonPath(manifestPath, manifest) {
|
|
162
|
+
const projectRoot = dirname(resolve(manifestPath));
|
|
163
|
+
return discoverLocalUis({ projectRoot, manifest });
|
|
164
|
+
}
|
|
165
|
+
function errorMessage(cause) {
|
|
166
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
167
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ggui-ai/project-config` — root barrel (browser-safe).
|
|
3
|
+
*
|
|
4
|
+
* Exports the v1 `ggui.json` schema + pure parsers. These carry no
|
|
5
|
+
* Node dependencies and can be imported from browser code (e.g.,
|
|
6
|
+
* paste-a-manifest validators, dev UIs).
|
|
7
|
+
*
|
|
8
|
+
* Filesystem helpers live on the `./node` subpath. See that module
|
|
9
|
+
* for `findGguiJson` / `loadGguiJson` / `saveGguiJson` / related
|
|
10
|
+
* types.
|
|
11
|
+
*/
|
|
12
|
+
export * from './schema.js';
|
|
13
|
+
export * from './ui-manifest.js';
|
|
14
|
+
export * from './primitives-manifest.js';
|
|
15
|
+
export * from './theme.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@ggui-ai/project-config` — root barrel (browser-safe).
|
|
3
|
+
*
|
|
4
|
+
* Exports the v1 `ggui.json` schema + pure parsers. These carry no
|
|
5
|
+
* Node dependencies and can be imported from browser code (e.g.,
|
|
6
|
+
* paste-a-manifest validators, dev UIs).
|
|
7
|
+
*
|
|
8
|
+
* Filesystem helpers live on the `./node` subpath. See that module
|
|
9
|
+
* for `findGguiJson` / `loadGguiJson` / `saveGguiJson` / related
|
|
10
|
+
* types.
|
|
11
|
+
*/
|
|
12
|
+
export * from './schema.js';
|
|
13
|
+
export * from './ui-manifest.js';
|
|
14
|
+
export * from './primitives-manifest.js';
|
|
15
|
+
export * from './theme.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { GguiJsonV1 } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* The export name callers should use on their mount module. A default
|
|
4
|
+
* export is also accepted when this named export is absent; the named
|
|
5
|
+
* form is preferred because it gives readers a visible symbol at the
|
|
6
|
+
* declaration site (`export function createGguiMcpMount() { ... }`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const GGUI_MCP_MOUNT_FACTORY_EXPORT = "createGguiMcpMount";
|
|
9
|
+
/**
|
|
10
|
+
* Result of a successfully resolved + imported + invoked mount
|
|
11
|
+
* declaration. The `mount` field is validated structurally — callers
|
|
12
|
+
* (the CLI) narrow `handlers: unknown[]` to the concrete
|
|
13
|
+
* `SharedHandler[]` at the adapter boundary. See module-level JSDoc
|
|
14
|
+
* for the reason project-config does not import the server's type.
|
|
15
|
+
*/
|
|
16
|
+
export interface DiscoveredMcpMount {
|
|
17
|
+
/** The module specifier as it appeared in `ggui.json#mcpMounts`. */
|
|
18
|
+
readonly spec: string;
|
|
19
|
+
/** Absolute filesystem path to the resolved module. */
|
|
20
|
+
readonly modulePath: string;
|
|
21
|
+
/** The factory's return — validated to have `{ name, handlers }`. */
|
|
22
|
+
readonly mount: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly handlers: ReadonlyArray<unknown>;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Issue shape matches blueprint / primitive discovery so CLI renderers
|
|
28
|
+
* can treat all three streams uniformly. */
|
|
29
|
+
export interface McpMountDiscoveryIssue {
|
|
30
|
+
/**
|
|
31
|
+
* The offending declared spec (not a filesystem path) — resolution
|
|
32
|
+
* may have failed before we located a file.
|
|
33
|
+
*/
|
|
34
|
+
path: string;
|
|
35
|
+
message: string;
|
|
36
|
+
/** Underlying cause (resolver error, `SyntaxError`, factory throw). */
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface McpMountDiscoveryResult {
|
|
40
|
+
/** Mounts that resolved + imported + produced a valid shape, in
|
|
41
|
+
* declaration order. */
|
|
42
|
+
mounts: DiscoveredMcpMount[];
|
|
43
|
+
/** Per-source issues. Non-empty = operator action required; `ggui
|
|
44
|
+
* serve` escalates to a fatal exit before binding. */
|
|
45
|
+
issues: McpMountDiscoveryIssue[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for {@link discoverMcpMounts}. `resolveModule` +
|
|
49
|
+
* `importModule` are exposed so tests can avoid building real
|
|
50
|
+
* `node_modules/` trees + real files — production callers omit both
|
|
51
|
+
* and get `createRequire` + native dynamic `import()` defaults.
|
|
52
|
+
*/
|
|
53
|
+
export interface DiscoverMcpMountsOptions {
|
|
54
|
+
/** Absolute project root — the directory containing `ggui.json`. */
|
|
55
|
+
projectRoot: string;
|
|
56
|
+
/** The parsed `ggui.json`. Only `mcpMounts` is consumed. */
|
|
57
|
+
manifest: GguiJsonV1;
|
|
58
|
+
/**
|
|
59
|
+
* Hook for tests — given the declared specifier and the project
|
|
60
|
+
* root, return the absolute path to the module file. Production
|
|
61
|
+
* callers omit this; the default resolves relative paths against
|
|
62
|
+
* the project root and bare specs through `createRequire`.
|
|
63
|
+
*/
|
|
64
|
+
resolveModule?: (spec: string, projectRoot: string) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Hook for tests — given a `file://…` URL, return the module's
|
|
67
|
+
* namespace object (or equivalent). Production callers omit this;
|
|
68
|
+
* the default uses native dynamic `import()`.
|
|
69
|
+
*/
|
|
70
|
+
importModule?: (fileUrl: string) => Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Walk `ggui.json#mcpMounts` and produce resolved + invoked mount
|
|
74
|
+
* payloads. Non-throwing per source; each failure lands on `issues`.
|
|
75
|
+
*
|
|
76
|
+
* Ordering: `mounts` preserves declaration order (so collision errors
|
|
77
|
+
* inside `composeHandlersWithMounts` deterministically blame the
|
|
78
|
+
* later-declared duplicate). `issues` likewise preserves declaration
|
|
79
|
+
* order so CLI renderers can print "issue #1 first" if they want.
|
|
80
|
+
*/
|
|
81
|
+
export declare function discoverMcpMounts(options: DiscoverMcpMountsOptions): Promise<McpMountDiscoveryResult>;
|
|
82
|
+
//# sourceMappingURL=mcp-mount-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-mount-discovery.d.ts","sourceRoot":"","sources":["../src/mcp-mount-discovery.ts"],"names":[],"mappings":"AAsDA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,uBAAuB,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC3C,CAAC;CACH;AAED;6CAC6C;AAC7C,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC;6BACyB;IACzB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B;2DACuD;IACvD,MAAM,EAAE,sBAAsB,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,EAAE,UAAU,CAAC;IACrB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9D;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAwFlC"}
|