Compare commits

..

8 Commits

Author SHA1 Message Date
51aa6eddad 4.2.0
Some checks failed
Default (tags) / security (push) Successful in 54s
Default (tags) / test (push) Failing after 4m1s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-08-29 16:22:04 +00:00
5910724b3c feat(cli): Add reset CLI command to stop all processes and clear saved configurations; integrate interactive confirmation and client plugin updates 2025-08-29 16:22:04 +00:00
a67d247e9c 4.1.1
Some checks failed
Default (tags) / security (push) Successful in 40s
Default (tags) / test (push) Failing after 3m57s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-08-29 13:35:20 +00:00
f7bc56e676 fix(daemon): Bump @push.rocks/smartdaemon to ^2.0.9 2025-08-29 13:35:20 +00:00
7bfda01768 4.1.0
Some checks failed
Default (tags) / security (push) Successful in 51s
Default (tags) / test (push) Failing after 3m57s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-08-29 12:16:43 +00:00
27384d03c7 feat(cli): Add support for restarting all processes from CLI; improve usage message and reporting 2025-08-29 12:16:43 +00:00
47afd4739a 4.0.0
Some checks failed
Default (tags) / security (push) Successful in 39s
Default (tags) / test (push) Failing after 3m57s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-08-29 09:43:54 +00:00
4db128edaf BREAKING CHANGE(cli): Add persistent process registration (tspm add), alias remove, and change start to use saved process IDs (breaking CLI behavior) 2025-08-29 09:43:54 +00:00
17 changed files with 655 additions and 189 deletions

View File

@@ -1,5 +1,36 @@
# Changelog
## 2025-08-29 - 4.2.0 - feat(cli)
Add 'reset' CLI command to stop all processes and clear saved configurations; integrate interactive confirmation and client plugin updates
- Add new CLI command 'reset' (ts/cli/commands/reset.ts) which stops all processes and removes saved process configurations after an interactive confirmation.
- Use @push.rocks/smartinteract for a confirmation prompt before destructive action.
- Register the new reset command in the CLI bootstrap (ts/cli/index.ts).
- Expose smartinteract from ts/plugins.ts and add @push.rocks/smartinteract to package.json dependencies.
- Introduce a lightweight client plugin shim (ts/client/plugins.ts) and switch tspm.ipcclient to import client plugins from ./plugins.js.
## 2025-08-29 - 4.1.1 - fix(daemon)
Bump @push.rocks/smartdaemon to ^2.0.9
- Update @push.rocks/smartdaemon from ^2.0.8 to ^2.0.9 (dependency version bump)
## 2025-08-29 - 4.1.0 - feat(cli)
Add support for restarting all processes from CLI; improve usage message and reporting
- CLI 'restart' command now accepts 'all' to restart all processes via the daemon (tspm restart all).
- Improved usage/help output when no process id is provided.
- CLI now prints summaries of restarted process IDs and failed restarts and sets a non-zero exit code when any restarts failed.
## 2025-08-29 - 4.0.0 - BREAKING CHANGE(cli)
Add persistent process registration (tspm add), alias remove, and change start to use saved process IDs (breaking CLI behavior)
- Add a new CLI command `tspm add` that registers a process configuration without starting it; daemon assigns a sequential numeric ID and returns the stored config.
- Change `tspm start` to accept a process ID and start the saved configuration instead of accepting ad-hoc commands/files. This is a breaking change to the CLI contract.
- Add `remove` as an alias for the existing `delete` command; both CLI and daemon now support `remove` which stops and deletes the stored process.
- Daemon and IPC protocol updated to support `add` and `remove` methods; shared IPC types extended accordingly.
- ProcessManager: implemented add() and getNextSequentialId() to persist configs and produce numeric IDs.
- CLI registration updated (registerIpcCommand) to accept multiple command names, enabling aliases for commands.
## 2025-08-29 - 3.1.3 - fix(client)
Improve IPC client robustness and daemon debug logging; update tests and package metadata

View File

