Skip to content

feat: inline named model expressions#1

Open
Copilot wants to merge 11 commits into
mainfrom
copilot/add-inline-named-models-support
Open

feat: inline named model expressions#1
Copilot wants to merge 11 commits into
mainfrom
copilot/add-inline-named-models-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 10, 2026

Adds support for defining named models inline in type expression positions:

model Parent {
  child: model Child {
    grandchild: model Grandchild {
      age: int32;
    };
  };
}

@@doc(Child, "The child model");
@@doc(Grandchild, "The grandchild model");

Inline named models are declared in the enclosing namespace/script scope, making them referenceable by augment decorators and subject to standard duplicate-name detection. Arbitrarily deep nesting is supported.

Compiler

  • AST (types.ts): Optional id: IdentifierNode on ModelExpressionNode
  • Parser (parser.ts): ModelKeyword case in parsePrimaryExpression dispatches to parseInlineNamedModelExpression(); visitChildren traverses optional id
  • Binder (binder.ts): bindModelExpression uses getEnclosingDeclarationScope() to walk up to the nearest namespace/script scope for symbol declaration
  • Checker (checker.ts): checkModelExpression uses explicit createType (matching checkModelStatement pattern), sets Model.name from node.id, processes augment decorators for named inline models
  • Formatter (printer.ts): Emits model <Name> prefix for named model expressions

Grammar & Semantic Tokens

  • inlineNamedModelExpression TextMate rule for model <Name> { ... } in expression position
  • statementKeywordExceptModel / universalEndExceptModel prevent model from prematurely terminating type annotation and model property contexts
  • classify.ts handles ModelExpression with id for semantic token highlighting

Tests

  • Parser: deep nesting (2/3 levels), missing-name error
  • Checker positive: augment decorators, nested models, deep nesting + augment decorators, spread properties
  • Checker negative: duplicate sibling names, conflict with top-level model, nested name reuse
  • Typekit: model.is(), model.getEffectiveModel(), type.getPlausibleName(), type.clone(), type.isAssignableTo(), type.resolve()
  • Colorization: semantic + tmlanguage tokenization

Sample

Updated playground http.tsp with inline named models in a model property, operation response, and template parameter position.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 10, 2026 02:30
Add optional `id` field to `ModelExpressionNode` to support inline
named models in property type positions. Example:

```typespec
model Parent {
    child: model Child {
        age: int32;
    }
}
```

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for inline named models with tests and documentation feat: add support for inline named model expressions Feb 10, 2026
Copilot AI requested a review from johanste February 10, 2026 02:37
@johanste
Copy link
Copy Markdown
Owner

@copilot update the changelog

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 10, 2026

@copilot update the changelog

Added the changelog entry in commit 6ac054e.

Copilot AI and others added 3 commits February 10, 2026 03:14
…rator and nesting support with tests

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
…st, response, and template parameter

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title feat: add support for inline named model expressions feat: inline named model expressions Feb 10, 2026
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
@johanste
Copy link
Copy Markdown
Owner

@copilot fix the failing checks

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Feb 11, 2026

@copilot fix the failing checks

Fixed in b0d2b6d:

  • Removed unused program variable in test/typekit/model.test.ts (lint warning)
  • Reformatted test/parser.test.ts (prettier formatting)

@johanste johanste marked this pull request as ready for review February 11, 2026 22:36
@github-actions
Copy link
Copy Markdown

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - feature ✏️

Add support for inline named model expressions in property type positions

johanste pushed a commit that referenced this pull request May 22, 2026
…icrosoft#9713)

Upgrades http-client-python dependencies to match root package.json
versions for consistency across the monorepo.

## Dependencies Updated

- **@types/node**: ~24.1.0 → ~25.0.2
- **rimraf**: ~6.0.1 → ~6.1.2
- **tsx**: ~4.19.1 → ^4.21.0
- **typescript**: ~5.8.2 → ~5.9.2
- **typescript-eslint**: ^8.21.0 → ^8.49.0
- **vitest**: ^3.1.2 → ^4.0.15

## Changes

- Updated `packages/http-client-python/package.json` with aligned
versions
- Regenerated `package-lock.json` via `npm install`
- Added changelog entry with `changeKind: dependencies`

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

update dependencies of packages/http-client-python/package.json. If they
are found it package.json, upgrade to same version. NOTE: PR title shall
starts with "[python]"

