Skip to content

Commit dbdd254

Browse files
committed
feat: configurator v2
1 parent d2b2e02 commit dbdd254

34 files changed

Lines changed: 4275 additions & 1187 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ _*
2323
TODO.txt
2424
**/.env
2525
**/id_rsa*
26+
.agent
27+
.claude
28+
CLAUDE.md
2629
.task/
2730
attic.txt
2831
**/venv/

AGENTS.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Apache OpenServerless Task Agent Guidelines
2+
3+
This file provides instructions for agentic coding agents working in this repository.
4+
5+
6+
## Setup commands
7+
8+
- Install Dependencies: `bun install`
9+
- Start development server: ``
10+
- Build the configurator utility: `cd util/config/configurator && bun run build`
11+
12+
## Testing instructions
13+
- Run tests: `bun test`
14+
15+
- Run a single test: `bun test util/config/configurator/tests/index.test.ts`
16+
- Run tests with verbose output `bun test --reporter=verbose`
17+
18+
## Running the application
19+
- Run the configurator utility: `cd util/config/configurator && bun run start`
20+
- Run the configurator utility with a specified configuration file: `bun run start -- <config-file>`
21+
- Run the configurator utility with a specified configuration file overriding existing values: `bun run start -- <config-file> [--override]`
22+
23+
24+
## Code style
25+
26+
- TypeScript strict mode
27+
28+
### Language & Version
29+
- Primary language: TypeScript
30+
- Runtime: Bun (Node.js compatible)
31+
- Target ES version: ES2022+
32+
- Module system: ES Modules (`"type": "module"` in package.json)
33+
34+
### File Organization
35+
- TypeScript files: `.ts` extension
36+
- Test files: `*.test.ts` located in `__tests__` or `tests` directories
37+
- Configuration: TOML (`.toml`) or JSON (`.json`)
38+
- Operations definitions: YAML (`.yml`)
39+
40+
### Imports
41+
1. **Order**:
42+
- Built-in Node.js/Bun modules (e.g., `import { $ } from "bun";`)
43+
- Third-party libraries (e.g., `import { select } from "@clack/prompts";`)
44+
- Local application files (relative paths)
45+
46+
2. **Syntax**:
47+
- Use ES module syntax: `import { foo } from "bar";`
48+
- Default imports: `import foo from "bar";`
49+
- Avoid `require()` syntax
50+
51+
3. **Specific Rules**:
52+
- Import types separately when needed: `import type { TypeName } from "./types";`
53+
- Group related imports together
54+
- No unused imports allowed
55+
56+
### Formatting
57+
- **Indentation**: 2 spaces (not tabs)
58+
- **Line length**: Maximum 100 characters (prefer 80-100)
59+
- **Semicolons**: Required (use semicolons to terminate statements)
60+
- **Quotes**:
61+
- Single quotes (`'`) for strings
62+
- Template literals (`` ` ``) for multi-line or interpolated strings
63+
- Double quotes (`"`) only when required by JSON or external specifications
64+
- **Commas**: Trailing commas in multi-line objects/arrays
65+
- **Braces**:
66+
- Opening brace on the same line as the statement
67+
- Closing brace on its own line
68+
- No braces for single-line conditionals when it improves readability
69+
70+
### Types
71+
- **Type Annotations**:
72+
- Always annotate function parameters
73+
- Annotate return values for public functions
74+
- Use type inference for local variables when obvious
75+
- **Interfaces vs Types**:
76+
- Use `interface` for object shapes that may be extended
77+
- Use `type` for unions, primitives, complex mapped types
78+
- **Strictness**: Enable strict TypeScript options (null checks, no implicit any, etc.)
79+
80+
### Naming Conventions
81+
- **Files & Directories**: kebab-case (e.g., `configurator.ts`, `all-config-parameters.toml`)
82+
- **Variables & Functions**: camelCase (e.g., `readPositionalFile`, `isInputConfigValid`)
83+
- **Constants**: UPPER_SNAKE_CASE (e.g., `HelpMsg`, `AdditionalArgsMsg`)
84+
- **Types & Interfaces**: PascalCase (e.g., `OpsConfig`, `PromptData`)
85+
- **Classes**: PascalCase (though minimal class usage in this codebase)
86+
- **Boolean Variables**: Prefix with `is`, `has`, `should`, `can` (e.g., `isValid`, `hasError`)
87+
88+
### Error Handling
89+
- **Early Returns**: Handle error conditions first with early returns
90+
- **Async Functions**: Use try/catch for async operations that can fail
91+
- **Bun Specific**:
92+
- Use `process.exit(1)` for error exits
93+
- Use `process.exit(0)` for successful exits
94+
- Check `success` property on result objects from utils
95+
- **Messages**:
96+
- Export constant error messages (as seen with `HelpMsg`, `NotValidJsonMsg`, etc.)
97+
- Use descriptive, user-friendly error messages
98+
- Log warnings with `console.warn()`, errors with `console.error()`
99+
100+
### Specific Patterns from Codebase
101+
- **Configuration Validation**: Separate validation functions (e.g., `isInputConfigValid`)
102+
- **File Operations**:
103+
- Read → Parse → Validate pattern
104+
- Return objects with `{ success: boolean, message?: string, ...data }` shape
105+
- **CLI Argument Parsing**: Use `util.parseArgs` with strict mode and positionals
106+
- **Interactive Prompts**: Use `@clack/prompts` with proper cancellation handling
107+
- **Shell Commands**: Use Bun's `$` helper for shell commands with `.quiet()` to suppress output
108+
109+
### Testing
110+
- **Framework**: Bun's built-in test framework (`bun:test`)
111+
- **File Naming**: `*.test.ts`
112+
- **Structure**:
113+
- Use `describe()` for test suites
114+
- Use `test()` for individual tests
115+
- Use `expect()` for assertions
116+
- **Mocking**: Minimal mocking; prefer testing actual behavior
117+
- **Async Tests**: Return promises or use `async`/`await`
118+
119+
### Comments
120+
- Use JSDoc-style comments for public APIs
121+
- Use `//` for inline comments explaining why (not what)
122+
- Keep comments up-to-date; delete outdated comments
123+
- TODO comments should include GitHub issue references when possible
124+
- When adding bash scripts in the documentation, always keep commands separate (one command per ```bash section)
125+
126+
### Security
127+
- Never log secrets or credentials
128+
- Use `password` prompt type for sensitive inputs
129+
- Validate and sanitize all external inputs
130+
- Follow the principle of least privilege
131+
132+
## Task Tracking
133+
134+
For any task that involves more than one non-trivial step (multi-file changes, investigations with uncertain outcomes, features spanning multiple components), maintain a TODO list using the `TaskCreate` / `TaskUpdate` / `TaskList` tools:
135+
136+
1. **Start**: call `TaskCreate` to create one task entry per step before writing any code.
137+
2. **Progress**: call `TaskUpdate` (status `in_progress`) when starting a step, `completed` when it is done.
138+
3. **Visibility**: after completing a task, call `TaskList` to confirm no steps are left open.
139+
140+
Keep task titles short and action-oriented ("Add `type` field to ConfigParameter", "Update parseParameter", etc.).
141+
Do **not** create tasks for trivial single-file edits or quick answers.
142+
143+
## Additional Notes
144+
- This repository uses Bun as its primary runtime/package manager
145+
- Configuration is driven by TOML files and environment variables
146+
- The `opsfile.yml` defines operational tasks but is not part of the main TypeScript codebase
147+
- When modifying the configurator utility, remember to rebuild after changes

bun.lock

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"@clack/prompts": "^1.0.1",
4+
"js-toml": "^1.0.2",
5+
"toml": "^3.0.0"
6+
}
7+
}

pnpm-lock.yaml

Lines changed: 132 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)