Commit 23b0538
## Summary
`nemoclaw <sandbox> policy-add` and `policy-remove` were prompt-only
flows, which made them unusable from headless shells, CI, and
`NEMOCLAW_NON_INTERACTIVE=1` paths. This change adds an explicit
preset-argument form so operators can script built-in preset changes
without `expect` or an interactive TTY.
## Changes
- **`src/nemoclaw.ts`** - accept `policy-add <preset>` and
`policy-remove <preset>`; validate the preset name; support `--yes` and
`NEMOCLAW_NON_INTERACTIVE=1` for the explicit-preset path; fail fast
with a clear usage message when non-interactive mode is requested
without a preset name; update CLI help text to show the new form.
- **`test/policies.test.ts`** - add regression coverage for scripted
add/remove with `--yes`, for the `NEMOCLAW_NON_INTERACTIVE=1` path, and
for the new fast-fail error when non-interactive mode is used without a
preset name.
## Testing
- `npm run build:cli`
- `npm run typecheck:cli`
- Manual scripted repro against the built CLI:
- `policy-add pypi --yes` applies without prompting
- `NEMOCLAW_NON_INTERACTIVE=1 policy-remove pypi` removes without
prompting
- `npm test`
- still fails in this environment with unrelated existing suite issues
in `src/lib/sandbox-version.test.ts`, `src/lib/preflight.test.ts`,
`test/install-preflight.test.ts`, and `test/legacy-path-guard.test.ts`
Fixes #2067
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Non-interactive/scripted mode for policy commands via
`--yes`/`--force` flags or an env var, allowing automated apply/remove
operations.
* Ability to specify a preset name as a positional argument for direct
policy selection and validation, with clear usage guidance when missing.
* **Tests**
* Added tests covering scripted non-interactive flows, successful
apply/remove with presets, and failure behavior when a preset is
required.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Co-authored-by: Aaron Erickson 🦞 <aerickson@nvidia.com>
1 parent 7732f5b commit 23b0538
2 files changed
Lines changed: 130 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1519 | 1519 | | |
1520 | 1520 | | |
1521 | 1521 | | |
| 1522 | + | |
| 1523 | + | |
1522 | 1524 | | |
1523 | 1525 | | |
1524 | 1526 | | |
1525 | | - | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1526 | 1550 | | |
1527 | 1551 | | |
1528 | 1552 | | |
| |||
1538 | 1562 | | |
1539 | 1563 | | |
1540 | 1564 | | |
1541 | | - | |
1542 | | - | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1543 | 1569 | | |
1544 | 1570 | | |
1545 | 1571 | | |
| |||
1741 | 1767 | | |
1742 | 1768 | | |
1743 | 1769 | | |
| 1770 | + | |
| 1771 | + | |
1744 | 1772 | | |
1745 | 1773 | | |
1746 | 1774 | | |
1747 | | - | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
1748 | 1798 | | |
1749 | 1799 | | |
1750 | 1800 | | |
| |||
1760 | 1810 | | |
1761 | 1811 | | |
1762 | 1812 | | |
1763 | | - | |
1764 | | - | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
1765 | 1817 | | |
1766 | 1818 | | |
1767 | 1819 | | |
| |||
2457 | 2509 | | |
2458 | 2510 | | |
2459 | 2511 | | |
2460 | | - | |
2461 | | - | |
| 2512 | + | |
| 2513 | + | |
2462 | 2514 | | |
2463 | 2515 | | |
2464 | 2516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
889 | 890 | | |
890 | 891 | | |
891 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
892 | 926 | | |
893 | 927 | | |
894 | 928 | | |
895 | | - | |
| 929 | + | |
896 | 930 | | |
897 | 931 | | |
898 | 932 | | |
| |||
933 | 967 | | |
934 | 968 | | |
935 | 969 | | |
| 970 | + | |
936 | 971 | | |
937 | 972 | | |
938 | 973 | | |
| |||
975 | 1010 | | |
976 | 1011 | | |
977 | 1012 | | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
978 | 1046 | | |
979 | 1047 | | |
0 commit comments