@@ -1,6 +1,6 @@
{
"name": "@git.zone/tspm",
"version": "3.1.3",
"version": "4.2.0",
"private": false,
"description": "a no fuzz process manager",
"main": "dist_ts/index.js",
@@ -35,7 +35,8 @@
"@push.rocks/npmextra": "^5.3.3",
"@push.rocks/projectinfo": "^5.0.2",
"@push.rocks/smartcli": "^4.0.11",
"@push.rocks/smartdaemon": "^2.0.8",
"@push.rocks/smartinteract": "^2.0.16",
"@push.rocks/smartdaemon": "^2.0.9",
"@push.rocks/smartipc": "^2.2.1",
"@push.rocks/smartpath": "^6.0.0",
"pidusage": "^4.0.1",

322
pnpm-lock.yaml generated
View File

@@ -18,8 +18,11 @@ importers:
specifier: ^4.0.11
version: 4.0.11
'@push.rocks/smartdaemon':
specifier: ^2.0.8
version: 2.0.8
specifier: ^2.0.9
version: 2.0.9
'@push.rocks/smartinteract':
specifier: ^2.0.16
version: 2.0.16
'@push.rocks/smartipc':
specifier: ^2.2.1
version: 2.2.1
@@ -551,6 +554,62 @@ packages:
resolution: {integrity: sha512-mfOoUlIw8VBiJYPrl5RZfMzkXC/z7gbSpi2ecycrj/gRWLq2CMV+Q+0G+JPjeOmuNFgg0skEIzkVFzVYFP6URw==}
engines: {node: '>=18.0.0'}
'@inquirer/checkbox@3.0.1':
resolution: {integrity: sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ==}
engines: {node: '>=18'}
'@inquirer/confirm@4.0.1':
resolution: {integrity: sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w==}
engines: {node: '>=18'}
'@inquirer/core@9.2.1':
resolution: {integrity: sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg==}
engines: {node: '>=18'}
'@inquirer/editor@3.0.1':
resolution: {integrity: sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q==}
engines: {node: '>=18'}
'@inquirer/expand@3.0.1':
resolution: {integrity: sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ==}
engines: {node: '>=18'}
'@inquirer/figures@1.0.13':
resolution: {integrity: sha512-lGPVU3yO9ZNqA7vTYz26jny41lE7yoQansmqdMLBEfqaGsmdg7V3W9mK9Pvb5IL4EVZ9GnSDGMO/cJXud5dMaw==}
engines: {node: '>=18'}
'@inquirer/input@3.0.1':
resolution: {integrity: sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg==}
engines: {node: '>=18'}
'@inquirer/number@2.0.1':
resolution: {integrity: sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ==}
engines: {node: '>=18'}
'@inquirer/password@3.0.1':
resolution: {integrity: sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ==}
engines: {node: '>=18'}
'@inquirer/prompts@6.0.1':
resolution: {integrity: sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==}
engines: {node: '>=18'}
'@inquirer/rawlist@3.0.1':
resolution: {integrity: sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ==}
engines: {node: '>=18'}
'@inquirer/search@2.0.1':
resolution: {integrity: sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg==}
engines: {node: '>=18'}
'@inquirer/select@3.0.1':
resolution: {integrity: sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q==}
engines: {node: '>=18'}
'@inquirer/type@2.0.0':
resolution: {integrity: sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==}
engines: {node: '>=18'}
'@isaacs/balanced-match@4.0.1':
resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==}
engines: {node: 20 || >=22}
@@ -755,8 +814,8 @@ packages:
'@push.rocks/smartcrypto@2.0.4':
resolution: {integrity: sha512-1+/5bsjyataf5uUkUNnnVXGRAt+gHVk1KDzozjTqgqJxHvQk1d9fVDohL6CxUhUucTPtu5VR5xNBiV8YCDuGyw==}
'@push.rocks/smartdaemon@2.0.8':
resolution: {integrity: sha512-92qCS8XqGhQrCBDrz5L+WrWzlAggy93mXacVx9zEzGK41QwxRxZSMfxEMTxq4FO9YD4Kymffesav7S3ivCuJeQ==}
'@push.rocks/smartdaemon@2.0.9':
resolution: {integrity: sha512-TJd2N/vMAY3qpuy7ub0btNsSqdy7oU/hF/D+BbmfJVAiTKpvlgtCXKE5POwfuee03SONyh8LuH5Ey1ycIpsEHA==}
'@push.rocks/smartdata@5.16.4':
resolution: {integrity: sha512-COiKw8yk9iAcLN44WmZHG8Gi0v+HGkgM8Osoq7Cns+UsOA+grPepqbN2r0XPG1fm5vOdJcaydi2ZU0xrnbGVvQ==}
@@ -803,6 +862,9 @@ packages:
'@push.rocks/smarthash@3.2.3':
resolution: {integrity: sha512-fBPQCGYtOlfLORm9tI3MyoJVT8bixs3MNTAfDDGBw91UKfOVOrPk5jBU+PwVnqZl7IE5mc9b+4wqAJn3giqEpw==}
'@push.rocks/smartinteract@2.0.16':
resolution: {integrity: sha512-eltvVRRUKBKd77DSFA4DPY2g4V4teZLNe8A93CDy/WglglYcUjxMoLY/b0DFTWCWKYT+yjk6Fe6p0FRrvX9Yvg==}
'@push.rocks/smartipc@2.2.1':
resolution: {integrity: sha512-yBFZwJsWRyVdN1YRSiHafRMfn0PYIi2IStcQqPkiU4Srr6XPDMZD3mmIeV2V1WL6bWvRWf+4WF9Y+rLhj4jGdA==}
@@ -842,6 +904,9 @@ packages:
'@push.rocks/smartmongo@2.0.12':
resolution: {integrity: sha512-NglYiO14BikxnlvW6JF18FtopBtaWQEGAtPxHmmSCbyhU8Mi0aEFO7VgCasE9Kguba/wcR597qhcDEdcpBg1eQ==}
'@push.rocks/smartnetwork@3.0.2':
resolution: {integrity: sha512-s6CNGzQ1n/d/6cOKXbxeW6/tO//dr1woLqI01g7XhqTriw0nsm2G2kWaZh2J0VOguGNWBgQVCIpR0LjdRNWb3g==}
'@push.rocks/smartnetwork@4.1.2':
resolution: {integrity: sha512-TjucG72ooHgzAUpNu2LAv4iFoettmZq2aEWhhzIa7AKcOvt4yxsk3Vl73guhKRohTfhdRauPcH5OHISLUHJbYA==}
@@ -923,8 +988,8 @@ packages:
'@push.rocks/smartstring@4.0.15':
resolution: {integrity: sha512-NTNeOjWyg+aHtBTiQEyXamr7oTvYZ3wS1fudHo9ua7CLrykpK+i+RxFyJaLg1zB5x9xQF3NLEQecB14HPFX8Cg==}
'@push.rocks/smartsystem@3.0.1':
resolution: {integrity: sha512-+W9AiSJWcRAjthqDFT8rDli2+5k3bk8c9Psndy3uKN2YbaQkMZwWptZRI3WgpXMG9NhsjF8XrkyiH/xHv9AxzQ==}
'@push.rocks/smartsystem@3.0.7':
resolution: {integrity: sha512-FSzrJKY+pAIxlPR1cQgUd/Edy82UDusl4n2aA+Fe564Qf7KHfFY9sTapjX1JJU6zP/hmBKWzApKa7/m+qF6Tog==}
'@push.rocks/smarttime@4.1.1':
resolution: {integrity: sha512-Ha/3J/G+zfTl4ahpZgF6oUOZnUjpLhrBja0OQ2cloFxF9sKT8I1COaSqIfBGDtoK2Nly4UD4aTJ3JcJNOg/kgA==}
@@ -998,10 +1063,6 @@ packages:
resolution: {integrity: sha512-PLvBNVeuY9BERNLq3PFDkhnHHc0RpilEGHd4aUI5XRFlZF++LETdLxPbxw+DHbvHlkUf/nep09f7rrL9Tqub1Q==}
deprecated: This package has been deprecated in favour of the new package at @push.rocks/smartmatch
'@pushrocks/smartnetwork@3.0.2':
resolution: {integrity: sha512-XKVeTzf22IRgAvY9m8naFlsjh5yYVCU4/Dqi7XnxQUVfrnrcNIJVo+9JIYjQetLbHiUOHAnthlZVP5yXppOxyw==}
deprecated: This package has been deprecated in favour of the new package at @push.rocks/smartnetwork
'@pushrocks/smartping@1.0.8':
resolution: {integrity: sha512-VM2gfS1sTuycj/jHyDa0lDntkPe7/JT0b2kGsy265RkichAJZkoEp3fboRJH/WAdzM8T4Du64JYgZkc8v2HHQg==}
deprecated: This package has been deprecated in favour of the new package at @push.rocks/smartping
@@ -1574,6 +1635,9 @@ packages:
'@types/ms@2.1.0':
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
'@types/mute-stream@0.0.4':
resolution: {integrity: sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==}
'@types/node-forge@1.3.14':
resolution: {integrity: sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==}
@@ -1661,6 +1725,9 @@ packages:
'@types/which@3.0.4':
resolution: {integrity: sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==}
'@types/wrap-ansi@3.0.0':
resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==}
'@types/ws@7.4.7':
resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==}
@@ -1939,6 +2006,9 @@ packages:
character-entities@2.0.2:
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
chardet@0.7.0:
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
chokidar@4.0.3:
resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==}
engines: {node: '>= 14.16.0'}
@@ -1968,6 +2038,10 @@ packages:
resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==}
engines: {node: '>=8'}
cli-width@4.1.0:
resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==}
engines: {node: '>= 12'}
cliui@7.0.4:
resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==}
@@ -2400,6 +2474,10 @@ packages:
extend@3.0.2:
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
external-editor@3.1.0:
resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==}
engines: {node: '>=4'}
extract-zip@2.0.1:
resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==}
engines: {node: '>= 10.17.0'}
@@ -2779,6 +2857,10 @@ packages:
ini@1.3.8:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
inquirer@11.1.0:
resolution: {integrity: sha512-CmLAZT65GG/v30c+D2Fk8+ceP6pxD6RL+hIUOWAltCmeyEqWYwqu9v76q03OvjyZ3AB0C1Ala2stn1z/rMqGEw==}
engines: {node: '>=18'}
internal-ip@6.2.0:
resolution: {integrity: sha512-D8WGsR6yDt8uq7vDMu7mjcR+yRMm3dW8yufyChmszWRjcSHuxLBkR3GdS2HZAjodsaGuCvXeEJpueisXJULghg==}
engines: {node: '>=10'}
@@ -3430,6 +3512,10 @@ packages:
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
mute-stream@1.0.0:
resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
nanocolors@0.2.13:
resolution: {integrity: sha512-0n3mSAQLPpGLV9ORXT5+C/D4mwew7Ebws69Hx4E2sgz2ZA5+32Q80B9tL8PbL7XHnRDiAxH/pnrUJ9a4fkTNTA==}
@@ -3525,6 +3611,10 @@ packages:
resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
engines: {node: '>=12'}
os-tmpdir@1.0.2:
resolution: {integrity: sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=}
engines: {node: '>=0.10.0'}
p-cancelable@3.0.0:
resolution: {integrity: sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==}
engines: {node: '>=12.20'}
@@ -3872,6 +3962,10 @@ packages:
rss-parser@3.13.0:
resolution: {integrity: sha512-7jWUBV5yGN3rqMMj7CZufl/291QAhvrrGpDNE4k/02ZchL0npisiYYqULF71jCEKoIiHvK/Q2e6IkDwPziT7+w==}
run-async@3.0.0:
resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==}
engines: {node: '>=0.12.0'}
run-parallel@1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
@@ -4140,14 +4234,14 @@ packages:
symbol-tree@3.2.4:
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
systeminformation@5.25.11:
resolution: {integrity: sha512-jI01fn/t47rrLTQB0FTlMCC+5dYx8o0RRF+R4BPiUNsvg5OdY0s9DKMFmJGrx5SwMZQ4cag0Gl6v8oycso9b/g==}
systeminformation@5.27.7:
resolution: {integrity: sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==}
engines: {node: '>=8.0.0'}
os: [darwin, linux, win32, freebsd, openbsd, netbsd, sunos, android]
hasBin: true
systeminformation@5.27.7:
resolution: {integrity: sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==}
systeminformation@5.27.8:
resolution: {integrity: sha512-d3Z0gaQO1MlUxzDUKsmXz5y4TOBCMZ8IyijzaYOykV3AcNOTQ7mT+tpndUOXYNSxzLK3la8G32xiUFvZ0/s6PA==}
engines: {node: '>=8.0.0'}
os: [darwin, linux, win32, freebsd, openbsd, netbsd, sunos, android]
hasBin: true
@@ -4183,6 +4277,10 @@ packages:
tiny-worker@2.3.0:
resolution: {integrity: sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==}
tmp@0.0.33:
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
engines: {node: '>=0.6.0'}
to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -4488,6 +4586,10 @@ packages:
resolution: {integrity: sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==}
engines: {node: '>= 4.0.0'}
yoctocolors-cjs@2.1.3:
resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==}
engines: {node: '>=18'}
zod@3.25.76:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
@@ -5687,6 +5789,102 @@ snapshots:
dependencies:
happy-dom: 15.11.7
'@inquirer/checkbox@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.13
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
yoctocolors-cjs: 2.1.3
'@inquirer/confirm@4.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/core@9.2.1':
dependencies:
'@inquirer/figures': 1.0.13
'@inquirer/type': 2.0.0
'@types/mute-stream': 0.0.4
'@types/node': 22.13.10
'@types/wrap-ansi': 3.0.0
ansi-escapes: 4.3.2
cli-width: 4.1.0
mute-stream: 1.0.0
signal-exit: 4.1.0
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
yoctocolors-cjs: 2.1.3
'@inquirer/editor@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
external-editor: 3.1.0
'@inquirer/expand@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/figures@1.0.13': {}
'@inquirer/input@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/number@2.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/password@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
'@inquirer/prompts@6.0.1':
dependencies:
'@inquirer/checkbox': 3.0.1
'@inquirer/confirm': 4.0.1
'@inquirer/editor': 3.0.1
'@inquirer/expand': 3.0.1
'@inquirer/input': 3.0.1
'@inquirer/number': 2.0.1
'@inquirer/password': 3.0.1
'@inquirer/rawlist': 3.0.1
'@inquirer/search': 2.0.1
'@inquirer/select': 3.0.1
'@inquirer/rawlist@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/search@2.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.13
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/select@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.13
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
yoctocolors-cjs: 2.1.3
'@inquirer/type@2.0.0':
dependencies:
mute-stream: 1.0.0
'@isaacs/balanced-match@4.0.1': {}
'@isaacs/brace-expansion@5.0.0':
@@ -6074,16 +6272,16 @@ snapshots:
'@types/node-forge': 1.3.14
node-forge: 1.3.1
'@push.rocks/smartdaemon@2.0.8':
'@push.rocks/smartdaemon@2.0.9':
dependencies:
'@push.rocks/lik': 6.1.0
'@push.rocks/smartfile': 11.2.0
'@push.rocks/lik': 6.2.2
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartfm': 2.2.2
'@push.rocks/smartlog': 3.0.7
'@push.rocks/smartlog': 3.1.8
'@push.rocks/smartlog-destination-local': 9.0.2
'@push.rocks/smartpath': 5.1.0
'@push.rocks/smartshell': 3.2.3
'@push.rocks/smartsystem': 3.0.1
'@push.rocks/smartpath': 6.0.0
'@push.rocks/smartshell': 3.3.0
'@push.rocks/smartsystem': 3.0.7
'@push.rocks/smartdata@5.16.4(@aws-sdk/credential-providers@3.758.0)(socks@2.8.7)':
dependencies:
@@ -6222,6 +6420,13 @@ snapshots:
'@types/through2': 2.0.41
through2: 4.0.2
'@push.rocks/smartinteract@2.0.16':
dependencies:
'@push.rocks/lik': 6.2.2
'@push.rocks/smartobject': 1.0.12
'@push.rocks/smartpromise': 4.2.3
inquirer: 11.1.0
'@push.rocks/smartipc@2.2.1':
dependencies:
'@push.rocks/smartdelay': 3.0.5
@@ -6318,6 +6523,16 @@ snapshots:
- socks
- supports-color
'@push.rocks/smartnetwork@3.0.2':
dependencies:
'@pushrocks/smartping': 1.0.8
'@pushrocks/smartpromise': 3.1.10
'@pushrocks/smartstring': 4.0.7
'@types/default-gateway': 3.0.1
isopen: 1.3.0
public-ip: 6.0.2
systeminformation: 5.27.8
'@push.rocks/smartnetwork@4.1.2':
dependencies:
'@push.rocks/smartping': 1.0.8
@@ -6559,13 +6774,13 @@ snapshots:
strip-indent: 4.0.0
url: 0.11.4
'@push.rocks/smartsystem@3.0.1':
'@push.rocks/smartsystem@3.0.7':
dependencies:
'@pushrocks/lik': 6.0.2
'@pushrocks/smartenv': 5.0.5
'@pushrocks/smartnetwork': 3.0.2
'@pushrocks/smartpromise': 3.1.10
systeminformation: 5.25.11
'@push.rocks/lik': 6.2.2
'@push.rocks/smartenv': 5.0.13
'@push.rocks/smartnetwork': 3.0.2
'@push.rocks/smartpromise': 4.2.3
systeminformation: 5.27.8
'@push.rocks/smarttime@4.1.1':
dependencies:
@@ -6721,16 +6936,6 @@ snapshots:
dependencies:
matcher: 5.0.0
'@pushrocks/smartnetwork@3.0.2':
dependencies:
'@pushrocks/smartping': 1.0.8
'@pushrocks/smartpromise': 3.1.10
'@pushrocks/smartstring': 4.0.7
'@types/default-gateway': 3.0.1
isopen: 1.3.0
public-ip: 6.0.2
systeminformation: 5.25.11
'@pushrocks/smartping@1.0.8':
dependencies:
'@types/ping': 0.4.4
@@ -7476,6 +7681,10 @@ snapshots:
'@types/ms@2.1.0': {}
'@types/mute-stream@0.0.4':
dependencies:
'@types/node': 22.13.10
'@types/node-forge@1.3.14':
dependencies:
'@types/node': 22.13.10
@@ -7562,6 +7771,8 @@ snapshots:
'@types/which@3.0.4': {}
'@types/wrap-ansi@3.0.0': {}
'@types/ws@7.4.7':
dependencies:
'@types/node': 22.13.10
@@ -7889,6 +8100,8 @@ snapshots:
character-entities@2.0.2: {}
chardet@0.7.0: {}
chokidar@4.0.3:
dependencies:
readdirp: 4.1.2
@@ -7915,6 +8128,8 @@ snapshots:
dependencies:
restore-cursor: 3.1.0
cli-width@4.1.0: {}
cliui@7.0.4:
dependencies:
string-width: 4.2.3
@@ -8371,6 +8586,12 @@ snapshots:
extend@3.0.2: {}
external-editor@3.1.0:
dependencies:
chardet: 0.7.0
iconv-lite: 0.4.24
tmp: 0.0.33
extract-zip@2.0.1:
dependencies:
debug: 4.4.1
@@ -8843,6 +9064,17 @@ snapshots:
ini@1.3.8: {}
inquirer@11.1.0:
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/prompts': 6.0.1
'@inquirer/type': 2.0.0
'@types/mute-stream': 0.0.4
ansi-escapes: 4.3.2
mute-stream: 1.0.0
run-async: 3.0.0
rxjs: 7.8.2
internal-ip@6.2.0:
dependencies:
default-gateway: 6.0.3
@@ -9681,6 +9913,8 @@ snapshots:
ms@2.1.3: {}
mute-stream@1.0.0: {}
nanocolors@0.2.13: {}
nanoid@3.3.11: {}
@@ -9761,6 +9995,8 @@ snapshots:
is-docker: 2.2.1
is-wsl: 2.2.0
os-tmpdir@1.0.2: {}
p-cancelable@3.0.0: {}
p-event@4.2.0:
@@ -10180,6 +10416,8 @@ snapshots:
entities: 2.2.0
xml2js: 0.5.0
run-async@3.0.0: {}
run-parallel@1.2.0:
dependencies:
queue-microtask: 1.2.3
@@ -10503,10 +10741,10 @@ snapshots:
symbol-tree@3.2.4: {}
systeminformation@5.25.11: {}
systeminformation@5.27.7: {}
systeminformation@5.27.8: {}
tar-fs@3.1.0:
dependencies:
pump: 3.0.3
@@ -10559,6 +10797,10 @@ snapshots:
dependencies:
esm: 3.2.25
tmp@0.0.33:
dependencies:
os-tmpdir: 1.0.2
to-regex-range@5.0.1:
dependencies:
is-number: 7.0.0
@@ -10829,6 +11071,8 @@ snapshots:
ylru@1.4.0: {}
yoctocolors-cjs@2.1.3: {}
zod@3.25.76: {}
zwitch@2.0.4: {}

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tspm',
version: '3.1.3',
version: '4.2.0',
description: 'a no fuzz process manager'
}

