This commit updates the `npx torch-lock init` command to automatically generate a `torch-config.json` file if it doesn't already exist. The generated configuration includes a randomized `nostrLock.namespace` (e.g., `torch-a1b2c3d4`) to ensure unique discovery topics for each installation, preventing message collisions across different repositories.
- Modified `src/ops.mjs` to import `crypto` and implement the config generation logic in `cmdInit`.
- Added a test case in `test/ops.test.mjs` to verify the random namespace generation.
- Uses `torch-config.example.json` as a template.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Update `torch-lock check` to scan `task-logs/<cadence>` for completed tasks.
- Add `--log-dir` and `--ignore-logs` flags to `check` command.
- Implement `getIsoWeekStr` utility for robust weekly cadence checking.
- Ensure completed agents are added to the `excluded` list, enabling the scheduler to skip them.
- Add comprehensive tests for log checking and date utilities.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactor src/lib.mjs to support dependency injection for cmdCheck, cmdLock, and cmdList.
This allows unit testing without heavy mocking frameworks or side effects.
Add test/lib.test.mjs covering:
- cmdCheck: happy path, paused/excluded agents, unknown agents.
- cmdLock: success, roster check, existing lock check, race check (lost), dry run.
- cmdList: listing locks, empty state.
Coverage for src/lib.mjs is now significantly improved.
Verification: Ran `npm test` and verified all tests pass.
Co-authored-by: PR0M3TH3AN <[email protected]>
Refactored `loadTorchConfig` to support dependency injection for `fs`, enabling true unit tests without disk I/O. Added comprehensive unit tests in `test/torch-config-unit.test.mjs`.
- Refactored `loadTorchConfig` to accept optional `fileSystem` argument.
- Created `test/torch-config-unit.test.mjs` with mocked fs tests.
- Verified existing tests pass.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Verified that `src/lib.mjs` no longer contains hardcoded relay URLs.
- Confirmed `DEFAULT_RELAYS` are defined in `src/constants.mjs` and used in `src/torch-config.mjs`.
- Added regression tests in `test/torch-config.test.mjs` to ensure `getRelays()` correctly falls back to `DEFAULT_RELAYS` and prioritizes environment variables.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Extract parseTorchConfig for better isolation in tests.
- Add _resetTorchConfigCache for deterministic unit testing.
- Implement comprehensive tests in test/torch-config.test.mjs covering:
- Path resolution with env var support.
- Normalization of cadence and status.
- Roster parsing and filtering.
- Error handling for malformed config files.
- Caching behavior.
Co-authored-by: PR0M3TH3AN <[email protected]>
- Rename `src/nostr-lock.mjs` to `src/lib.mjs` and export core functions.
- Create `bin/torch-lock.mjs` as the CLI entry point.
- Implement `dashboard` command in `src/lib.mjs` to serve the dashboard using Node.js.
- Update `package.json` to configure `bin`, `main`, and `files` for NPM packaging.
- Create `torch-config.example.json` as a template for consumers.
- Update tests and README.md to reflect the new structure.
- Exclude task-specific artifacts (logs, context) from the package while retaining prompts and docs.
Co-authored-by: PR0M3TH3AN <[email protected]>