@syndicalt/snow-cli 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +62 -1
  2. package/dist/index.js +6179 -2461
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,6 +28,10 @@ A portable CLI for ServiceNow. Query tables, inspect schemas, edit and search sc
28
28
 
29
29
  ---
30
30
 
31
+ ## Full Documentation
32
+
33
+ The full documentation is available on the [documentation page](https://syndicalt.github.io/snow_cli/). This README provides a quick overview and examples to get started.
34
+
31
35
  ## Installation
32
36
 
33
37
  **From npm (when published):**
@@ -89,6 +93,9 @@ snow diff all --against test --scripts --scope x_myco_myapp
89
93
  # 11. Run the full factory pipeline: plan → build → test → promote
90
94
  snow factory "Build a hardware asset request app with approval workflow" --envs test,prod
91
95
 
96
+ # 11b. Run tests and auto-fix failures with the LLM optimization loop
97
+ snow factory "Create a Script Include named SLACalculator with risk level logic" --run-tests --optimize
98
+
92
99
  # 12. Start an interactive session to build iteratively
93
100
  snow ai chat
94
101
 
@@ -845,6 +852,12 @@ snow factory "Build an incident escalation app" --dry-run
845
852
  # Generate and immediately run ATF tests
846
853
  snow factory "Build a change approval workflow" --run-tests
847
854
 
855
+ # Generate ATF tests, run them, and auto-fix failures with the LLM (up to 3 retries)
856
+ snow factory "Create a priority calculator script include" --run-tests --optimize
857
+
858
+ # Same, but allow up to 5 fix iterations
859
+ snow factory "Create a priority calculator script include" --run-tests --optimize --max-retries 5
860
+
848
861
  # Skip ATF test generation (faster)
849
862
  snow factory "Add a business rule to auto-assign P1 incidents" --skip-tests
850
863
 
@@ -863,6 +876,8 @@ snow factory "" --list
863
876
  | `--scope <prefix>` | Override the application scope prefix for all artifacts (e.g. `x_myco_myapp`) |
864
877
  | `--skip-tests` | Skip ATF test generation |
865
878
  | `--run-tests` | Execute the generated ATF test suite immediately after pushing |
879
+ | `--optimize` | After running tests, auto-fix failures via LLM feedback loop (implies `--run-tests`) |
880
+ | `--max-retries <n>` | Max optimization iterations when using `--optimize` (default: `3`) |
866
881
  | `--dry-run` | Show the generated plan only — no builds, no deployments |
867
882
  | `--resume <id>` | Resume a previous run from its checkpoint (see `--list`) |
868
883
  | `--list` | Show recent factory runs and their component completion status |
@@ -886,7 +901,13 @@ snow factory "" --list
886
901
  [4/N] Generating ATF tests (unless --skip-tests)
887
902
  LLM generates a test suite with server-side script assertions
888
903
  Tests pushed to the instance as sys_atf_test + sys_atf_step records
889
- Optionally executed if --run-tests is set
904
+ If --run-tests or --optimize: suite is executed via the CICD API
905
+ Pass/fail counts and per-test results are displayed
906
+
907
+ If --optimize and tests failed:
908
+ → LLM receives the failing test names + error messages + artifact source
909
+ → Generates corrected artifacts, re-pushes them, re-runs the suite
910
+ → Repeats until all pass or --max-retries is exhausted
890
911
 
891
912
  [5/N] Promoting to <env> (once per additional env in --envs)
892
913
  Checks for pre-existing artifacts on the target
@@ -906,6 +927,40 @@ snow factory "" --resume abc12345 # resume from last successful phase
906
927
 
907
928
  The resume prompt argument is ignored when `--resume` is provided — the original prompt and plan are loaded from the checkpoint.
908
929
 
930
+ #### Auto-optimization loop
931
+
932
+ When `--optimize` is set, the factory runs an automated fix cycle after the initial ATF test run. For each iteration:
933
+
934
+ 1. Failing test names and error messages are collected from the `sys_atf_result` table
935
+ 2. The current source code of every script-bearing artifact is extracted from the local manifest
936
+ 3. A structured fix prompt is sent to the LLM — no questions, just a corrected build
937
+ 4. Fixed artifacts are merged into the build (replaced by `type + name`), re-pushed to the instance
938
+ 5. The existing ATF suite is re-run; if all tests pass, the loop exits early
939
+
940
+ ```
941
+ [Optimize 1/3] 2 test(s) failing — asking LLM to fix...
942
+ ────────────────────────────────────────────────
943
+ Patching:
944
+ ~ script_include SLACalculator
945
+ Re-pushing fixed artifacts to instance...
946
+ Re-running ATF tests...
947
+ 3/3 tests passed
948
+ ✓ Test low risk level
949
+ ✓ Test medium risk level
950
+ ✓ Test high risk level
951
+
952
+ ✔ All tests passing after optimization!
953
+ ```
954
+
955
+ If failures persist after all retries, a warning is shown and the best-effort build is kept on disk.
956
+
957
+ **Requirements for ATF test execution:**
958
+ - The `sn_cicd` plugin must be active on the instance
959
+ - The authenticated user must have the `sn_cicd` role
960
+ - ATF must be enabled (`System ATF` → `Properties` → `Enable ATF`)
961
+
962
+ The optimization loop uses the same LLM provider as the build. Each iteration costs one LLM call, so `--max-retries 3` (default) means at most 3 additional calls beyond the initial build.
963
+
909
964
  #### Example output
910
965
 
911
966
  ```
@@ -968,6 +1023,12 @@ The resume prompt argument is ignored when `--resume` is provided — the origin
968
1023
  • Test manager notification trigger (2 steps)
969
1024
  ✓ Test suite created
970
1025
  https://dev12345.service-now.com/nav_to.do?uri=sys_atf_test_suite.do?sys_id=...
1026
+ Running ATF tests...
1027
+ 4/4 tests passed
1028
+ ✓ Test employee record creation and field defaults
1029
+ ✓ Test OnboardingUtils task generation
1030
+ ✓ Test business rule fires on insert
1031
+ ✓ Test manager notification trigger
971
1032
  ```
972
1033
 
973
1034
  #### Permission-denied errors