seshat-scribe 0.9.1 → 2.0.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/README.md +47 -58
- package/dist/commands/generate.d.ts +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +41 -86
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +73 -338
- package/dist/commands/init.js.map +1 -1
- package/dist/config.d.ts +10 -179
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -112
- package/dist/config.js.map +1 -1
- package/dist/core/analyzer.d.ts +1 -1
- package/dist/core/analyzer.d.ts.map +1 -1
- package/dist/core/analyzer.js +2 -115
- package/dist/core/analyzer.js.map +1 -1
- package/dist/core/artist.d.ts +1 -2
- package/dist/core/artist.d.ts.map +1 -1
- package/dist/core/artist.js +2 -5
- package/dist/core/artist.js.map +1 -1
- package/dist/core/portable-writer.d.ts +2 -2
- package/dist/core/portable-writer.d.ts.map +1 -1
- package/dist/core/portable-writer.js +69 -51
- package/dist/core/portable-writer.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -8
- package/dist/core/writer.d.ts +0 -7
- package/dist/core/writer.d.ts.map +0 -1
- package/dist/core/writer.js +0 -126
- package/dist/core/writer.js.map +0 -1
- package/dist/lib/detection.d.ts +0 -13
- package/dist/lib/detection.d.ts.map +0 -1
- package/dist/lib/detection.js +0 -158
- package/dist/lib/detection.js.map +0 -1
- package/dist/lib/frontmatter.d.ts +0 -28
- package/dist/lib/frontmatter.d.ts.map +0 -1
- package/dist/lib/frontmatter.js +0 -114
- package/dist/lib/frontmatter.js.map +0 -1
package/dist/lib/detection.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* Common content directory patterns to check
|
|
5
|
-
*/
|
|
6
|
-
const CONTENT_DIR_PATTERNS = [
|
|
7
|
-
'app/routes/blog', // Remix
|
|
8
|
-
'content/posts',
|
|
9
|
-
'content/blog',
|
|
10
|
-
'posts',
|
|
11
|
-
'blog',
|
|
12
|
-
'src/content/blog', // Astro
|
|
13
|
-
'src/content/posts',
|
|
14
|
-
'app/blog', // Next.js app router
|
|
15
|
-
'pages/blog', // Next.js pages router
|
|
16
|
-
'content',
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
|
-
* Common asset directory patterns to check
|
|
20
|
-
*/
|
|
21
|
-
const ASSET_DIR_PATTERNS = [
|
|
22
|
-
'public/images',
|
|
23
|
-
'public/assets',
|
|
24
|
-
'public/img',
|
|
25
|
-
'public/images/generated',
|
|
26
|
-
'public/assets/images',
|
|
27
|
-
'assets/images',
|
|
28
|
-
];
|
|
29
|
-
/**
|
|
30
|
-
* Detect framework from package.json dependencies
|
|
31
|
-
*/
|
|
32
|
-
async function detectFramework(cwd) {
|
|
33
|
-
try {
|
|
34
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
35
|
-
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
|
|
36
|
-
const allDeps = {
|
|
37
|
-
...packageJson.dependencies,
|
|
38
|
-
...packageJson.devDependencies,
|
|
39
|
-
};
|
|
40
|
-
// Check for framework-specific dependencies
|
|
41
|
-
if (allDeps['@remix-run/react'] || allDeps['@remix-run/node']) {
|
|
42
|
-
return 'remix';
|
|
43
|
-
}
|
|
44
|
-
if (allDeps['next']) {
|
|
45
|
-
return 'next';
|
|
46
|
-
}
|
|
47
|
-
if (allDeps['astro']) {
|
|
48
|
-
return 'astro';
|
|
49
|
-
}
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Count MDX/MD files in a directory recursively
|
|
58
|
-
*/
|
|
59
|
-
async function countContentFiles(dirPath) {
|
|
60
|
-
try {
|
|
61
|
-
let count = 0;
|
|
62
|
-
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
63
|
-
for (const entry of entries) {
|
|
64
|
-
const fullPath = path.join(dirPath, entry.name);
|
|
65
|
-
if (entry.isDirectory()) {
|
|
66
|
-
// Skip node_modules and hidden directories
|
|
67
|
-
if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
68
|
-
count += await countContentFiles(fullPath);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (entry.isFile()) {
|
|
72
|
-
if (entry.name.endsWith('.mdx') || entry.name.endsWith('.md')) {
|
|
73
|
-
count++;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return count;
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Find the first existing directory from a list of patterns
|
|
85
|
-
*/
|
|
86
|
-
async function findExistingDirectory(cwd, patterns) {
|
|
87
|
-
for (const pattern of patterns) {
|
|
88
|
-
const fullPath = path.join(cwd, pattern);
|
|
89
|
-
try {
|
|
90
|
-
const stat = await fs.stat(fullPath);
|
|
91
|
-
if (stat.isDirectory()) {
|
|
92
|
-
const fileCount = await countContentFiles(fullPath);
|
|
93
|
-
if (fileCount > 0) {
|
|
94
|
-
return pattern;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
// Directory doesn't exist, continue
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Detect public asset path from assets directory
|
|
107
|
-
*/
|
|
108
|
-
function derivePublicAssetPath(assetsDir) {
|
|
109
|
-
// Extract the public-facing path (everything after 'public/')
|
|
110
|
-
if (assetsDir.startsWith('public/')) {
|
|
111
|
-
return '/' + assetsDir.substring('public/'.length);
|
|
112
|
-
}
|
|
113
|
-
// Default fallback
|
|
114
|
-
return '/images/generated';
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Auto-detect blog structure in the current directory
|
|
118
|
-
*/
|
|
119
|
-
export async function detectBlogStructure(cwd = process.cwd()) {
|
|
120
|
-
const detected = {
|
|
121
|
-
hasExistingContent: false,
|
|
122
|
-
contentFileCount: 0,
|
|
123
|
-
};
|
|
124
|
-
// Detect framework
|
|
125
|
-
detected.framework = await detectFramework(cwd);
|
|
126
|
-
// Detect content directory
|
|
127
|
-
detected.contentDir = await findExistingDirectory(cwd, CONTENT_DIR_PATTERNS);
|
|
128
|
-
if (detected.contentDir) {
|
|
129
|
-
// Count content files
|
|
130
|
-
const contentPath = path.join(cwd, detected.contentDir);
|
|
131
|
-
detected.contentFileCount = await countContentFiles(contentPath);
|
|
132
|
-
detected.hasExistingContent = detected.contentFileCount > 0;
|
|
133
|
-
}
|
|
134
|
-
// Detect assets directory
|
|
135
|
-
detected.assetsDir = await findExistingDirectory(cwd, ASSET_DIR_PATTERNS);
|
|
136
|
-
// If no existing assets dir found, try to find any public/images or public/assets dir
|
|
137
|
-
if (!detected.assetsDir) {
|
|
138
|
-
for (const pattern of ASSET_DIR_PATTERNS) {
|
|
139
|
-
const fullPath = path.join(cwd, pattern);
|
|
140
|
-
try {
|
|
141
|
-
const stat = await fs.stat(fullPath);
|
|
142
|
-
if (stat.isDirectory()) {
|
|
143
|
-
detected.assetsDir = pattern;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Derive public asset path
|
|
153
|
-
if (detected.assetsDir) {
|
|
154
|
-
detected.publicAssetPath = derivePublicAssetPath(detected.assetsDir);
|
|
155
|
-
}
|
|
156
|
-
return detected;
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=detection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detection.js","sourceRoot":"","sources":["../../src/lib/detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAWxB;;GAEG;AACH,MAAM,oBAAoB,GAAG;IAC3B,iBAAiB,EAAO,QAAQ;IAChC,eAAe;IACf,cAAc;IACd,OAAO;IACP,MAAM;IACN,kBAAkB,EAAM,QAAQ;IAChC,mBAAmB;IACnB,UAAU,EAAc,qBAAqB;IAC7C,YAAY,EAAY,uBAAuB;IAC/C,SAAS;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,eAAe;IACf,eAAe;IACf,YAAY;IACZ,yBAAyB;IACzB,sBAAsB;IACtB,eAAe;CAChB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,GAAW;IACxC,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG;YACd,GAAG,WAAW,CAAC,YAAY;YAC3B,GAAG,WAAW,CAAC,eAAe;SAC/B,CAAC;QAEF,4CAA4C;QAC5C,IAAI,OAAO,CAAC,kBAAkB,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9D,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB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C,CAAC;QACjE,QAAQ,CAAC,kBAAkB,GAAG,QAAQ,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,GAAG,MAAM,qBAAqB,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAE1E,sFAAsF;IACtF,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACxB,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACzC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACrC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACvB,QAAQ,CAAC,SAAS,GAAG,OAAO,CAAC;oBAC7B,MAAM;gBACR,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvB,QAAQ,CAAC,eAAe,GAAG,qBAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FrontmatterConfig } from '../config.js';
|
|
2
|
-
/**
|
|
3
|
-
* Format a date according to the specified format
|
|
4
|
-
*/
|
|
5
|
-
export declare function formatDate(date: Date, format?: string): string;
|
|
6
|
-
/**
|
|
7
|
-
* Format a multiline string for YAML (using >- syntax)
|
|
8
|
-
*/
|
|
9
|
-
export declare function formatMultilineYAML(text: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Build frontmatter string from configuration and values
|
|
12
|
-
*/
|
|
13
|
-
export declare function buildFrontmatter(config: FrontmatterConfig, values: {
|
|
14
|
-
title: string;
|
|
15
|
-
description: string;
|
|
16
|
-
date: Date;
|
|
17
|
-
tag: string;
|
|
18
|
-
imagePath: string | null;
|
|
19
|
-
}): string;
|
|
20
|
-
/**
|
|
21
|
-
* Generate file name from template
|
|
22
|
-
*/
|
|
23
|
-
export declare function buildFileName(template: string, slug: string, date: Date, extension: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Build nested directory path based on date
|
|
26
|
-
*/
|
|
27
|
-
export declare function buildNestedPath(date: Date, baseDir: string): string;
|
|
28
|
-
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/lib/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CA2B9D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE;IACN,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GACA,MAAM,CA2CR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,GAChB,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnE"}
|
package/dist/lib/frontmatter.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a date according to the specified format
|
|
3
|
-
*/
|
|
4
|
-
export function formatDate(date, format) {
|
|
5
|
-
if (!format || format === 'iso') {
|
|
6
|
-
return date.toISOString();
|
|
7
|
-
}
|
|
8
|
-
if (format === 'date-only') {
|
|
9
|
-
return date.toISOString().split('T')[0];
|
|
10
|
-
}
|
|
11
|
-
// Custom format support (basic implementation)
|
|
12
|
-
// Supports: YYYY, MM, DD, HH, mm, ss
|
|
13
|
-
let formatted = format;
|
|
14
|
-
const year = date.getFullYear();
|
|
15
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
16
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
17
|
-
const hours = String(date.getHours()).padStart(2, '0');
|
|
18
|
-
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
19
|
-
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
20
|
-
formatted = formatted.replace('YYYY', String(year));
|
|
21
|
-
formatted = formatted.replace('MM', month);
|
|
22
|
-
formatted = formatted.replace('DD', day);
|
|
23
|
-
formatted = formatted.replace('HH', hours);
|
|
24
|
-
formatted = formatted.replace('mm', minutes);
|
|
25
|
-
formatted = formatted.replace('ss', seconds);
|
|
26
|
-
return formatted;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Format a multiline string for YAML (using >- syntax)
|
|
30
|
-
*/
|
|
31
|
-
export function formatMultilineYAML(text) {
|
|
32
|
-
const lines = text.split('\n').map(line => line.trim()).filter(Boolean);
|
|
33
|
-
if (lines.length === 0)
|
|
34
|
-
return '""';
|
|
35
|
-
if (lines.length === 1)
|
|
36
|
-
return `"${lines[0]}"`;
|
|
37
|
-
return `>-\n ${lines.join('\n ')}`;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Build frontmatter string from configuration and values
|
|
41
|
-
*/
|
|
42
|
-
export function buildFrontmatter(config, values) {
|
|
43
|
-
const lines = ['---'];
|
|
44
|
-
// Title (always included)
|
|
45
|
-
lines.push(`title: "${values.title}"`);
|
|
46
|
-
// Description (multiline format)
|
|
47
|
-
lines.push(`description: ${formatMultilineYAML(values.description)}`);
|
|
48
|
-
// Date (with custom field name and format)
|
|
49
|
-
const dateField = config.dateField || 'date';
|
|
50
|
-
const formattedDate = formatDate(values.date, config.dateFormat);
|
|
51
|
-
lines.push(`${dateField}: ${formattedDate}`);
|
|
52
|
-
// Taxonomy field (tag/category)
|
|
53
|
-
const taxonomyField = config.taxonomyField || 'tag';
|
|
54
|
-
lines.push(`${taxonomyField}: ${values.tag}`);
|
|
55
|
-
// Image field (with custom field name) - only if image exists
|
|
56
|
-
if (values.imagePath) {
|
|
57
|
-
const imageField = config.imageField || 'image';
|
|
58
|
-
lines.push(`${imageField}: "${values.imagePath}"`);
|
|
59
|
-
}
|
|
60
|
-
// Additional custom fields
|
|
61
|
-
if (config.additionalFields) {
|
|
62
|
-
for (const [key, value] of Object.entries(config.additionalFields)) {
|
|
63
|
-
if (typeof value === 'string') {
|
|
64
|
-
lines.push(`${key}: "${value}"`);
|
|
65
|
-
}
|
|
66
|
-
else if (typeof value === 'boolean' || typeof value === 'number') {
|
|
67
|
-
lines.push(`${key}: ${value}`);
|
|
68
|
-
}
|
|
69
|
-
else if (Array.isArray(value)) {
|
|
70
|
-
lines.push(`${key}: [${value.map(v => `"${v}"`).join(', ')}]`);
|
|
71
|
-
}
|
|
72
|
-
else if (value && typeof value === 'object') {
|
|
73
|
-
// Simple object serialization
|
|
74
|
-
lines.push(`${key}: ${JSON.stringify(value)}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
lines.push('---');
|
|
79
|
-
return lines.join('\n');
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Generate file name from template
|
|
83
|
-
*/
|
|
84
|
-
export function buildFileName(template, slug, date, extension) {
|
|
85
|
-
let fileName = template;
|
|
86
|
-
// Replace template variables
|
|
87
|
-
fileName = fileName.replace('{{slug}}', slug);
|
|
88
|
-
// Date components
|
|
89
|
-
const year = date.getFullYear();
|
|
90
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
91
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
92
|
-
fileName = fileName.replace('{{year}}', String(year));
|
|
93
|
-
fileName = fileName.replace('{{month}}', month);
|
|
94
|
-
fileName = fileName.replace('{{day}}', day);
|
|
95
|
-
fileName = fileName.replace('{{date}}', `${year}-${month}-${day}`);
|
|
96
|
-
// Handle {{ext}} placeholder or append extension
|
|
97
|
-
if (fileName.includes('{{ext}}')) {
|
|
98
|
-
fileName = fileName.replace('{{ext}}', extension);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// If no {{ext}} in template, append .extension
|
|
102
|
-
fileName = `${fileName}.${extension}`;
|
|
103
|
-
}
|
|
104
|
-
return fileName;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Build nested directory path based on date
|
|
108
|
-
*/
|
|
109
|
-
export function buildNestedPath(date, baseDir) {
|
|
110
|
-
const year = date.getFullYear();
|
|
111
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
112
|
-
return `${baseDir}/${year}/${month}`;
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/lib/frontmatter.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,MAAe;IACpD,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,C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