<analysis>
[Chronological Review:  
- The user provided a timestamp and requested: **“clean all changes”**.
- Assistant initiated a parallel tool call with:
  1) `functions.report_intent` (intent logging), and  
  2) `functions.powershell` to run a git cleanup command chain.  
- PowerShell command executed:  
`git --no-pager status --short && git reset --hard HEAD && git clean -fd
&& git --no-pager status --short`
- Tool output showed there was a modified file before reset (`M
packages/http-client-python/package.json`), then successful hard reset
to commit `efbf17ff8`, and successful completion (exit code 0).
- Assistant then ran a second verification command:  
  `git --no-pager status --short`  
  which returned no output and exit code 0 (clean working tree).  
- Assistant called `functions.task_complete` with a summary indicating
all tracked/untracked changes were removed and cleanliness verified.
- Assistant replied to user: repo is clean.  
- User then asked for a structured conversation summary emphasizing
recent commands/tool results.]

[Intent Mapping:  
- Explicit user request #1: **“clean all changes”** (clear local tracked
and untracked changes).
- Explicit user request #2: Summarize conversation history with emphasis
on recent commands/results and no additional tool calls.
- Implicit expectation: confirm repo cleanliness after cleanup and
provide a handoff-quality summary.]

[Technical Inventory:  
- Version control: **Git**.  
- Commands used: `git status --short`, `git reset --hard HEAD`, `git
clean -fd`.
- Agent tooling: `multi_tool_use.parallel`, `functions.report_intent`,
`functions.powershell`, `functions.task_complete`.
- Environment note from user reminder: no SQL tables currently exist;
SQL tool was not used.]

[Code Archaeology:  
- Mentioned file: `packages/http-client-python/package.json` (was
modified before cleanup).
- No new code edits were made; all local edits were discarded.  
- Repository state restored to `HEAD` commit `efbf17ff8` with no
remaining local diffs/untracked files.]

[Progress Assessment:  
- Completed: workspace cleanup and verification.  
- Pending: none from original cleanup task.  
- New active task: produce detailed structured summary (current
response).]

[Context Validation:  
- Captured user goals, all tool calls, exact command strings, key
outputs, and final repo state.
- Captured immediate pre-summary state (cleanup completed, user
requested summary).
- Noted that summarization was user-triggered; no evidence of an actual
runtime token-overflow event in the visible transcript.]

[Recent Commands Analysis:  
- Last agent commands executed:
- `functions.report_intent` with `intent: "Cleaning workspace"` →
result: “Intent logged”.
  - `functions.powershell` command chain for cleanup and status checks.
- Follow-up `functions.powershell` with `git --no-pager status --short`
for explicit verification.
  - `functions.task_complete` with cleanup summary.
- Key tool results:
- Pre-clean status included `M
packages/http-client-python/package.json`.
  - `git reset --hard HEAD` succeeded: `HEAD is now at efbf17f ...`.
- Final status checks returned clean output (empty `git status
--short`), exit code 0.
- Immediate pre-summarization state: task already completed and
user-confirmed response sent; then user requested this summary.]
</analysis>

<summary>
1. Conversation Overview:
   - Primary Objectives:
     - User requested: **“clean all changes”**.
- Later requested: **“Summarize the conversation history so far, paying
special attention to the most recent agent commands and tool
results...”**
   - Session Context:
- Single operational task session: detect local changes, discard
everything, verify clean state, report completion.
   - User Intent Evolution:
     - Started with repo cleanup.
- Shifted to documentation/handoff summary of what was executed and what
results were returned.

2. Technical Foundation:
   - Git CLI:
     - Used to inspect and forcibly restore working tree state.
   - Agent Tooling:
- `multi_tool_use.parallel` for concurrent intent logging + shell
action.
     - `functions.powershell` for command execution.
     - `functions.task_complete` for formal completion marker.
   - Workflow Pattern:
- Execute destructive cleanup (`reset --hard` + `clean -fd`) then verify
with explicit status check.
   - Environment Detail:
- User reminder included SQL tool note (“No tables currently exist...”),
but no SQL operations were performed.

3. Codebase Status:
   - `packages/http-client-python/package.json`:
     - Purpose: package metadata/config for python HTTP client package.
- Current State: previously modified; modification discarded by hard
reset.
     - Key Code Segments: none discussed.
     - Dependencies: only r...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

Created from Copilot CLI via the copilot delegate command.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants