@researchdatabox/redbox-dev-tools 0.0.1 → 5.0.0-RC2

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.
Files changed (129) hide show
  1. package/README.md +259 -14
  2. package/bin/cli.js +3 -0
  3. package/bin/run-hook-mocha.js +3 -0
  4. package/bin/run-hook-tsc.js +3 -0
  5. package/bin/wrapper-webpack.js +168 -0
  6. package/config/tsconfig.base.json +16 -0
  7. package/dist/bin/run-hook-mocha.d.ts +1 -0
  8. package/dist/bin/run-hook-mocha.js +49 -0
  9. package/dist/bin/run-hook-tsc.d.ts +1 -0
  10. package/dist/bin/run-hook-tsc.js +19 -0
  11. package/dist/cli-parsers.d.ts +9 -0
  12. package/dist/cli-parsers.js +131 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +495 -0
  15. package/dist/commands/form-config.d.ts +6 -0
  16. package/dist/commands/form-config.js +401 -0
  17. package/dist/commands/sync-translation.d.ts +23 -0
  18. package/dist/commands/sync-translation.js +348 -0
  19. package/dist/completion/index.d.ts +1 -0
  20. package/dist/completion/index.js +218 -0
  21. package/dist/generators/add-method.d.ts +27 -0
  22. package/dist/generators/add-method.js +235 -0
  23. package/dist/generators/angular-app.d.ts +24 -0
  24. package/dist/generators/angular-app.js +342 -0
  25. package/dist/generators/angular-service.d.ts +21 -0
  26. package/dist/generators/angular-service.js +154 -0
  27. package/dist/generators/controller.d.ts +40 -0
  28. package/dist/generators/controller.js +195 -0
  29. package/dist/generators/form-component.d.ts +46 -0
  30. package/dist/generators/form-component.js +906 -0
  31. package/dist/generators/form-field.d.ts +15 -0
  32. package/dist/generators/form-field.js +160 -0
  33. package/dist/generators/migration.d.ts +15 -0
  34. package/dist/generators/migration.js +100 -0
  35. package/dist/generators/model.d.ts +42 -0
  36. package/dist/generators/model.js +206 -0
  37. package/dist/generators/service.d.ts +16 -0
  38. package/dist/generators/service.js +111 -0
  39. package/dist/runtime-resolver.d.ts +3 -0
  40. package/dist/runtime-resolver.js +27 -0
  41. package/dist/templates/hook-archetype.d.ts +12 -0
  42. package/dist/templates/hook-archetype.js +187 -0
  43. package/dist/testing.d.ts +7 -0
  44. package/dist/testing.js +53 -0
  45. package/dist/utils/config-helper.d.ts +71 -0
  46. package/dist/utils/config-helper.js +574 -0
  47. package/dist/utils/generator.d.ts +10 -0
  48. package/dist/utils/generator.js +68 -0
  49. package/dist/utils/hook-tsconfig.d.ts +9 -0
  50. package/dist/utils/hook-tsconfig.js +104 -0
  51. package/dist/utils/paths.d.ts +10 -0
  52. package/dist/utils/paths.js +60 -0
  53. package/index.js +4 -0
  54. package/package.json +76 -19
  55. package/runtime-resolver.d.ts +1 -0
  56. package/runtime-resolver.js +3 -0
  57. package/skills/redbox-angular-apps/SKILL.md +42 -0
  58. package/skills/redbox-angular-services/SKILL.md +29 -0
  59. package/skills/redbox-controllers/SKILL.md +65 -0
  60. package/skills/redbox-feature-design-planner/SKILL.md +169 -0
  61. package/skills/redbox-feature-implementation-review/SKILL.md +117 -0
  62. package/skills/redbox-form-components/SKILL.md +114 -0
  63. package/skills/redbox-form-config/SKILL.md +34 -0
  64. package/skills/redbox-hook-development/SKILL.md +66 -0
  65. package/skills/redbox-services/SKILL.md +54 -0
  66. package/skills/redbox-test-verification/SKILL.md +38 -0
  67. package/skills/redbox-testing/SKILL.md +64 -0
  68. package/skills/redbox-web-verification/SKILL.md +71 -0
  69. package/skills/redbox-web-verification/redbox-angular-apps/SKILL.md +48 -0
  70. package/skills/redbox-web-verification/redbox-angular-services/SKILL.md +30 -0
  71. package/skills/redbox-web-verification/redbox-controllers/SKILL.md +56 -0
  72. package/skills/redbox-web-verification/redbox-form-config/SKILL.md +29 -0
  73. package/skills/redbox-web-verification/redbox-hook-development/SKILL.md +61 -0
  74. package/skills/redbox-web-verification/redbox-services/SKILL.md +45 -0
  75. package/skills/redbox-web-verification/redbox-testing/SKILL.md +53 -0
  76. package/skills/redbox-web-verification/redbox-web-verification/SKILL.md +47 -0
  77. package/templates/hook-archetype/standard/.gitignore.hbs +5 -0
  78. package/templates/hook-archetype/standard/.npmignore.hbs +4 -0
  79. package/templates/hook-archetype/standard/.npmrc.hbs +6 -0
  80. package/templates/hook-archetype/standard/.nvmrc.hbs +1 -0
  81. package/templates/hook-archetype/standard/AGENTS.md.hbs +51 -0
  82. package/templates/hook-archetype/standard/Dockerfile.hbs +29 -0
  83. package/templates/hook-archetype/standard/README.md.hbs +57 -0
  84. package/templates/hook-archetype/standard/assets/default/.gitkeep +1 -0
  85. package/templates/hook-archetype/standard/assets/fonts/.gitkeep +1 -0
  86. package/templates/hook-archetype/standard/assets/images/.gitkeep +1 -0
  87. package/templates/hook-archetype/standard/assets/styles/.gitkeep +1 -0
  88. package/templates/hook-archetype/standard/language-defaults/.gitkeep +1 -0
  89. package/templates/hook-archetype/standard/language-defaults/README.md.hbs +10 -0
  90. package/templates/hook-archetype/standard/language-defaults/en/translation.json.hbs +3 -0
  91. package/templates/hook-archetype/standard/language-defaults/meta.json.hbs +6 -0
  92. package/templates/hook-archetype/standard/package.json.hbs +44 -0
  93. package/templates/hook-archetype/standard/src/api/controllers/ExampleController.ts.hbs +21 -0
  94. package/templates/hook-archetype/standard/src/api/controllers/index.ts.hbs +23 -0
  95. package/templates/hook-archetype/standard/src/api/services/ExampleService.ts.hbs +22 -0
  96. package/templates/hook-archetype/standard/src/api/services/index.ts.hbs +23 -0
  97. package/templates/hook-archetype/standard/src/config/brandingConfigurationDefaults.ts.hbs +9 -0
  98. package/templates/hook-archetype/standard/src/config/reusableFormDefinitions.ts.hbs +6 -0
  99. package/templates/hook-archetype/standard/src/form-config/default-1.0-draft.ts.hbs +20 -0
  100. package/templates/hook-archetype/standard/src/form-config/index.ts.hbs +8 -0
  101. package/templates/hook-archetype/standard/src/index.ts.hbs +55 -0
  102. package/templates/hook-archetype/standard/src/migrations/index.ts.hbs +19 -0
  103. package/templates/hook-archetype/standard/support/bootstrap-data/.gitkeep +1 -0
  104. package/templates/hook-archetype/standard/support/bootstrap-data/namedqueries/.gitkeep +1 -0
  105. package/templates/hook-archetype/standard/support/bootstrap-data/records/.gitkeep +1 -0
  106. package/templates/hook-archetype/standard/support/bootstrap-data/reports/.gitkeep +1 -0
  107. package/templates/hook-archetype/standard/support/bootstrap-data/vocabularies/.gitkeep +1 -0
  108. package/templates/hook-archetype/standard/support/development/core-mount.env.hbs +3 -0
  109. package/templates/hook-archetype/standard/support/development/docker-compose.core-mount.yml.hbs +37 -0
  110. package/templates/hook-archetype/standard/support/development/docker-compose.yml.hbs +108 -0
  111. package/templates/hook-archetype/standard/support/development/prepare-core-mount.sh.hbs +61 -0
  112. package/templates/hook-archetype/standard/support/integration-testing/docker-compose.mocha.yml.hbs +118 -0
  113. package/templates/hook-archetype/standard/support/integration-testing/run-mocha-hook.sh.hbs +14 -0
  114. package/templates/hook-archetype/standard/support/integration-testing/run-mocha-redbox.sh.hbs +100 -0
  115. package/templates/hook-archetype/standard/support/prepare-minio.sh.hbs +74 -0
  116. package/templates/hook-archetype/standard/test/integration/hook-registration.test.ts.hbs +15 -0
  117. package/templates/hook-archetype/standard/test/support/globals.ts.hbs +40 -0
  118. package/templates/hook-archetype/standard/test/tsconfig.json.hbs +8 -0
  119. package/templates/hook-archetype/standard/test/unit/.mocharc.cjs.hbs +9 -0
  120. package/templates/hook-archetype/standard/test/unit/index.test.ts.hbs +46 -0
  121. package/templates/hook-archetype/standard/tsconfig.json.hbs +15 -0
  122. package/templates/hook-archetype/standard/views/.gitkeep +1 -0
  123. package/templates/hook-archetype/standard/views/default/.gitkeep +1 -0
  124. package/testing.d.ts +1 -0
  125. package/testing.js +3 -0
  126. package/.travis.yml +0 -23
  127. package/commands/initProject.js +0 -129
  128. package/redbox-dev-tools +0 -70
  129. package/yarn.lock +0 -1061
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: 'Redbox Feature Implementation Review'
3
+ description: 'Review completed ReDBox feature implementations against a growing ruleset and emit structured issues for agent remediation.'
4
+ ---
5
+
6
+ # Skill: Redbox Feature Implementation Review
7
+
8
+ ## Purpose
9
+
10
+ Use this skill after a feature implementation lands (services, controllers, models, Angular app) to verify adherence to platform rules and report actionable issues that can be looped back into an agent for fixes.
11
+
12
+ ## Inputs
13
+
14
+ - `implementation_plan.md` for expected schema, flows, and required components.
15
+ - The feature’s code changes in core-types, app, and angular directories.
16
+
17
+ ## Review Workflow
18
+
19
+ 1. Read `implementation_plan.md` and list expected services, models, controllers, routes, and UI surfaces.
20
+ 2. Locate the implemented code and tests.
21
+ 3. Evaluate each rule below and record any violations as structured issues.
22
+ 4. Emit only violations; do not propose unrelated refactors.
23
+
24
+ ## Rule Checks
25
+
26
+ ### Type-safety / Any-casts
27
+
28
+ 1. Search the implementation for usages of `as any`, `(object as any)`, `as unknown as`, or other patterns that cast to `any` to bypass TypeScript types.
29
+ - Rationale: model and service code must adhere to declared Waterline model interfaces; casting to `any` hides mismatches and leads to runtime failures.
30
+ - Expected behavior: replace casts with proper interfaces, refine types, or add clear TODOs referencing a follow-up task (do not permanently use `as any`).
31
+ - Area mapping: set `area` to match the location of the cast (use `services` for service code, `models` for Waterline models, `controllers` for backend controllers, and `angular` for Angular/front-end code).
32
+ Example: `packages/redbox-core/src/services/FooService.ts` -> `area: services`.
33
+ - Severity: treat `as any` casts in model/service code as `blocker`; in controllers or angular code treat as `major` or `minor` depending on context but always report.
34
+ - Evidence: include the exact file, line range, and code snippet where the cast occurs, and ensure the reported `area` matches the file type where the cast appears.
35
+
36
+ ### Services
37
+
38
+ 1. Services extend `CoreService`.
39
+ - Expected location: `packages/redbox-core/src/services`.
40
+ 2. Each service has a unit test in `packages/redbox-core/test`.
41
+ 3. Each service has at least one integration test in `typescript/test/unit` (prefer `typescript/test/unit/services`).
42
+ 4. Avoid redundant local service declarations.
43
+ - Rationale: Sails places services on the global scope (and via `sails.services`), so declaring `declare const SomeService` or creating local service aliases in controllers or other modules (a common pattern added by debugging agents) is unnecessary and can cause confusion or type drift.
44
+ - Expected behavior: reference services via the canonical global (e.g. `SomeService`, `sails.services.someservice`, or via dependency access patterns used elsewhere in the repo) and remove local `declare const` statements or redundant `const X = globalThis.X` aliases.
45
+ - Area mapping: `controllers` or `angular` depending on where the declaration appears.
46
+ - Severity: `minor` for stylistic fixes, `major` if the declaration hides or masks a different service implementation.
47
+ - Evidence: include the exact file, line range, and snippet where the local declaration occurs (e.g., `declare const VocabularyService: ...`).
48
+ - Suggested fix: remove the local declaration and use the global service reference; update typings if necessary instead of duplicating runtime declarations.
49
+
50
+ ### Waterline Models
51
+
52
+ 1. The schema matches `implementation_plan.md`.
53
+ 2. Models are defined in `packages/redbox-core/src/waterline-models`.
54
+ 3. Avoid using `globalThis` to access Waterline models.
55
+ - Rationale: Waterline models are exposed as global variables (for example `Vocabulary`, `VocabularyEntry`) by Sails at runtime. Wrapping them again with `globalThis` lookups (e.g., `globalThis as typeof globalThis & { Vocabulary?: ... }`) is unnecessary and noisy; prefer referencing the global model by name and, if needed, cast to the appropriate model interface for typing only (e.g., `const VocabularyModel = Vocabulary as unknown as VocabularyWaterlineModel`).
56
+ - Expected behavior: use direct global model references in service/controller code instead of building `globalThis` accessor objects.
57
+ - Area mapping: `services`, `controllers` where Waterline models are used.
58
+ - Severity: `minor` for stylistic/clarity fixes, `major` if the `globalThis` indirection caused incorrect model resolution.
59
+ - Evidence: include file path, line range, and snippet where `globalThis` is used to access models.
60
+ - Suggested fix: replace `globalThis` lookups with direct model names and add a local typed alias only for TypeScript typing (see example above).
61
+
62
+ ### Controllers
63
+
64
+ 1. Controllers extend `CoreController`.
65
+ 2. All controller actions use `this.sendResp` for responses.
66
+ - Never use `res.json`, `res.send`, `this.apiRespond`, or `this.ajaxRespond`.
67
+ 3. Routing includes both:
68
+ - CSRF-secured routes on `/:branding/:portal/<path>`.
69
+ - Non-CSRF routes on `/:branding/:portal/api/<path>`.
70
+ 4. Navigation configuration is set for any new pages or menus.
71
+ - Check core-types config models (for example `packages/redbox-core/src/configmodels/MenuConfig.ts`) and any branding defaults touched by the feature.
72
+ 5. Controllers include unit tests.
73
+ - Expected location: `packages/redbox-core/test`.
74
+ 6. Controllers include integration tests for Bruno.
75
+ - Expected location: `test/bruno`.
76
+
77
+ ### Angular App
78
+
79
+ 1. Angular services use `HttpClientService`.
80
+ 2. The app does not define Angular routing (not an SPA).
81
+ 3. Angular apps include tests.
82
+ - Expected: unit tests for the app runnable via `ng test <app-name>` (located under `angular/projects/<app-name>/`), and any e2e or integration suites as appropriate.
83
+
84
+ ## Output Format
85
+
86
+ If any issues are found: return a JSON payload with an `issues` array. Each issue must include:
87
+
88
+ - `id`: short unique identifier (e.g., `svc-extends-core`).
89
+ - `area`: `services`, `models`, `controllers`, or `angular`.
90
+ - `rule`: the rule text that failed.
91
+ - `severity`: `blocker`, `major`, or `minor`.
92
+ - `message`: clear, actionable description.
93
+ - `file`: path to the violating file.
94
+ - `lines`: line range string (e.g., `L12-L40`) or `null` if unknown.
95
+ - `evidence`: snippet or description pointing to the violation.
96
+ - `suggested_fix`: concise change that resolves the issue.
97
+
98
+ If no issues are found: output the exact ASCII string (without quotes):
99
+
100
+ NO ISSUES FOUND
101
+
102
+ Example payload when issues exist:
103
+ {
104
+ "issues": [
105
+ {
106
+ "id": "controller-sendresp",
107
+ "area": "controllers",
108
+ "rule": "All controller actions use this.sendResp for responses.",
109
+ "severity": "major",
110
+ "message": "Controller action uses res.json instead of this.sendResp.",
111
+ "file": "packages/redbox-core/src/controllers/MyController.ts",
112
+ "lines": "L88-L96",
113
+ "evidence": "res.json({ ok: true })",
114
+ "suggested_fix": "Replace res.json with this.sendResp(res, 200, payload)."
115
+ }
116
+ ]
117
+ }
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: 'Redbox Form Components'
3
+ description: 'Build or update ReDBox form field components end-to-end across Angular form rendering and sails-ng-common config typing/visitor infrastructure. Use when creating a new form component class/model, adding component config properties, wiring component dictionaries, handling config migration/template extraction, or adding form-component tests.'
4
+ ---
5
+
6
+ # Skill: Redbox Form Components
7
+
8
+ Use this workflow to add a new form component that is actually usable in form config, construct/migrate/template visitors, and Angular runtime.
9
+
10
+ ## Start With Generator
11
+
12
+ - First run the hook-kit scaffold command:
13
+ - `redbox-dev-tools generate form-component <name> --app form`
14
+ - Optional companion service scaffold:
15
+ - `redbox-dev-tools generate form-component <name> --app form --with-service`
16
+ - Treat the generated files as the baseline, then implement component-specific config properties, rendering logic, and visitor custom behavior.
17
+
18
+ ## Canonical Example
19
+
20
+ - Treat `CheckboxTreeComponent` as the reference implementation:
21
+ - `angular/projects/researchdatabox/form/src/app/component/checkbox-tree.component.ts`
22
+ - `packages/sails-ng-common/src/config/component/checkbox-tree.outline.ts`
23
+ - `packages/sails-ng-common/src/config/component/checkbox-tree.model.ts`
24
+
25
+ ## Implementation Workflow
26
+
27
+ 1. Define component and model contracts in `sails-ng-common`.
28
+ 2. Register those contracts in dictionary/type unions.
29
+ 3. Add visitor methods everywhere (`base.*` plus concrete visitors).
30
+ 4. Implement Angular component/model and register them in the form app.
31
+ 5. Add/update supporting services only if the component needs API data.
32
+ 6. Add tests for runtime behavior and visitor behavior.
33
+
34
+ ## 1) Define the component contract (`sails-ng-common`)
35
+
36
+ - Create `packages/sails-ng-common/src/config/component/<component>.outline.ts`.
37
+ - Export component/model name constants (`<ComponentName>`, `<ModelName>`).
38
+ - Define config frames/outlines for both field component and field model.
39
+ - Define form component frame/outline and final `<Component>Types` union.
40
+ - Create `packages/sails-ng-common/src/config/component/<component>.model.ts`.
41
+ - Implement config/definition/model classes with `accept(visitor)` methods.
42
+ - Export `<Component>Map` and `<Component>Defaults`.
43
+
44
+ ## 2) Register dictionary and exports
45
+
46
+ - Add `<Component>Types` to `AllTypes` in `packages/sails-ng-common/src/config/dictionary.outline.ts`.
47
+ - Add `<Component>Map` into `AllDefs` and `<Component>Defaults` into `RawDefaults` in `packages/sails-ng-common/src/config/dictionary.model.ts`.
48
+ - Export the new outline/model files in `packages/sails-ng-common/src/index.ts`.
49
+
50
+ ## 3) Wire visitor infrastructure
51
+
52
+ - Add methods to `packages/sails-ng-common/src/config/visitor/base.outline.ts`:
53
+ - `visit<Component>FieldComponentDefinition`
54
+ - `visit<Component>FieldModelDefinition`
55
+ - `visit<Component>FormComponentDefinition`
56
+ - Add default stubs in `packages/sails-ng-common/src/config/visitor/base.model.ts`.
57
+ - Add pass-through/validation methods in:
58
+ - `construct.visitor.ts` (usually includes config property overrides)
59
+ - `client.visitor.ts`
60
+ - `data-value.visitor.ts`
61
+ - `json-type-def.visitor.ts`
62
+ - `validator.visitor.ts`
63
+ - `template.visitor.ts` (extract template-capable fields, if any)
64
+ - `migrate-config-v4-v5.visitor.ts` (legacy class mapping + coercion/defaults/warnings as needed)
65
+
66
+ If the component uses `inlineVocab`, update `packages/redbox-core/src/visitor/vocab-inline.visitor.ts` to resolve vocab data into the component config shape.
67
+
68
+ ## 4) Implement Angular form component
69
+
70
+ - Create `angular/projects/researchdatabox/form/src/app/component/<component>.component.ts`.
71
+ - Create `<Component>Model` extending `FormFieldModel<T>`.
72
+ - Create `<Component>Component` extending `FormFieldBaseComponent<T>`.
73
+ - Read component config in `setPropertiesFromComponentMapEntry`.
74
+ - Do async bootstrapping in `initData` for remote data.
75
+ - Keep model sync explicit (`formControl.setValue`, dirty/touched updates).
76
+ - Include accessibility semantics for interactive components (`role`, `aria-*`, keyboard behavior).
77
+
78
+ Register Angular wiring:
79
+
80
+ - Add component to `declarations` in `angular/projects/researchdatabox/form/src/app/form.module.ts`.
81
+ - Add component/model class maps in `angular/projects/researchdatabox/form/src/app/static-comp-field.dictionary.ts`.
82
+
83
+ ## 5) Add supporting service (if needed)
84
+
85
+ - If component makes API calls, create `angular/projects/researchdatabox/form/src/app/service/<service>.service.ts`.
86
+ - Prefer extending `HttpClientService`.
87
+ - Enable CSRF context in `waitForInit()`.
88
+ - Normalize old/new response shapes if backend compatibility is required.
89
+
90
+ If new backend endpoints are needed, update `redbox-core` controller/service/routes and add tests there.
91
+
92
+ ## 6) Testing gates
93
+
94
+ - Add component spec:
95
+ - `angular/projects/researchdatabox/form/src/app/component/<component>.component.spec.ts`
96
+ - Cover at least:
97
+ - render/create
98
+ - config-driven behavior
99
+ - model update correctness
100
+ - keyboard/accessibility behavior for interactive components
101
+ - loading/error states for async branches
102
+ - Add Angular service spec when service is introduced:
103
+ - `angular/projects/researchdatabox/form/src/app/service/<service>.service.spec.ts`
104
+ - Add visitor tests for:
105
+ - construct visitor mapping
106
+ - migration visitor mapping/coercion
107
+ - template visitor extraction (if template fields exist)
108
+ - vocab-inline behavior (if inline vocab is supported)
109
+
110
+ ## Quality Rules
111
+
112
+ - Keep type safety strict; do not use `as any` to bypass type issues.
113
+ - Keep selection/model semantics explicit; do not hide side effects.
114
+ - Prefer deterministic config defaults and migration coercions with warnings for malformed legacy input.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: "Redbox Form Config"
3
+ description: "ReDBox uses a JSON-based DSL for configuring record forms, workflows, and record types."
4
+ ---
5
+
6
+ # Skill: Redbox Form Config
7
+
8
+ ## Context
9
+ ReDBox uses a JSON-based DSL for configuring record forms, workflows, and record types.
10
+
11
+ ## Locations
12
+ - Form configurations: `config/form.js`
13
+ - Workflow configurations: `config/workflow.js`
14
+ - Record type configurations: `config/recordtype.js`
15
+
16
+ ## Key Concepts
17
+ - **Record Type**: Defines the entity (e.g., `rdmp`) and its search filters.
18
+ - **Workflow**: Defines stages (e.g., `draft`, `review`), transitions, roles, and which form to use at each stage.
19
+ - **Form**: Defines the layout and fields.
20
+ - **Field**: Each field has a `class` (usually `Container`), a `compClass` (the Angular component name, e.g., `TextBlockComponent`), and a `definition`.
21
+
22
+ ## Generating Form Fields
23
+ Use the `redbox-dev-tools` CLI generator `generate_form_field`:
24
+ - `name`: Field name as an argument.
25
+ - `--type <type>`: Record type (e.g., `rdmp`).
26
+
27
+ ## Form Expressions
28
+ Dynamic behavior is handled via `expressions`:
29
+ - Listen to events using JSON Pointer paths (e.g., `/form_tab/source_field::field.value.changed`).
30
+ - Apply conditions and templates (using JSONata).
31
+ - Target model or component properties.
32
+
33
+ ## Language Files
34
+ Labels and messages should use keys (starting with `@`) that map to entries in `assets/locales/<language>/translation.json`.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: 'Redbox Hook Development'
3
+ description: 'ReDBox hooks are NPM packages that extend or customize ReDBox functionality. They are loaded during the Sails lift process.'
4
+ ---
5
+
6
+ # Skill: Redbox Hook Development
7
+
8
+ ## Context
9
+
10
+ ReDBox hooks are NPM packages that extend or customize ReDBox functionality. They are loaded during the Sails lift process.
11
+
12
+ ## Project Structure
13
+
14
+ - `redbox-hook-[project-name]`
15
+ - `typescript/`: TypeScript source code.
16
+ - `assets/`: Custom assets.
17
+ - `views/`: Custom EJS views.
18
+ - `config/`: Configuration overrides.
19
+ - `form-config/`: Form configuration overrides.
20
+
21
+ ## Hook Capabilities
22
+
23
+ Declared in `package.json` under the `sails` key:
24
+
25
+ - `hasModels`: Provides Waterline models.
26
+ - `hasPolicies`: Provides Sails policies.
27
+ - `hasServices`: Provides business logic services (can override core).
28
+ - `hasControllers`: Provides internal/app controllers (Sails controllers used by the portal).
29
+ - `hasWebserviceControllers`: Provides HTTP/webservice-facing controllers (API endpoints).
30
+ - `hasBootstrap`: Provides a startup function.
31
+ - `hasConfig`: Provides configuration object to merge.
32
+
33
+ ## Required Exports
34
+
35
+ The hook's main entry point (usually `index.ts` compiled to `index.js`) must export registration functions **only** for the capabilities enabled in `package.json`:
36
+
37
+ - `registerRedboxModels()` — required when `hasModels` is `true`.
38
+ - `registerRedboxPolicies()` — required when `hasPolicies` is `true`.
39
+ - `registerRedboxServices()` — required when `hasServices` is `true`.
40
+ - `registerRedboxControllers()` — required when `hasControllers` is `true` (internal/app controllers).
41
+ - `registerRedboxWebserviceControllers()` — required when `hasWebserviceControllers` is `true` (HTTP/webservice controllers).
42
+ - `registerRedboxBootstrap()` — required when `hasBootstrap` is `true`.
43
+ - `registerRedboxConfig()` — required when `hasConfig` is `true`.
44
+
45
+ If a capability is disabled, its matching export must be omitted.
46
+
47
+ ## Development with Hook Kit
48
+
49
+ The `redbox-dev-tools` CLI simplifies hook development:
50
+
51
+ - Use `init` to scaffold a new project.
52
+ - Use generators to add components (controllers, services, etc.).
53
+ - Use `redbox-dev-tools generate model` to add Waterline models.
54
+
55
+ ## Generating Models
56
+
57
+ Use the `redbox-dev-tools` CLI generator `generate model`:
58
+
59
+ - `--identity <identity>`: Waterline identity (table name), defaults to lowercase name.
60
+ - `--attrs <attrs>`: Comma-separated list of attributes (e.g. `name:string:required,age:number`).
61
+ - `--belongs-to <associations>`: Comma-separated belongsTo associations (e.g. `owner:user`).
62
+ - `--has-many <associations>`: Comma-separated hasMany associations (e.g. `pets:animal:owner`).
63
+
64
+ ## Overriding Core Components
65
+
66
+ To override a core service or controller, register a component with the same name as the core one. It is recommended to extend the core class in your implementation.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: 'Redbox Services'
3
+ description: 'ReDBox business logic is encapsulated in TypeScript services in `@researchdatabox/redbox-core`.'
4
+ ---
5
+
6
+ # Skill: Redbox Services
7
+
8
+ ## Context
9
+
10
+ ReDBox business logic is encapsulated in TypeScript services in `@researchdatabox/redbox-core`.
11
+
12
+ ## Locations
13
+
14
+ - Services: `packages/redbox-core/src/services/`
15
+ - Index: `packages/redbox-core/src/services/index.ts`
16
+
17
+ ## Patterns
18
+
19
+ - Extend `Services.Core.Service`.
20
+ - Implement `bootstrap()` for initialization.
21
+ - Use `_exportedMethods` to define exposed methods.
22
+ - Often use RxJS Observables for async operations.
23
+ - Access Waterline models via globals (e.g., `declare var Record: Model;`).
24
+
25
+ ## Type Safety Guidance
26
+
27
+ - Do not use `(object as any)`, `as any`, or other deliberate `any` casts to bypass TypeScript compilation errors. Fix the types, declare appropriate interfaces, or request guidance in the skill instead. Maintaining type safety helps prevent runtime errors and keeps the codebase maintainable.
28
+
29
+ ## Generating Services
30
+
31
+ Use the `redbox-dev-tools` CLI generator `generate_service`:
32
+
33
+ - `name`: Service name (e.g., `Records`) as an argument.
34
+ - `--methods <list>`: Comma-separated initial methods.
35
+
36
+ ## Adding Methods
37
+
38
+ Use `redbox-dev-tools generate method` to add methods to an existing service:
39
+
40
+ - `--file <path>`: Path to the service file.
41
+ - `--method <name>`: Method name.
42
+
43
+ ## Index Updates
44
+
45
+ When adding a service, update `packages/redbox-core/src/services/index.ts`:
46
+
47
+ - Import the service module.
48
+ - Re-export the service.
49
+ - Add to `ServiceExports` with a lazy getter.
50
+
51
+ ## Overriding Services in Hooks
52
+
53
+ Hooks can override core services by registering them in `registerRedboxServices`.
54
+ Override services should extend the core service they are replacing.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: 'Redbox Test Verification'
3
+ description: 'Ensure every new service or controller gets Mocha or Bruno coverage by analyzing the implemented code and writing integration tests.'
4
+ ---
5
+
6
+ # Skill: Redbox Test Verification
7
+
8
+ ## Purpose
9
+
10
+ Use this skill whenever new business logic or routes are merged so the functionality can be verified by automated tests before release.
11
+
12
+ ## Analyze first
13
+
14
+ - Inspect the new/updated code in `packages/redbox-core/src/services` (for services) or `packages/redbox-core/src/controllers` plus `config/routes` (for routes) to understand the happy path, dependencies, and any edge cases the feature must cover.
15
+ - Take notes on expected inputs, persisted entities, authorization requirements, and downstream effects; those points become the assertions in the new test.
16
+
17
+ ## Mocha service integration coverage
18
+
19
+ - For every new/modified service in `packages/redbox-core/src/services`, add an integration test under `typescript/test/integration/services`. Prefer naming the file after the service (e.g., `MyService.test.ts`).
20
+ - These are integration tests (no mocking, full-stack). The test should orchestrate creating real data (often via helper seed utilities), let the service execute against the database, and assert on the persisted state or returned payloads.
21
+ - Import shared fixtures or helpers from `typescript/test/integration/services/helpers` as needed, but focus on exercising the whole service flow (setup data, call the method or endpoint, then read back the data it should have created/updated).
22
+ - Keep the tests in TypeScript, run via Mocha inside the Docker test harness, and update any shared fixtures or `typescript/test/unit/services/index.ts` helpers if required.
23
+
24
+ ## Bruno route coverage
25
+
26
+ - When a new controller or route is introduced (or an existing route grows new behavior), add a Bruno scenario under `test/bruno` that hits the HTTP endpoint through the normal request pipeline.
27
+ - Reuse existing Bruno test patterns for authentication, parameter passing, and response validation; the new suite should cover the new route name/path plus potential role restrictions.
28
+ - Keep suites grouped under the relevant Bruno folder (e.g., `test/bruno/general`) and ensure the new file is wired into the `test/bruno/run` scripts if needed.
29
+ - Do not toggle CSRF headers/flags in route configs; the Bruno environments already disable CSRF globally in Sails config, so follow the default route definitions.
30
+
31
+ ## Verify by running the suites
32
+
33
+ - After adding the tests, run the Mocha suite with `npm run test:mocha:mount` (local iteration) or `npm run test:mocha` (CI) to build confidence that the service behaves as expected.
34
+ - For the Bruno scenarios, run `npm run test:bruno:general:mount` (or the appropriate profile) and ensure the new route passes before finishing.
35
+
36
+ ## Documentation
37
+
38
+ - If the new tests uncover side effects or contract changes, document them in the wiki page that best fits (see `support/wiki/redbox-core.md` or `support/wiki/Redbox-Loader.md`).
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: "Redbox Testing"
3
+ description: "ReDBox uses Mocha for integration testing and Bruno for API testing. All integration tests are run within Docker containers managed by docker-compose profiles."
4
+ ---
5
+
6
+ # Skill: Redbox Testing
7
+
8
+ ## Context
9
+ ReDBox uses Mocha for integration testing and Bruno for API testing. All integration tests are run within Docker containers managed by docker-compose profiles.
10
+
11
+ ## Mocha Tests
12
+ Mocha tests are located in `packages/*/test`. To run them, they are executed within a Docker environment.
13
+
14
+ ### Commands
15
+ - **Run all Mocha tests (Development):**
16
+ ```bash
17
+ npm run test:mocha:mount
18
+ ```
19
+ This mounts your local code into the test containers, allowing for faster iteration.
20
+
21
+ - **Run selected Mocha tests (Development):**
22
+ ```bash
23
+ RBPORTAL_MOCHA_TESTS="test/unit/services/SolrSearchService.test.js" npm run test:mocha:mount
24
+ ```
25
+ Provide space-separated test file paths or glob patterns. The bootstrap test is always included.
26
+
27
+ - **Run all Mocha tests (CI):**
28
+ ```bash
29
+ npm run test:mocha
30
+ ```
31
+ This runs the tests using the `portal` profile without mounting local code.
32
+
33
+ - **Clean up Mocha test resources:**
34
+ ```bash
35
+ npm run test:mocha:clean
36
+ ```
37
+
38
+ ## Bruno Tests
39
+ Bruno is used for API testing. Tests are located in `test/bruno`.
40
+
41
+ ### Commands
42
+ - **Run Bruno OIDC tests (Development):**
43
+ ```bash
44
+ npm run test:bruno:oidc:mount
45
+ ```
46
+ This runs tests specifically for OIDC authentication flows with mounted code.
47
+
48
+ - **Run Bruno General tests (Development):**
49
+ ```bash
50
+ npm run test:bruno:general:mount
51
+ ```
52
+ This runs a general suite of Bruno tests with mounted code.
53
+
54
+ - **Run Bruno tests (CI):**
55
+ The non-mount variants (e.g. `npm run test:bruno:oidc`) are intended for CircleCI builds.
56
+
57
+ - **Cleanup:**
58
+ Use the corresponding clean command for the test suite you ran:
59
+ - `npm run test:bruno:clean`
60
+ - `npm run test:bruno:oidc:clean`
61
+ - `npm run test:bruno:general:clean`
62
+
63
+ ## Docker Profiles
64
+ These commands utilize Docker Compose profiles to start the necessary services (e.g., `redboxportal`, `keycloak`, `mongo`, `solr`). The `package.json` scripts define which profiles and compose files are used for each test suite.
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: 'Web Interface Verification'
3
+ description: "This skill outlines the workflow for verifying the Redbox Portal web interface using the Agent's built-in browser capabilities and natural language test scripts."
4
+ ---
5
+
6
+ # Skill: Web Interface Verification
7
+
8
+ ## Context
9
+
10
+ This skill outlines the workflow for verifying the Redbox Portal web interface using the Agent's built-in browser capabilities and natural language test scripts.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Start the Application
15
+
16
+ Start the application in development mode with the mount profile. The `dev:run` script applies the mount profile implicitly (no extra flags required).
17
+ **Important:** Capture the `CommandId` returned by this command to monitor logs later. The `CommandId` is typically a UUID or numeric ID printed near startup; look for it before or around the "Sails lifted" readiness marker.
18
+
19
+ ```bash
20
+ npm run dev:run
21
+ ```
22
+
23
+ Example output (capture the value after `CommandId:`):
24
+
25
+ ```text
26
+ CommandId: 9f2b5c3a-1d4e-4a6a-9e5b-0a1234567890
27
+ ...Sails lifted...
28
+ ```
29
+
30
+ Extract it from the logs with a one-liner (or copy the `CommandId:` line directly):
31
+
32
+ ```bash
33
+ grep -m 1 "CommandId:" .tmp/logs/dev-run.log
34
+ ```
35
+
36
+ Wait for the application to be ready (look for "Sails lifted").
37
+
38
+ ### 2. Launch Browser
39
+
40
+ Use the `browser_subagent` tool to launch a browser session.
41
+
42
+ - **TaskName:** Web Verification
43
+ - **Task:** "Open http://localhost:1500 and [Insert Natural Language Script Here]"
44
+
45
+ ### 3. Execute Natural Language Script
46
+
47
+ Follow the natural language instructions provided by the user.
48
+ **Example Script:**
49
+
50
+ 1. "Login to the system."
51
+ 2. "Expectation: You are navigated to `/researcher/home`."
52
+ 3. "Navigate to 'My Data'."
53
+ 4. "Verify the 'Create Record' button is visible."
54
+
55
+ **Agent Responsibilities:**
56
+
57
+ - translate high-level actions (e.g., "Login") into interaction steps (type username, type password, click login).
58
+ - Verify URLs and UI elements match expectations.
59
+
60
+ ### 4. Monitor Logs
61
+
62
+ While the browser session is active or after a step fails, check the logs of the running application using the `command_status` tool and the captured `CommandId`.
63
+
64
+ - Look for server-side errors (500s, exceptions) that correlate with UI actions.
65
+
66
+ ### 5. Report Findings
67
+
68
+ After completing the script or encountering a failure, report the results to the user.
69
+
70
+ - **Success:** Confirm all steps passed.
71
+ - **Failure:** Detail which step failed, the observed vs. expected behavior, and any relevant server logs.
@@ -0,0 +1,48 @@
1
+ # Skill: Redbox Angular Apps
2
+
3
+ ## Context
4
+
5
+ ReDBox uses embedded Angular applications within EJS views instead of a single SPA. Each feature is often its own Angular project.
6
+
7
+ ## Locations
8
+
9
+ - Angular projects: `angular/projects/researchdatabox/<app-name>/`
10
+ - Output assets: `assets/angular/<app-name>/browser/`
11
+ - EJS views: `views/default/default/admin/<app-name>.ejs`
12
+
13
+ ## Generating Angular Apps
14
+
15
+ Use the `redbox-dev-tools` CLI generator `generate_angular_app`:
16
+
17
+ - `name`: App name as an argument (lowercase).
18
+ - `--ejs-view <view>`: EJS view name.
19
+ - `--auth <roles>`: Roles for page access.
20
+
21
+ ## Patterns
22
+
23
+ - Apps are scaffolded using `@angular-devkit/build-angular:application`.
24
+ - EJS views include the Angular component tag and the hashed JS/CSS bundles.
25
+ - Use `CacheService.getNgAppFileHash(appName, type, prefix)` for hashed asset names. `type` selects the asset category (for example `js`, `css`, `map`, or other build artifact names your bundler emits) and influences the lookup logic; `prefix` is an optional path or name prefix to scope the lookup (for example `vendor/`). If omitted, defaults are used by `CacheService` and an invalid type may fall back to the default asset group.
26
+ - Example: `CacheService.getNgAppFileHash("myApp", "js", "vendor/")` -> `"vendor/main.abc123.js"`.
27
+ - Apps are usually served via `RenderViewController.render` with the view specified in `locals`.
28
+
29
+ ## angular.json
30
+
31
+ New projects must be added to `angular.json` with appropriate `outputPath` and `baseHref`.
32
+ Example `outputPath`: `../assets/angular/<name>` and `baseHref`: `/assets/angular/<name>/`
33
+
34
+ ## Testing
35
+
36
+ To run tests for a specific Angular app:
37
+
38
+ - `ng test <app-name>`
39
+ - `npm test -- <app-name>`
40
+
41
+ ### Root Execution
42
+
43
+ If running inside a container as root (e.g. Docker), you must use the `--browsers=ChromeHeadlessNoSandbox` flag:
44
+ `ng test --browsers=ChromeHeadlessNoSandbox <app-name>`
45
+
46
+ ### Convenience Script
47
+
48
+ A convenience script is available at `support/unit-testing/angular/testDevAngular.sh` which handles the browser flags logic automatically.
@@ -0,0 +1,30 @@
1
+ # Skill: Redbox Angular Services
2
+
3
+ ## Context
4
+
5
+ Angular services in ReDBox typically extend `HttpClientService` to handle base URLs, configuration, and CSRF protection.
6
+
7
+ ## Location
8
+
9
+ - Within an Angular project: `angular/projects/researchdatabox/<app-name>/src/app/`
10
+
11
+ ## Patterns
12
+
13
+ - Extend `HttpClientService` from `@researchdatabox/portal-ng-common`.
14
+ - Inject `HttpClient`, `APP_BASE_HREF`, `UtilityService`, and `ConfigService`.
15
+ - Override `waitForInit()` and call `this.enableCsrfHeader()`.
16
+ - Use `this.brandingAndPortalUrl` for building API URLs.
17
+ - Use `this.httpContext` in request options to include the CSRF token.
18
+
19
+ ## Generating Angular Services
20
+
21
+ Use the `redbox-dev-tools` CLI generator `generate_angular_service`:
22
+
23
+ - `name`: Service name as an argument.
24
+ - `--app <app>`: Target Angular app name.
25
+ - `--methods <methods>`: Comma-separated list of methods to generate (e.g. `get,save`).
26
+
27
+ ## CSRF Handling
28
+
29
+ - `this.enableCsrfHeader()` sets the `RB_HTTP_INTERCEPTOR_AUTH_CSRF` context variable.
30
+ - For `FormData` uploads (file/image uploads or any `multipart/form-data` request), set `RB_HTTP_INTERCEPTOR_SKIP_JSON_CONTENT_TYPE` to `true` so the interceptor does not force `application/json` and the browser can set the correct boundary. This is not needed for JSON payloads or requests that explicitly set `Content-Type: application/json`.