View File

@@ -0,0 +1,91 @@
import * as plugins from '../../../plugins.js';
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
import type { CliArguments } from '../../types.js';
import { parseMemoryString, formatMemory } from '../../helpers/memory.js';
import { registerIpcCommand } from '../../registration/index.js';
export function registerAddCommand(smartcli: plugins.smartcli.Smartcli) {
registerIpcCommand(
smartcli,
'add',
async (argvArg: CliArguments) => {
const args = argvArg._.slice(1);
if (args.length === 0) {
console.error('Error: Please provide a command or .ts file');
console.log('Usage: tspm add <command|file.ts> [options]');
console.log('\nOptions:');
console.log(' --name <name> Optional name');
console.log(' --memory <size> Memory limit (e.g., 512MB, 2GB)');
console.log(' --cwd <path> Working directory');
console.log(' --watch Watch for file changes');
console.log(' --watch-paths <paths> Comma-separated paths');
console.log(' --autorestart Auto-restart on crash (default true)');
return;
}
const script = args.join(' ');
const projectDir = argvArg.cwd || process.cwd();
const memoryLimit = argvArg.memory
? parseMemoryString(argvArg.memory)
: 512 * 1024 * 1024;
// Resolve .ts single-file execution via tsx if needed
const parts = script.split(' ');
const first = parts[0];
let command = script;
let cmdArgs: string[] | undefined;
if (parts.length === 1 && first.endsWith('.ts')) {
try {
const { createRequire } = await import('module');
const require = createRequire(import.meta.url);
const tsxPath = require.resolve('tsx/dist/cli.mjs');
const filePath = plugins.path.isAbsolute(first)
? first
: plugins.path.join(projectDir, first);
command = tsxPath;
cmdArgs = [filePath];
} catch {
command = 'tsx';
cmdArgs = [first];
}
}
const name = argvArg.name || script;
const watch = argvArg.watch || false;
const autorestart = argvArg.autorestart !== false;
const watchPaths = argvArg.watchPaths
? typeof argvArg.watchPaths === 'string'
? (argvArg.watchPaths as string).split(',')
: argvArg.watchPaths
: undefined;
console.log('Adding process configuration:');
console.log(` Command: ${script}${parts.length === 1 && first.endsWith('.ts') ? ' (via tsx)' : ''}`);
console.log(` Directory: ${projectDir}`);
console.log(` Memory limit: ${formatMemory(memoryLimit)}`);
console.log(` Auto-restart: ${autorestart}`);
if (watch) {
console.log(` Watch: enabled`);
if (watchPaths) console.log(` Watch paths: ${watchPaths.join(',')}`);
}
const response = await tspmIpcClient.request('add', {
config: {
name,
command,
args: cmdArgs,
projectDir,
memoryLimitBytes: memoryLimit,
autorestart,
watch,
watchPaths,
},
});
console.log('✓ Added');
console.log(` Assigned ID: ${response.id}`);
},
{ actionLabel: 'add process config' },
);
}

