Merge remote-tracking branch 'upstream/master' into fix/subagent-zh-terminology
This commit is contained in:
commit
f4c6b012aa
211 files changed
+3304
-686
No files matched your search
@@ -184,6 +184,30 @@ describe('client slot projection', () => {
|
||||
expect(entry?.example).toContain("id: 'my-entry'")
|
||||
})
|
||||
|
||||
it('expands composed owner aliases without expanding their field value types', () => {
|
||||
const types = new Map(OWNER_TYPES)
|
||||
for (const [name, text] of [
|
||||
['Phase', "export type Phase = { phase: 'preparing'; block: BigSnapshot } | { phase: 'start'; block: BigSnapshot }"],
|
||||
['Owner', 'export type Owner = DemoOwnerProps & (Phase | Alias)'],
|
||||
['Alias', 'export type Alias = Owner'],
|
||||
['BigSnapshot', 'export interface BigSnapshot { history: string[] }'],
|
||||
] as const) types.set(name, { name, text, source: 'owner.ts:1' })
|
||||
const [entry] = resolveSlotEntries([declaration({ ownerType: 'Owner' })], [], types, kits)
|
||||
expect(entry?.ownerProps).toHaveLength(4)
|
||||
expect(entry?.ownerProps.join('\n')).toContain('width: number')
|
||||
expect(entry?.ownerProps.join('\n')).toContain("phase: 'preparing'")
|
||||
expect(entry?.ownerProps.join('\n')).not.toContain('history: string[]')
|
||||
expect(entry?.ownerPropsReferences).toEqual(['BigSnapshot'])
|
||||
})
|
||||
|
||||
it('keeps generic owner arguments as references instead of expanding unselected fields', () => {
|
||||
const types = new Map(OWNER_TYPES)
|
||||
types.set('Owner', { name: 'Owner', text: "export type Owner = Pick<DemoOwnerProps, 'width'>", source: 'owner.ts:1' })
|
||||
const [entry] = resolveSlotEntries([declaration({ ownerType: 'Owner' })], [], types, kits)
|
||||
expect(entry?.ownerProps).toHaveLength(1)
|
||||
expect(entry?.ownerPropsReferences).toEqual(['DemoOwnerProps'])
|
||||
})
|
||||
|
||||
it('uses an authored example when a slot interaction needs more than generic markup', () => {
|
||||
const [entry] = resolveSlotEntries([
|
||||
declaration({ jsDoc: '/** A seat.\n * @example\n * return { custom: true }\n */' }),
|
||||
@@ -227,5 +251,14 @@ describe('the real workspace surface', () => {
|
||||
expect(root?.occupants.join(' ')).toContain('AppFrame')
|
||||
expect(entries.find(entry => entry.key === 'conversation.session')?.declaredBy)
|
||||
.toContain("factory 'conversation.content' (client-ui-conversation)")
|
||||
const tool = entries.find(entry => entry.key === 'tool.call.toolview')!
|
||||
const owner = tool.ownerProps.join('\n')
|
||||
for (const field of ['callId', 'toolName', 'useDisclosure', 'cwd', 'home', 'openFile', 'loadImage', 'inspect']) {
|
||||
expect(owner).toMatch(new RegExp(`\\b${field}\\??:`))
|
||||
}
|
||||
for (const phase of ['preparing', 'start', 'result']) expect(owner).toContain(`phase: '${phase}'`)
|
||||
expect(owner).not.toContain('truncated')
|
||||
expect(tool.ownerPropsReferences).not.toContain('ToolCallCommonProps')
|
||||
expect(tool.ownerPropsReferences).not.toContain('ToolCallPhaseProps')
|
||||
})
|
||||
})
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import ts from 'typescript'
|
||||
import {
|
||||
declaredTypes,
|
||||
indexExportedTypes,
|
||||
@@ -306,24 +307,40 @@ function entryOf(
|
||||
}
|
||||
|
||||
/**
|
||||
* The owner-props contract at ONE level: the owner declaration(s) themselves,
|
||||
* plus the names of the shapes their fields reference. Expanding transitively
|
||||
* pulled the whole session model into four seats (one report exceeded 2400
|
||||
* lines), which defeats the purpose of narrowing to a single slot — a registrant
|
||||
* needs the fields and their documented meaning, not the type graph behind them.
|
||||
* Owner declarations include the aliases that compose their top-level fields.
|
||||
* Field value types remain references so one slot does not expand the Session graph.
|
||||
*/
|
||||
function ownerShapes(
|
||||
ownerType: string | undefined,
|
||||
types: ReadonlyMap<string, TypeDeclaration>,
|
||||
): { declarations: TypeDeclaration[]; references: string[] } {
|
||||
if (ownerType === undefined) return { declarations: [], references: [] }
|
||||
const declarations = declaredTypes(referencedTypeNames([ownerType], types), types)
|
||||
const own = new Set(declarations.map(declaration => declaration.name))
|
||||
const own = new Map(declaredTypes(referencedTypeNames([ownerType], types), types)
|
||||
.map(declaration => [declaration.name, declaration]))
|
||||
for (const declaration of own.values()) {
|
||||
const source = ts.createSourceFile(declaration.source, declaration.text, ts.ScriptTarget.Latest, true)
|
||||
const alias = source.statements.find(ts.isTypeAliasDeclaration)
|
||||
if (alias === undefined) continue
|
||||
for (const composed of declaredTypes(ownerCompositionNames(alias.type), types)) {
|
||||
own.set(composed.name, composed)
|
||||
}
|
||||
}
|
||||
const declarations = [...own.values()].sort((left, right) => left.name.localeCompare(right.name))
|
||||
const references = referencedTypeNames(declarations.map(declaration => declaration.text), types)
|
||||
.filter(name => !own.has(name))
|
||||
return { declarations, references }
|
||||
}
|
||||
|
||||
/** Top-level composition excludes nested field values and generic arguments. */
|
||||
function ownerCompositionNames(type: ts.TypeNode): string[] {
|
||||
if (ts.isUnionTypeNode(type) || ts.isIntersectionTypeNode(type)) return type.types.flatMap(ownerCompositionNames)
|
||||
if (ts.isParenthesizedTypeNode(type)) return ownerCompositionNames(type.type)
|
||||
if (ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeArguments === undefined) {
|
||||
return [type.typeName.text]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/** How a keyed slot's key domain is constrained, '' for the other kinds. */
|
||||
function keyDomainOf(declaration: SlotDeclaration, occupants: readonly SlotRegistration[]): string {
|
||||
if (declaration.kind !== 'keyed') return ''
|
||||
|
||||
@@ -350,7 +350,6 @@
|
||||
"e16418d396e5aa0dc24e4e963fd984fcd0d6641c2286f101fff3a87a160a4805": 1
|
||||
},
|
||||
"packages/boot/plugin-manager/tests/operations.spec.ts": {
|
||||
"3f67668a2a47b23d156327c25aec9838ccfb824ad8e28234cf3e3ed78b7ca84b": 1,
|
||||
"657d57900ec8cdcfa9a4b11544ef4799d3a60c43c49e20f7aea13d3522ddbbee": 2
|
||||
},
|
||||
"packages/boot/plugin-manager/tests/tools.spec.ts": {
|
||||
@@ -765,9 +764,6 @@
|
||||
"packages/client/ui-sidebar/src/client/index.ts": {
|
||||
"4c73f40f3ce989f285848573d7154fb295886bba707ad829e2c8c089e326aeea": 1
|
||||
},
|
||||
"packages/client/ui-skill/tests/skill-row.client.spec.tsx": {
|
||||
"6a1c3746f69a09ed859887aa4f1c9c0cffc1a9152459f3b1aef8b39c0020be74": 1
|
||||
},
|
||||
"packages/client/ui-subagent/tests/browser-plugin.client.spec.ts": {
|
||||
"810a8e63d34628d25866491b3c6455a51b2d114261b67e62b42728b765370993": 1
|
||||
},
|
||||
@@ -1306,15 +1302,6 @@
|
||||
"packages/extensions/ui-cordis/tests/inventory.client.spec.ts": {
|
||||
"205cd2f0d90ee000d0bd5f8c9e7e03d7d602f22e12220ebdf8043d68fd9b796a": 1
|
||||
},
|
||||
"packages/extensions/ui-cordis/tests/status-icons.client.spec.tsx": {
|
||||
"197a02bb861b1e7f091fed36ce23f7fe7b29686e869eae4ef97ca5f2d3db0c3f": 1,
|
||||
"21e66428cbbde28dc4babe182c025a24ce551db8213ad838f32032f1637f82f3": 1,
|
||||
"2a1282321e7b71e11b6c7f185fee563b40d3bb154ae3ddea20b09885f7e70d1e": 1,
|
||||
"39b3669a761fd862ddc2653942105307bb6b7e9af87a52924dce1f9a6a3ca27d": 1,
|
||||
"3f1740cf4e1f98e62eed39475eefe4975e40c0ef37f9eaa9d42b82e2b3e59441": 1,
|
||||
"ac0beabad88e70e9d83e0ff5f45e36c04da79841f57a9580531dd930d2695511": 1,
|
||||
"c331b9162c06d90cddeb7fd093839d0e12eb2ef6a17e1a5afbcaa335ed3a29c2": 1
|
||||
},
|
||||
"packages/feedback/command-feedback/tests/loader-composition.spec.ts": {
|
||||
"59c63f734e8bba862325f776e3fcbebd78a84cfb4161f8df41c216950d9bf351": 1
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user