Commit Graph
41 Commits
Author SHA1 Message Date
thePR0M3TH3AN d2db0cf25b Update generated dashboard links to torchagent.ai 2026-02-26 14:23:01 -05:00
thePR0M3TH3AN 32d0f905a6 Fix self-hosted update path collision in cmdUpdate 2026-02-26 08:41:36 -05:00
thePR0M3TH3AN 811f45b3af Harden memory workflow to reduce merge conflicts 2026-02-26 08:18:47 -05:00
thePR0M3TH3AN 1fb668064e update 2026-02-25 16:17:25 -05:00
thePR0M3TH3AN 85f9d3c4e7 Fix non-interactive init to complete with piped stdin 2026-02-25 14:54:02 -05:00
thePR0M3TH3AN 1fa4d4560e Fix host-repo scheduler config resolution and handoff defaults 2026-02-25 14:48:11 -05:00
thePR0M3TH3AN 723d9c8b53 Fix host-repo scheduler flow and init lint compatibility 2026-02-25 14:36:29 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1be3480003 feat: simplify generated TORCH dashboard link
Update `createDashboardLinkFile` in `src/ops.mjs` to generate a dashboard URL that only includes the `hashtag` parameter, as requested. This simplifies the link shared in `TORCH_DASHBOARD.md` and aligns with the expected format.