View File

@@ -6,24 +6,27 @@ import { registerIpcCommand } from '../../registration/index.js';
export function registerDeleteCommand(smartcli: plugins.smartcli.Smartcli) {
registerIpcCommand(
smartcli,
'delete',
['delete', 'remove'],
async (argvArg: CliArguments) => {
const id = argvArg._[1];
if (!id) {
console.error('Error: Please provide a process ID');
console.log('Usage: tspm delete <id>');
console.log('Usage: tspm delete <id> | tspm remove <id>');
return;
}
console.log(`Deleting process: ${id}`);
const response = await tspmIpcClient.request('delete', { id });
// Determine if command was 'remove' to use the new IPC route, otherwise 'delete'
const cmd = String(argvArg._[0]);
const useRemove = cmd === 'remove';
console.log(`${useRemove ? 'Removing' : 'Deleting'} process: ${id}`);
const response = await tspmIpcClient.request(useRemove ? 'remove' : 'delete', { id } as any);
if (response.success) {
console.log(`${response.message}`);
console.log(`${response.message || (useRemove ? 'Removed successfully' : 'Deleted successfully')}`);
} else {
console.error(`✗ Failed to delete process: ${response.message}`);
console.error(`✗ Failed to ${useRemove ? 'remove' : 'delete'} process: ${response.message}`);
}
},
{ actionLabel: 'delete process' },
{ actionLabel: 'delete/remove process' },
);
}

