Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function appendRun(
return runs;
}

const SKILL_TOKEN_REGEX = /(^|\s)\$([a-zA-Z][a-zA-Z0-9:_-]*)(?=\s|$)/g;
const SKILL_TOKEN_REGEX = /(^|\s)\$(?:"((?:\\.|[^"\\])*)"|([a-zA-Z][a-zA-Z0-9:_-]*))(?=\s|$)/g;

function formatSkillLabel(skill: SelectableMarkdownSkill): string {
const displayName = skill.displayName?.trim();
Expand Down Expand Up @@ -225,13 +225,14 @@ function decorateSkillRuns(
let matched = false;
for (const match of run.text.matchAll(SKILL_TOKEN_REGEX)) {
const prefix = match[1] ?? "";
const name = match[2] ?? "";
const quotedName = match[2];
const name = quotedName !== undefined ? quotedName.replace(/\\(.)/g, "$1") : (match[3] ?? "");
const skill = skillByName.get(name);
if (!skill) {
continue;
}
const start = (match.index ?? 0) + prefix.length;
const end = start + name.length + 1;
const end = start + match[0].length - prefix.length;
if (start > cursor) {
decorated.push({ ...run, text: run.text.slice(cursor, start) });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
detectComposerTrigger,
replaceTextRange,
serializeComposerFileLink,
serializeComposerSkillToken,
} from "@t3tools/shared/composerTrigger";
import {
insertRankedSearchResult,
Expand Down Expand Up @@ -262,7 +263,7 @@ export function useComposerCommandMenu({
if (item.type === "path") {
replacement = `${serializeComposerFileLink(item.path)} `;
} else if (item.type === "skill") {
replacement = `$${item.skill.name} `;
replacement = `${serializeComposerSkillToken(item.skill.name)} `;
} else if (item.type === "slash-command") {
replacement = `/${item.command} `;
} else if (item.type === "provider-slash-command") {
Expand Down
25 changes: 25 additions & 0 deletions apps/mobile/src/lib/nativeMarkdownText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@ describe("nativeMarkdownDocumentRuns", () => {
});
});

it("decorates quoted skill names that contain spaces", () => {
const node: MarkdownNode = {
type: "document",
children: [
{
type: "paragraph",
children: [{ type: "text", content: 'Use $"Create Hook" for this.' }],
},
],
};

expect(
nativeMarkdownDocumentRuns(node, [{ name: "Create Hook", displayName: "Create Hook" }]),
).toEqual([
{ text: "Use ", role: "body" },
{
text: '$"Create Hook"',
role: "body",
skillName: "Create Hook",
skillLabel: "Create Hook",
},
{ text: " for this.", role: "body" },
]);
});

it("leaves unknown skill-like text unchanged", () => {
const node: MarkdownNode = {
type: "document",
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/provider/Drivers/CursorDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
const path = yield* Path.Path;
const httpClient = yield* HttpClient.HttpClient;
const serverSettings = yield* ServerSettingsService;
const { cwd } = yield* ServerConfig;
const eventLoggers = yield* ProviderEventLoggers;
const processEnv = mergeProviderInstanceEnvironment(environment);
const continuationIdentity = defaultProviderContinuationIdentity({
Expand All @@ -132,7 +133,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
});
const textGeneration = yield* makeCursorTextGeneration(effectiveConfig, processEnv);

const checkProvider = checkCursorProviderStatus(effectiveConfig, processEnv).pipe(
const checkProvider = checkCursorProviderStatus(effectiveConfig, processEnv, cwd).pipe(
Effect.map(stampIdentity),
Effect.provideService(Crypto.Crypto, crypto),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
Expand Down
Loading
Loading