Test: Verified with reproduction script and existing `test/ops.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-25 18:59:59 +00:00
thePR0M3TH3AN 55208c2e45 Merge origin/main into refactor/lock-ops-decomposition-2507393976208881863 (resolve conflicts) 2026-02-25 12:22:43 -05:00
google-labs-jules[bot]andPR0M3TH3AN 4e244dd847 chore(ai): doc src/ops.mjs (docs-code-investigator)
- Added JSDoc to src/ops.mjs
- Created docs/ops-overview.md
- Updated run artifacts

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-22 18:23:40 +00:00
google-labs-jules[bot]andPR0M3TH3AN 003e18b93b Fix CI lint error in lock-publisher.mjs
- Ensure `src/lock-publisher.mjs` does not import `randomInt`.
- Clean up test output artifacts.
- Re-verify tests pass locally.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-21 20:48:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7c8eeb939c refactor(ops): extract cmdRemove to src/cmd-remove.mjs
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-21 20:32:12 +00:00
thePR0M3TH3AN 9fef4c4f46 update 2026-02-21 15:16:45 -05:00
google-labs-jules[bot]andPR0M3TH3AN c0c5ac5473 fix(torch-lock): re-apply fixes for circular deps and syntax errors
- Moved `withTimeout` implementation to `src/lock-utils.mjs` and exported it correctly.
- Removed duplicate local definitions of `withTimeout`, `mergeRelayList`, and `secureRandom` in `src/lock-ops.mjs` and `src/lock-publisher.mjs`.
- Fixed imports in `src/lock-ops.mjs`, `src/lock-publisher.mjs`, and `src/relay-health.mjs` to use `src/lock-utils.mjs` consistently.
- Updated `test/utils.test.mjs` and `test/utils-async.test.mjs` to fix broken imports and test definitions.
- Verified `npm run lock:complete` and `npm run scheduler:daily` execute correctly.
- Updated `src/todo/TODO_2026-02-20T03-00-00Z.md` to mark verification task as completed.
- Verified `src/relay-health.mjs` does not use `MINUTE_MS` locally, despite mysterious CI error. Confirmed imports are correct.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-21 19:23:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN eb32c839d8 Refactor cmdRemove in src/ops.mjs to improve maintainability
Extracted helper functions identifyRemovalTargets, confirmRemoval, executeRemoval, and cleanupPostRemoval to reduce complexity of cmdRemove.
Fixed JSDoc comments and removed unused parameters.
Verified with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 21:55:45 +00:00
thePR0M3TH3AN 2b706f6085 Merge pull request #359 from PR0M3TH3AN/fix/torch-init-gitignore-13639849350884611583
Ensure torch init adds .gitignore with node_modules
2026-02-19 23:10:56 -05:00
google-labs-jules[bot]andPR0M3TH3AN c36735dbde fix: ensure torch init adds .gitignore with node_modules
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 04:01:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 08d8407a7d feat(cli): enhance init output with config summary and dashboard link
- Updates `cmdInit` to output the Nostr hashtag, namespace, and a direct dashboard URL upon completion.
- Refactors `createDashboardLinkFile` to return the generated URL for console output.
- Ensures the initialization process provides clear next steps for both human users and agents.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-20 03:39:00 +00:00
thePR0M3TH3AN 158026bdb4 Merge pull request #346 from PR0M3TH3AN/claude/add-torch-removal-command-keFx5
Add cmdRemove command to completely uninstall TORCH from projects
2026-02-19 21:09:54 -05:00
Claude 7984c7de66 feat: add torch-lock remove command for complete TORCH uninstallation
Users who installed TORCH via `npm install <tarball> && npx torch-lock init`
had no built-in way to cleanly remove it. This adds a `remove` command that
detects and removes all TORCH artifacts: the torch/ directory, config files,
runtime directories (.torch/, .scheduler-memory/, task-logs/), governance
proposals, host package.json scripts, and the npm package itself.

- Add cmdRemove() in src/ops.mjs with detection, preview, confirmation, and cleanup
- Wire up `remove` command in CLI dispatcher (src/lib.mjs)
- Add TORCH_HOST_SCRIPTS constant in constants.mjs for shared script key list
- Add docs/removal.md with full manual removal instructions
- Add removal section to README.md
- Add 7 scenario tests in test/ops-remove.test.mjs

https://claude.ai/code/session_011Snrxu3iZGLtJ9pnFSajpM
2026-02-20 01:59:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN 016f3e34e2 feat: generate dashboard file and config hashtag during init
This change updates the `torch init` command to:
1.  Prompt the user for a Nostr hashtag (defaulting to `${namespace}-agent-lock`).
2.  Explicitly save the `hashtag` to `torch-config.json` under `dashboard.hashtag` for easier editing.
3.  Generate a `TORCH_DASHBOARD.md` file in the installation directory containing a link to the TORCH dashboard with the correct `hashtag`, `namespace`, and `relays` pre-filled.

This improves the onboarding experience by making it easier to find and monitor the agent locks immediately after initialization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-19 21:45:19 +00:00
Claude 639ad6877d chore: code quality, CI/CD, and DX improvements
Phase 3 — Code Quality:
- Deduplicate nowUnix() in lock-ops.mjs (import from utils.mjs)
- Promote ESLint no-unused-vars to error, fix all 46 violations
- Remove dead code: unused imports, variables, and catch bindings
- Add /* global marked */ for CDN-loaded library in dashboard

Phase 4 — CI/CD:
- Add Node.js version matrix (22, 23) to CI workflow
- Add npm audit security scan step to CI
- Add innerHTML usage check to CI pipeline
- Enable Dependabot for npm and GitHub Actions dependencies
- Create PR template

Phase 5 — Developer Experience:
- Create .env.example documenting all environment variables
- Expand CONTRIBUTING.md with commit conventions, agent/prompt
  creation guide, architecture overview, and test integrity
- Add system architecture diagram with Mermaid (docs/architecture/)

https://claude.ai/code/session_01GfwUNbgeMgXreFDbsNQMsS
2026-02-19 21:03:30 +00:00
google-labs-jules[bot]andPR0M3TH3AN 64b6f43df1 feat: add governance system for prompt evolution
Implement a comprehensive governance system to manage agent prompt changes safely.

Key features:
- **Proposal Workflow:** Prompt changes are now "proposals" stored in `src/proposals/` with metadata and diffs.
- **Governance Agent:** A new `governance-agent` reviews and applies proposals using `scripts/governance/process-proposals.mjs`.
- **Validation:** Strict validation ensures changes are limited to allowed directories (`src/prompts/daily|weekly`) and preserve required headers.
- **Lock Enhancements:** Lock events now include `promptHash`, `promptPath`, and `gitCommit` for full auditability.
- **Rollback:** New `torch-lock rollback` command restores prompts from local history (`.torch/prompt-history/`) or git.
- **CLI:** Added `proposal` (create, list, show, apply, reject) and `rollback` commands.

This establishes a "Stage -> Evaluate -> Apply" gate for prompt evolution, preventing silent drift and ensuring constitutional stability.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 21:09:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 7c41e040bd docs: align package config and documentation paths
- Update `package.json` to include `TORCH.md` and `scripts/memory/` in distribution.
- Update `README.md` to reference `TORCH.md` correctly.
- Update `src/ops.mjs` to robustly handle memory policy paths in `torch-config.json` generation.
- Update `.gitignore` to exclude `.scheduler-memory/`.
- Update `torch-config.example.json` to include memory policy with standard defaults.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 16:51:35 +00:00
google-labs-jules[bot]andPR0M3TH3AN 57f6675c64 Weekly fuzz-agent run: fixes and execution
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 15:22:04 +00:00
thePR0M3TH3AN 30212a6213 Merge pull request #275 from PR0M3TH3AN/fix-install-dir-command-injection-4005485668731201594
🔒 Fix command injection via install directory name
2026-02-18 09:47:23 -05:00
google-labs-jules[bot]andPR0M3TH3AN b1353cb79b fix: prevent command injection in init scripts by validating install dir
- Added `validateInstallDir` function to `src/ops.mjs` to enforce strict allowlist for directory names (alphanumeric, hyphens, underscores, slashes, periods).
- Integrated validation into `resolveConfiguration` to sanitize both interactive and mock inputs.
- Added comprehensive unit tests in `test/install_dir_validation.test.mjs`.

This fixes a vulnerability where malicious directory names could inject shell commands into `package.json` scripts during initialization.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:28:59 +00:00
google-labs-jules[bot]andPR0M3TH3AN ba5d86142c Refactor: Move ensureDir to src/utils.mjs
Moved the `ensureDir` utility function from `src/ops.mjs` to `src/utils.mjs` to promote code reuse and centralization.
Updated `src/ops.mjs` and `src/services/memory/index.js` to use the shared utility.
Added unit tests for `ensureDir` in `test/utils.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-18 03:28:09 +00:00
google-labs-jules[bot]andPR0M3TH3AN 68da87ac48 Refactor cmdInit in src/ops.mjs to improve modularity and maintainability
- Extracted logic into helper functions: `resolveConfiguration`, `ensureInstallDirectory`, `installAppAssets`, `installTorchAssets`, `configureTorch`, `injectHostScriptsIfNeeded`.
- Updated `cmdInit` to orchestrate these functions.
- Verified functionality with existing tests.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 19:01:15 +00:00
google-labs-jules[bot]andPR0M3TH3AN a437ddd9f7 chore(ai): refactor duplicated copying logic in src/ops.mjs
- Extracted `syncAppDirectories` and `syncAppFiles` helper functions.
- Updated `cmdInit` and `cmdUpdate` to use the new helpers.
- Improved `cmdInit` to throw an Error instead of warning when the target directory is not empty and not forced.
- Fixed hanging tests in `test/ops.test.mjs` by providing `MOCK_CONFIG`.
- Updated tests to verify strict directory check in `cmdInit`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 17:09:39 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8b5cec4890 Consolidate agent docs into TORCH.md and update installer
- Merged AGENTS.md, CLAUDE.md, and src/docs/TORCH.md into a single TORCH.md in the root.
- Updated src/ops.mjs to copy TORCH.md during init/update and correctly transform path references.
- Updated src/prompts/META_PROMPTS.md and src/prompts/scheduler-flow.md to reference TORCH.md.
- Deleted obsolete AGENTS.md, CLAUDE.md, and src/docs/TORCH.md.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-17 03:11:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN d23e6ff0b3 Refactor memory scripts and fix configuration for new installs
- Replaced fragile inline Node.js scripts in `torch-config.json` with dedicated modules: `scripts/memory/retrieve.mjs` and `scripts/memory/store.mjs`.
- Updated `src/ops.mjs` initialization logic to dynamically configure `scheduler.memoryPolicyByCadence` with correct paths based on the installation directory.
- Added default memory policy configuration to `torch-config.example.json` to guide users.
- Injected `torch:memory:list` and `torch:memory:inspect` convenience scripts into the host `package.json` during `init`.
- Removed legacy shell scripts (`run-memory-retrieval.sh`, `run-memory-store.sh`).
- Verified memory scripts function correctly and pass linting.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 17:19:55 +00:00
google-labs-jules[bot]andPR0M3TH3AN 487081f319 Improve torch init experience with interactive prompts and script injection
- Modified `init` to be interactive, asking for install directory, namespace, and relays.
- Added automatic injection of convenience scripts (`torch:check`, `torch:lock`, etc.) into the host `package.json`.
- Increased default network timeouts (30s query, 15s publish) to reduce failure rate.
- Added visual feedback (logs) during relay connection and querying.
- Refactored `src/ops.mjs` to support flexible installation paths.
- Updated `src/torch-config.mjs` to support config resolution from parent directories (e.g., when running via `npm run --prefix`).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 02:44:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN 6d2af25774 fix(init): ensure torch-config.json is created in project root
- Modified `src/ops.mjs` to create `torch-config.json` in `paths.root` instead of `paths.torchDir` during `cmdInit`.
- This aligns the initialization behavior with the documentation (`README.md`) and resolves a discrepancy found by `test/ops.test.mjs`.
- Verified with `npm test`.
- Included `docs-agent` run artifact `src/context/CONTEXT_2026-02-16T00-33-39Z.md`.
- Included `task-logs/daily/2026-02-16T00-35-14Z__docs-agent__completed.md`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 00:38:44 +00:00
google-labs-jules[bot]andPR0M3TH3AN 3f3f45b13f feat: ensure torch init installs full application package
- Modify `src/ops.mjs` to copy all critical application directories (`src`, `bin`, `dashboard`, `scripts`, etc.) and files (`package.json`, `build.mjs`) to the `torch/` directory during `init` and `update`.
- Update `src/ops.mjs` to generate `torch-config.json` inside the `torch/` directory (if missing) instead of only in the project root, supporting self-contained execution.
- Update `src/roster.mjs` to fallback to checking for `roster.json` in the current working directory, enabling `npm run` commands to work correctly when executed from within the `torch/` directory.
- This allows `torch/` to function as a standalone sub-package within a project, where users can `cd torch`, `npm install`, and `npm run build` as expected.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-16 00:00:28 +00:00
google-labs-jules[bot]andPR0M3TH3AN 0f3fd3209f feat: random namespace generation in init
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]>
2026-02-14 23:19:25 +00:00
google-labs-jules[bot]andPR0M3TH3AN eb7ce149c7 Package audit scripts and update prompts for consumer repos
- Add `scripts/check-file-size.mjs` and `scripts/check-innerhtml.mjs` to `package.json` files list.
- Update `src/ops.mjs` to copy these scripts to `torch/scripts/` during `init` and `update` commands.
- Update all agent prompts in `src/prompts/` to reference `torch/scripts/` instead of `scripts/`.
- Ensure `torch/scripts/agent/` directory is created.
- Scripts are treated as "evolving" files (preserved on update unless forced).

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 18:04:15 +00:00
thePR0M3TH3AN 6f7098fcbb Merge pull request #65 from PR0M3TH3AN/refactor/redundant-check-ops-8051921680686035210
Refactor ensureDir to remove redundant existence check
2026-02-14 09:32:03 -05:00
google-labs-jules[bot]andPR0M3TH3AN 758d3c3c56 Refactor ensureDir to remove redundant existence check
- Remove explicit `fs.existsSync` check in `ensureDir`.
- Rely on `fs.mkdirSync(dir, { recursive: true })` idempotency.
- Verified with existing tests in `test/ops.test.mjs`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 14:13:58 +00:00
google-labs-jules[bot]andPR0M3TH3AN eee6dfa09f Refactor cmdInit and cmdUpdate to be synchronous
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 14:12:20 +00:00
google-labs-jules[bot]andPR0M3TH3AN b0381b8c39 feat: add init and update commands for user-space configuration
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-14 07:21:05 +00:00