View File

@@ -8,13 +8,31 @@ export function registerRestartCommand(smartcli: plugins.smartcli.Smartcli) {
smartcli,
'restart',
async (argvArg: CliArguments) => {
const id = argvArg._[1];
if (!id) {
console.error('Error: Please provide a process ID');
console.log('Usage: tspm restart <id>');
const arg = argvArg._[1];
if (!arg) {
console.error('Error: Please provide a process ID or "all"');
console.log('Usage:');
console.log(' tspm restart <id>');
console.log(' tspm restart all');
return;
}
if (String(arg).toLowerCase() === 'all') {
console.log('Restarting all processes...');
const res = await tspmIpcClient.request('restartAll', {});
if (res.restarted.length > 0) {
console.log(`✓ Restarted ${res.restarted.length} processes:`);
for (const id of res.restarted) console.log(` - ${id}`);
}
if (res.failed.length > 0) {
console.log(`✗ Failed to restart ${res.failed.length} processes:`);
for (const f of res.failed) console.log(` - ${f.id}: ${f.error}`);
process.exitCode = 1;
}
return;
}
const id = String(arg);
console.log(`Restarting process: ${id}`);
const response = await tspmIpcClient.request('restart', { id });

View File

@@ -10,108 +10,22 @@ export function registerStartCommand(smartcli: plugins.smartcli.Smartcli) {
smartcli,
'start',
async (argvArg: CliArguments) => {
// Get all arguments after 'start' command
const commandArgs = argvArg._.slice(1);
if (commandArgs.length === 0) {
console.error('Error: Please provide a command to run');
console.log('Usage: tspm start <command> [options]');
console.log('\nExamples:');
console.log(' tspm start "npm run dev"');
console.log(' tspm start pnpm start');
console.log(' tspm start node server.js');
console.log(' tspm start script.ts');
console.log('\nOptions:');
console.log(' --name <name> Name for the process');
console.log(
' --memory <size> Memory limit (e.g., "512MB", "2GB")',
);
console.log(' --cwd <path> Working directory');
console.log(
' --watch Watch for file changes and restart',
);
console.log(' --watch-paths <paths> Comma-separated paths to watch');
console.log(' --autorestart Auto-restart on crash');
const id = argvArg._[1];
if (!id) {
console.error('Error: Please provide a process ID to start');
console.log('Usage: tspm start <id>');
return;
}
// Join all command parts to form the full command
const script = commandArgs.join(' ');
const memoryLimit = argvArg.memory
? parseMemoryString(argvArg.memory)
: 512 * 1024 * 1024;
const projectDir = argvArg.cwd || process.cwd();
// Parse the command to determine if we need to handle .ts files
let actualCommand: string;
let processArgs: string[] | undefined = undefined;
// Split the script to check if it's a single .ts file or a full command
const scriptParts = script.split(' ');
const firstPart = scriptParts[0];
// Check if this is a direct .ts file execution (single argument ending in .ts)
if (scriptParts.length === 1 && firstPart.endsWith('.ts')) {
try {
const tsxPath = await (async () => {
const { createRequire } = await import('module');
const require = createRequire(import.meta.url);
return require.resolve('tsx/dist/cli.mjs');
})();
const scriptPath = plugins.path.isAbsolute(firstPart)
? firstPart
: plugins.path.join(projectDir, firstPart);
actualCommand = tsxPath;
processArgs = [scriptPath];
} catch {
actualCommand = 'tsx';
processArgs = [firstPart];
}
} else {
// For multi-word commands, use the entire script as the command
// This handles cases like "pnpm start", "npm run dev", etc.
actualCommand = script;
processArgs = undefined;
const desc = await tspmIpcClient.request('describe', { id }).catch(() => null);
if (!desc) {
console.error(`Process with id '${id}' not found. Use 'tspm add' first.`);
return;
}
const name = argvArg.name || script;
const watch = argvArg.watch || false;
const autorestart = argvArg.autorestart !== false; // default true
const watchPaths = argvArg.watchPaths
? typeof argvArg.watchPaths === 'string'
? (argvArg.watchPaths as string).split(',')
: argvArg.watchPaths
: undefined;
const processConfig: IProcessConfig = {
id: name.replace(/[^a-zA-Z0-9-_]/g, '_'),
name,
command: actualCommand,
args: processArgs,
projectDir,
memoryLimitBytes: memoryLimit,
autorestart,
watch,
watchPaths,
};
console.log(`Starting process: ${name}`);
console.log(
` Command: ${script}${scriptParts.length === 1 && firstPart.endsWith('.ts') ? ' (via tsx)' : ''}`,
);
console.log(` Directory: ${projectDir}`);
console.log(` Memory limit: ${formatMemory(memoryLimit)}`);
console.log(` Auto-restart: ${autorestart}`);
if (watch) {
console.log(` Watch mode: enabled`);
if (watchPaths) console.log(` Watch paths: ${watchPaths.join(', ')}`);
}
const response = await tspmIpcClient.request('start', {
config: processConfig,
});
console.log(`✓ Process started successfully`);
console.log(`Starting process id ${id} (${desc.config.name || id})...`);
const response = await tspmIpcClient.request('start', { config: desc.config });
console.log('✓ Process started');
console.log(` ID: ${response.processId}`);
console.log(` PID: ${response.pid || 'N/A'}`);
console.log(` Status: ${response.status}`);

50
ts/cli/commands/reset.ts Normal file
View File

@@ -0,0 +1,50 @@
import * as plugins from '../../plugins.js';
import { registerIpcCommand } from '../registration/index.js';
import { tspmIpcClient } from '../../client/tspm.ipcclient.js';
export function registerResetCommand(smartcli: plugins.smartcli.Smartcli) {
registerIpcCommand(
smartcli,
'reset',
async () => {
console.log('This will stop all processes and clear saved configurations.');
const confirmed = await plugins.smartinteract.SmartInteract.getCliConfirmation(
'Are you sure you want to reset TSPM? (stops all and removes configs)',
false,
);
if (!confirmed) {
console.log('Reset cancelled. No changes made.');
return;
}
// Stop all processes first
const stopAllRes = await tspmIpcClient.request('stopAll', {});
if (stopAllRes.failed.length) {
console.log(
`Stopped ${stopAllRes.stopped.length}, ${stopAllRes.failed.length} failed to stop. Proceeding with config reset...`,
);
} else {
console.log(`Stopped ${stopAllRes.stopped.length} processes.`);
}
// List all processes/configs currently known
const listRes = await tspmIpcClient.request('list', {});
// Remove each config
for (const proc of listRes.processes) {
try {
// Prefer 'remove' which handles stop-if-running semantics as well
await tspmIpcClient.request('remove', { id: proc.id });
console.log(`Removed config for process ${proc.id}.`);
} catch (err) {
console.error(`Failed to remove config for ${proc.id}:`, (err as Error)?.message || String(err));
}
}
console.log('TSPM has been reset: processes stopped and configs cleared.');
},
{ actionLabel: 'reset TSPM' },
);
}

View File

@@ -5,6 +5,7 @@ import { Logger, LogLevel } from '../shared/common/utils.errorhandler.js';
// Import command registration functions
import { registerDefaultCommand } from './commands/default.js';
import { registerStartCommand } from './commands/process/start.js';
import { registerAddCommand } from './commands/process/add.js';
import { registerStopCommand } from './commands/process/stop.js';
import { registerRestartCommand } from './commands/process/restart.js';
import { registerDeleteCommand } from './commands/process/delete.js';
@@ -17,6 +18,7 @@ import { registerRestartAllCommand } from './commands/batch/restart-all.js';
import { registerDaemonCommand } from './commands/daemon/index.js';
import { registerEnableCommand } from './commands/service/enable.js';
import { registerDisableCommand } from './commands/service/disable.js';
import { registerResetCommand } from './commands/reset.js';
// Export types for external use
export type { CliArguments } from './types.js';
@@ -43,6 +45,7 @@ export const run = async (): Promise<void> => {
registerDefaultCommand(smartcliInstance);
// Process commands
registerAddCommand(smartcliInstance);
registerStartCommand(smartcliInstance);
registerStopCommand(smartcliInstance);
registerRestartCommand(smartcliInstance);
@@ -63,6 +66,9 @@ export const run = async (): Promise<void> => {
registerEnableCommand(smartcliInstance);
registerDisableCommand(smartcliInstance);
// Maintenance commands
registerResetCommand(smartcliInstance);
// Start parsing commands
smartcliInstance.startParse();
};

View File

@@ -17,13 +17,15 @@ import { ensureDaemonOrHint } from './daemon-check.js';
*/
export function registerIpcCommand(
smartcli: plugins.smartcli.Smartcli,
name: string,
name: string | string[],
action: CommandAction,
opts: IpcCommandOptions = {},
) {
const { actionLabel = name, keepAlive = false, requireDaemon = true } = opts;
const names = Array.isArray(name) ? name : [name];
for (const singleName of names) {
const { actionLabel = singleName, keepAlive = false, requireDaemon = true } = opts;
smartcli.addCommand(name).subscribe({
smartcli.addCommand(singleName).subscribe({
next: async (argv: CliArguments) => {
// Early preflight for better UX
const ok = await ensureDaemonOrHint(requireDaemon, actionLabel);
@@ -57,7 +59,7 @@ export function registerIpcCommand(
error: (err) => {
// Fallback error path (should be rare with try/catch in next)
console.error(
`Unexpected error in command "${name}":`,
`Unexpected error in command "${singleName}":`,
unknownError(err),
);
process.exit(1);
@@ -65,6 +67,7 @@ export function registerIpcCommand(
complete: () => {},
});
}
}
/**
* Register local commands that don't require IPC/daemon connection

6
ts/client/plugins.ts Normal file
View File

@@ -0,0 +1,6 @@
// Minimal plugin set for lightweight client startup
import * as path from 'node:path';
import * as smartipc from '@push.rocks/smartipc';
export { path, smartipc };

View File

@@ -1,4 +1,4 @@
import * as plugins from '../plugins.js';
import * as plugins from './plugins.js';
import * as paths from '../paths.js';
import type {

View File

@@ -34,6 +34,42 @@ export class ProcessManager extends EventEmitter {
this.loadProcessConfigs();
}
/**
* Add a process configuration without starting it.
* Returns the assigned numeric sequential id as string.
*/
public async add(configInput: Omit<IProcessConfig, 'id'> & { id?: string }): Promise<string> {
// Determine next numeric id
const nextId = this.getNextSequentialId();
const config: IProcessConfig = {
id: String(nextId),
name: configInput.name || `process-${nextId}`,
command: configInput.command,
args: configInput.args,
projectDir: configInput.projectDir,
memoryLimitBytes: configInput.memoryLimitBytes || 512 * 1024 * 1024,
monitorIntervalMs: configInput.monitorIntervalMs,
env: configInput.env,
logBufferSize: configInput.logBufferSize,
autorestart: configInput.autorestart ?? true,
watch: configInput.watch,
watchPaths: configInput.watchPaths,
};
// Store config and initial info
this.processConfigs.set(config.id, config);
this.processInfo.set(config.id, {
id: config.id,
status: 'stopped',
memory: 0,
restarts: 0,
});
await this.saveProcessConfigs();
return config.id;
}
/**
* Start a new process with the given configuration
*/
@@ -342,6 +378,20 @@ export class ProcessManager extends EventEmitter {
}
}
/**
* Compute next sequential numeric id based on existing configs
*/
private getNextSequentialId(): number {
let maxId = 0;
for (const id of this.processConfigs.keys()) {
const n = parseInt(id, 10);
if (!isNaN(n)) {
maxId = Math.max(maxId, n);
}
}
return maxId + 1;
}
/**
* Save all process configurations to config storage
*/

View File

@@ -171,6 +171,31 @@ export class TspmDaemon {
);
// Query handlers
this.ipcServer.onMessage(
'add',
async (request: RequestForMethod<'add'>) => {
try {
const id = await this.tspmInstance.add(request.config as any);
const config = this.tspmInstance.processConfigs.get(id)!;
return { id, config };
} catch (error) {
throw new Error(`Failed to add process: ${error.message}`);
}
},
);
this.ipcServer.onMessage(
'remove',
async (request: RequestForMethod<'remove'>) => {
try {
await this.tspmInstance.delete(request.id);
return { success: true, message: `Process ${request.id} deleted successfully` };
} catch (error) {
throw new Error(`Failed to remove process: ${error.message}`);
}
},
);
this.ipcServer.onMessage(
'list',
async (request: RequestForMethod<'list'>) => {

View File

@@ -12,9 +12,10 @@ import * as smartcli from '@push.rocks/smartcli';
import * as smartdaemon from '@push.rocks/smartdaemon';
import * as smartipc from '@push.rocks/smartipc';
import * as smartpath from '@push.rocks/smartpath';
import * as smartinteract from '@push.rocks/smartinteract';
// Export with explicit module types
export { npmextra, projectinfo, smartcli, smartdaemon, smartipc, smartpath };
export { npmextra, projectinfo, smartcli, smartdaemon, smartipc, smartpath, smartinteract };
// third-party scope
import psTree from 'ps-tree';

View File

@@ -200,12 +200,35 @@ export interface HeartbeatResponse {
status: 'healthy' | 'degraded';
}
// Add (register config without starting)
export interface AddRequest {
// Optional id is ignored server-side if present; server assigns sequential id
config: Omit<IProcessConfig, 'id'> & { id?: string };
}
export interface AddResponse {
id: string;
config: IProcessConfig;
}
// Remove (delete config and stop if running)
export interface RemoveRequest {
id: string;
}
export interface RemoveResponse {
success: boolean;
message?: string;
}
// Type mappings for methods
export type IpcMethodMap = {
start: { request: StartRequest; response: StartResponse };
stop: { request: StopRequest; response: StopResponse };
restart: { request: RestartRequest; response: RestartResponse };
delete: { request: DeleteRequest; response: DeleteResponse };
add: { request: AddRequest; response: AddResponse };
remove: { request: RemoveRequest; response: RemoveResponse };
list: { request: ListRequest; response: ListResponse };
describe: { request: DescribeRequest; response: DescribeResponse };
getLogs: { request: GetLogsRequest; response: GetLogsResponse };