You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make standalone script template creation reliable (#1736)
## Context
The existing Script project template is presented as a PEP 723
standalone script, but its placeholder metadata is not valid TOML. The
quick-create path also returns without creating a file, even though
external callers provide a script project name and destination.
This change fixes the existing user-facing template and file-creation
workflow. It does not create, select, or expose an inline-script
environment.
## Why this change is needed
- The shipped metadata block cannot be parsed by the extension's own PEP
723 parser.
- Quick create skips the copy/register/open path.
- External quick callers provide a base project name such as
`hello_world`, not necessarily a complete `.py` filename.
- Filename/path handling needs to reject traversal, reserved Windows
device names, remote-workspace identity loss, and physical symlink
escapes.
- Project-registration failure can otherwise leave a generated file or
in-memory ghost project.
- Copilot instruction paths can be redirected outside the workspace
through existing symlinks or junctions.
## What changed
- The template now contains valid `requires-python = ">=3.9"` metadata
and an empty dependency list.
- Quick base names are normalized to `.py`; interactive creation
continues requiring an explicit `.py` filename.
- Interactive and quick flows share validation for extension,
characters, separators, traversal, containment, and Windows reserved
names.
- Workspace matching preserves remote URI scheme and authority.
- Destination and Copilot-instruction paths are physically checked
against the containing workspace before any side effect.
- Quick and interactive creation share the file copy, substitution,
project registration, instruction, and open flow.
- Project registration is awaited. Insert-then-fail behavior removes the
in-memory project and copied script while preserving the original error.
- Out-of-workspace destinations are rejected because they cannot be
durably registered.
- Related documentation and Copilot instructions now describe the actual
script behavior and metadata fields.
## Behavior and compatibility
- Package project creation is unchanged.
- Script creation still does not provision an environment.
- The hidden inline manager remains undeclared, default-off, and
unregistered.
- Users already saw a PEP 723 block in generated scripts; this change
makes that existing block valid.
- Opening the now-valid generated file may emit the existing anonymized
telemetry-only detection event. It does not create or select an
environment.
## Reviewer guide
1. Review shared filename normalization and validation.
2. Review workspace URI matching and physical containment preflight.
3. Review side-effect ordering and registration rollback.
4. Review the actual template parser test and quick-create tests.
## Validation
- `npm run compile-tests --silent`
- Targeted metadata parser and script creator suites: 71 passing
- ESLint on changed TypeScript files
- `git diff --check`
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1487b95c-ac14-455f-9b7f-9770cf65e11e
0 commit comments