Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ai-bot/tests/prompt-construction-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7343,7 +7343,7 @@ module('markdown skills', () => {
});
});

module('markdown skill commands', (hooks) => {
module('markdown skill tools', (hooks) => {
let fakeMatrixClient: FakeMatrixClient;
let mockResponses: Map<string, { ok: boolean; text: string }>;
let originalFetch: any;
Expand Down
6 changes: 3 additions & 3 deletions packages/base/ai-app-generator.gts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export class AiAppGenerator extends CardDef {
};

askAi = restartableTask(async () => {
let commandContext = this.args.context?.commandContext;
if (!commandContext) {
let toolContext = this.args.context?.toolContext;
if (!toolContext) {
throw new Error('No command context found');
}

let command = new AskAiTool(commandContext);
let command = new AskAiTool(toolContext);
await command.execute(
new AskAiInput({
prompt: this.args.model.promptValue,
Expand Down
12 changes: 8 additions & 4 deletions packages/base/card-api.gts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ interface RelationshipOptions extends Options {
}

export interface CardContext<T extends CardDef = CardDef> {
toolContext?: ToolContext;
// Pre-rename spelling of `toolContext`. Realm content reads
// `@context.commandContext`; populated with the same value until no
// deployed content references it.
commandContext?: ToolContext;
cardComponentModifier?: typeof Modifier<{
Args: {
Expand Down Expand Up @@ -3280,16 +3284,16 @@ export class Theme extends CardDef {

[getMenuItems](params: GetMenuItemParams): MenuItemOptions[] {
let menuItems = super[getMenuItems](params);
if (params.menuContext === 'interact' && params.commandContext && this.id) {
if (params.menuContext === 'interact' && params.toolContext && this.id) {
menuItems = [
...menuItems,
{
label: 'Copy and Edit',
action: async () => {
if (!params.commandContext || !this.id) {
if (!params.toolContext || !this.id) {
return;
}
let cmd = new CopyAndEditTool(params.commandContext);
let cmd = new CopyAndEditTool(params.toolContext);
await cmd.execute({
card: this,
});
Expand All @@ -3300,7 +3304,7 @@ export class Theme extends CardDef {
{
label: 'Modify Theme via AI',
action: async () => {
let cmd = new PatchThemeTool(params.commandContext);
let cmd = new PatchThemeTool(params.toolContext);
await cmd.execute({
cardId: this.id as unknown as string,
});
Expand Down
10 changes: 5 additions & 5 deletions packages/base/commands/search-card-result.gts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class SearchCardsResultEmbeddedView extends Component<
}

<template>
<div class='command-result'>
<div class='tool-call-result'>
<CardList
@cardIds={{this.cardIdsToDisplay}}
@format='atom'
Expand All @@ -207,7 +207,7 @@ class SearchCardsResultEmbeddedView extends Component<
</div>
</div>
<style scoped>
.command-result {
.tool-call-result {
color: var(--boxel-dark);
background-color: var(--boxel-light);
border-radius: var(--boxel-border-radius);
Expand Down Expand Up @@ -251,7 +251,7 @@ class SearchCardsResultEmbeddedView extends Component<

class SearchCardsResultIsolatedView extends SearchCardsResultEmbeddedView {
<template>
<section class='command-result' data-test-tool-result-isolated>
<section class='tool-call-result' data-test-tool-result-isolated>
<header>
<h3>Search Results</h3>
<p class='result-count'>
Expand All @@ -273,10 +273,10 @@ class SearchCardsResultIsolatedView extends SearchCardsResultEmbeddedView {
</div>
</section>
<style scoped>
.command-result {
.tool-call-result {
padding: var(--boxel-sp-lg) var(--boxel-sp-xl);
}
.command-result > * + * {
.tool-call-result > * + * {
margin-top: var(--boxel-sp-lg);
}
h3 {
Expand Down
4 changes: 2 additions & 2 deletions packages/base/default-templates/missing-template.gts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export default class MissingTemplate extends GlimmerComponent<{
return;
}
let moduleId = moduleFrom(ref);
let commandContext = this.args.context?.commandContext;
await new SwitchSubmodeTool(commandContext!).execute({
let toolContext = this.args.context?.toolContext;
await new SwitchSubmodeTool(toolContext!).execute({
codePath: moduleId,
submode: 'code',
});
Expand Down
2 changes: 1 addition & 1 deletion packages/base/field-component.gts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const DEFAULT_CARD_CONTEXT = {
modify() {}
},
actions: undefined,
commandContext: undefined,
toolContext: undefined,
getCard: () => {},
getCards: () => {},
getCardCollection: () => {},
Expand Down
12 changes: 6 additions & 6 deletions packages/base/file-menu-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Copy as Markdown',
action: () =>
new CopyCardAsMarkdownTool(params.commandContext).execute({
new CopyCardAsMarkdownTool(params.toolContext).execute({
cardId: fileDefInstanceId,
}),
icon: ClipboardCopy,
Expand All @@ -59,7 +59,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeTool(params.commandContext).execute({
await new SwitchSubmodeTool(params.toolContext).execute({
submode: 'code',
codePath: fileDefInstanceId,
});
Expand Down Expand Up @@ -89,13 +89,13 @@ export function getDefaultFileMenuItems(
label: 'Copy to Workspace',
action: async () => {
let { newFileIdentifier } = await new CopyFileToRealmTool(
params.commandContext,
params.toolContext,
).execute({
sourceFileIdentifier: fileDefInstance.sourceUrl,
targetRealm: params.menuContextParams.activeRealmURL,
});

await new ShowFileTool(params.commandContext).execute({
await new ShowFileTool(params.toolContext).execute({
fileIdentifier: newFileIdentifier,
});
},
Expand All @@ -108,7 +108,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Interact Mode',
action: () => {
new OpenInInteractModeTool(params.commandContext).execute({
new OpenInInteractModeTool(params.toolContext).execute({
cardId: fileDefInstanceId,
format: params.format === 'edit' ? 'edit' : 'isolated',
});
Expand All @@ -120,7 +120,7 @@ export function getDefaultFileMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeTool(params.commandContext).execute({
await new SwitchSubmodeTool(params.toolContext).execute({
submode: 'code',
codePath: fileDefInstanceId,
});
Expand Down
20 changes: 10 additions & 10 deletions packages/base/menu-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type MenuContext =
export type GetMenuItemParams = {
canEdit: boolean;
cardCrudFunctions: Partial<CardCrudFunctions>;
commandContext: ToolContext;
toolContext: ToolContext;
format?: Format;
useBaseTemplate?: boolean;
} & MenuContext;
Expand Down Expand Up @@ -92,7 +92,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Copy as Markdown',
action: () =>
new CopyCardAsMarkdownTool(params.commandContext).execute({
new CopyCardAsMarkdownTool(params.toolContext).execute({
cardId,
}),
icon: ClipboardCopy,
Expand Down Expand Up @@ -170,13 +170,13 @@ export function getDefaultCardMenuItems(
label: 'Copy to Workspace',
action: async () => {
const { newCardId } = await new CopyCardCommand(
params.commandContext,
params.toolContext,
).execute({
sourceCard: card,
targetRealm: params.menuContextParams.activeRealmURL,
});

let showCardCommand = new ShowCardTool(params.commandContext);
let showCardCommand = new ShowCardTool(params.toolContext);
await showCardCommand.execute({
cardId: newCardId,
});
Expand All @@ -190,7 +190,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Open in Interact Mode',
action: () => {
new OpenInInteractModeTool(params.commandContext).execute({
new OpenInInteractModeTool(params.toolContext).execute({
cardId,
format: params.format === 'edit' ? 'edit' : 'isolated',
});
Expand All @@ -203,7 +203,7 @@ export function getDefaultCardMenuItems(
menuItems.push({
label: 'Open in Code Mode',
action: async () => {
await new SwitchSubmodeTool(params.commandContext).execute({
await new SwitchSubmodeTool(params.toolContext).execute({
submode: 'code',
codePath: cardId,
});
Expand All @@ -224,7 +224,7 @@ export function getDefaultCardMenuItems(
if (!targetRealm) {
throw new Error('Unable to determine target realm from card');
}
await new OpenCreateListingModalTool(params.commandContext).execute({
await new OpenCreateListingModalTool(params.toolContext).execute({
codeRef,
openCardIds: [cardId],
targetRealm,
Expand All @@ -240,15 +240,15 @@ export function getDefaultCardMenuItems(

function getSampleDataMenuItems(
card: CardDef,
{ commandContext }: Pick<GetMenuItemParams, 'commandContext'>,
{ toolContext }: Pick<GetMenuItemParams, 'toolContext'>,
): MenuItemOptions[] {
let cardId = card.id as unknown as string;
let menuItems: MenuItemOptions[] = [];
if (cardId) {
menuItems.push({
label: `Fill in Sample Data with AI`,
action: async () =>
await new PopulateWithSampleDataTool(commandContext).execute({
await new PopulateWithSampleDataTool(toolContext).execute({
cardId: card.id,
}),
icon: Wand,
Expand All @@ -260,7 +260,7 @@ function getSampleDataMenuItems(
menuItems.push({
label: `Generate ${GENERATED_EXAMPLE_COUNT} examples with AI`,
action: async () => {
await new GenerateExampleCardsTool(commandContext).execute({
await new GenerateExampleCardsTool(toolContext).execute({
count: GENERATED_EXAMPLE_COUNT,
codeRef: codeRef as ResolvedCodeRef,
realm: card[realmURL]?.href,
Expand Down
6 changes: 3 additions & 3 deletions packages/base/resources/command-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ export function commandData<
const state = new CommandExecutionState<
CardResultType extends CardDefConstructor ? CardResultType : never
>();
let commandContext = parent.args.context?.commandContext;
if (!commandContext) {
let toolContext = parent.args.context?.toolContext;
if (!toolContext) {
state.setError(new Error('no context'));
return state;
}

const command = new commandClass(commandContext);
const command = new commandClass(toolContext);

state.setLoading();
(executeArgs ? command.execute(executeArgs()) : command.execute())
Expand Down
18 changes: 9 additions & 9 deletions packages/base/spec.gts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ import {
export type SpecType = 'card' | 'field' | 'component' | 'app' | 'command';

class PopulateFieldSpecExampleCommand extends PopulateWithSampleDataTool {
constructor(commandContext: ToolContext) {
super(commandContext);
constructor(toolContext: ToolContext) {
super(toolContext);
}
protected get prompt() {
return `Fill in sample data for this example on the card's spec.`;
Expand Down Expand Up @@ -98,8 +98,8 @@ class PopulateFieldSpecExampleCommand extends PopulateWithSampleDataTool {
}

class GenerateExamplesForFieldSpecCommand extends GenerateExampleCardsTool {
constructor(commandContext: ToolContext) {
super(commandContext);
constructor(toolContext: ToolContext) {
super(toolContext);
}
protected getPrompt(count: number) {
return `Generate ${count} additional examples on this card's spec.`;
Expand Down Expand Up @@ -279,15 +279,15 @@ export class SpecReadmeSection extends GlimmerComponent<SpecReadmeSectionSignatu
return;
}

let commandContext = this.args.context?.commandContext;
if (!commandContext) {
let toolContext = this.args.context?.toolContext;
if (!toolContext) {
console.error('Command context not available');
return;
}

try {
const generateReadmeSpecCommand = new GenerateReadmeSpecTool(
commandContext,
toolContext,
);
await generateReadmeSpecCommand.execute({
spec: this.args.model as Spec,
Expand Down Expand Up @@ -966,7 +966,7 @@ export class Spec extends CardDef {
label: 'Fill in Sample Data with AI',
action: async () => {
await new PopulateFieldSpecExampleCommand(
params.commandContext,
params.toolContext,
).execute({
cardId: this.id,
});
Expand All @@ -978,7 +978,7 @@ export class Spec extends CardDef {
label: `Generate ${GENERATED_EXAMPLE_COUNT} examples with AI`,
action: async () => {
await new GenerateExamplesForFieldSpecCommand(
params.commandContext,
params.toolContext,
).execute({
count: GENERATED_EXAMPLE_COUNT,
codeRef: codeRefWithAbsoluteIdentifier(
Expand Down
Loading
Loading