@djangocfg/nextjs 2.1.7 ā 2.1.9
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 +3 -3
- package/dist/ai/cli.mjs +52 -27
- package/dist/ai/cli.mjs.map +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/ai/CLAUDE.md +12 -0
- package/src/ai/cli.ts +61 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"LICENSE"
|
|
94
94
|
],
|
|
95
95
|
"bin": {
|
|
96
|
-
"
|
|
96
|
+
"djangocfg-docs": "./dist/ai/cli.mjs"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"build": "tsup",
|
|
@@ -105,13 +105,13 @@
|
|
|
105
105
|
"ai-docs": "tsx src/ai/cli.ts"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@djangocfg/api": "^2.1.
|
|
108
|
+
"@djangocfg/api": "^2.1.9",
|
|
109
109
|
"next": "^15.5.7"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@djangocfg/imgai": "^2.1.
|
|
113
|
-
"@djangocfg/layouts": "^2.1.
|
|
114
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
112
|
+
"@djangocfg/imgai": "^2.1.9",
|
|
113
|
+
"@djangocfg/layouts": "^2.1.9",
|
|
114
|
+
"@djangocfg/typescript-config": "^2.1.9",
|
|
115
115
|
"@types/node": "^24.7.2",
|
|
116
116
|
"@types/react": "19.2.2",
|
|
117
117
|
"@types/react-dom": "19.2.1",
|
package/src/ai/CLAUDE.md
CHANGED
|
@@ -14,6 +14,18 @@ DjangoCFG documentation is available via MCP server.
|
|
|
14
14
|
}
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## CLI
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install globally
|
|
21
|
+
npm install -g @djangocfg/nextjs
|
|
22
|
+
|
|
23
|
+
# Use CLI
|
|
24
|
+
djangocfg-docs search "database configuration"
|
|
25
|
+
djangocfg-docs mcp
|
|
26
|
+
djangocfg-docs info
|
|
27
|
+
```
|
|
28
|
+
|
|
17
29
|
## API
|
|
18
30
|
|
|
19
31
|
```bash
|
package/src/ai/cli.ts
CHANGED
|
@@ -3,70 +3,102 @@
|
|
|
3
3
|
* DjangoCFG AI Docs CLI
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* npx @djangocfg/nextjs ai-docs search "query"
|
|
6
|
+
* npx djangocfg-docs search "database configuration"
|
|
7
|
+
* npx djangocfg-docs mcp
|
|
9
8
|
*/
|
|
10
9
|
|
|
10
|
+
import { consola } from 'consola';
|
|
11
11
|
import { search, getMcpConfig, MCP_SERVER_URL, MCP_API_URL } from './index';
|
|
12
12
|
|
|
13
13
|
const args = process.argv.slice(2);
|
|
14
14
|
const command = args[0];
|
|
15
15
|
const query = args.slice(1).join(' ');
|
|
16
16
|
|
|
17
|
+
/** Wrap text to terminal width with indent */
|
|
18
|
+
function wrapText(text: string, indent = 3, maxWidth?: number): string {
|
|
19
|
+
const width = maxWidth || process.stdout.columns || 80;
|
|
20
|
+
const effectiveWidth = width - indent;
|
|
21
|
+
const prefix = ' '.repeat(indent);
|
|
22
|
+
|
|
23
|
+
// Clean up text - remove extra whitespace and newlines
|
|
24
|
+
const cleaned = text.replace(/\s+/g, ' ').trim();
|
|
25
|
+
|
|
26
|
+
if (cleaned.length <= effectiveWidth) {
|
|
27
|
+
return prefix + cleaned;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const words = cleaned.split(' ');
|
|
31
|
+
const lines: string[] = [];
|
|
32
|
+
let currentLine = '';
|
|
33
|
+
|
|
34
|
+
for (const word of words) {
|
|
35
|
+
if (currentLine.length + word.length + 1 <= effectiveWidth) {
|
|
36
|
+
currentLine += (currentLine ? ' ' : '') + word;
|
|
37
|
+
} else {
|
|
38
|
+
if (currentLine) lines.push(prefix + currentLine);
|
|
39
|
+
currentLine = word;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (currentLine) lines.push(prefix + currentLine);
|
|
43
|
+
|
|
44
|
+
return lines.join('\n');
|
|
45
|
+
}
|
|
46
|
+
|
|
17
47
|
async function main() {
|
|
18
48
|
switch (command) {
|
|
19
49
|
case 'search':
|
|
20
50
|
case 's':
|
|
21
51
|
if (!query) {
|
|
22
|
-
|
|
52
|
+
consola.error('Usage: djangocfg-docs search "your query"');
|
|
23
53
|
process.exit(1);
|
|
24
54
|
}
|
|
25
|
-
|
|
55
|
+
consola.info(`Searching: ${query}\n`);
|
|
26
56
|
try {
|
|
27
57
|
const results = await search(query, { limit: 5 });
|
|
28
58
|
if (results.length === 0) {
|
|
29
|
-
|
|
59
|
+
consola.warn('No results found.');
|
|
30
60
|
} else {
|
|
31
61
|
results.forEach((r, i) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log('');
|
|
62
|
+
consola.success(`${i + 1}. ${r.title}`);
|
|
63
|
+
// Wrap content to terminal width
|
|
64
|
+
const contentPreview = r.content.slice(0, 200);
|
|
65
|
+
console.log(wrapText(contentPreview + '...'));
|
|
66
|
+
if (r.url) consola.log(` ${r.url}`);
|
|
67
|
+
consola.log('');
|
|
36
68
|
});
|
|
37
69
|
}
|
|
38
70
|
} catch (err) {
|
|
39
|
-
|
|
71
|
+
consola.error('Error:', err instanceof Error ? err.message : err);
|
|
40
72
|
process.exit(1);
|
|
41
73
|
}
|
|
42
74
|
break;
|
|
43
75
|
|
|
44
76
|
case 'mcp':
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
77
|
+
consola.box('MCP Server Configuration');
|
|
78
|
+
consola.log(JSON.stringify(getMcpConfig(), null, 2));
|
|
79
|
+
consola.info('Add this to your AI assistant configuration.');
|
|
48
80
|
break;
|
|
49
81
|
|
|
50
82
|
case 'info':
|
|
51
83
|
case 'i':
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
consola.box('DjangoCFG AI Documentation');
|
|
85
|
+
consola.info(`MCP Server: ${MCP_SERVER_URL}`);
|
|
86
|
+
consola.info(`Search API: ${MCP_API_URL}`);
|
|
87
|
+
consola.log('\nUsage:');
|
|
88
|
+
consola.log(' npx djangocfg-docs search "database configuration"');
|
|
89
|
+
consola.log(' npx djangocfg-docs mcp');
|
|
58
90
|
break;
|
|
59
91
|
|
|
60
92
|
default:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
consola.box('DjangoCFG AI Documentation CLI');
|
|
94
|
+
consola.log('Commands:');
|
|
95
|
+
consola.log(' search <query> Search documentation');
|
|
96
|
+
consola.log(' mcp Show MCP server config');
|
|
97
|
+
consola.log(' info Show help\n');
|
|
98
|
+
consola.log('Examples:');
|
|
99
|
+
consola.log(' npx djangocfg-docs search "database configuration"');
|
|
100
|
+
consola.log(' npx djangocfg-docs search "redis cache"');
|
|
101
|
+
consola.log(' npx djangocfg-docs mcp');
|
|
70
102
|
break;
|
|
71
103
|
}
|
|
72
104
|
}
|