JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat(cli): add /rename and /config command for cli
ldstyle8d498f9e160ef
diff --git a/jiuwenclaw/cli/src/core/attachments.ts b/jiuwenclaw/cli/src/core/attachments.tsindex db636f2f0a..fb4a387e3c 100644--- a/jiuwenclaw/cli/src/core/attachments.ts+++ b/jiuwenclaw/cli/src/core/attachments.ts@@ -160,3 +160,45 @@ export function extractFilePathsFromPaste(return paths;}++/** Same `@path` token pattern as `AT_MENTION_RE`, for single-line cursor lookups. */+const AT_MENTION_PER_LINE_RE = /(^|[\t ])@(?:"([^"]+)"|([^\s]+))/g;++export function findAttachmentTokenAtCursor(+ line: string,+ col: number,+): { start: number; end: number } | null {+ for (const match of line.matchAll(AT_MENTION_PER_LINE_RE)) {+ const startIdx = match.index ?? 0;+ const endIdx = startIdx + match[0].length;+ if (col > startIdx && col <= endIdx) {+ return { start: startIdx, end: endIdx };+ }+ }+ return null;+}++/**+ * Reconciles image `@mentions` in composer text with a sidecar list (e.g. base64 previews).+ * Drops entries no longer present in text and preserves `content` for paths still referenced.+ */+export function syncComposerImageTokens(+ text: string,+ previous: readonly FileAttachment[],+ isImagePath: (path: string) => boolean,+): { normalizedText: string; attachments: FileAttachment[] } {+ const extracted = extractAttachmentsFromText(text, {+ classifyAttachment: (path) => (isImagePath(path) ? "image" : null),+ });++ const prevByPath = new Map(previous.map((a) => [a.path, a]));+ const attachments: FileAttachment[] = extracted.map(({ resolvedPath: _r, ...rest }) => {+ const prev = prevByPath.get(rest.path);+ if (prev?.content) {+ return { ...rest, content: prev.content };+ }+ return rest;+ });++ return { normalizedText: text, attachments };+}diff --git a/jiuwenclaw/cli/src/ui/app-screen.ts b/jiuwenclaw/cli/src/ui/app-screen.tsindex cf9e5bd09e..a6038cbaed 100644--- a/jiuwenclaw/cli/src/ui/app-screen.ts+++ b/jiuwenclaw/cli/src/ui/app-screen.ts@@ -16,9 +16,11 @@ import type { CliPiAppState } from "../app-state.js";import {extractAttachmentsFromText,extractFilePathsFromPaste,+ findAttachmentTokenAtCursor,formatAttachmentMention,isImageAttachment,isSupportedAttachment,+ syncComposerImageTokens,} from "../core/attachments.js";import { CommandService, parseSlashCommand } from "../core/commands/CommandService.js";import { addError, addInfo } from "../core/commands/helpers.js";@@ -345,6 +347,8 @@ export class AppScreen implements Component, Focusable {private pendingSubmittedInput: string | null = null;private pendingSubmittedBaseline = 0;private pendingSubmittedSessionId: string | null = null;+ /** Image attachments keyed by composer `@path` tokens (e.g. cached base64 for terminal preview). */+ private composerAttachments: FileAttachment[] = [];constructor(private readonly tui: TUI,@@ -625,7 +629,6 @@ export class AppScreen implements Component, Focusable {return;}- const content = this.composeOutgoingMessage(text);if (!content) return;const snapshot = this.state.getSnapshot();@@ -935,6 +938,9 @@ export class AppScreen implements Component, Focusable {return {content: text.replace(/[ \t]{2,}/g, " ").replace(/[ \t]+\n/g, "\n").trim(),attachments: this.collectComposerAttachments(text),+ };+ }+private buildConfigEditorLines(width: number): string[] {if (!this.configEditorState) {return [];@@ -1239,9 +1245,16 @@ export class AppScreen implements Component, Focusable {this.syncingComposerInput = true;this.editor.setText(nextText);- const editorState = this.editor as unknown as {- state?: { cursorLine: number; cursorCol: number };+ const ed = this.editor as unknown as {+ state: { cursorLine: number };+ setCursorCol: (col: number) => void;};+ ed.state.cursorLine = cursor.line;+ ed.setCursorCol(nextCol);+ this.syncingComposerInput = false;+ this.syncComposerAttachmentsFromEditor();+ this.tui.requestRender();+ return true;}private collectComposerAttachments(text: string): FileAttachment[] {@@ -1266,6 +1279,10 @@ export class AppScreen implements Component, Focusable {}}+ private isComposerImageFile(path: string): boolean {+ return this.isAcceptedAttachment(path) && isImageAttachment(path);+ }+/** Handle pasted/dragged content - detects file paths and converts to @path references. */private handleDroppedFiles(filePaths: string[]): void {const insertText = filePaths