@agimon-ai/po-build 0.0.0-alpha.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 +22 -0
- package/README.md +96 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/browserFile.cjs +1 -0
- package/dist/browserFile.d.mts +2 -0
- package/dist/browserFile.mjs +1 -0
- package/dist/constants/contributions.cjs +2 -0
- package/dist/constants/contributions.cjs.map +1 -0
- package/dist/constants/contributions.mjs +2 -0
- package/dist/constants/contributions.mjs.map +1 -0
- package/dist/constants/layout.cjs +2 -0
- package/dist/constants/layout.cjs.map +1 -0
- package/dist/constants/layout.d.mts +56 -0
- package/dist/constants/layout.d.mts.map +1 -0
- package/dist/constants/layout.mjs +2 -0
- package/dist/constants/layout.mjs.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.mjs +1 -0
- package/dist/services/browserFile/index.cjs +2 -0
- package/dist/services/browserFile/index.cjs.map +1 -0
- package/dist/services/browserFile/index.d.mts +22 -0
- package/dist/services/browserFile/index.d.mts.map +1 -0
- package/dist/services/browserFile/index.mjs +2 -0
- package/dist/services/browserFile/index.mjs.map +1 -0
- package/dist/services/filename/index.cjs +2 -0
- package/dist/services/filename/index.cjs.map +1 -0
- package/dist/services/filename/index.d.mts +29 -0
- package/dist/services/filename/index.d.mts.map +1 -0
- package/dist/services/filename/index.mjs +2 -0
- package/dist/services/filename/index.mjs.map +1 -0
- package/dist/services/generate/index.cjs +3 -0
- package/dist/services/generate/index.cjs.map +1 -0
- package/dist/services/generate/index.d.mts +15 -0
- package/dist/services/generate/index.d.mts.map +1 -0
- package/dist/services/generate/index.mjs +3 -0
- package/dist/services/generate/index.mjs.map +1 -0
- package/dist/services/generate/type.d.mts +28 -0
- package/dist/services/generate/type.d.mts.map +1 -0
- package/dist/services/identity/index.cjs +2 -0
- package/dist/services/identity/index.cjs.map +1 -0
- package/dist/services/identity/index.mjs +2 -0
- package/dist/services/identity/index.mjs.map +1 -0
- package/dist/services/renderClient/index.cjs +3 -0
- package/dist/services/renderClient/index.cjs.map +1 -0
- package/dist/services/renderClient/index.mjs +3 -0
- package/dist/services/renderClient/index.mjs.map +1 -0
- package/dist/services/renderEntry/index.cjs +7 -0
- package/dist/services/renderEntry/index.cjs.map +1 -0
- package/dist/services/renderEntry/index.d.mts +18 -0
- package/dist/services/renderEntry/index.d.mts.map +1 -0
- package/dist/services/renderEntry/index.mjs +7 -0
- package/dist/services/renderEntry/index.mjs.map +1 -0
- package/dist/services/renderEntry/type.d.mts +16 -0
- package/dist/services/renderEntry/type.d.mts.map +1 -0
- package/dist/services/renderMcpWidgets/index.cjs +3 -0
- package/dist/services/renderMcpWidgets/index.cjs.map +1 -0
- package/dist/services/renderMcpWidgets/index.mjs +3 -0
- package/dist/services/renderMcpWidgets/index.mjs.map +1 -0
- package/dist/services/resolveTarget/index.cjs +2 -0
- package/dist/services/resolveTarget/index.cjs.map +1 -0
- package/dist/services/resolveTarget/index.d.mts +18 -0
- package/dist/services/resolveTarget/index.d.mts.map +1 -0
- package/dist/services/resolveTarget/index.mjs +2 -0
- package/dist/services/resolveTarget/index.mjs.map +1 -0
- package/dist/services/resolveTarget/type.d.mts +30 -0
- package/dist/services/resolveTarget/type.d.mts.map +1 -0
- package/dist/services/scan/index.cjs +2 -0
- package/dist/services/scan/index.cjs.map +1 -0
- package/dist/services/scan/index.d.mts +8 -0
- package/dist/services/scan/index.d.mts.map +1 -0
- package/dist/services/scan/index.mjs +2 -0
- package/dist/services/scan/index.mjs.map +1 -0
- package/dist/services/scan/type.d.mts +25 -0
- package/dist/services/scan/type.d.mts.map +1 -0
- package/dist/services/segments/index.cjs +2 -0
- package/dist/services/segments/index.cjs.map +1 -0
- package/dist/services/segments/index.d.mts +26 -0
- package/dist/services/segments/index.d.mts.map +1 -0
- package/dist/services/segments/index.mjs +2 -0
- package/dist/services/segments/index.mjs.map +1 -0
- package/dist/services/syncManifest/index.cjs +2 -0
- package/dist/services/syncManifest/index.cjs.map +1 -0
- package/dist/services/syncManifest/index.d.mts +21 -0
- package/dist/services/syncManifest/index.d.mts.map +1 -0
- package/dist/services/syncManifest/index.mjs +2 -0
- package/dist/services/syncManifest/index.mjs.map +1 -0
- package/dist/services/syncManifest/type.d.mts +15 -0
- package/dist/services/syncManifest/type.d.mts.map +1 -0
- package/dist/services/tsdownPreset/index.cjs +2 -0
- package/dist/services/tsdownPreset/index.cjs.map +1 -0
- package/dist/services/tsdownPreset/index.d.mts +89 -0
- package/dist/services/tsdownPreset/index.d.mts.map +1 -0
- package/dist/services/tsdownPreset/index.mjs +2 -0
- package/dist/services/tsdownPreset/index.mjs.map +1 -0
- package/dist/services/unistylesBabel/index.cjs +2 -0
- package/dist/services/unistylesBabel/index.cjs.map +1 -0
- package/dist/services/unistylesBabel/index.d.mts +17 -0
- package/dist/services/unistylesBabel/index.d.mts.map +1 -0
- package/dist/services/unistylesBabel/index.mjs +2 -0
- package/dist/services/unistylesBabel/index.mjs.map +1 -0
- package/dist/services/unistylesBabel/type.d.mts +13 -0
- package/dist/services/unistylesBabel/type.d.mts.map +1 -0
- package/dist/services/writeGenerated/index.cjs +2 -0
- package/dist/services/writeGenerated/index.cjs.map +1 -0
- package/dist/services/writeGenerated/index.d.mts +23 -0
- package/dist/services/writeGenerated/index.d.mts.map +1 -0
- package/dist/services/writeGenerated/index.mjs +2 -0
- package/dist/services/writeGenerated/index.mjs.map +1 -0
- package/dist/tsdown.cjs +1 -0
- package/dist/tsdown.d.mts +3 -0
- package/dist/tsdown.mjs +1 -0
- package/dist/types/extensionGraph.d.mts +75 -0
- package/dist/types/extensionGraph.d.mts.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vuong Ngo
|
|
4
|
+
Copyright (c) 2026 pulseaiclub
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @agimon-ai/po-build
|
|
2
|
+
|
|
3
|
+
Folder-convention scanner and build presets for Po extensions.
|
|
4
|
+
|
|
5
|
+
An extension declares what it contributes by where its files sit. This package reads that tree and hands the result to the generators and bundler presets, so a package keeps no parallel registry of its own contents.
|
|
6
|
+
|
|
7
|
+
See [Extension layout](../../../docs/extension-layout.md) for the convention and [Extension lifecycles](../../../docs/lifecycles.md) for what happens to a contribution once mounted.
|
|
8
|
+
|
|
9
|
+
## Scanning
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { scanExtensions } from '@agimon-ai/po-build';
|
|
13
|
+
|
|
14
|
+
const graph = scanExtensions({ packageDir: process.cwd() });
|
|
15
|
+
for (const entry of graph.entries) console.log(entry.scope, entry.side, entry.surface, entry.name);
|
|
16
|
+
for (const notice of graph.notices) console.warn(notice.path, notice.message);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The scan is filesystem in, data out. It walks directories rather than globbing, which is what keeps parenthesised group folders safe: tsdown's globber reads a bare `(name)` as an extglob group, and a walk never sees a pattern at all.
|
|
20
|
+
|
|
21
|
+
Nothing throws. A folder the convention does not recognise becomes a notice and its subtree is skipped, so one bad directory never costs a package its other contributions.
|
|
22
|
+
|
|
23
|
+
## What a path declares
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
src/extensions/<scope>/(side)/<surface>/<name>[.<target>][.<platform>].<ext>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Axis | Read from |
|
|
30
|
+
| -------- | ------------------------------------------------------------------ |
|
|
31
|
+
| scope | `workspaces/` and `sessions/` nesting below the root |
|
|
32
|
+
| side | the `(backend)` or `(frontend)` group folder |
|
|
33
|
+
| gate | a `mode/<id>/` or `domain/<id>/` container folder |
|
|
34
|
+
| surface | the folder directly holding the file, such as `tool/` |
|
|
35
|
+
| route | folders below a routed surface, with `[param]` and `[...catchAll]` |
|
|
36
|
+
| name | the first filename segment |
|
|
37
|
+
| target | filename segments between the name and the platform |
|
|
38
|
+
| platform | a trailing filename segment naming a platform for that side |
|
|
39
|
+
|
|
40
|
+
`_private` folders are never scanned. `*.test.*`, `*.spec.*` and `*.stories.*` are excluded everywhere.
|
|
41
|
+
|
|
42
|
+
## Options
|
|
43
|
+
|
|
44
|
+
Every name in the convention is configurable, and the defaults are the documented ones.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
scanExtensions({
|
|
48
|
+
packageDir,
|
|
49
|
+
root: 'src/extensions',
|
|
50
|
+
sides: { backend: 'backend', frontend: 'frontend' },
|
|
51
|
+
platforms: { backend: ['server', 'mcp'], frontend: ['web', 'native', 'ios', 'android', 'desktop'] },
|
|
52
|
+
generatedEntries: ['pi', 'server', 'web', 'native', 'mcp', 'client'],
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Platforms and targets
|
|
57
|
+
|
|
58
|
+
The build emits four hosts: `server` and `mcp` from `(backend)`, and `web` and `native` from `(frontend)`. `ios`, `android`, and `desktop` are authorable but have no build target, so a file naming one produces a notice and is not emitted.
|
|
59
|
+
|
|
60
|
+
The server and the cockpit accept an unsuffixed file as a fallback when no sibling names their platform. `mcp` and `native` never do: they read only files that name them, because an unsuffixed backend file may reach the whole server and an unsuffixed frontend file may use the DOM. `native` reads `tool/`, `tab/`, `slot/`, `fill/`, `channel/`, `activity-group/`, `setting/`, `lifecycle/`, and `store/`, and writes the same contribution fields as the cockpit for them, because the Po phone app reuses the cockpit's plugin registry.
|
|
61
|
+
|
|
62
|
+
`isBrowserFile` and `isNativeFile` (from `@agimon-ai/po-build/browserFile`) classify a package-relative path without reading it. A `(frontend)` path whose filename names `native` anywhere between its name and extension, including `.native.stories.tsx`, is native; every other `(frontend)` path is browser code. Lint rules use these to apply browser and native rules to the right files.
|
|
63
|
+
|
|
64
|
+
## Generating
|
|
65
|
+
|
|
66
|
+
`generateExtension` scans the authored tree, renders an entry for each host it contributes to, and writes build inputs beneath ignored `generated/`. A target with no contributions produces no entry, and removing a target deletes its obsolete generated entry.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { generateExtension } from '@agimon-ai/po-build';
|
|
70
|
+
|
|
71
|
+
const { targets, changed, notices } = generateExtension({ packageDir });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Without a `target` option it generates `server`, `web`, and `native`. The native entry, `generated/native.ts`, exports `nativePlugin = defineNativePlugin({...})` from `@agimon-ai/po-core/native`.
|
|
75
|
+
|
|
76
|
+
Normal builds generate missing or stale entries, including in CI. Pass `check: true` only for an explicit write-free freshness check. Generated files are disposable build output and are not committed.
|
|
77
|
+
|
|
78
|
+
## The tsdown preset
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// tsdown.config.ts, the whole file
|
|
82
|
+
import { poExtension } from '@agimon-ai/po-build/tsdown';
|
|
83
|
+
import { defineConfig } from 'tsdown';
|
|
84
|
+
|
|
85
|
+
export default defineConfig(poExtension());
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The preset generates entries while the config loads because tsdown needs its entry map before building. It builds Node host entries and public `src/exports` modules, then bundles routed frontend contributions separately to `dist/extensions/web.mjs`. The browser bundle keeps bare package imports external so the cockpit supplies shared React and store singletons. It also emits local `?url` assets and `?worker&url` worker chunks.
|
|
89
|
+
|
|
90
|
+
When a package has `.native` contributions, the preset adds a third config that bundles `generated/native.ts` to `dist/extensions/native.mjs`: ESM, `platform: 'neutral'`, every bare import external, typechecked under `tsconfig.native.json`. Its `po-unistyles-babel` transform runs the `react-native-unistyles` Babel plugin (`{ root: 'src' }`) over `.ts` and `.tsx` files under the package's own `src` that mention `react-native`, before rolldown strips the TypeScript. po-build does not depend on Babel or Unistyles: it loads `@babel/core` and `react-native-unistyles/plugin` from the extension package with `createRequire`, and fails with a message naming both when either is missing. This file bundle is not yet a composition; the `po` CLI joins every package's native half into one signed composition and checks its imports against the native host module list (see [Composition and package loading](../../../docs/bundling.md#the-global-native-build)).
|
|
91
|
+
|
|
92
|
+
Native component libraries reuse the same transform: `import { unistylesBabel } from '@agimon-ai/po-build/tsdown'` and add `unistylesBabel(import.meta.dirname)` to their own tsdown `plugins`.
|
|
93
|
+
|
|
94
|
+
The build synchronizes `pi`, `poServer`, `poWeb`, `poNative`, and generated host exports in `package.json`. `poNative` holds `pluginId`, the frame types its `.native` channels claim, `client: './dist/extensions/native.mjs'`, and the scopes it contributes to; the build also writes the `./extensions/native` export. `poWeb` and `poNative` describe disjoint files, because the cockpit never reads `.native` files. Keep package-specific public entries with the preset `entry` option, use `exportsDir` for a nonstandard public-export root, and set `pluginId` when the historical cockpit id differs from the package-derived default.
|
|
95
|
+
|
|
96
|
+
Packages with a frontend target typecheck it through a root `tsconfig.web.json`. Include `generated` in the Node project, exclude routed `(frontend)` files from it, and include those files plus `generated/web.ts` in the browser project. Packages with a native target also own a `tsconfig.native.json` with no DOM lib that includes `src/extensions/**/(frontend)/**/*.native.*` and `generated/native.ts`; exclude `**/*.native.*` from `tsconfig.web.json` and add `@babel/core`, `react-native`, and `react-native-unistyles` to the package's dev dependencies. `layers/task/po-task` is the working example.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));exports.__toESM=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/browserFile/index.cjs");exports.isBrowserFile=e.isBrowserFile,exports.isNativeFile=e.isNativeFile;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isBrowserFile as e,isNativeFile as t}from"./services/browserFile/index.mjs";export{e as isBrowserFile,t as isNativeFile};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,setting:`settingsSections`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`};exports.ACTION_FIELDS=a,exports.MCP_FIELDS=t,exports.NATIVE_FIELDS=r,exports.SERVER_FIELDS=e,exports.SETTING_FIELDS=i,exports.WEB_FIELDS=n;
|
|
2
|
+
//# sourceMappingURL=contributions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contributions.cjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n setting: 'settingsSections',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,QAAS,mBACT,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,setting:`settingsSections`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`};export{a as ACTION_FIELDS,t as MCP_FIELDS,r as NATIVE_FIELDS,e as SERVER_FIELDS,i as SETTING_FIELDS,n as WEB_FIELDS};
|
|
2
|
+
//# sourceMappingURL=contributions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contributions.mjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n setting: 'settingsSections',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,QAAS,mBACT,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
|
|
2
|
+
//# sourceMappingURL=layout.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = ['pi', 'server', 'web', 'native', 'mcp', 'client'];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/** Filename infixes excluded everywhere, whatever their position. */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,EA+BpDC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EA+BzFC,EAA2C,CAAC,KAAM,SAAU,MAAO,SAAU,MAAO,QAAQ,EAW5FC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAWrFC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAGjEC,EAAsC,CAAC,OAAQ,OAAQ,SAAS"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/constants/layout.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The folder-convention vocabulary, in one place.
|
|
4
|
+
*
|
|
5
|
+
* Every name here is part of the authoring contract in
|
|
6
|
+
* docs/extension-layout.md. Adding a surface means adding it to both.
|
|
7
|
+
*/
|
|
8
|
+
/** Where the scan starts, package-relative. */
|
|
9
|
+
export declare const DEFAULT_ROUTING_ROOT = "src/extensions";
|
|
10
|
+
/** Accepted spelling of the same root, for packages that prefer the singular. */
|
|
11
|
+
export declare const ROUTING_ROOT_ALIAS = "src/extension";
|
|
12
|
+
/** Gate folders. Each is followed by exactly one id segment. */
|
|
13
|
+
export declare const GATE_SEGMENTS: readonly string[];
|
|
14
|
+
/** The leaf filename of an HTTP route, as Next.js spells it. */
|
|
15
|
+
export declare const ROUTE_FILE_NAME = "route";
|
|
16
|
+
/**
|
|
17
|
+
* Where generated entries are written, package-relative.
|
|
18
|
+
*
|
|
19
|
+
* Not `src`. That directory is authored code, and a build that writes into it
|
|
20
|
+
* makes every package carry output its author did not write and must not edit.
|
|
21
|
+
* This one is gitignored per package, and the repository's formatter already
|
|
22
|
+
* skips a directory by this name.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GENERATED_DIR = "generated";
|
|
25
|
+
/**
|
|
26
|
+
* Platform suffixes, scoped to their side. A target may not reuse one of these words.
|
|
27
|
+
*
|
|
28
|
+
* Every public routed file names one of these, so which host reads it is read
|
|
29
|
+
* off the filename rather than inferred. A file that names none is a notice.
|
|
30
|
+
*/
|
|
31
|
+
export declare const BACKEND_PLATFORMS: readonly string[];
|
|
32
|
+
export declare const FRONTEND_PLATFORMS: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* The React Native frontend, for the iOS and Android app alike.
|
|
35
|
+
*
|
|
36
|
+
* Only a file naming it reaches the native host. An unsuffixed frontend file is
|
|
37
|
+
* never a fallback here, because the web half is free to use the DOM.
|
|
38
|
+
*/
|
|
39
|
+
export declare const NATIVE_PLATFORM = "native";
|
|
40
|
+
/**
|
|
41
|
+
* Surfaces that produce contributions on the backend side.
|
|
42
|
+
*
|
|
43
|
+
* `mode` is absent on purpose: it is a gate folder, so it is consumed before
|
|
44
|
+
* the surface check and its declaration file synthesises the surface instead.
|
|
45
|
+
*/
|
|
46
|
+
export declare const BACKEND_SURFACES: readonly string[];
|
|
47
|
+
/**
|
|
48
|
+
* Surfaces that produce contributions on the frontend side.
|
|
49
|
+
*/
|
|
50
|
+
export declare const FRONTEND_SURFACES: readonly string[];
|
|
51
|
+
/** Surfaces whose filename carries a relationship target. */
|
|
52
|
+
export declare const TARGETED_SURFACES: readonly string[];
|
|
53
|
+
/** Surfaces whose folders below the surface spell a route path. */
|
|
54
|
+
export declare const ROUTED_SURFACES: readonly string[];
|
|
55
|
+
//#endregion
|
|
56
|
+
//# sourceMappingURL=layout.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAkDA;qBACA;;;;;;;qBAQA;;;;;;;qBAWA;;;;qBAgBA;;qBAuBA;;qBAGA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u={server:`server`,web:`web`,native:`native`,mcp:`mcp`},d=`client`,f=`src/types/apiRoutes.ts`,p=[`pi`,`server`,`web`,`native`,`mcp`,`client`],m=[`server`,`mcp`],h=[`web`,`native`,`ios`,`android`,`desktop`],g=`native`,_=[`server`,`web`,`native`,`mcp`],v=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],y=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],b=[`fill`,`action`],x=[`api`],S=[`ts`,`tsx`,`mts`,`cts`],C=[`test`,`spec`,`stories`];export{f as API_ROUTES_MODULE,n as BACKEND_GROUP,m as BACKEND_PLATFORMS,v as BACKEND_SURFACES,_ as BUILD_TARGET_PLATFORMS,e as DEFAULT_ROUTING_ROOT,C as EXCLUDED_INFIXES,r as FRONTEND_GROUP,h as FRONTEND_PLATFORMS,y as FRONTEND_SURFACES,o as GATE_SEGMENTS,d as GENERATED_CLIENT_NAME,l as GENERATED_DIR,u as GENERATED_ENTRY_FILENAMES,p as GENERATED_ENTRY_NAMES,g as NATIVE_PLATFORM,c as ROOT_FILE_NAME,x as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,a as SESSION_SEGMENT,S as SOURCE_EXTENSIONS,b as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
|
|
2
|
+
//# sourceMappingURL=layout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = ['pi', 'server', 'web', 'native', 'mcp', 'client'];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/** Filename infixes excluded everywhere, whatever their position. */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,YAQhBC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAUzFC,EAAwB,SASxBC,EAAoB,yBAYpBC,EAA2C,CAAC,KAAM,SAAU,MAAO,SAAU,MAAO,QAAQ,EAW5FC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAQrFC,EAAkB,SAGlBC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAGjEC,EAAsC,CAAC,OAAQ,OAAQ,SAAS"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants/layout.cjs"),t=require("./services/segments/index.cjs"),n=require("./services/browserFile/index.cjs"),r=require("./services/filename/index.cjs"),i=require("./services/scan/index.cjs"),a=require("./services/resolveTarget/index.cjs"),o=require("./services/renderEntry/index.cjs"),s=require("./services/writeGenerated/index.cjs"),c=require("./services/generate/index.cjs"),l=require("./services/syncManifest/index.cjs");exports.BACKEND_PLATFORMS=e.BACKEND_PLATFORMS,exports.BACKEND_SURFACES=e.BACKEND_SURFACES,exports.DEFAULT_ROUTING_ROOT=e.DEFAULT_ROUTING_ROOT,exports.FRONTEND_PLATFORMS=e.FRONTEND_PLATFORMS,exports.FRONTEND_SURFACES=e.FRONTEND_SURFACES,exports.GATE_SEGMENTS=e.GATE_SEGMENTS,exports.GENERATED_DIR=e.GENERATED_DIR,exports.NATIVE_PLATFORM=e.NATIVE_PLATFORM,exports.ROUTED_SURFACES=e.ROUTED_SURFACES,exports.ROUTE_FILE_NAME=e.ROUTE_FILE_NAME,exports.ROUTING_ROOT_ALIAS=e.ROUTING_ROOT_ALIAS,exports.StaleGeneratedError=s.StaleGeneratedError,exports.TARGETED_SURFACES=e.TARGETED_SURFACES,exports.classifySegment=t.classifySegment,exports.defaultPluginId=c.defaultPluginId,exports.generateExtension=c.generateExtension,exports.isNativeFile=n.isNativeFile,exports.parseFilename=r.parseFilename,exports.renderNativeEntry=o.renderNativeEntry,exports.renderServerEntry=o.renderServerEntry,exports.renderWebEntry=o.renderWebEntry,exports.resolveRoutingRoot=i.resolveRoutingRoot,exports.resolveTarget=a.resolveTarget,exports.scanExtensions=i.scanExtensions,exports.syncManifest=l.syncManifest,exports.writeGenerated=s.writeGenerated,exports.writeManifest=l.writeManifest;
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isNativeFile } from "./services/browserFile/index.mjs";
|
|
2
|
+
import { ExtensionEntry, ExtensionGate, ExtensionGraph, ExtensionNotice, ExtensionScope, ExtensionSide, RouteParam, RouteSegment } from "./types/extensionGraph.mjs";
|
|
3
|
+
import { Segment, classifySegment } from "./services/segments/index.mjs";
|
|
4
|
+
import { ParsedFilename, parseFilename } from "./services/filename/index.mjs";
|
|
5
|
+
import { ScanOptions } from "./services/scan/type.mjs";
|
|
6
|
+
import { resolveRoutingRoot, scanExtensions } from "./services/scan/index.mjs";
|
|
7
|
+
import { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from "./services/resolveTarget/type.mjs";
|
|
8
|
+
import { resolveTarget } from "./services/resolveTarget/index.mjs";
|
|
9
|
+
import { BACKEND_PLATFORMS, BACKEND_SURFACES, DEFAULT_ROUTING_ROOT, FRONTEND_PLATFORMS, FRONTEND_SURFACES, GATE_SEGMENTS, GENERATED_DIR, NATIVE_PLATFORM, ROUTED_SURFACES, ROUTE_FILE_NAME, ROUTING_ROOT_ALIAS, TARGETED_SURFACES } from "./constants/layout.mjs";
|
|
10
|
+
import { GenerateOptions, GenerateResult } from "./services/generate/type.mjs";
|
|
11
|
+
import { defaultPluginId, generateExtension } from "./services/generate/index.mjs";
|
|
12
|
+
import { RenderOptions } from "./services/renderEntry/type.mjs";
|
|
13
|
+
import { renderNativeEntry, renderServerEntry, renderWebEntry } from "./services/renderEntry/index.mjs";
|
|
14
|
+
import { StaleGeneratedError, WriteResult, writeGenerated } from "./services/writeGenerated/index.mjs";
|
|
15
|
+
import { ManifestSync } from "./services/syncManifest/type.mjs";
|
|
16
|
+
import { syncManifest, writeManifest } from "./services/syncManifest/index.mjs";
|
|
17
|
+
export { BACKEND_PLATFORMS, BACKEND_SURFACES, type BuildTarget, DEFAULT_ROUTING_ROOT, type ExtensionEntry, type ExtensionGate, type ExtensionGraph, type ExtensionNotice, type ExtensionScope, type ExtensionSide, FRONTEND_PLATFORMS, FRONTEND_SURFACES, type FrontendTarget, GATE_SEGMENTS, GENERATED_DIR, type GenerateOptions, type GenerateResult, type ManifestSync, NATIVE_PLATFORM, type ParsedFilename, ROUTED_SURFACES, ROUTE_FILE_NAME, ROUTING_ROOT_ALIAS, type RenderOptions, type ResolvedContribution, type RouteParam, type RouteSegment, type ScanOptions, type Segment, StaleGeneratedError, TARGETED_SURFACES, type TargetResolution, type WriteResult, classifySegment, defaultPluginId, generateExtension, isNativeFile, parseFilename, renderNativeEntry, renderServerEntry, renderWebEntry, resolveRoutingRoot, resolveTarget, scanExtensions, syncManifest, writeGenerated, writeManifest };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BACKEND_PLATFORMS as e,BACKEND_SURFACES as t,DEFAULT_ROUTING_ROOT as n,FRONTEND_PLATFORMS as r,FRONTEND_SURFACES as i,GATE_SEGMENTS as a,GENERATED_DIR as o,NATIVE_PLATFORM as s,ROUTED_SURFACES as c,ROUTE_FILE_NAME as l,ROUTING_ROOT_ALIAS as u,TARGETED_SURFACES as d}from"./constants/layout.mjs";import{classifySegment as f}from"./services/segments/index.mjs";import{isNativeFile as p}from"./services/browserFile/index.mjs";import{parseFilename as m}from"./services/filename/index.mjs";import{resolveRoutingRoot as h,scanExtensions as g}from"./services/scan/index.mjs";import{resolveTarget as _}from"./services/resolveTarget/index.mjs";import{renderNativeEntry as v,renderServerEntry as y,renderWebEntry as b}from"./services/renderEntry/index.mjs";import{StaleGeneratedError as x,writeGenerated as S}from"./services/writeGenerated/index.mjs";import{defaultPluginId as C,generateExtension as w}from"./services/generate/index.mjs";import{syncManifest as T,writeManifest as E}from"./services/syncManifest/index.mjs";export{e as BACKEND_PLATFORMS,t as BACKEND_SURFACES,n as DEFAULT_ROUTING_ROOT,r as FRONTEND_PLATFORMS,i as FRONTEND_SURFACES,a as GATE_SEGMENTS,o as GENERATED_DIR,s as NATIVE_PLATFORM,c as ROUTED_SURFACES,l as ROUTE_FILE_NAME,u as ROUTING_ROOT_ALIAS,x as StaleGeneratedError,d as TARGETED_SURFACES,f as classifySegment,C as defaultPluginId,w as generateExtension,p as isNativeFile,m as parseFilename,v as renderNativeEntry,y as renderServerEntry,b as renderWebEntry,h as resolveRoutingRoot,_ as resolveTarget,g as scanExtensions,T as syncManifest,S as writeGenerated,E as writeManifest};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../constants/layout.cjs"),t=require("../segments/index.cjs");function n(t){for(let n of[e.DEFAULT_ROUTING_ROOT,e.ROUTING_ROOT_ALIAS])if(t.startsWith(`${n}/`))return t.slice(n.length+1).split(`/`)}function r(r){let i=n(r);if(i===void 0||i.length<2)return!1;for(let n of i.slice(0,-1)){let r=t.classifySegment(n);if(r.kind===`group`&&(r.name===`backend`||r.name===`frontend`))return r.name===e.FRONTEND_GROUP}return!1}function i(t){return t.slice(t.lastIndexOf(`/`)+1).split(`.`).slice(1,-1).includes(e.NATIVE_PLATFORM)}function a(e){return r(e)&&i(e)}function o(e){return r(e)&&!i(e)}exports.isBrowserFile=o,exports.isNativeFile=a;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","classifySegment","FRONTEND_GROUP","NATIVE_PLATFORM","require_layout","require_index","routedSegments","root","relativePath","isFrontendPath","segments","folder","segment","namesNative","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"iFAUA,SAASO,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACR,EAAAA,qBAAsBC,EAAAA,kBAAkB,EAC1D,GAAIQ,EAAa,WAAW,GAAGD,EAAK,EAAE,EAAG,OAAOC,EAAa,MAAMD,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASE,EAAe,EAA+B,CACrD,IAAMC,EAAWJ,EAAeE,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUX,EAAAA,gBAAgBU,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASV,EAAAA,cACjG,CACA,MAAO,EACT,CAGA,SAASW,EAAY,EAA+B,CAIlD,OAHiBL,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASL,EAAAA,eAAe,CAClE,CAUA,SAAgBW,EAAa,EAA+B,CAC1D,OAAOL,EAAeD,CAAY,GAAKK,EAAYL,CAAY,CACjE,CAWA,SAAgBO,EAAc,EAA+B,CAC3D,OAAON,EAAeD,CAAY,GAAK,CAACK,EAAYL,CAAY,CAClE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/services/browserFile/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether a package-relative path holds code the native app bundles.
|
|
4
|
+
*
|
|
5
|
+
* A `(frontend)` file that names `.native`, including the private helpers and
|
|
6
|
+
* stories colocated beside a surface. It imports React Native, never the DOM.
|
|
7
|
+
*
|
|
8
|
+
* Path in, answer out: nothing here reads the file or the filesystem.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isNativeFile(relativePath: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a package-relative path holds code the cockpit bundles.
|
|
13
|
+
*
|
|
14
|
+
* Po has no terminal host, so the `(frontend)` side is browser-bound,
|
|
15
|
+
* including the private folders colocated beside a surface. The one
|
|
16
|
+
* exception is a `.native` file, which only the native app reads.
|
|
17
|
+
*
|
|
18
|
+
* Path in, answer out: nothing here reads the file or the filesystem.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isBrowserFile(relativePath: string): boolean;
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/browserFile/index.ts"],"mappings":";;;;;;;;;wBA+CgB,aAAa;;;;;;;;;;wBAab,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{DEFAULT_ROUTING_ROOT as e,FRONTEND_GROUP as t,NATIVE_PLATFORM as n,ROUTING_ROOT_ALIAS as r}from"../../constants/layout.mjs";import{classifySegment as i}from"../segments/index.mjs";function a(t){for(let n of[e,r])if(t.startsWith(`${n}/`))return t.slice(n.length+1).split(`/`)}function o(e){let n=a(e);if(n===void 0||n.length<2)return!1;for(let e of n.slice(0,-1)){let n=i(e);if(n.kind===`group`&&(n.name===`backend`||n.name===`frontend`))return n.name===t}return!1}function s(e){return e.slice(e.lastIndexOf(`/`)+1).split(`.`).slice(1,-1).includes(n)}function c(e){return o(e)&&s(e)}function l(e){return o(e)&&!s(e)}export{l as isBrowserFile,c as isNativeFile};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["routedSegments","root","DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","relativePath","isFrontendPath","segments","folder","segment","classifySegment","FRONTEND_GROUP","namesNative","NATIVE_PLATFORM","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"2LAUA,SAASA,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACC,EAAsBC,CAAkB,EAC1D,GAAIC,EAAa,WAAW,GAAGH,EAAK,EAAE,EAAG,OAAOG,EAAa,MAAMH,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASI,EAAe,EAA+B,CACrD,IAAMC,EAAWN,EAAeI,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUC,EAAgBF,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASE,CACjG,CACA,MAAO,EACT,CAGA,SAASC,EAAY,EAA+B,CAIlD,OAHiBP,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASQ,CAAe,CAClE,CAUA,SAAgBC,EAAa,EAA+B,CAC1D,OAAOR,EAAeD,CAAY,GAAKO,EAAYP,CAAY,CACjE,CAWA,SAAgBU,EAAc,EAA+B,CAC3D,OAAOT,EAAeD,CAAY,GAAK,CAACO,EAAYP,CAAY,CAClE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../constants/layout.cjs");function t(t,n){let r=t.lastIndexOf(`.`);if(r<=0)return;let i=t.slice(r+1);if(!e.SOURCE_EXTENSIONS.includes(i))return;let a=t.slice(0,r).split(`.`),[o,...s]=a;if(o===void 0||o===``||a.some(t=>e.EXCLUDED_INFIXES.includes(t)))return;let c=s[s.length-1],l=c!==void 0&&n.includes(c)?s.pop():void 0;return{name:o,target:s.length>0?s.join(`.`):void 0,platform:l,extension:i}}exports.parseFilename=t;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["SOURCE_EXTENSIONS","EXCLUDED_INFIXES","require_layout","parseFilename","lastDot","fileName","extension","parts","name","rest","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"8CA4BA,SAAgBG,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACJ,EAAAA,kBAAkB,SAASM,CAAS,EAAG,OAE5C,IAAMC,EAAQF,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACI,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASN,EAAAA,iBAAiB,SAASS,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOF,EAAKA,EAAK,OAAS,GAC1BG,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIF,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/services/filename/index.d.ts
|
|
2
|
+
/** One filename split into the four things the grammar encodes. */
|
|
3
|
+
export interface ParsedFilename {
|
|
4
|
+
/** The contribution's identity. */
|
|
5
|
+
readonly name: string;
|
|
6
|
+
/** The relationship target, such as the slot a fill names. */
|
|
7
|
+
readonly target: string | undefined;
|
|
8
|
+
/** The platform this file serves, or undefined when the filename names none. */
|
|
9
|
+
readonly platform: string | undefined;
|
|
10
|
+
readonly extension: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parses `{name}[.{target}][.{platform}].{ext}`.
|
|
14
|
+
*
|
|
15
|
+
* Right to left, because the platform set is closed and the target is not: a
|
|
16
|
+
* dotted slot name such as `task.detail` would otherwise be ambiguous. A file
|
|
17
|
+
* whose extension is not a source extension, or that carries an excluded
|
|
18
|
+
* infix, returns undefined rather than an entry the caller has to filter.
|
|
19
|
+
*
|
|
20
|
+
* The one word a target may not be is a platform name for its own side, since
|
|
21
|
+
* the last segment is read as a platform whenever it matches.
|
|
22
|
+
*
|
|
23
|
+
* A filename that names no platform still parses, with `platform: undefined`.
|
|
24
|
+
* Requiring one is the scan's job, since only the scan knows whether the file
|
|
25
|
+
* is public: a private `_lib` helper and an `api/` route sibling name none.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined;
|
|
28
|
+
//#endregion
|
|
29
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/filename/index.ts"],"mappings":";;iBAGiB;;WAEN;;WAEA;;WAEA;WACA;;;;;;;;;;;;;;;;;wBAkBK,cAAc,kBAAkB,+BAA+B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{EXCLUDED_INFIXES as e,SOURCE_EXTENSIONS as t}from"../../constants/layout.mjs";function n(n,r){let i=n.lastIndexOf(`.`);if(i<=0)return;let a=n.slice(i+1);if(!t.includes(a))return;let o=n.slice(0,i).split(`.`),[s,...c]=o;if(s===void 0||s===``||o.some(t=>e.includes(t)))return;let l=c[c.length-1],u=l!==void 0&&r.includes(l)?c.pop():void 0;return{name:s,target:c.length>0?c.join(`.`):void 0,platform:u,extension:a}}export{n as parseFilename};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["parseFilename","lastDot","fileName","extension","SOURCE_EXTENSIONS","parts","name","rest","EXCLUDED_INFIXES","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"qFA4BA,SAAgBA,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACG,EAAkB,SAASD,CAAS,EAAG,OAE5C,IAAME,EAAQH,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACK,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASG,EAAiB,SAASC,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOH,EAAKA,EAAK,OAAS,GAC1BI,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIH,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../constants/layout.cjs"),n=require("../scan/index.cjs"),r=require("../resolveTarget/index.cjs"),i=require("../renderClient/index.cjs"),a=require("../renderEntry/index.cjs"),o=require("../renderMcpWidgets/index.cjs"),s=require("../writeGenerated/index.cjs");let c=require("node:fs");c=e.__toESM(c,1);let l=require("node:path");l=e.__toESM(l,1);function u(e){return e.replace(/^@[^/]+\//u,``).replace(/^po-/u,``)}function d(e){let t=JSON.parse(c.default.readFileSync(l.default.join(e,`package.json`),`utf8`));if(typeof t.name!=`string`)throw Error(`${e}/package.json has no name`);return t.name}const f={server:a.renderServerEntry,web:a.renderWebEntry,native:a.renderNativeEntry,mcp:a.renderMcpEntry},p=t.GENERATED_ENTRY_FILENAMES;function m(e){let a=e.packageName??d(e.packageDir),m=e.pluginId??u(a),h=n.scanExtensions(e),g=[...h.notices],_=/* @__PURE__ */ new Map,v=[],y=e.target===`mcp`?o.renderMcpWidgets(h,a,t.GENERATED_DIR):void 0;y?.source!==void 0&&_.set(`${t.GENERATED_DIR}/mcp-ui.ts`,y.source);for(let e of h.entries)e.platform===void 0||t.BUILD_TARGET_PLATFORMS.includes(e.platform)||g.push({path:e.file,message:`'${e.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`});let b=h.notices.filter(e=>e.message===n.RETIRED_PLATFORM_NOTICE);if(b.length>0)throw Error(`${a}: ${n.RETIRED_PLATFORM_NOTICE}\n${b.map(e=>` ${e.path}`).join(`
|
|
2
|
+
`)}`);let x=e.target===void 0?[`server`,`web`,`native`]:[e.target];for(let e of x){let n=r.resolveTarget(h,e);if(g.push(...n.notices),n.contributions.length===0&&n.escapeHatches.length===0&&n.roots.length===0)continue;v.push(e);let i=f[e],o=i(n,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR,mcpWidgets:y?.declarations});_.set(`${t.GENERATED_DIR}/${p[e]}.ts`,o)}let S=e.target===void 0&&c.default.existsSync(l.default.join(e.packageDir,`src/types/apiRoutes.ts`)),C=v.includes(`web`),w=S&&C?i.renderApiClient(h,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR}):void 0;w!==void 0&&_.set(`${t.GENERATED_DIR}/${t.GENERATED_CLIENT_NAME}.ts`,w),S&&C&&w===void 0&&g.push({path:t.API_ROUTES_MODULE,message:`declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted`});let T=e.target===void 0?t.GENERATED_ENTRY_NAMES.filter(t=>t!==`mcp`||!c.default.existsSync(l.default.join(e.packageDir,`tsdown.mcp.config.ts`))).map(e=>`${t.GENERATED_DIR}/${e}.ts`):[`${t.GENERATED_DIR}/${p[e.target]}.ts`,...e.target===`mcp`?[`${t.GENERATED_DIR}/mcp-ui.ts`]:[]],{changed:E}=s.writeGenerated(e.packageDir,_,e.check,T);return{graph:h,packageName:a,pluginId:m,files:_,changed:E,notices:g,targets:v}}exports.defaultPluginId=u,exports.generateExtension=m;
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fs","path","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","GENERATED_ENTRY_FILENAMES","scanExtensions","renderMcpWidgets","GENERATED_DIR","BUILD_TARGET_PLATFORMS","RETIRED_PLATFORM_NOTICE","resolveTarget","renderApiClient","GENERATED_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","writeGenerated","require_runtime","require_layout","require_index","require_index$1","require_index$2","require_index$3","require_index$4","require_index$5","node_fs","node_path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","ENTRY_FILENAME","generateExtension","options","pluginId","graph","notices","files","targets","mcpWidgets","entry","retired","notice","requestedTargets","target","resolution","render","source","hasRouteTable","hasBrowserHalf","client","managed","name"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n if (hasRouteTable && hasBrowserHalf && client === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GenerateOptions, GenerateResult } from "./type.mjs";
|
|
2
|
+
//#region src/services/generate/index.d.ts
|
|
3
|
+
/** `@agimon-ai/po-plan` becomes `plan`. */
|
|
4
|
+
export declare function defaultPluginId(packageName: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Scans a package and renders every entry its tree calls for.
|
|
7
|
+
*
|
|
8
|
+
* A target with nothing in it produces no file, so a backend-only package
|
|
9
|
+
* never grows an empty cockpit entry. Notices from the scan and from each
|
|
10
|
+
* resolution are gathered rather than thrown: an unrecognised folder costs
|
|
11
|
+
* that folder, never the build.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateExtension(options: GenerateOptions): GenerateResult;
|
|
14
|
+
//#endregion
|
|
15
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/generate/index.ts"],"mappings":";;;wBAsBgB,gBAAgB;;;;;;;;;wBA2BhB,kBAAkB,SAAS,kBAAkB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{API_ROUTES_MODULE as e,BUILD_TARGET_PLATFORMS as t,GENERATED_CLIENT_NAME as n,GENERATED_DIR as r,GENERATED_ENTRY_FILENAMES as i,GENERATED_ENTRY_NAMES as a}from"../../constants/layout.mjs";import{RETIRED_PLATFORM_NOTICE as o,scanExtensions as s}from"../scan/index.mjs";import{resolveTarget as c}from"../resolveTarget/index.mjs";import{renderApiClient as l}from"../renderClient/index.mjs";import{renderMcpEntry as u,renderNativeEntry as d,renderServerEntry as f,renderWebEntry as p}from"../renderEntry/index.mjs";import{renderMcpWidgets as m}from"../renderMcpWidgets/index.mjs";import{writeGenerated as h}from"../writeGenerated/index.mjs";import g from"node:fs";import _ from"node:path";function v(e){return e.replace(/^@[^/]+\//u,``).replace(/^po-/u,``)}function y(e){let t=JSON.parse(g.readFileSync(_.join(e,`package.json`),`utf8`));if(typeof t.name!=`string`)throw Error(`${e}/package.json has no name`);return t.name}const b={server:f,web:p,native:d,mcp:u},x=i;function S(i){let u=i.packageName??y(i.packageDir),d=i.pluginId??v(u),f=s(i),p=[...f.notices],S=/* @__PURE__ */ new Map,C=[],w=i.target===`mcp`?m(f,u,r):void 0;w?.source!==void 0&&S.set(`${r}/mcp-ui.ts`,w.source);for(let e of f.entries)e.platform===void 0||t.includes(e.platform)||p.push({path:e.file,message:`'${e.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`});let T=f.notices.filter(e=>e.message===o);if(T.length>0)throw Error(`${u}: ${o}\n${T.map(e=>` ${e.path}`).join(`
|
|
2
|
+
`)}`);let E=i.target===void 0?[`server`,`web`,`native`]:[i.target];for(let e of E){let t=c(f,e);if(p.push(...t.notices),t.contributions.length===0&&t.escapeHatches.length===0&&t.roots.length===0)continue;C.push(e);let n=b[e],i=n(t,{packageName:u,pluginId:d,root:f.root,entryDir:r,mcpWidgets:w?.declarations});S.set(`${r}/${x[e]}.ts`,i)}let D=i.target===void 0&&g.existsSync(_.join(i.packageDir,`src/types/apiRoutes.ts`)),O=C.includes(`web`),k=D&&O?l(f,{packageName:u,pluginId:d,root:f.root,entryDir:r}):void 0;k!==void 0&&S.set(`${r}/${n}.ts`,k),D&&O&&k===void 0&&p.push({path:e,message:`declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted`});let A=i.target===void 0?a.filter(e=>e!==`mcp`||!g.existsSync(_.join(i.packageDir,`tsdown.mcp.config.ts`))).map(e=>`${r}/${e}.ts`):[`${r}/${x[i.target]}.ts`,...i.target===`mcp`?[`${r}/mcp-ui.ts`]:[]],{changed:j}=h(i.packageDir,S,i.check,A);return{graph:f,packageName:u,pluginId:d,files:S,changed:j,notices:p,targets:C}}export{v as defaultPluginId,S as generateExtension};
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs","path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","ENTRY_FILENAME","GENERATED_ENTRY_FILENAMES","generateExtension","options","pluginId","graph","scanExtensions","notices","files","targets","mcpWidgets","renderMcpWidgets","GENERATED_DIR","entry","BUILD_TARGET_PLATFORMS","retired","notice","RETIRED_PLATFORM_NOTICE","requestedTargets","target","resolution","resolveTarget","render","source","hasRouteTable","hasBrowserHalf","client","renderApiClient","GENERATED_CLIENT_NAME","API_ROUTES_MODULE","managed","GENERATED_ENTRY_NAMES","name","writeGenerated"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n if (hasRouteTable && hasBrowserHalf && client === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ExtensionGraph, ExtensionNotice } from "../../types/extensionGraph.mjs";
|
|
2
|
+
import { ScanOptions } from "../scan/type.mjs";
|
|
3
|
+
import { BuildTarget } from "../resolveTarget/type.mjs";
|
|
4
|
+
//#region src/services/generate/type.d.ts
|
|
5
|
+
export interface GenerateOptions extends ScanOptions {
|
|
6
|
+
/** Generate only one isolated host target. Omitted preserves the normal build. */
|
|
7
|
+
readonly target?: BuildTarget;
|
|
8
|
+
/** Defaults to the name in the package's own package.json. */
|
|
9
|
+
readonly packageName?: string;
|
|
10
|
+
/** Defaults to the package name without its scope and `po-` prefix. */
|
|
11
|
+
readonly pluginId?: string;
|
|
12
|
+
/** Throw on stale output instead of writing it. */
|
|
13
|
+
readonly check?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface GenerateResult {
|
|
16
|
+
readonly graph: ExtensionGraph;
|
|
17
|
+
readonly packageName: string;
|
|
18
|
+
readonly pluginId: string;
|
|
19
|
+
/** Package-relative path to rendered source, for every entry the tree calls for. */
|
|
20
|
+
readonly files: ReadonlyMap<string, string>;
|
|
21
|
+
/** Package-relative paths whose contents changed. */
|
|
22
|
+
readonly changed: readonly string[];
|
|
23
|
+
readonly notices: readonly ExtensionNotice[];
|
|
24
|
+
/** The hosts this package contributes to. */
|
|
25
|
+
readonly targets: readonly BuildTarget[];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.mts","names":[],"sources":["../../../src/services/generate/type.ts"],"mappings":";;;;iBAIiB,wBAAwB;;WAE9B,SAAS;;WAET;;WAEA;;WAEA;;iBAGM;WACN,OAAO;WACP;WACA;;WAEA,OAAO;;WAEP;WACA,kBAAkB;;WAElB,kBAAkB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e.replace(/([a-z0-9])([A-Z])/gu,`$1-$2`).toLowerCase().replaceAll(`-`,`_`)}function t(e){return e.replace(/([a-z0-9])([A-Z])/gu,`$1-$2`).toLowerCase()}function n(e){return Object.entries(e).map(([e,t])=>Array.isArray(t)?`${e}: [${t.map(e=>`'${e}'`).join(`, `)}]`:`${e}: '${t}'`).join(`, `)}exports.renderIdentity=n,exports.toKebab=t,exports.toSnake=e;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["toSnake","name","toKebab","renderIdentity","identity","key","value","item"],"sources":["../../../src/services/identity/index.ts"],"sourcesContent":["/**\n * What a path knows about a contribution's identity.\n *\n * The generator supplies these and the authored file is spread over the top,\n * so a file that states its own name or id always wins. That is what lets the\n * filename be the identity without taking the choice away.\n */\n\n/** `write-plan` and `writePlan` both become `write_plan`. */\nexport function toSnake(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/gu, '$1-$2')\n .toLowerCase()\n .replaceAll('-', '_');\n}\n\n/** `PlanPanel` becomes `plan-panel`; an already-kebab name is unchanged. */\nexport function toKebab(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/gu, '$1-$2').toLowerCase();\n}\n\n/** One derived field and the literal it holds. */\nexport type Identity = Readonly<Record<string, string | readonly string[]>>;\n\n/** Renders an identity as object-literal members, ready to precede a spread. */\nexport function renderIdentity(identity: Identity): string {\n return Object.entries(identity)\n .map(([key, value]) =>\n Array.isArray(value)\n ? `${key}: [${value.map((item) => `'${item}'`).join(', ')}]`\n : `${key}: '${value as string}'`,\n )\n .join(', ');\n}\n"],"mappings":"AASA,SAAgBA,EAAQ,EAAsB,CAC5C,OAAOC,EACJ,QAAQ,sBAAuB,OAAO,CAAC,CACvC,YAAY,CAAC,CACb,WAAW,IAAK,GAAG,CACxB,CAGA,SAAgBC,EAAQ,EAAsB,CAC5C,OAAOD,EAAK,QAAQ,sBAAuB,OAAO,CAAC,CAAC,YAAY,CAClE,CAMA,SAAgBE,EAAe,EAA4B,CACzD,OAAO,OAAO,QAAQC,CAAQ,CAAC,CAC5B,KAAK,CAACC,EAAKC,KACV,MAAM,QAAQA,CAAK,EACf,GAAGD,EAAI,KAAKC,EAAM,IAAK,GAAS,IAAIC,EAAK,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,GACxD,GAAGF,EAAI,KAAKC,EAAgB,EAClC,CAAC,CACA,KAAK,IAAI,CACd"}
|