@pennyfarthing/shared 7.9.0 → 9.3.0
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/dist/browser.d.ts +6 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +8 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/marker/constants.d.ts +5 -3
- package/dist/marker/constants.d.ts.map +1 -1
- package/dist/marker/constants.js +7 -4
- package/dist/marker/constants.js.map +1 -1
- package/dist/marker/continue.test.d.ts +12 -0
- package/dist/marker/continue.test.d.ts.map +1 -0
- package/dist/marker/continue.test.js +76 -0
- package/dist/marker/continue.test.js.map +1 -0
- package/dist/marker/detect.js +1 -1
- package/dist/marker/detect.js.map +1 -1
- package/dist/marker/detect.test.js +3 -2
- package/dist/marker/detect.test.js.map +1 -1
- package/dist/marker/types.d.ts +1 -1
- package/dist/marker/types.d.ts.map +1 -1
- package/dist/migrate-theme-schema.test.js +47 -14
- package/dist/migrate-theme-schema.test.js.map +1 -1
- package/dist/portrait-resolver.d.ts.map +1 -1
- package/dist/portrait-resolver.js +97 -19
- package/dist/portrait-resolver.js.map +1 -1
- package/dist/theme-loader.d.ts +57 -11
- package/dist/theme-loader.d.ts.map +1 -1
- package/dist/theme-loader.js +442 -35
- package/dist/theme-loader.js.map +1 -1
- package/package.json +11 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 4. Scoped npm (node_modules/@pennyfarthing/core/pennyfarthing-dist/)
|
|
9
9
|
* 5. Legacy npm (node_modules/pennyfarthing/pennyfarthing-dist/)
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
11
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
12
12
|
import { join, dirname, resolve } from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
// Get the directory where this module is located
|
|
@@ -64,25 +64,13 @@ export function resolvePennyfarthingDist() {
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @param agent - Agent name (e.g., 'sm', 'tea', 'dev')
|
|
70
|
-
* @returns Full path to portrait file, or null if not found
|
|
67
|
+
* Find portrait in a specific theme directory.
|
|
68
|
+
* Shared logic for both core and theme package portrait resolution.
|
|
71
69
|
*/
|
|
72
|
-
|
|
73
|
-
const distPath = resolvePennyfarthingDist();
|
|
74
|
-
if (!distPath) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
const paths = getPortraitPaths(distPath);
|
|
78
|
-
const portraitsThemeDir = join(paths.portraitsDir, theme);
|
|
70
|
+
function findPortraitInDir(portraitsThemeDir, agent) {
|
|
79
71
|
if (!existsSync(portraitsThemeDir)) {
|
|
80
72
|
return null;
|
|
81
73
|
}
|
|
82
|
-
// Look for portrait file matching the agent
|
|
83
|
-
// Portraits are in size subdirectories: large/, medium/, small/, original/
|
|
84
|
-
// Portraits follow pattern: {shortName}-{ocean}.png
|
|
85
|
-
// Agent names in tests may be short names (sm, tea, dev) or need mapping
|
|
86
74
|
try {
|
|
87
75
|
// Check size subdirectories in preference order
|
|
88
76
|
const sizeDirectories = ['large', 'medium', 'small', 'original'];
|
|
@@ -102,9 +90,6 @@ export function resolvePortraitPath(theme, agent) {
|
|
|
102
90
|
searchDir = portraitsThemeDir;
|
|
103
91
|
}
|
|
104
92
|
// Map agent names to portrait file prefixes based on theme conventions
|
|
105
|
-
// For most themes, portrait names use character short names
|
|
106
|
-
// We need to find a file that contains the agent name or its mapping
|
|
107
|
-
// Note: This includes characters from multiple themes (shakespeare, norse, a-team)
|
|
108
93
|
const agentMappings = {
|
|
109
94
|
'sm': ['prospero', 'baldur', 'face', 'faceman', 'sm'],
|
|
110
95
|
'tea': ['hamlet', 'tyr', 'murdock', 'tea'],
|
|
@@ -132,6 +117,99 @@ export function resolvePortraitPath(theme, agent) {
|
|
|
132
117
|
}
|
|
133
118
|
return null;
|
|
134
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Discover theme package portrait directories.
|
|
122
|
+
* Inlined here to avoid circular dependency with theme-loader.ts.
|
|
123
|
+
*/
|
|
124
|
+
function discoverThemePackagePortraitDirs() {
|
|
125
|
+
const results = [];
|
|
126
|
+
let currentDir = process.cwd();
|
|
127
|
+
// Check node_modules/@pennyfarthing/themes-*
|
|
128
|
+
for (let i = 0; i < 10; i++) {
|
|
129
|
+
const nmPfDir = join(currentDir, 'node_modules', '@pennyfarthing');
|
|
130
|
+
if (existsSync(nmPfDir)) {
|
|
131
|
+
try {
|
|
132
|
+
for (const entry of readdirSync(nmPfDir)) {
|
|
133
|
+
if (!entry.startsWith('themes-'))
|
|
134
|
+
continue;
|
|
135
|
+
const pkgJsonPath = join(nmPfDir, entry, 'package.json');
|
|
136
|
+
if (!existsSync(pkgJsonPath))
|
|
137
|
+
continue;
|
|
138
|
+
try {
|
|
139
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
140
|
+
if (pkgJson['pennyfarthing-theme-pack'] === true) {
|
|
141
|
+
results.push({ portraitsDir: join(nmPfDir, entry, 'portraits') });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch { /* skip */ }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch { /* skip */ }
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
const parentDir = dirname(currentDir);
|
|
151
|
+
if (parentDir === currentDir)
|
|
152
|
+
break;
|
|
153
|
+
currentDir = parentDir;
|
|
154
|
+
}
|
|
155
|
+
// Check monorepo packages/themes-*
|
|
156
|
+
currentDir = process.cwd();
|
|
157
|
+
for (let i = 0; i < 10; i++) {
|
|
158
|
+
const packagesDir = join(currentDir, 'packages');
|
|
159
|
+
if (existsSync(packagesDir)) {
|
|
160
|
+
try {
|
|
161
|
+
for (const entry of readdirSync(packagesDir)) {
|
|
162
|
+
if (!entry.startsWith('themes-'))
|
|
163
|
+
continue;
|
|
164
|
+
const pkgJsonPath = join(packagesDir, entry, 'package.json');
|
|
165
|
+
if (!existsSync(pkgJsonPath))
|
|
166
|
+
continue;
|
|
167
|
+
try {
|
|
168
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
169
|
+
if (pkgJson['pennyfarthing-theme-pack'] === true) {
|
|
170
|
+
const portraitsDir = join(packagesDir, entry, 'portraits');
|
|
171
|
+
if (!results.some(r => r.portraitsDir === portraitsDir)) {
|
|
172
|
+
results.push({ portraitsDir });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch { /* skip */ }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch { /* skip */ }
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
const parentDir = dirname(currentDir);
|
|
183
|
+
if (parentDir === currentDir)
|
|
184
|
+
break;
|
|
185
|
+
currentDir = parentDir;
|
|
186
|
+
}
|
|
187
|
+
return results;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Resolve the full path to a portrait image
|
|
191
|
+
* @param theme - Theme name (e.g., 'shakespeare', 'norse-mythology')
|
|
192
|
+
* @param agent - Agent name (e.g., 'sm', 'tea', 'dev')
|
|
193
|
+
* @returns Full path to portrait file, or null if not found
|
|
194
|
+
*/
|
|
195
|
+
export function resolvePortraitPath(theme, agent) {
|
|
196
|
+
// 1. Check core portraits
|
|
197
|
+
const distPath = resolvePennyfarthingDist();
|
|
198
|
+
if (distPath) {
|
|
199
|
+
const paths = getPortraitPaths(distPath);
|
|
200
|
+
const coreResult = findPortraitInDir(join(paths.portraitsDir, theme), agent);
|
|
201
|
+
if (coreResult)
|
|
202
|
+
return coreResult;
|
|
203
|
+
}
|
|
204
|
+
// 2. Check theme package portraits
|
|
205
|
+
const themePackages = discoverThemePackagePortraitDirs();
|
|
206
|
+
for (const pkg of themePackages) {
|
|
207
|
+
const pkgResult = findPortraitInDir(join(pkg.portraitsDir, theme), agent);
|
|
208
|
+
if (pkgResult)
|
|
209
|
+
return pkgResult;
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
135
213
|
/**
|
|
136
214
|
* Get all portrait-related paths for a resolved dist directory
|
|
137
215
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portrait-resolver.js","sourceRoot":"","sources":["../src/portrait-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"portrait-resolver.js","sourceRoot":"","sources":["../src/portrait-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQzC,iDAAiD;AACjD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,oDAAoD;IACpD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC/C,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,oEAAoE;IACtE,CAAC;IAED,qEAAqE;IACrE,iEAAiE;IACjE,IAAI,UAAU,GAAG,SAAS,CAAC;IAC3B,KAAK,IAAI,CA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AAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7E,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;IACpC,CAAC;IAED,mCAAmC;IACnC,MAAM,aAAa,GAAG,gCAAgC,EAAE,CAAC;IACzD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1E,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC;IAClC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,4CAA4C;IAC5C,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEpD,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,WAAW,CAAC;QAC3D,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC;QAC3C,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
package/dist/theme-loader.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Theme Loader -
|
|
2
|
+
* Theme Loader - Unified theme discovery, loading, and metadata for Pennyfarthing
|
|
3
|
+
*
|
|
4
|
+
* This is the ONE canonical implementation of theme loading. All other packages
|
|
5
|
+
* (core CLI, cyclist, Python scripts, bash scripts) should delegate here.
|
|
6
|
+
*
|
|
7
|
+
* Discovery algorithm (checked in order, deduped by theme ID):
|
|
8
|
+
* 1. Core themes: resolvePennyfarthingDist()/personas/themes/
|
|
9
|
+
* 2. Theme packages: node_modules/@pennyfarthing/themes-* /themes/
|
|
10
|
+
* 3. Project custom: {projectRoot}/.claude/pennyfarthing/themes/
|
|
11
|
+
* 4. User custom: ~/.claude/pennyfarthing/themes/
|
|
3
12
|
*/
|
|
4
13
|
export interface ThemeAgent {
|
|
5
14
|
character: string;
|
|
@@ -14,22 +23,59 @@ export interface Theme {
|
|
|
14
23
|
description: string;
|
|
15
24
|
agents: Record<string, ThemeAgent>;
|
|
16
25
|
}
|
|
26
|
+
export interface ThemePackageInfo {
|
|
27
|
+
packageName: string;
|
|
28
|
+
themesDir: string;
|
|
29
|
+
portraitsDir: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ThemeMetadata {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
source: string;
|
|
36
|
+
tier: 'S' | 'A' | 'B' | 'U';
|
|
37
|
+
category: string;
|
|
38
|
+
agentCount: number;
|
|
39
|
+
}
|
|
40
|
+
export declare const CATEGORY_MAP: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Derive category from theme ID and source text.
|
|
43
|
+
* Uses CATEGORY_MAP for known themes, falls back to pattern matching.
|
|
44
|
+
*/
|
|
45
|
+
export declare function deriveCategory(themeId: string, source: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Discover installed @pennyfarthing/themes-* packages.
|
|
48
|
+
* Walks up from projectRoot looking for node_modules/@pennyfarthing/,
|
|
49
|
+
* then checks each themes-* directory for a valid theme pack.
|
|
50
|
+
*/
|
|
51
|
+
export declare function discoverThemePackages(projectRoot?: string): ThemePackageInfo[];
|
|
52
|
+
/**
|
|
53
|
+
* Discover all directories containing theme YAML files.
|
|
54
|
+
* Returns dirs in priority order (core, theme packages, project custom, user custom).
|
|
55
|
+
*/
|
|
56
|
+
export declare function discoverAllThemeDirs(projectRoot?: string): string[];
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the file path for a specific theme across all sources.
|
|
59
|
+
* Returns the first match found in priority order, or null.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveThemePath(themeId: string, projectRoot?: string): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Load metadata for all discoverable themes.
|
|
64
|
+
* Deduplicates by theme ID (first source wins).
|
|
65
|
+
*/
|
|
66
|
+
export declare function loadAllThemeMetadata(projectRoot?: string): ThemeMetadata[];
|
|
17
67
|
/**
|
|
18
|
-
* Load a theme configuration by name
|
|
19
|
-
*
|
|
20
|
-
* @returns Parsed theme configuration or null if not found
|
|
68
|
+
* Load a theme configuration by name.
|
|
69
|
+
* Searches all theme sources in priority order.
|
|
21
70
|
*/
|
|
22
71
|
export declare function loadTheme(themeName: string): Theme | null;
|
|
23
72
|
/**
|
|
24
|
-
* List all available
|
|
25
|
-
*
|
|
73
|
+
* List all available theme IDs across all sources.
|
|
74
|
+
* Deduplicates — first source wins.
|
|
26
75
|
*/
|
|
27
|
-
export declare function listThemes(): string[];
|
|
76
|
+
export declare function listThemes(projectRoot?: string): string[];
|
|
28
77
|
/**
|
|
29
|
-
* Get agent persona from a theme
|
|
30
|
-
* @param themeName - Theme name
|
|
31
|
-
* @param agentName - Agent name (e.g., 'sm', 'tea', 'dev')
|
|
32
|
-
* @returns Agent persona or null if not found
|
|
78
|
+
* Get agent persona from a theme.
|
|
33
79
|
*/
|
|
34
80
|
export declare function getAgentPersona(themeName: string, agentName: string): ThemeAgent | null;
|
|
35
81
|
//# sourceMappingURL=theme-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-loader.d.ts","sourceRoot":"","sources":["../src/theme-loader.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"theme-loader.d.ts","sourceRoot":"","sources":["../src/theme-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,Y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