Skip to content

Commit 2a8a631

Browse files
committed
feat(cli): harden rocket init
Generate a concise Atlas-backed starter and project-local skills while keeping init quiet in existing Rocket sites. Reuse existing Rocket start/build scripts, skip starter example Pages when a repo already has several Rocket Pages, and keep generated starter data type-clean. Also harden standalone demo rendering and matching, expose reusable demo component and icon helpers, support direct layout re-exports, add start flags, and document the static JavaScript/request-demo caveats.
1 parent 57aab9e commit 2a8a631

44 files changed

Lines changed: 1415 additions & 286 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: coding-style
3+
description: Indexes this repo's coding conventions for file placement, tests, API shape, component authoring, and commit messages. Use when creating or editing source files, adding tests, designing function signatures, creating components, or writing commits in this repo.
4+
---
5+
6+
# Coding Style
7+
8+
Open only the convention file needed for the current task. If a task spans multiple areas, read each relevant file before editing:
9+
10+
- Source and test files: see [source-and-tests.md](source-and-tests.md)
11+
- Function signatures and calls: see [apis-and-functions.md](apis-and-functions.md)
12+
- Components: see [components.md](components.md)
13+
- Commit messages: see [commits.md](commits.md)
14+
15+
Prefer these conventions over generic language or framework defaults unless nearby code clearly establishes a narrower local pattern.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# APIs and Functions
2+
3+
Keep function signatures easy to read at the call site. Prefer positional parameters only when their meaning is obvious and the argument list stays short.
4+
5+
When a function would take more than two parameters, prefer a single object parameter with named properties:
6+
7+
```js
8+
foo({ some: 'stuff', safe: true, retries: 2 });
9+
```
10+
11+
Avoid signatures that require readers to remember positional meaning:
12+
13+
```js
14+
foo('stuff', true, 2);
15+
```
16+
17+
Also prefer an object parameter for fewer arguments when a primitive or boolean flag would be ambiguous at the call site:
18+
19+
```js
20+
foo({ some: 'stuff', safe: true });
21+
```
22+
23+
Keep existing public APIs stable unless the task explicitly includes changing callers. For private helpers, update the call sites when the object form makes the code clearer.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Commit Messages
2+
3+
Use a small Conventional Commits style for the header:
4+
5+
`<type>(<module>): <short message>`
6+
7+
Allowed types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`, `build`, `ci`.
8+
9+
`<module>` is a short lowercase area such as `api`, `ui`, `docs`, `deploy`, or `tdd`.
10+
11+
Keep the header short, specific, and scannable. Use imperative or present-tense wording, and do not end it with a period.
12+
13+
Examples:
14+
15+
```txt
16+
feat(auth): add login redirect
17+
fix(deploy): handle missing env file
18+
docs(setup): clarify build command
19+
test(loop): cover retry failure path
20+
refactor(cli): simplify command parsing
21+
chore(deps): update lockfile
22+
ci(release): add publish workflow
23+
```
24+
25+
Write a generated commit body for non-trivial commits.
26+
27+
The body should be human-readable prose based on the actual diff, not a rigid template. Explain why the change was needed, what changed, and any behavior or test impact worth preserving in history. Do not repeat the header in sentence form.
28+
29+
Prefer one short paragraph for focused commits. Use a few bullets only when the commit spans multiple notable areas. Skip generic boilerplate such as "This commit..." or "Generated by AI".
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Components
2+
3+
When creating components, always prefer `LitElement` unless the existing code in that area clearly uses a different component base.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Source and Test Files
2+
3+
Prefer colocated tests. For `src/foo.js`, put the test in `src/foo.test.js`. For nested modules, keep the test next to the source file it covers.
4+
5+
Name source files after their primary export. Use `camelCase` for functions and plain modules, and `UpperCamelCase` for classes and custom elements:
6+
7+
- `src/mySuperFunction.js`
8+
- `src/mySuperFunction.test.js`
9+
- `src/MyElement.js`
10+
- `src/MyElement.test.js`
11+
12+
For new Node tests, prefer `describe` and `it` from `node:test`:
13+
14+
```js
15+
import { describe, it } from 'node:test';
16+
17+
describe('Test addressList', () => {
18+
it('01: finds default address', async () => {
19+
// ...
20+
});
21+
});
22+
```
23+
24+
Use numbered `it` cases (`01:`, `02:`, etc.) when a module has multiple behavior examples. Keep test names behavior-focused.

.agents/skills/rocket/SKILL.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: rocket
3+
description: Use when editing Rocket Pages, config, layouts, component reference Pages, or build behavior in this project.
4+
---
5+
6+
# Rocket
7+
8+
## Rules
9+
10+
- Read `rocket-config.js` first; Page discovery follows `includeGlobs`.
11+
- Every Page owns its URL through `config.path`; put general docs in `docs/pages` and component docs next to the component.
12+
- Prefer Markdown for durable content; use JavaScript Pages for request-time or programmatic output.
13+
- Prefer interactive examples for component and behavior docs; use `js demo` when readers benefit from trying the UI.
14+
- Prefer Atlas docs layouts: `atlasDocLayout` for docs, `atlasHeroLayout` for a standalone docs home, with matching `components` exports.
15+
- Markdown using Rocket custom elements needs a `components` export; use Atlas component maps or `rocketDemoComponents`.
16+
- Add `menu.iconName` to Atlas docs navigation Pages so the left navigation has icons.
17+
- Direct layout re-exports are supported when no local wrapper function is needed.
18+
- Custom layouts rendering `rocket-icon` need `addBootstrapIconLibrary(pageData)` before `document()`.
19+
- Static JavaScript Pages render once per concrete path; query/header/cookie/live-data output needs `render: 'server'`.
20+
- Static Request Demos should target concrete non-query URLs.
21+
- After adding a `js demo`, verify the parent Page and Standalone Demo URL `/page/_demo/demoName/`.
22+
- Keep `npm run build` passing; record Rocket package issues separately from local workarounds.

.changeset/sparkly-pots-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket/js': patch
3+
---
4+
5+
Harden rocket init for Atlas docs starters and existing Rocket sites, add demo/icon helpers, start flags, and standalone demo build validation.

AGENTS.md

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,7 @@
1-
## Agent skills
2-
31
### Issue tracker
42

53
Issues are tracked as local markdown files under `.scratch/<feature-slug>/`. See `docs/agents/issue-tracker.md`.
64

7-
### Triage labels
8-
9-
Use the default mattpocock/skills triage label vocabulary. See `docs/agents/triage-labels.md`.
10-
115
### Domain docs
126

137
This repo uses a single-context domain documentation layout. See `docs/agents/domain.md`.
14-
15-
### Source and test files
16-
17-
Prefer colocated tests. For `src/foo.js`, put the test in `src/foo.test.js`. For nested modules, keep the test next to the source file it covers.
18-
19-
Name source files after their primary export. Use `camelCase` for functions and plain modules, and `UpperCamelCase` for classes and custom elements:
20-
21-
- `src/mySuperFunction.js`
22-
- `src/mySuperFunction.test.js`
23-
- `src/MyElement.js`
24-
- `src/MyElement.test.js`
25-
26-
For new Node tests, prefer `describe` and `it` from `node:test`:
27-
28-
```js
29-
import { describe, it } from 'node:test';
30-
31-
describe('Test addressList', () => {
32-
it('01: finds default address', async () => {
33-
// ...
34-
});
35-
});
36-
```
37-
38-
Use numbered `it` cases (`01:`, `02:`, etc.) when a module has multiple behavior examples. Keep test names behavior-focused.
39-
40-
### Commit messages
41-
42-
Use a small Conventional Commits style:
43-
44-
`<type>(<module>): <short message>`
45-
46-
Allowed types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`, `build`, `ci`.
47-
48-
`<module>` is a short lowercase area such as `api`, `ui`, `docs`, `deploy`, or `tdd`. Keep the message short, use imperative or present-tense wording, and do not end it with a period.
49-
50-
Examples:
51-
52-
```txt
53-
feat(auth): add login redirect
54-
fix(deploy): handle missing env file
55-
docs(setup): clarify build command
56-
test(loop): cover retry failure path
57-
refactor(cli): simplify command parsing
58-
chore(deps): update lockfile
59-
ci(release): add publish workflow
60-
```

