refactor(ts-migration): move policies to typescript - #1670
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe changes migrate policy preset management functionality from JavaScript to TypeScript. A new Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Code as applyPreset()
participant FS as File System
participant YAML as YAML Parser
participant Registry as Sandbox Registry
participant CLI as openshell CLI
User->>Code: applyPreset(sandboxName, presetName)
Code->>Code: Validate sandbox name (RFC1123)
Code->>FS: Load preset YAML file
FS-->>Code: Preset content
Code->>YAML: Extract network_policies section
YAML-->>Code: Preset entries
Code->>CLI: buildPolicyGetCommand(sandboxName)
CLI-->>Code: Current policy YAML
Code->>YAML: parseCurrentPolicy(raw)
YAML-->>Code: Parsed current policy
Code->>Code: mergePresetIntoPolicy(current, preset)
Code-->>Code: Merged policy
Code->>FS: Write merged policy to temp file (mode 0600)
FS-->>Code: Temp file created
Code->>CLI: openshell policy set (via temp file)
CLI-->>Code: Success/Failure
Code->>Registry: getSandbox(sandboxName)
Registry-->>Code: Sandbox object
Code->>Registry: updateSandbox (record applied preset)
Registry-->>Code: Updated
Code->>FS: Clean up temp files/directories
FS-->>Code: Cleanup complete
Code-->>User: Result
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Aaron Erickson <aerickson@nvidia.com> # Conflicts: # scripts/migrate-js-to-ts.ts # test/skills-frontmatter.test.ts
## Summary - add the policies migration phase manifest - mechanically move `bin/lib/policies.js` into `src/lib/policies.ts` - keep a compatibility wrapper in `bin/lib/policies.js` - rename `test/policies.test.js` to `.ts` ## Testing - npm run build:cli - npm run typecheck:cli - npm run lint - npx vitest run test/policies.test.ts - npm test <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added policy preset management system enabling users to list, load, and apply network policy presets to sandboxes. * Interactive preset selection interface with status indicators showing applied and available presets. * Automatic YAML policy merging and validation for sandbox configuration. * **Chores** * Internal restructuring of policy management components. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
Summary
bin/lib/policies.jsintosrc/lib/policies.tsbin/lib/policies.jstest/policies.test.jsto.tsTesting
Summary by CodeRabbit
New Features
Chores