Skip to content

feat: add npx open-stellar bootstrap CLI (#242)#307

Open
Killerjunior wants to merge 6 commits into
Bitcoindefi:mainfrom
Killerjunior:feature/bootstrap-cli
Open

feat: add npx open-stellar bootstrap CLI (#242)#307
Killerjunior wants to merge 6 commits into
Bitcoindefi:mainfrom
Killerjunior:feature/bootstrap-cli

Conversation

@Killerjunior

Copy link
Copy Markdown

Closes #242

- Add scripts/cli/bootstrap.mjs — scaffolds a new agent project:
  - Creates [project-name]/ directory with guard against existing dirs
  - Copies all template files from scripts/templates/agent/
  - Substitutes {{PROJECT_NAME}} in package.json, README.md, app/page.tsx
  - Runs npm install in the new directory
  - Prints colourised success message with next-steps
  - Validates project name (lowercase, alphanumeric + hyphens)

- Add scripts/templates/agent/ template files:
  - package.json (minimal Next.js + Stellar deps)
  - tsconfig.json
  - next.config.mjs
  - .env.example (all vars from main project with inline comments)
  - README.md (with {{PROJECT_NAME}} placeholder)
  - lib/agent.ts (minimal agent registration stub)
  - app/page.tsx (styled placeholder dashboard)

- Add scripts/cli/bootstrap.test.ts (Vitest):
  - Verifies all expected files are created
  - Verifies {{PROJECT_NAME}} substitution in package.json, README, page.tsx
  - Verifies .env.example contains all required env var keys
  - Verifies npm install creates node_modules
  - Verifies error on duplicate directory
  - Verifies error on missing project name
  - Verifies error on invalid project name (uppercase)

- Register open-stellar binary in root package.json
- Add bootstrap convenience npm script
@leocagli

Copy link
Copy Markdown
Collaborator

CI is failing with a TypeScript error in the template file:

scripts/templates/agent/app/page.tsx(41,13): error TS2353:
Object literal may only specify known properties, and 'PROJECT_NAME' does not exist in type...
error TS18004: No value exists in scope for the shorthand property 'PROJECT_NAME'

In scripts/templates/agent/app/page.tsx line 41, you're using PROJECT_NAME as a shorthand property but TypeScript can't find it in scope. Fix by declaring it first:

// At the top of the template file or before line 41:
const PROJECT_NAME = process.env.NEXT_PUBLIC_PROJECT_NAME ?? 'My Agent'

// Or if this is a template placeholder string, escape it from TS checking:
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const PROJECT_NAME = (globalThis as any).PROJECT_NAME ?? 'My Agent'

Push the fix and CI should pass!

@leocagli

Copy link
Copy Markdown
Collaborator

The latest push (fc58135) still has the same error:

scripts/templates/agent/app/page.tsx(41,13): error TS2353
'PROJECT_NAME' does not exist in type / No value exists in scope for shorthand property 'PROJECT_NAME'

The fix needs to be in scripts/templates/agent/app/page.tsx line 41 specifically. Whatever change was pushed didn't touch that file. Please open scripts/templates/agent/app/page.tsx, find line 41, and either:

// Option A: declare the variable
const PROJECT_NAME = process.env.NEXT_PUBLIC_APP_NAME ?? 'My Agent'

Or if PROJECT_NAME is a template placeholder that gets replaced at build time, exclude the templates folder from TypeScript compilation by adding to tsconfig.json:

{ "exclude": ["scripts/templates/**"] }

@Killerjunior

Copy link
Copy Markdown
Author

Changes made. Kindly re-review.

For the second PR, it is an error on my part. It was not meant for this repo.

@Killerjunior

Copy link
Copy Markdown
Author

Kindly rereview please.

@sonarqubecloud

Copy link
Copy Markdown

@leocagli leocagli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Killerjunior — the required CI ("Typecheck, tests, build, and guards") fails: scripts/cli/bootstrap.test.ts (9 tests) can't resolve scripts/cli/bootstrap.mjs:

Error: Cannot find module '/home/runner/work/Open-Stellar/scripts/cli/bootstrap.mjs'

The test references a source file that isn't included in the PR (or the path is wrong). Please add scripts/cli/bootstrap.mjs (or fix the import path) so the tests pass. SonarCloud and the spec guard are green — once CI is fully green and the branch is rebased on main, this can merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: npx open-stellar bootstrap to scaffold a new agent project

2 participants