CONTEXT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ _Avoid_: Rewrite, alias, Page
482482
- **Zero-install Agent Onboarding** creates an **Agent Starter Site** by default.
483483
- An **Agent Starter Site** uses static Pages unless the **Site Author** asks for request-time behavior.
484484
- A **Rocket Initializer** may create an **Agent Starter Site** in an empty project or add Rocket documentation Pages to an existing codebase.
485-
- A **Rocket Initializer** creates the smallest durable Rocket site shape; project-specific expansion belongs to a **Coding Agent**.
485+
- A **Rocket Initializer** creates a compact Atlas-backed **Agent Starter Site** with shared layout data, starter documentation Pages, demo examples, and a **Rocket Agent Skill**; project-specific expansion belongs to a **Coding Agent**.
486486
- A **Rocket Initializer** creates a **Rocket Agent Skill** by default.
487487
- A **Rocket Initializer** creates **General Documentation Pages** in the project's documentation area for both **Standalone Rocket Sites** and documentation added to an existing codebase.
488488
- **Component Reference Pages** may live near the component they document.

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ npm install @rocket/js
7676
npx rocket init
7777
```
7878

79-
`rocket init` creates `rocket-config.js`, `docs/pages/index.rocket.md`, and a removable
80-
project-local Rocket Agent Skill. It also adds npm scripts when the names are available:
79+
`rocket init` creates a compact Atlas docs starter, including `rocket-config.js`,
80+
`docs/pages/sharedData.js`, starter Markdown Pages, a static JSON Page for a Request Demo, and a
81+
removable project-local Rocket Agent Skill. It also adds npm scripts when the names are available:
8182

8283
```json
8384
{
@@ -102,7 +103,7 @@ export default {
102103
};
103104
```
104105

105-
The generated `docs/pages/index.rocket.md` gives you a first Page:
106+
The generated `docs/pages/index.rocket.md` gives you an Atlas hero home Page:
106107

107108
````md
108109
```js server
@@ -112,14 +113,22 @@ export const config = {
112113
title: 'Rocket Site',
113114
description: 'Documentation built with Rocket.',
114115
},
116+
menu: {
117+
iconName: 'house',
118+
order: 0,
119+
},
115120
};
116121

117-
export { layout } from '@rocket/js/layout.js';
122+
import { atlasHeroLayout, atlasHeroComponents } from '@rocket/js/layouts/atlasHero.js';
123+
import { heroData } from './sharedData.js';
124+
125+
export const components = atlasHeroComponents;
126+
export const layout = pageData => atlasHeroLayout(pageData, heroData);
118127
```
119128

120129
# Rocket Site
121130

122-
This Page is rendered by Rocket.
131+
This starter is rendered with Rocket's Atlas hero layout.
123132
````
124133

125134
Then run:

0 commit comments

Comments
 (0)