@rien7/seji 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/seji.mjs +12 -0
- package/dist/cli/dev.mjs +10 -6
- package/dist/cli/doctor.mjs +9 -4
- package/dist/cli/setup.mjs +3 -0
- package/dist/editor/App.d.ts.map +1 -1
- package/dist/editor/App.js +4 -2
- package/dist/editor/App.js.map +1 -1
- package/dist/editor-bundle/editor.js +56 -56
- package/dist/shared/legacyPaths.d.mts +1 -0
- package/dist/shared/legacyPaths.mjs +9 -0
- package/dist/shared/prompt.d.mts +5 -0
- package/dist/shared/prompt.mjs +18 -2
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/plugin.js +9 -0
- package/dist/vite/plugin.js.map +1 -1
- package/package.json +2 -2
- package/skills/seji/SKILL.md +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function legacyEditorRedirect(reqUrl: string | undefined): string | null
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 0.5.x served the editor and its API under /__design; 0.6.0 moved them to /__seji. Old
|
|
2
|
+
// bookmarks and links get a 302 to the same place under /__seji (query kept).
|
|
3
|
+
|
|
4
|
+
/** The /__seji location for an old /__design[/…] request URL, else null. */
|
|
5
|
+
export function legacyEditorRedirect(reqUrl) {
|
|
6
|
+
const url = new URL(reqUrl ?? '/', 'http://seji.local')
|
|
7
|
+
if (url.pathname !== '/__design' && !url.pathname.startsWith('/__design/')) return null
|
|
8
|
+
return `/__seji${url.pathname.slice('/__design'.length)}${url.search}`
|
|
9
|
+
}
|
package/dist/shared/prompt.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ReviewItem } from './types'
|
|
2
2
|
|
|
3
3
|
export declare const PROMPT_RULES: readonly string[]
|
|
4
|
+
export declare const REPLY_LANGUAGE_RULE: string
|
|
5
|
+
export declare const LOCALE_LANGUAGES: Record<string, string>
|
|
6
|
+
export declare function userLanguageRule(locale: string | undefined | null): string | null
|
|
4
7
|
export declare function isUnreviewedProposal(item: ReviewItem): boolean
|
|
5
8
|
export declare function isCopyableReviewItem(item: ReviewItem): boolean
|
|
6
9
|
export declare function itemTargetLabel(item: ReviewItem): string
|
|
@@ -17,4 +20,6 @@ export declare function buildAgentPrompt(options: {
|
|
|
17
20
|
items: ReviewItem[]
|
|
18
21
|
batchId?: string
|
|
19
22
|
missingComponents?: Array<{ name: string; file: string }>
|
|
23
|
+
/** The editor's i18n locale ('en' | 'zh-CN'): the prompt states the user's language. */
|
|
24
|
+
locale?: string
|
|
20
25
|
}): string
|
package/dist/shared/prompt.mjs
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { itemTargetKind } from './sketches.mjs'
|
|
2
2
|
|
|
3
|
+
export const REPLY_LANGUAGE_RULE =
|
|
4
|
+
"- Write every reply (`seji reply`, `--reply`) in the language the comment / item author wrote in; when the item has no human text (a tool or token edit only), use the editor's language."
|
|
5
|
+
|
|
6
|
+
/** How the prompt names the editor's locale. */
|
|
7
|
+
export const LOCALE_LANGUAGES = { en: 'English', 'zh-CN': '中文' }
|
|
8
|
+
|
|
9
|
+
/** "The user's language is …" for an editor locale, or null when unknown. */
|
|
10
|
+
export function userLanguageRule(locale) {
|
|
11
|
+
const language = locale ? LOCALE_LANGUAGES[locale] ?? locale : null
|
|
12
|
+
return language ? `- The user's language is ${language} (the editor's language).` : null
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export const PROMPT_RULES = [
|
|
4
16
|
'- The review ledger is the source of truth. Do not delete items or create per-frame session files.',
|
|
5
17
|
'- Tokens are design-scoped. Apply the tokenAction to the DTCG source named on the item (`design/tokens/*.tokens.json`), then run `seji tokens build` and `seji tokens check` (or `pnpm tokens:build` and `pnpm tokens:check`). Do not invent token names or edit generated token files. The surface verifies the generated value/alias before archiving.',
|
|
@@ -18,6 +30,7 @@ export const PROMPT_RULES = [
|
|
|
18
30
|
'- Items with a `Screenshot:` line carry a PNG of the frame exactly as the person saw it (tab, state, scroll) when posting; read it before acting on the item.',
|
|
19
31
|
'- Comments with `Sketch: yes` point at a sketch component (source under `design/`, canvas-only): change the sketch and say in the reply that only the sketch changed and the product did not. Other comments about product UI change `src/`: follow the source to the component the product renders, and write the call chain from the product entry point plus the `src/` file you changed in the reply before resolving. Unsure which one it is: ask first.',
|
|
20
32
|
'- Reply to comment threads with `seji reply <design> <itemId> "<message>" [--resolve]`.',
|
|
33
|
+
REPLY_LANGUAGE_RULE,
|
|
21
34
|
'- Do not write `verifiedAt` or `archivedAt`, and do not delete or archive items manually. Token items archive only after verification plus 10 minutes; rejected proposals and non-token resolved items archive after 10 minutes; items with a snapshot baseline also wait for a passing snapshot check.',
|
|
22
35
|
'- Before editing source for these items, run `seji snapshot wait <design>`: the canvas captures "before" snapshots of new items in the background, and editing first would record the changed state as the baseline.',
|
|
23
36
|
'- Items with `snapshot rejected …` were sent back from snapshot review: fix what the reason describes on the named screens, mark the item `resolved`, then run `seji verify --snapshots` so the screens are compared again. Do not accept or reject snapshots yourself.',
|
|
@@ -172,7 +185,10 @@ export function missingComponentPages(catalog, hasPage) {
|
|
|
172
185
|
.map((component) => ({ name: component.name, file: String(component.file).replace(/^(?:\.\.\/)+/, '') }))
|
|
173
186
|
}
|
|
174
187
|
|
|
175
|
-
|
|
188
|
+
/** `locale`: the editor's language (i18n locale), stated next to the reply-language rule. */
|
|
189
|
+
export function buildAgentPrompt({ design, items, batchId, missingComponents = [], locale }) {
|
|
190
|
+
const language = userLanguageRule(locale)
|
|
191
|
+
const rules = language ? PROMPT_RULES.flatMap((rule) => (rule === REPLY_LANGUAGE_RULE ? [rule, language] : [rule])) : PROMPT_RULES
|
|
176
192
|
const lines = [
|
|
177
193
|
'Apply the pending review items from the design surface.',
|
|
178
194
|
'',
|
|
@@ -195,7 +211,7 @@ export function buildAgentPrompt({ design, items, batchId, missingComponents = [
|
|
|
195
211
|
]
|
|
196
212
|
: []),
|
|
197
213
|
'Rules:',
|
|
198
|
-
...
|
|
214
|
+
...rules,
|
|
199
215
|
]
|
|
200
216
|
return lines.join('\n')
|
|
201
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAA;AAoDjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;IACd,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACxC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IAC7B,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sEAAsE;IACtE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CACvC,CAAA;AA0MD,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA6kCtE"}
|
package/dist/vite/plugin.js
CHANGED
|
@@ -23,6 +23,7 @@ import { readLayout, writeLayout } from "./layout.js";
|
|
|
23
23
|
import { ownRuntimeDir, runtimeAliases, workspaceRootOf } from '../shared/packages.mjs';
|
|
24
24
|
import { applyReviewOps, emptyReview, readReview } from "./review.js";
|
|
25
25
|
import { SAFE_ITEM_ID, commentShotPath, decodePngDataUrl, storeCommentShot } from '../shared/commentShots.mjs';
|
|
26
|
+
import { legacyEditorRedirect } from '../shared/legacyPaths.mjs';
|
|
26
27
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
27
28
|
const packageRoot = path.resolve(here, '../..');
|
|
28
29
|
const packageVersion = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8')).version;
|
|
@@ -603,6 +604,14 @@ ${hotAccept('components')}`;
|
|
|
603
604
|
server.httpServer?.once('close', () => void agentRoutes.close());
|
|
604
605
|
server.middlewares.use((req, res, next) => {
|
|
605
606
|
const url = new URL(req.url ?? '/', 'http://seji.local');
|
|
607
|
+
const moved = legacyEditorRedirect(req.url);
|
|
608
|
+
if (moved) {
|
|
609
|
+
res.statusCode = 302;
|
|
610
|
+
res.setHeader('location', moved);
|
|
611
|
+
res.setHeader('cache-control', 'no-store');
|
|
612
|
+
res.end();
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
606
615
|
if (agentRoutes.handle(req, res, url))
|
|
607
616
|
return;
|
|
608
617
|
if (url.pathname === '/__seji/api/events') {
|