@sixbell-telco/sdk-tools 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +277 -2
- package/data/security-floors.json +47 -0
- package/package.json +40 -4
- package/recipes/README.md +53 -0
- package/recipes/crud-list.md +21 -0
- package/recipes/custom-component.md +35 -0
- package/recipes/detail-page.md +19 -0
- package/recipes/form-dialog.md +17 -0
- package/recipes/parts/crud-list/i18n.json +83 -0
- package/recipes/parts/crud-list/src/app/features/__name__/__name__.routes.ts.tpl +30 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.html.tpl +102 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.spec.ts.tpl +101 -0
- package/recipes/parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.ts.tpl +143 -0
- package/recipes/parts/detail-page/i18n.json +32 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.html.tpl +35 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.spec.ts.tpl +58 -0
- package/recipes/parts/detail-page/src/app/features/__name__/pages/__name__-detail/__name__-detail.component.ts.tpl +68 -0
- package/recipes/parts/entity/i18n.json +5 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.model.ts.tpl +9 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.service.spec.ts.tpl +29 -0
- package/recipes/parts/entity/src/app/features/__name__/__name__.service.ts.tpl +33 -0
- package/recipes/parts/form-dialog/i18n.json +35 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.html.tpl +33 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.spec.ts.tpl +69 -0
- package/recipes/parts/form-dialog/src/app/features/__name__/components/__name__-form-dialog/__name__-form-dialog.component.ts.tpl +73 -0
- package/src/add/add.mjs +251 -0
- package/src/check/config.mjs +112 -0
- package/src/check/exceptions.mjs +103 -0
- package/src/check/federation.mjs +224 -0
- package/src/check/finding.mjs +23 -0
- package/src/check/harness.mjs +146 -0
- package/src/check/i18n.mjs +218 -0
- package/src/check/integration.mjs +566 -0
- package/src/check/security.mjs +165 -0
- package/src/check/steps.mjs +37 -0
- package/src/check/styles.mjs +347 -0
- package/src/check/wiring.mjs +198 -0
- package/src/check.mjs +333 -0
- package/src/cli.mjs +551 -0
- package/src/docs/docs.mjs +154 -0
- package/src/doctor/doctor.mjs +492 -0
- package/src/format.mjs +102 -0
- package/src/info/info.mjs +149 -0
- package/src/init/init.mjs +490 -0
- package/src/init/merge.mjs +191 -0
- package/src/init/template.mjs +292 -0
- package/src/mcp/catalog.mjs +248 -0
- package/src/mcp/glossary.mjs +75 -0
- package/src/mcp/manifest.mjs +53 -0
- package/src/mcp/recipes.mjs +198 -0
- package/src/mcp/server.mjs +249 -0
- package/src/mcp/upgrade-guide.mjs +116 -0
- package/src/mcp/usage.mjs +48 -0
- package/src/project/project.mjs +220 -0
- package/src/types.d.ts +448 -0
- package/src/upgrade/lockstep.mjs +153 -0
- package/src/upgrade/upgrade.mjs +623 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# sdk-tools Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@sixbell-telco/sdk-tools` are documented in this file. Changes to the SDK itself are in the [SDK changelog](https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit/blob/develop/projects/sdk/CHANGELOG.md), and the lint rules in the [eslint-plugin-sdk changelog](https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit/blob/develop/projects/eslint-plugin-sdk/CHANGELOG.md).
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.1] - 2026-11-13
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `npx @sixbell-telco/sdk-tools` works outside an app (`init` in an empty folder, any command run before the tools are installed): the `@sixbell-telco/sdk` peer is optional, so npx no longer installs an SDK whose Angular peers failed to resolve (ERESOLVE). The tools read the SDK installed in the app, as before
|
|
15
|
+
|
|
16
|
+
## [0.1.0] - 2026-11-13
|
|
17
|
+
|
|
18
|
+
First release. Needs Node 22.12+ or 24, Angular 19 and `@sixbell-telco/sdk` 4.6.0 or later; depends on the exact `@sixbell-telco/eslint-plugin-sdk` version it was tested with.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **check**: `sdk-tools check [--json] [--fix]` runs the `@sixbell-telco/eslint-plugin-sdk` rules and the Angular strict template type check over an app as one findings list; `eslint-disable` comments cannot silence a kit finding
|
|
23
|
+
- **check**: design rules from `shadcn-lint-angular` 0.1.2, pinned (raw colors, arbitrary values, inline styles, restyling `st-*` components, unknown classes), compiled against the app's own Tailwind entry, plus Angular `prefer-control-flow`
|
|
24
|
+
- **check**: human output grouped by file, colors only in a terminal (`NO_COLOR`, pipes and CI stay plain) and a summary with the most frequent rules, the fixable count and the time taken; `--quiet`, `--max-warnings <n>`, `--version` and `<command> --help` with "did you mean" hints. With `--json`, every result is one envelope on stdout
|
|
25
|
+
- **check**: project steps on the whole app, with the mfe-tools ids: federation, harness, wiring, config, i18n, CSS and theme catalogs (`.scss` is a finding), and security floors shipped as data; exceptions in `sdk-tools.exceptions.json` (`excepted`, expiring with `until`)
|
|
26
|
+
- **check**: `check --integration --root <dir>` checks the wiring between a host, its children and their integration and database repos (MFE_INT_001..010, MFE_INT_ASSET_001..004); every `--json` finding has an `id`
|
|
27
|
+
- **mcp**: `sdk-tools mcp` starts a stdio MCP server (`SixbellSdk`) that answers from the installed SDK manifest and the `check` engine: `list_components`, `search_components`, `get_component`, `get_tokens`, `check_usage`, `get_recipe` and `get_upgrade_guide(from, to)`; `DESIGN.md` and the recipes are resources
|
|
28
|
+
- **mcp**: `get_glossary(term?)` and the `glossary` resource serve the installed SDK's `GLOSSARY.md`; a rejected word returns the term to use, and an SDK without the file gets a one-line message
|
|
29
|
+
- **init**: `sdk-tools init [--host|--child] [--dry-run]` creates an MFE from its template repo or brings an existing one up to it, keeping product code, themes and i18n keys
|
|
30
|
+
- **upgrade**: `sdk-tools upgrade [--to <v>] [--dry-run]` checks the app first (clean git tree, Angular stays on 19.2, peer floors, the target exists; exit 3 with the unblock step), applies the SDK's `ng update` migrations, runs `check` and reports what was applied, what is manual and what still fails
|
|
31
|
+
- **upgrade**: federation lockstep: in a host, a remote whose local checkout is on another SDK than the target blocks (exit 3) and a remote with no local checkout is a warning; in a child it names the hosts to move with it (`--root`, `SDK_TOOLS_FLEET_ROOT`)
|
|
32
|
+
- **upgrade**: every message says what to edit and run: peer floors name the `package.json` edit (direct dependency or override), one layout-config item shows a block that keeps the app's `defaultLayout`, template copies name the repo, paths and `sdk-tools init --dry-run`; a gitignored `mfe-foundation.config.json` is a warning, and peers npm installs with the SDK are not reported missing. The 4.0.0 migration keeps the app's `themes.json` formatting and `meta`, and indents inserted code like its block
|
|
33
|
+
- **add**: `sdk-tools add <recipe> [name]` writes the `crud-list`, `form-dialog` and `detail-page` composition recipes as local `app-*` code with i18n keys in en, es and pt; never overwrites a file without `--force`
|
|
34
|
+
- **info**, **doctor**, **docs**: `sdk-tools info --json` gives skills the project context (kit version and entry points, theme, layout, MFE role, federation); `doctor` reports Node/npm against engines and drift from the role template with the mfe-tools ids and a fix each; `docs <selector|recipe>` prints a component's API or a recipe from the installed manifest
|
|
35
|
+
- **upgrade**: formats the files the migrations changed with the app's own Prettier (skipped, and reported, when the app has none); an install that only prints `npm warn ERESOLVE` peer warnings no longer counts as failed
|
|
36
|
+
- **init**: finds the template checkout from apps up to six folders deep (nearest folder first); the error names `--template-root` and `SDK_TOOLS_TEMPLATE_ROOT`
|
|
37
|
+
- **add**: `add crud-list` writes the feature's `<name>.routes.ts` (list and detail page, `configurationGuard`, route title and subtitle i18n keys), and its navigation keeps the menu param
|
|
38
|
+
- **check**: component styles (inline `styles` and `styleUrl(s)` files) report literal colors (`DS_COMPONENT_COLOR_LITERAL`) and `.st-*`/`st-*` selectors (`DS_KIT_RESTYLE`, naming the kit inputs to use); `.scss` rules are checked like CSS
|
package/README.md
CHANGED
|
@@ -1,3 +1,278 @@
|
|
|
1
|
-
# @sixbell-telco/sdk-tools
|
|
1
|
+
# @sixbell-telco/sdk-tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The CLI for apps built with `@sixbell-telco/sdk`. It gives an agent, or a person, a deterministic answer to "did I use the kit correctly?".
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @sixbell-telco/sdk-tools check # lint and type-check src/
|
|
7
|
+
npx @sixbell-telco/sdk-tools check src/app/orders # only some paths
|
|
8
|
+
npx @sixbell-telco/sdk-tools check --json # one JSON envelope, for agents and scripts
|
|
9
|
+
npx @sixbell-telco/sdk-tools check --fix # apply the safe fixes (deprecated tokens)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## check
|
|
13
|
+
|
|
14
|
+
`check` reports one sorted list of findings: `file:line:column severity rule message`.
|
|
15
|
+
|
|
16
|
+
- **Lint, kit API:** the [`@sixbell-telco/eslint-plugin-sdk`](../eslint-plugin-sdk/README.md) rules over `.html` templates, inline templates (through angular-eslint's processor) and `.ts` imports.
|
|
17
|
+
- **Lint, design:** the rules of [shadcn-lint-angular](https://github.com/ChernyshovA/shadcn-lint-angular) (an Angular port of `@shadcn/lint`, pinned), compiled against the app's own Tailwind entry. The entry is the first CSS file in `angular.json` build styles, or `src/styles.css`. Only the kit theme's tokens count:
|
|
18
|
+
- `no-raw-colors`: `bg-red-500`, hex or rgb values;
|
|
19
|
+
- `no-arbitrary-values`: `p-[13px]`, with the scale step to use;
|
|
20
|
+
- `no-inline-styles`: `style=` and `[ngStyle]`;
|
|
21
|
+
- `no-restyle`: color, typography or surface classes on an `st-*` component, where only layout and spacing are allowed;
|
|
22
|
+
- `no-unknown-classes`: a class no stylesheet defines (a warning).
|
|
23
|
+
- **Lint, Angular:** `prefer-control-flow`, which reports `*ngIf` and `*ngFor`.
|
|
24
|
+
- The check uses its own config. Your project's ESLint config is not loaded, and `eslint-disable` comments do not silence kit findings.
|
|
25
|
+
- The rules read the installed SDK's manifest (`@sixbell-telco/sdk/manifest.json`).
|
|
26
|
+
- **Type check:** TypeScript and Angular strict template diagnostics through the Angular compiler API, using `tsconfig.app.json` (or `tsconfig.json`, or `--project`). A TypeScript error does not hide template errors, which `ngc` alone would.
|
|
27
|
+
|
|
28
|
+
Test and story files (`*.spec.ts`, `*.stories.ts`) are not linted: their templates are fixtures, not app UI.
|
|
29
|
+
|
|
30
|
+
**Project steps.** When `check` covers the whole app (`src`, the default, or `.`, however spelled: `./src`, `src/app/..` or an absolute path), it also reads the project once (role, `federation.config.js`, `angular.json`, `package.json`, the lockfile) and runs these steps. Their findings keep the ids the mfe-tools scripts used, as the `rule`, so scripts and exceptions can match them:
|
|
31
|
+
|
|
32
|
+
| Step | What it checks | Ids |
|
|
33
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| federation | Child: exposes point at a remote shell that renders `MfeShadowShellComponent`; the stylesheet-href build step. Host: remotes wired, no child-only files. dayjs sharing | `MFE_CHILD_003`..`007`, `MFE_CHILD_FEDERATION_001`..`004`, `MFE_HOST_RUNTIME_002`..`005`, `MFE_FEDERATION_DAYJS_001`/`002` |
|
|
35
|
+
| harness | The child's standalone harness (`MainLayoutComponent`, no remote shell inside) and the kit shell (`st-app-layout`, `provideLayout`, `provideLayoutAccount`, no local layout copies) | `MFE_CHILD_009`..`011`, `MFE_CHILD_HARNESS_001`/`002`, `MFE_CHILD_ROUTE_001`, `MFE_LAYOUT_001`..`003`, `005`, `006`, `008` |
|
|
36
|
+
| wiring | Pubsub (child AUTH, host PERMISSIONS), request bypass by context in a child, the static dev menu, starter identity left behind | `MFE_CHILD_PUBSUB_001`, `MFE_HOST_PUBSUB_001`, `MFE_CHILD_CONFIG_001`, `MFE_MENU_001`/`002`, `MFE_GUAS_MENU_003`/`004`, `MFE_FEATURE_MENU_001`, `MFE_IDENTITY_001` |
|
|
37
|
+
| config | npm scripts against `angular.json` configurations and files, the test target, the showcase script, JSON that does not parse | `MFE_PROJECT_SCRIPT_001`, `MFE_PROJECT_TEST_001`, `MFE_SHOWCASE_001`, `MFE_JSON_001` |
|
|
38
|
+
| i18n | `translation.json` schema and languages, bundles per language, the SDK bundles served from the installed package (not copied) | `MFE_I18N_001`..`009`, `MFE_CHILD_I18N_001`..`005`, `MFE_CHILD_I18N_WARN_001`, `MFE_TRANSLATIONS_001`, `MFE_ASSET_I18N_001`, `MFE_I18N_SDK_001` |
|
|
39
|
+
| styles | `src/**/*.css` and the theme catalogs: literal colors outside theme definitions (catalogs, `@plugin "daisyui/theme"`, `@theme`), raw shadows and fonts, theme token overrides, legacy names; `.scss`, `.sass` and `.less` files; component styles (inline `styles`, `styleUrl(s)` files): literal colors and `.st-*`/`st-*` selectors (the Tailwind entry and global stylesheets are not component styles); the status-illustration animations in `styles.css` | `DS_COLOR_LITERAL`, `DS_COLOR_PALETTE`, `DS_SHADOW_RAW`, `DS_FONT_FAMILY`, `DS_THEME_TOKEN_OVERRIDE`, `DS_THEME_DUPLICATE`, `DS_MODIFIER_UNSAFE`, `DS_THEME_STALE_IDENTITY`, `DS_SIXBELL_LEGACY`, `DS_POPPINS_LEGACY`, `DS_SCSS_FILE`, `DS_COMPONENT_COLOR_LITERAL`, `DS_KIT_RESTYLE`, `MFE_STATUS_CSS_001` |
|
|
40
|
+
| security | Installed versions (every copy in `package-lock.json`, else `node_modules`) against the floors in `data/security-floors.json`; each finding names the floor and the fix | `MFE_SEC_DEPS_002`..`010` |
|
|
41
|
+
|
|
42
|
+
The role is the `role` of `mfe-foundation.config.json`, else `child` when `federation.config.js` has exposes, else `host` when there is a federation manifest or a `loadRemoteModule` route. An app with no role gets only the config, styles and security steps. mfe-tools' `review` severity is a warning here.
|
|
43
|
+
|
|
44
|
+
**Exceptions.** An approved exception lives in `sdk-tools.exceptions.json` at the app root and goes through PR review:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
"rule": "DS_COLOR_LITERAL",
|
|
50
|
+
"path": "src/app/charts/**/*.css",
|
|
51
|
+
"reason": "chart palette from the customer contract",
|
|
52
|
+
"owner": "web team",
|
|
53
|
+
"until": "2027-03-31"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Every finding in `--json` has an `id`: the mfe-tools id (a project step's `rule`, an eslint-plugin-sdk finding's messageId), or `null` when there is none.
|
|
59
|
+
|
|
60
|
+
`rule` matches a finding's `rule` (an mfe-tools id, or a lint rule name such as `sdk/button-role`) or its `id` (eslint-plugin-sdk findings carry the mfe-tools id, their messageId, as `id`). `path` is a glob over the finding's file (`**`, `*`, `?`). A matched finding moves to `excepted` in `--json`, shows as a count in the human output and does not change the exit code. After `until` the entry excepts nothing and is itself a finding (`exceptions/expired`); a malformed entry is `exceptions/invalid`.
|
|
61
|
+
|
|
62
|
+
Options:
|
|
63
|
+
|
|
64
|
+
| Option | Meaning |
|
|
65
|
+
| ---------------------- | ------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `[paths...]` | Files or folders to lint (default `src` and `setup-jest.ts` or `test-setup.ts` at the root) |
|
|
67
|
+
| `--json` | Print `{ ok, code, data: { findings, counts, excepted }, error? }` |
|
|
68
|
+
| `--quiet` | Show errors only |
|
|
69
|
+
| `--max-warnings <n>` | Fail when there are more than `n` warnings |
|
|
70
|
+
| `--fix` | Apply fixable lint findings |
|
|
71
|
+
| `--no-typecheck` | Lint only |
|
|
72
|
+
| `--project <tsconfig>` | The tsconfig to type-check |
|
|
73
|
+
| `--manifest <file>` | Check against this manifest instead of the installed one |
|
|
74
|
+
| `--integration` | Check the cross-repo wiring under `--root` instead (below) |
|
|
75
|
+
| `--root <dir>` | With `--integration`: the folder holding the repos (default `.`) |
|
|
76
|
+
|
|
77
|
+
Exit codes: 0 no errors (warnings allowed, unless `--max-warnings`), 1 errors or a failure, 2 usage error.
|
|
78
|
+
|
|
79
|
+
### check --integration
|
|
80
|
+
|
|
81
|
+
`sdk-tools check --integration --root <dir>` checks the wiring between repos, opt-in (plain `check` never does). `<dir>` holds the host, its children and their integration and database repos, or is one integration repo. It reads files only: no network, browser or git. Under `<dir>` it finds Angular apps (host or child, as in the project steps), integration repos (a `web/` folder serving `federation`, `translation`, `themes`, `config` or `mfe-*`) and database repos (`database`, `db` or `*-db` folders with SQL). An integration or database repo belongs to the apps under its parent folder (`irp/web/integration` serves `irp/web/frontend/...`). A remote matches its child by federation name, by the folder of its remoteEntry URL, or by the `web/<folder>` the child's integration repo serves.
|
|
82
|
+
|
|
83
|
+
| Id | What it checks |
|
|
84
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
85
|
+
| `MFE_INT_001` | The host federation manifest exists and lists every remote a `loadRemoteModule` call loads |
|
|
86
|
+
| `MFE_INT_002` | `src/app/app.routes.ts` exists; each loaded module is in the child's exposes; a manifest remote nothing mounts (warning) |
|
|
87
|
+
| `MFE_INT_003` | The host proxy config (`proxy-config.json.example`, else `proxy-config.json`) has an entry for each relative remoteEntry |
|
|
88
|
+
| `MFE_INT_004` | A child's `federation.config.js` has a name and exposes |
|
|
89
|
+
| `MFE_INT_005` | A child has `src/assets/configuration/mfe_config.json` |
|
|
90
|
+
| `MFE_INT_006` | The host's integration repo serves `web/federation/federation.manifest.json` with every remote the host loads |
|
|
91
|
+
| `MFE_INT_007` | The host's integration repo serves `web/translation/translation.json` |
|
|
92
|
+
| `MFE_INT_008` | When that translation config loads permission translations, the host has `src/assets/i18n/permissions/<lang>.json` |
|
|
93
|
+
| `MFE_INT_009` | The host's database repo has a permission or menu seed (`access-control/data.sql` or `data.sql`) |
|
|
94
|
+
| `MFE_INT_010` | A child's database repo has data scripts (`access-control/data.sql` or `data.sql`) |
|
|
95
|
+
| `MFE_INT_ASSET_001` | Integration translation paths use `/assets/themes/assets/i18n` |
|
|
96
|
+
| `MFE_INT_ASSET_002` | Every catalog `web/themes/themes.json` lists exists, when the integration serves the catalog folder |
|
|
97
|
+
| `MFE_INT_ASSET_003` | Compose does not mount `web/themes/assets` without the catalog while themes.json references catalogs (warning) |
|
|
98
|
+
| `MFE_INT_ASSET_004` | Banner assets in a served catalog declare `tone { light, dark }` |
|
|
99
|
+
|
|
100
|
+
Findings have the same shape as `check`'s, plus `repo` (the repo's folder relative to `<dir>`); `file` is relative to that repo. Each repo's own `sdk-tools.exceptions.json` applies to its findings. The GUAS evidence check of mfe-tools (`MFE_INT_GUAS_001`) is not ported: it needs manual evidence.
|
|
101
|
+
|
|
102
|
+
**Human output:**
|
|
103
|
+
|
|
104
|
+
- **Findings:** grouped by file, `line:col severity message rule`.
|
|
105
|
+
- **Summary:** totals, the most frequent rules, how many problems `--fix` can fix, and the time taken.
|
|
106
|
+
- **Progress:** while the slow steps run, progress shows on stderr, only in an interactive terminal.
|
|
107
|
+
- **Colors:** on in a terminal, off when piped, with `NO_COLOR`, or in CI logs without color support; `FORCE_COLOR` turns them on.
|
|
108
|
+
|
|
109
|
+
`sdk-tools --help` and `sdk-tools <command> --help` list the commands, options and examples.
|
|
110
|
+
|
|
111
|
+
## mcp
|
|
112
|
+
|
|
113
|
+
`sdk-tools mcp` starts an MCP server over stdio, named `SixbellSdk`. Its tools answer from the `@sixbell-telco/sdk` installed in the folder it starts in (the SDK's `manifest.json`), so an agent gets the facts of the version the app really uses. `check_usage` runs the same lint as `check`.
|
|
114
|
+
|
|
115
|
+
Add it to the app's `.mcp.json`:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{ "mcpServers": { "SixbellSdk": { "command": "npx", "args": ["@sixbell-telco/sdk-tools", "mcp"] } } }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
| Tool | Returns |
|
|
122
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
123
|
+
| `list_components` | Every component, directive and pipe: selector, class, kind, entry point, one-line description (`kind` filters) |
|
|
124
|
+
| `search_components` | The best matches for a need in a few words (`"confirm dialog"`) |
|
|
125
|
+
| `get_component` | One component: inputs with allowed values and defaults, outputs, slots, import line, a starting template, related components, stories, do and don't |
|
|
126
|
+
| `get_tokens` | Theme tokens by group (color, radius, shadow, ease, animate, font, text) and the deprecated ones with their replacements |
|
|
127
|
+
| `check_usage` | `check`'s lint findings (kit API and design rules) for a `file` in the app or a `snippet` (template or component source). No type check |
|
|
128
|
+
| `get_recipe` | A step-by-step recipe; with no `id`, the list: `custom-component` (a local kit candidate) and the `add` recipes with the `files` they write |
|
|
129
|
+
| `get_upgrade_guide` | For `from` and `to` (at most the installed version; `3.x` works): the migrations that would run, the steps no migration applies and the changelog consumer-upgrade steps |
|
|
130
|
+
| `get_glossary` | One kit term (`term`, also found by a word it rejects) or all of them, from the installed SDK's `GLOSSARY.md`: definition, example and the words not to use |
|
|
131
|
+
|
|
132
|
+
Resources: `sixbell-sdk://design` (the app's `DESIGN.md`), `sixbell-sdk://glossary` (the installed SDK's `GLOSSARY.md`; an SDK before 4.6.0 gets a one-line message) and `sixbell-sdk://recipes/<id>`. Recipes live in [`recipes/`](recipes), whose README documents the format.
|
|
133
|
+
|
|
134
|
+
A tool that needs the manifest returns an error naming the fix when the SDK is not installed or ships no manifest (SDK 4.6.0 or later). `--manifest <file>` answers from another manifest.
|
|
135
|
+
|
|
136
|
+
## init
|
|
137
|
+
|
|
138
|
+
`init` creates an MFE from its template repo, or brings an existing MFE up to the template. It replaces the `apply-mfe-foundation` script.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npx @sixbell-telco/sdk-tools init orders --child # a new child MFE in ./orders
|
|
142
|
+
npx @sixbell-telco/sdk-tools init --dry-run # the plan for the app in this folder; writes nothing
|
|
143
|
+
npx @sixbell-telco/sdk-tools init # apply it
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Template.** `--host` uses `EnghouseGlobal/nw-sx-starters-mfe-host-template`, `--child` uses `EnghouseGlobal/nw-sx-starters-mfe-child-template`. On an existing app the kind comes from `mfe-foundation.config.json` (or `federation.config.js`). The template is read at run time, in this order:
|
|
147
|
+
|
|
148
|
+
1. `--template <dir>`;
|
|
149
|
+
2. a local checkout whose origin remote is the template repo, below `--template-root <dir>` (repeatable), `SDK_TOOLS_TEMPLATE_ROOT`, or else the folders above the app, nearest first (up to six, not above your home folder);
|
|
150
|
+
3. a clone of the default branch cached in `SDK_TOOLS_TEMPLATE_CACHE` (default `~/.cache/sdk-tools/templates`). The clone uses the host of the app's origin remote, so an ssh host alias keeps working, else `https://github.com`. Set `SDK_TOOLS_TEMPLATE_REMOTE` (with `{repo}`) to use another remote; `--offline` never clones.
|
|
151
|
+
|
|
152
|
+
**New app.** In an empty folder, `init` copies the template and renames its identity (package name, display name, i18n prefix), as the template's `scripts/rename-project.mjs` does. `--name` and `--display-name` set them; the defaults are the folder name and its title case. Then run `npm install`, `npm run build` and `npx @sixbell-telco/sdk-tools check`.
|
|
153
|
+
|
|
154
|
+
**Existing app.** `init` plans every template file before it writes anything:
|
|
155
|
+
|
|
156
|
+
| Plan | When | What happens |
|
|
157
|
+
| -------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
158
|
+
| `add` | The app lacks the file (and its git does not ignore it) | Written from the template |
|
|
159
|
+
| `update` | The app has an untouched copy of an older template version, found in the template's git history | Replaced by the current template version |
|
|
160
|
+
| `merge` | JSON and ignore files | Template keys and lines the app lacks are added |
|
|
161
|
+
| `manual` | A foundation file the product changed, or a file the merge cannot read or whose shape differs | Left alone and reported: merge it by hand |
|
|
162
|
+
| `kept` | Any other file the product changed | The product copy stays |
|
|
163
|
+
|
|
164
|
+
- **Merges never drop or change a product value.** Product i18n keys, theme settings, lists (tsconfig `files`, theme catalogs, translation paths) and dependency versions stay; only missing keys are added (and missing angular.json budget types). The template's example-feature strings are not merged.
|
|
165
|
+
- **Product-owned paths are never touched:** `src/app/features/`, the expose shells (`src/app/*-shell.routes.ts`), `mfe-foundation.config.json`, `package-lock.json`, README, CHANGELOG, CODEOWNERS, `.github/`, `sonar-project.properties`. Missing theme catalogs are not added.
|
|
166
|
+
- **Foundation files** (`federation.config.js`, `app.config.ts`, `app.routes.ts`, `Menu.ts`, the account-actions, environment, menu, pubsub and session services, `src/environments/`) are `manual` when the product changed them.
|
|
167
|
+
- **Writes are all or nothing:** each target must still hold what the plan read, and a failed write restores the files written before it.
|
|
168
|
+
|
|
169
|
+
Options: `[dir]` (default `.`), `--host`, `--child`, `--dry-run`, `--json` (`data` is the plan: `operations`, `manual`, `kept`, `counts`, `template`), `--name`, `--display-name`, `--template`, `--template-root`, `--offline`.
|
|
170
|
+
|
|
171
|
+
Exit codes: 0 done (or nothing to do), 1 manual files remain or a failure, 2 usage error.
|
|
172
|
+
|
|
173
|
+
## upgrade
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
npx @sixbell-telco/sdk-tools upgrade --dry-run # plan: the edits and manual items, nothing changes
|
|
177
|
+
npx @sixbell-telco/sdk-tools upgrade --to 4.6.0 # install, migrate, check, report
|
|
178
|
+
npx @sixbell-telco/sdk-tools upgrade --to ./sixbell-telco-sdk-4.6.0.tgz --json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`upgrade` moves the app to a newer `@sixbell-telco/sdk` with the SDK's own `ng update` migrations, the same ones `ng update @sixbell-telco/sdk` runs:
|
|
182
|
+
|
|
183
|
+
1. **Pre-checks**: the app uses the SDK, the git tree is clean, Angular stays on 19.2 (installed and in the target's peers), the installed peers meet the target's floors, the target exists (a version, a dist-tag or a packed `.tgz`), and the federation moves in lockstep (below). A failed pre-check exits 3 and prints the step that unblocks it. `--dry-run` reports a dirty tree without blocking.
|
|
184
|
+
2. **Plan**: the migrations between the installed and the target version run in dry-run mode; their planned edits and manual items are the inventory.
|
|
185
|
+
3. **Apply**: `npm install --save-exact` the target (only npm's exit code decides: `npm warn ERESOLVE` peer warnings on a successful install are a warning in the report), run the migrations, format the files they changed with the app's own Prettier (`node_modules/.bin/prettier --write`; skipped, and said so, when the app has none), then `sdk-tools check` (skip it with `--no-check`). The `--json` report's `format` lists the files passed to Prettier.
|
|
186
|
+
|
|
187
|
+
The report lists what was **applied**, what is **manual** (a migration found a shape it will not change on its own) and what **still fails** (migration errors and `check` errors). Exit 0 when nothing is manual or failing, 1 otherwise. It also lists the **manual steps** no migration applies for the versions crossed (dialog widths, `offsetY`, banner choices, button variants and the like); they are reminders and do not change the exit code.
|
|
188
|
+
|
|
189
|
+
**Federation lockstep.** A host and the remotes it loads share one SDK at run time. In a host, `upgrade` reads the remotes from `mfe-foundation.config.json` (else `federation.config.js`) and looks for each remote's local checkout below `--root <dir>` (repeatable), else `SDK_TOOLS_FLEET_ROOT` (path-delimited), else the five folders above the app. A remote matches by its GitHub origin when its entry has a `repo` (`org/name`), else by the federation name the checkout declares. A remote on another SDK version blocks with exit 3; a remote with no local checkout is a warning naming what to verify. In a child, the report names the hosts that load it, which move together with it.
|
|
190
|
+
|
|
191
|
+
**Apps on SDK 3.** The 4.0.0 migration adopts the SDK 4 shell (the kit `st-app-layout`, providers, menu adapter, child `MfeShadowShellComponent` route, legacy shell removed) and theme assets (v3 catalog merged over the product's, theme list, SDK i18n glob, recognized `styles.css` and table hover cleanups). The shell needs the `layout` block of `mfe-foundation.config.json` (`defaultLayout`, `topLevelGroups`, `activeMatch`); without it the shell is a manual item. Once you resolve a shell manual item (add the layout block, copy a service the kit account provider imports from the MFE template), commit and run the migrations again with `ng update @sixbell-telco/sdk --migrate-only --from 3.99.0`; `sdk-tools upgrade` does not rerun them because the app is already on the target. The shell is all or nothing; each asset file group is applied on its own. Missing theme images are listed, not copied: take them from the MFE template. Each manual item names the file to edit or copy (and from which template repository) and the command to run next; `themes.json` keeps its indentation and `meta.hash`.
|
|
192
|
+
|
|
193
|
+
## add
|
|
194
|
+
|
|
195
|
+
`add` writes a recipe from the UI composition standard (`DESIGN.md`, "UI composition") into the app as local `app-*` code: standalone components with signals, `st-*` components only, i18n keys instead of literal text, and a Jest spec for each.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npx @sixbell-telco/sdk-tools add # list the recipes
|
|
199
|
+
npx @sixbell-telco/sdk-tools add crud-list product # src/app/features/product/...
|
|
200
|
+
npx @sixbell-telco/sdk-tools add detail-page product --dry-run
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Recipe | Writes |
|
|
204
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
205
|
+
| `crud-list` | A list page: `st-table` with search, paging and kebab row actions, an empty state, the form dialog, a delete confirm |
|
|
206
|
+
| `form-dialog` | A create/edit `st-dialog` (`lg`) with a validated reactive form: required legend, hints, `[Cancel] [Save]` |
|
|
207
|
+
| `detail-page` | A read-only page: one `st-card`, `st-description-list` sections, Edit in the header, no footer |
|
|
208
|
+
|
|
209
|
+
Every recipe also writes `<name>.model.ts` and an in-memory `<name>.service.ts` (replace its bodies with your backend calls); `crud-list` and `detail-page` include the form dialog. `<name>` is kebab-case (default `item`). The i18n keys go into `src/assets/i18n/<lang>.json` under `<app>.<name>`, where `<app>` is the package name in snake case, in the file's own layout.
|
|
210
|
+
|
|
211
|
+
- **Never overwrites.** A file that exists with other content is reported (`EXISTS`) and nothing is written (exit 1); `--force` overwrites those files. A file shared between recipes (the model, the store, the form dialog) keeps an existing copy, and existing i18n values are never changed.
|
|
212
|
+
- **One source.** The files come from the recipe's template parts in [`recipes/parts/`](recipes/parts); MCP `get_recipe` returns the same recipe with its `files` and `i18nKeys`.
|
|
213
|
+
- **Next steps** are printed: register the routes, rename "record" in the i18n values to your entity, format, and run `check`.
|
|
214
|
+
|
|
215
|
+
Options: `--dry-run`, `--force`, `--json` (`data` is the plan: `files` with their `action`, `i18n`, `warnings`, `next`).
|
|
216
|
+
|
|
217
|
+
## info
|
|
218
|
+
|
|
219
|
+
`info` prints the project context that skills load at start (`` !`npx @sixbell-telco/sdk-tools info --json` ``). It reads files only (no lint, no type check, no npm), so it answers in well under a second, and it always exits 0: a folder that is not an app is `role: "none"` with empty fields.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npx @sixbell-telco/sdk-tools info # a short summary
|
|
223
|
+
npx @sixbell-telco/sdk-tools info --json # the data below, in the usual envelope
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`data` (schema version 1; fields are only ever added, never renamed or removed):
|
|
227
|
+
|
|
228
|
+
| Field | Value |
|
|
229
|
+
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| `schemaVersion` | `1` |
|
|
231
|
+
| `root`, `name` | the app folder and its `package.json` name (`null` without one) |
|
|
232
|
+
| `role`, `roleSource` | `host`, `child` or `none`, and what decided it (`mfe-foundation.config.json` role, federation exposes...) |
|
|
233
|
+
| `kit.declared`, `kit.installed` | the `@sixbell-telco/sdk` range in `package.json` and the installed version (node_modules, else the lock) |
|
|
234
|
+
| `kit.entryPoints` | the `@sixbell-telco/sdk/...` entry points imported under `src`, sorted |
|
|
235
|
+
| `angular.declared`, `angular.installed` | the same for `@angular/core` |
|
|
236
|
+
| `theme.default`, `theme.themes`, `.source` | from `src/assets/themes/themes.json`, else the `themes` of `mfe-foundation.config.json` |
|
|
237
|
+
| `layout` | the `layout` block of `mfe-foundation.config.json`, or `null` |
|
|
238
|
+
| `federation` | `{ name, exposes, remotes }` from `federation.config.js` (remotes from the host manifest), or `null` |
|
|
239
|
+
| `files` | `{ designMd, agentsMd, foundationConfig }`: whether each file exists |
|
|
240
|
+
|
|
241
|
+
## doctor
|
|
242
|
+
|
|
243
|
+
`doctor` reports what `check` does not judge: the environment and drift from the MFE templates. Each finding keeps its mfe-tools id and has a `fix` (usually an `sdk-tools init` or `upgrade` command). Errors exit 1; warnings alone exit 0.
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npx @sixbell-telco/sdk-tools doctor
|
|
247
|
+
npx @sixbell-telco/sdk-tools doctor --template-root ~/src/starters --json
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
| Id | Severity | Reports |
|
|
251
|
+
| -------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
252
|
+
| `ENV_NODE_001`, `ENV_NPM_001` | error | Node or npm outside `package.json` `engines` |
|
|
253
|
+
| `CU_TARGET_SDK_MISSING` | error | `package.json` does not depend on `@sixbell-telco/sdk` |
|
|
254
|
+
| `BUTTON_VARIANT_001` | warn | the SDK declared is before 4: run `sdk-tools upgrade` |
|
|
255
|
+
| `MFE_SEC_DEPS_001` | error | an MFE without a readable `package.json` |
|
|
256
|
+
| `MFE_DOC_002`, `MFE_DOC_001` | error, warn | `DESIGN.md`, `AGENTS.md` missing (existence only) |
|
|
257
|
+
| `MFE_LAYOUT_CONFIG_003`, `_001`, `_002` | warn, error | `mfe-foundation.config.json` missing, unreadable, or without a `layout` block (its values are `check`'s) |
|
|
258
|
+
| `MFE_AGENT_TRACKED_001` | error | agent tooling (`.claude`, `.agents`, skill locks...) tracked in git (`git ls-files`, read only) |
|
|
259
|
+
| `MFE_FEATURE_003` | error | a starter feature (`host`, `microfrontend`, `example`) left next to a real feature |
|
|
260
|
+
| `MFE_CHILD_001`, `MFE_CHILD_002` | error | a child without `src/app/app.routes.ts` or `src/assets/configuration/mfe_config.json` |
|
|
261
|
+
| `MFE_CHILD_ERR_002`, `MFE_CHILD_ERR_003` | error | the child error interceptor navigates to `/server-error`, or swallows 401/403 |
|
|
262
|
+
| `MFE_JEST_001`, `MFE_PROXY_001/002`, `MFE_SEC_DEPS_011`, `MFE_TEST_SHELL_001`, `MFE_CHILD_ERR_001` | error | a file the role template has is missing (`jest.config.js`, proxy configs, `scripts/security-check.mjs`, shell specs, the child error interceptor) |
|
|
263
|
+
| `DOCTOR_TEMPLATE_001` | warn | no local template checkout, so the template files were not judged |
|
|
264
|
+
| `CU_PACKAGE_JSON_MISSING`, `CU_DESIGN_MD_MISSING`, `CU_AGENTS_MD_MISSING` | error, warn | the same checks for a folder that is no MFE |
|
|
265
|
+
|
|
266
|
+
Template drift is judged against the role's template as `init` renders it, from a local checkout found the way `init` finds one (`--template <dir>`, `--template-root <dir>`, `SDK_TOOLS_TEMPLATE_ROOT`, the folders above the app). `doctor` never clones: without a checkout it says so (`DOCTOR_TEMPLATE_001`). A file counts as missing only when the template has it.
|
|
267
|
+
|
|
268
|
+
## docs
|
|
269
|
+
|
|
270
|
+
`docs` prints a component's API from the manifest of the installed SDK, or a recipe: the same answers as the MCP `get_component` and `get_recipe` tools.
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npx @sixbell-telco/sdk-tools docs st-button # inputs with types, allowed values and defaults, outputs, import, example
|
|
274
|
+
npx @sixbell-telco/sdk-tools docs crud-list # a recipe
|
|
275
|
+
npx @sixbell-telco/sdk-tools docs # list the components and the recipes
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
An unknown name prints the nearest matches and exits 1. `--manifest <file>` answers from a manifest file; `--json` gives `data.kind` (`component`, `recipe`, `list` or `not-found` with `suggestions`).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"description": "Minimum safe versions for apps built with @sixbell-telco/sdk, checked by sdk-tools check (MFE_SEC_DEPS_*). direct: the app's own dependencies; overrides: transitive packages, every installed copy; nestedOverrides: parent.child pins; scripts: the npm scripts that run the floor check in CI. Angular stays on 19.2.",
|
|
4
|
+
"direct": {
|
|
5
|
+
"@angular/animations": "19.2.25",
|
|
6
|
+
"@angular/common": "19.2.25",
|
|
7
|
+
"@angular/compiler": "19.2.25",
|
|
8
|
+
"@angular/core": "19.2.25",
|
|
9
|
+
"@angular/forms": "19.2.25",
|
|
10
|
+
"@angular/platform-browser": "19.2.25",
|
|
11
|
+
"@angular/platform-browser-dynamic": "19.2.25",
|
|
12
|
+
"@angular/router": "19.2.25",
|
|
13
|
+
"@angular/compiler-cli": "19.2.25",
|
|
14
|
+
"@angular/cli": "19.2.27",
|
|
15
|
+
"@angular/build": "19.2.27",
|
|
16
|
+
"@angular-devkit/build-angular": "19.2.27",
|
|
17
|
+
"eslint": "9.39.4",
|
|
18
|
+
"@eslint/js": "9.39.4",
|
|
19
|
+
"typescript-eslint": "8.61.1",
|
|
20
|
+
"angular-eslint": "19.8.1",
|
|
21
|
+
"jest-preset-angular": "14.6.2",
|
|
22
|
+
"postcss": "8.5.15",
|
|
23
|
+
"lint-staged": "15.5.2"
|
|
24
|
+
},
|
|
25
|
+
"overrides": {
|
|
26
|
+
"tar": "7.5.19",
|
|
27
|
+
"node-forge": "1.4.0",
|
|
28
|
+
"qs": "6.15.2",
|
|
29
|
+
"lodash": "4.18.1"
|
|
30
|
+
},
|
|
31
|
+
"nestedOverrides": {
|
|
32
|
+
"@tailwindcss/oxide.tar": "7.5.19",
|
|
33
|
+
"cacache.tar": "7.5.19",
|
|
34
|
+
"pacote.tar": "7.5.19",
|
|
35
|
+
"node-gyp.tar": "7.5.19",
|
|
36
|
+
"@angular/build.vite": "6.4.3",
|
|
37
|
+
"@angular/build.rollup": "4.62.0",
|
|
38
|
+
"@angular-devkit/build-angular.webpack": "5.107.2",
|
|
39
|
+
"@angular-devkit/build-angular.webpack-dev-server": "5.2.5",
|
|
40
|
+
"@angular-devkit/build-angular.http-proxy-middleware": "3.0.7",
|
|
41
|
+
"@angular-devkit/core.ajv": "8.20.0",
|
|
42
|
+
"schema-utils.ajv": "8.20.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"security:check": "node scripts/security-check.mjs"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixbell-telco/sdk-tools",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI and MCP server for apps built with @sixbell-telco/sdk: check templates, imports and types against the installed SDK, and create or upgrade MFEs from their template repos",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sdk-tools": "./src/cli.mjs"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/check.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"data",
|
|
15
|
+
"recipes",
|
|
16
|
+
"README.md",
|
|
17
|
+
"CHANGELOG.md"
|
|
18
|
+
],
|
|
5
19
|
"license": "Apache-2.0",
|
|
20
|
+
"author": "Enghouse Networks",
|
|
6
21
|
"repository": {
|
|
7
22
|
"type": "git",
|
|
8
23
|
"url": "git+https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit.git",
|
|
9
24
|
"directory": "projects/sdk-tools"
|
|
10
25
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^22.12.0 || ^24.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
31
|
+
"@sixbell-telco/eslint-plugin-sdk": "0.1.1",
|
|
32
|
+
"angular-eslint": "^19.0.0",
|
|
33
|
+
"eslint": "^9.0.0",
|
|
34
|
+
"shadcn-lint-angular": "0.1.2",
|
|
35
|
+
"typescript-eslint": "^8.0.0",
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@angular-devkit/core": "^19.0.0",
|
|
40
|
+
"@angular-devkit/schematics": "^19.0.0",
|
|
41
|
+
"@angular/compiler-cli": "^19.0.0",
|
|
42
|
+
"@sixbell-telco/sdk": ">=4.6.0",
|
|
43
|
+
"typescript": "^5.5.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@sixbell-telco/sdk": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
13
49
|
}
|
|
14
50
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Recipes
|
|
2
|
+
|
|
3
|
+
A recipe is a short, step-by-step guide for building something with `@sixbell-telco/sdk`. The MCP server (`sdk-tools mcp`) returns recipes through the `get_recipe` tool and lists each one as the resource `sixbell-sdk://recipes/<id>`.
|
|
4
|
+
|
|
5
|
+
## Format
|
|
6
|
+
|
|
7
|
+
One Markdown file per recipe, named `<id>.md`, starting with a front matter block:
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
---
|
|
11
|
+
id: form-dialog
|
|
12
|
+
title: Build a form dialog
|
|
13
|
+
summary: A dialog with a validated form and Cancel and Save actions
|
|
14
|
+
kitCandidate: false
|
|
15
|
+
tags: [dialog, form]
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
1. First step, with the exact code or command.
|
|
19
|
+
2. ...
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Field | Required | Meaning |
|
|
23
|
+
| -------------- | -------- | ------------------------------------------------------------------------------------ |
|
|
24
|
+
| `id` | yes | Lowercase, kebab-case; equal to the file name without `.md` |
|
|
25
|
+
| `title` | yes | One line, imperative |
|
|
26
|
+
| `summary` | yes | One line; `get_recipe` lists it in its tool description, so keep it short |
|
|
27
|
+
| `kitCandidate` | no | `true` when the recipe builds local code the kit could adopt later (default `false`) |
|
|
28
|
+
| `tags` | no | `[a, b]` list of words that help an agent choose the recipe |
|
|
29
|
+
| `parts` | no | `[a, b]` template parts `sdk-tools add` writes, in order (see below) |
|
|
30
|
+
|
|
31
|
+
Values are plain text, `true`/`false`, or a `[a, b]` list; there is no nesting. `README.md` is not a recipe.
|
|
32
|
+
|
|
33
|
+
## Template parts
|
|
34
|
+
|
|
35
|
+
A recipe that `sdk-tools add` can write lists its `parts`. Each part is a folder `parts/<part>/` that mirrors the app: `parts/crud-list/src/app/features/__name__/pages/__name__-list/__name__-list.component.ts.tpl` is written to `src/app/features/<name>/pages/<name>-list/<name>-list.component.ts`. Files end in `.tpl` so the repo's linters skip them.
|
|
36
|
+
|
|
37
|
+
- Placeholders: `__name__` (kebab-case name), `__Name__` (PascalCase), `__NAME__` (upper snake case, for `__NAME___ROUTES`) and `__i18n__` (the i18n prefix, `<app>.<name>`).
|
|
38
|
+
- A `*.routes.ts` file imports the MFE templates' `configurationGuard`; in an app without `src/app/core/guards/configuration/configuration.guard.ts`, `add` writes it without the guard and warns.
|
|
39
|
+
- `parts/<part>/i18n.json` holds the part's keys under `__i18n__` as `{ "en": {…}, "es": {…}, "pt": {…} }`. Every language has the same keys, and two parts of a recipe never give one key different values.
|
|
40
|
+
- The part named like the recipe is its own; the others are shared with other recipes (`entity` holds the model and the store), so `add` keeps an existing copy of their files.
|
|
41
|
+
- `get_recipe` returns `parts`, `files` (each `path` with `<name>`, and `shared`) and `i18nKeys`, read from the same folders, so the MCP and `add` describe the same files.
|
|
42
|
+
- The generated code follows the composition standard: `st-*` components only, role variants, dialog widths, i18n keys for every text, and a Jest spec. `test/add.test.mjs` checks this on every recipe.
|
|
43
|
+
|
|
44
|
+
## Writing a recipe
|
|
45
|
+
|
|
46
|
+
Recipes are read by small models, so:
|
|
47
|
+
|
|
48
|
+
- Number the steps and keep each one to a single action.
|
|
49
|
+
- Name kit components by selector and tell the agent to call `get_component` for their inputs. Never list inputs, values or tokens in a recipe: the manifest holds those facts.
|
|
50
|
+
- Use only APIs and rules from `DESIGN.md` and the SDK.
|
|
51
|
+
- End with the `check_usage` (or `sdk-tools check`) gate.
|
|
52
|
+
|
|
53
|
+
The test `projects/sdk-tools/test/mcp.test.mjs` loads every recipe, so a malformed file fails `npm run tools:test`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: crud-list
|
|
3
|
+
title: Build a list page with search, row actions, a form dialog and a delete confirm
|
|
4
|
+
summary: A CRUD list page (st-table, search, kebab row actions, empty state, create/edit dialog, delete confirm)
|
|
5
|
+
parts: [entity, form-dialog, detail-page, crud-list]
|
|
6
|
+
tags: [list, table, crud, page, dialog, delete]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`npx @sixbell-telco/sdk-tools add crud-list <name>` writes every file below (listed in `files`) and merges the i18n keys into `src/assets/i18n/{en,es,pt}.json` under `<app>.<name>`. Build it by hand only where the command cannot run, following the same steps.
|
|
10
|
+
|
|
11
|
+
1. **Model and store.** `<name>.model.ts` holds the record type; `<name>.service.ts` is an in-memory signal store. Replace its method bodies with your backend calls and keep the signal API.
|
|
12
|
+
2. **Page card.** The route root is one `st-card`. The title goes in `st-card-header` (`st-card-title as="h2"`), and the single `primary` "New <record>" button with an add icon goes in `st-card-header-aside`.
|
|
13
|
+
3. **Search.** An `st-input` (`max-w-80`) filters the rows and resets to page 1. A Clear button (`primary`, ghost, `sm`) shows only while a filter is set.
|
|
14
|
+
4. **Table.** `st-table` gets the current page of rows, `totalItems` and `pagination`; the page slices the filtered rows itself.
|
|
15
|
+
5. **Row actions.** Three actions (view `primary`, edit `warning`, delete `error`), so they go in the kebab: `st-table-actions mode="dropdown"` with `contextLabel` set to the row name. Labels are i18n keys.
|
|
16
|
+
6. **Empty state.** Project `st-empty-state size="sm"` into `st-table`: "No results" with one `secondary` "Clear filters" while filtering, else a plain empty state (the toolbar already has "New <record>").
|
|
17
|
+
7. **Create and edit.** Both open the `form-dialog` recipe's dialog (`[(opened)]`, `[value]`, `(saved)`).
|
|
18
|
+
8. **Delete confirm.** An `st-dialog width="xl"` with the row in a small `st-table`, then `[Cancel]` (`secondary`) and `[Delete]` (`error`, last). Never delete without it.
|
|
19
|
+
9. **Routes.** `<name>.routes.ts` exports `<NAME>_ROUTES`: the list at `<name>` and the `detail-page` recipe's page at `<name>/:id` (the view action), each with `canActivate: [configurationGuard]` and a `title` and `data.subtitle` i18n key (`list.subtitle`, `detail.subtitle`). Spread it into the app's feature routes. Navigation inside the feature keeps the menu param (`queryParamsHandling: 'merge'`), so the host keeps the menu item highlighted.
|
|
20
|
+
10. **Text.** Rename "record" in the generated i18n values to your entity, one complete key per language for gender agreement.
|
|
21
|
+
11. **Check.** Run `npx @sixbell-telco/sdk-tools check src/app/features/<name>` (or `check_usage`) and fix every error.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: custom-component
|
|
3
|
+
title: Build a local app-* component the kit does not have
|
|
4
|
+
summary: When no kit component fits, build a local app-* component that follows kit conventions and mark it as a kit candidate
|
|
5
|
+
kitCandidate: true
|
|
6
|
+
tags: [component, custom, local, missing]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Use this only after search_components found nothing that fits. A component built this way is a **kit candidate**: it may move into `@sixbell-telco/sdk` later, so it follows the kit's own conventions from the start.
|
|
10
|
+
|
|
11
|
+
1. **Confirm the gap.** Call `search_components` with two or three different wordings of the need. If a kit component covers most of it, use that component (call `get_component`) and compose around it instead.
|
|
12
|
+
2. **Place it.** Create `src/app/shared/components/<name>/<name>.component.ts` (kebab-case name). Use the `app-` selector prefix: `app-<name>`. Never use `st-`, which is reserved for the kit.
|
|
13
|
+
3. **Mark it as a kit candidate.** Start the class JSDoc with `Kit candidate:` and one line saying what kit gap it fills, so it can be found and proposed for the kit later:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
/** Kit candidate: a step indicator for multi-page forms (no kit equivalent in 4.x). */
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
4. **Write it the kit's way.** A standalone component with:
|
|
20
|
+
- `changeDetection: ChangeDetectionStrategy.OnPush`;
|
|
21
|
+
- signal APIs only: `input()`, `input.required()`, `output()`, `model()`, `computed()`, `inject()`;
|
|
22
|
+
- `host: {}` metadata for host classes and attributes (no `@HostBinding` or `@HostListener`);
|
|
23
|
+
- `@if`, `@for` and `@switch` (no `*ngIf` or `*ngFor`);
|
|
24
|
+
- no `@Input()`, `@Output()`, `EventEmitter` or constructor injection.
|
|
25
|
+
5. **Build it from the kit.** Inside the template, use kit components for every part the kit has (buttons, badges, icons, inputs, cards). Import each from its entry point, for example `@sixbell-telco/sdk/components/button`, never from `@sixbell-telco/sdk`.
|
|
26
|
+
6. **Style with theme tokens only.** Call `get_tokens` for the names.
|
|
27
|
+
- Colors: semantic tokens such as `bg-base-200`, `text-base-content`, `border-base-300`; status text uses the `-strong` tokens.
|
|
28
|
+
- Shape and depth: the radius and shadow roles (`rounded-box`, `rounded-field`, the shadow tokens).
|
|
29
|
+
- Never: palette colors (`bg-red-500`), hex or rgb values, arbitrary values (`p-[13px]`), `style=` or `[ngStyle]`, `transition-all`, `outline-none` (use `outline-hidden` and keep a `focus-visible` style).
|
|
30
|
+
- Never restyle a kit component's color, typography or surface; put only layout and spacing classes on `st-*` elements.
|
|
31
|
+
7. **Variants.** For a component with variants, define them with `cva` from `class-variance-authority` and merge classes with `cn()` from `@sixbell-telco/sdk/utils/cn`. Name the variant input like the kit does (`variant`, `size`) and type it as a string union.
|
|
32
|
+
8. **Accessibility (WCAG 2.2 AA).** Use native elements or the right ARIA role, make it work with the keyboard with a visible focus, respect `prefers-reduced-motion` (`motion-safe:` utilities), and never show status by color alone (add text or an icon).
|
|
33
|
+
9. **Text.** No hard-coded user-facing strings: take them as inputs or translate them with the app's i18n keys.
|
|
34
|
+
10. **Test it.** Add `<name>.component.spec.ts` that renders it and sets inputs with `fixture.componentRef.setInput()`.
|
|
35
|
+
11. **Check it.** Call `check_usage` with the file path (or run `npx @sixbell-telco/sdk-tools check src/app/shared/components/<name>`). Fix every error and check again until there are none.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: detail-page
|
|
3
|
+
title: Build a read-only detail page
|
|
4
|
+
summary: A read-only detail page (one st-card, description list sections, Edit in the header, no footer)
|
|
5
|
+
parts: [entity, form-dialog, detail-page]
|
|
6
|
+
tags: [detail, view, read-only, page, description-list]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`npx @sixbell-telco/sdk-tools add detail-page <name>` writes every file below (listed in `files`) and merges the i18n keys into `src/assets/i18n/{en,es,pt}.json` under `<app>.<name>`. Build it by hand only where the command cannot run, following the same steps.
|
|
10
|
+
|
|
11
|
+
1. **Record.** The page reads the route parameter `id` and finds the record in `<name>.service.ts`.
|
|
12
|
+
2. **Card.** The route root is one `st-card`. The record name is the `st-card-title as="h2"`; the view-mode Edit (`primary`, outline, `sm`) goes in `st-card-header-aside` and opens the `form-dialog` recipe's dialog.
|
|
13
|
+
3. **Sections.** `st-card-section-group [divided]="true"`, one `st-card-section` per group of fields, each with an `st-card-title` heading.
|
|
14
|
+
4. **Values.** Key/value rows are `st-description-list` with `div[st-description-item]` (`copyable` on ids and codes). Never disabled inputs as a read-only view.
|
|
15
|
+
5. **No footer.** The page banner back link is the only way back; do not add a Back button.
|
|
16
|
+
6. **Not found.** An unknown id shows `st-empty-state` instead of the card.
|
|
17
|
+
7. **Route.** Register it in the feature's `<name>.routes.ts` (the `crud-list` recipe writes one with this route): `{ path: '<name>/:id', component: <Name>DetailComponent, canActivate: [configurationGuard], title: '<app>.<name>.detail.title', data: { title, subtitle: '<app>.<name>.detail.subtitle' } }`.
|
|
18
|
+
8. **Text.** Rename "record" in the generated i18n values to your entity.
|
|
19
|
+
9. **Check.** Run `npx @sixbell-telco/sdk-tools check src/app/features/<name>` (or `check_usage`) and fix every error.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: form-dialog
|
|
3
|
+
title: Build a create and edit form dialog
|
|
4
|
+
summary: A create/edit st-dialog (width lg) with a validated reactive form, required legend, hints, and Cancel then Save
|
|
5
|
+
parts: [entity, form-dialog]
|
|
6
|
+
tags: [dialog, form, create, edit, validation]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`npx @sixbell-telco/sdk-tools add form-dialog <name>` writes every file below (listed in `files`) and merges the i18n keys into `src/assets/i18n/{en,es,pt}.json` under `<app>.<name>`. Build it by hand only where the command cannot run, following the same steps.
|
|
10
|
+
|
|
11
|
+
1. **API.** `app-<name>-form-dialog` has `opened` (a `model()`, bind `[(opened)]`), `value` (the record to edit, `null` to create), `saving` and the `saved` output with the form value. The parent saves and closes it.
|
|
12
|
+
2. **Dialog.** `st-dialog width="lg"` (a form dialog). The title says what it does: "New <record>" or "Edit <record>".
|
|
13
|
+
3. **Form.** A reactive `FormGroup` reset from `value` every time the dialog opens. Put one `st-form-required-legend` above the first field; each field is an `st-form-item` with the kit input, an `st-form-hint` where it helps and `st-form-errors` with i18n messages.
|
|
14
|
+
4. **Actions.** In `st-dialog-actions` (right-aligned by default): `[Cancel]` as `secondary`, then the confirm as `primary`, last. The confirm matches the title: "Create" or "Save".
|
|
15
|
+
5. **Validation.** Save stays enabled (disabled only while `saving`). On submit, an invalid form marks every field touched and focuses the first invalid one; a valid form emits `saved`.
|
|
16
|
+
6. **Text.** Rename "record" in the generated i18n values to your entity.
|
|
17
|
+
7. **Check.** Run `npx @sixbell-telco/sdk-tools check src/app/features/<name>` (or `check_usage`) and fix every error.
|