prosicht 1.6.0 → 1.7.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 +12 -0
- package/index.js +29 -2
- package/lib/overrides.js +42 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,6 +25,18 @@ npx prosicht update
|
|
|
25
25
|
```
|
|
26
26
|
Sunum klasörlerinde `update` yalnızca çekirdek dosyaları (`index.html`, `css/core/`, `js/core/`, `AGENTS.md`) yeniler; `js/scenes.js`, `js/sims/`, `css/theme.css`, `css/sims/`, `assets/` ve `sources.md` dokunulmadan kalır. Blog klasörlerinde de yalnızca çekirdek yenilenir (`js/post.js`, `js/sims/`, `css/theme.css`, `css/sims/`, `assets/`, `sources.md` dokunulmaz). Eski (1.x) klasör yapısındaki sunumlar onayla yeni yapıya taşınır (`--yes` sormadan taşır). Sunum ve blog aynı çekirdek yollarını kullanır: bir kitin klasörüne diğeri yazılmadan önce onay istenir, `--yes` ile bu durumda işlem yapılmaz.
|
|
27
27
|
|
|
28
|
+
### Projeye özel kurallar
|
|
29
|
+
|
|
30
|
+
`init` ve `update`, `AGENTS.md`'yi şablondan baştan yazar. Projeye özel kuralları (ör. Next.js şablonunu Nuxt'a uyarlayan eşlemeler) şu işaretler arasına yazın; CLI bu bloğu olduğu gibi korur ve yeni şablonda ilk `## ` başlığının önüne (başlık ve giriş paragrafından sonra) koyar:
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
<!-- BEGIN:project-overrides -->
|
|
34
|
+
## 0. Project Overrides
|
|
35
|
+
- ...
|
|
36
|
+
<!-- END:project-overrides -->
|
|
37
|
+
```
|
|
38
|
+
İşaretler eksik, ters sırada ya da birden fazlaysa CLI hata verir ve `AGENTS.md`'ye dokunmaz. Uygulama şablonlarında ve sunum / blog kitlerinde aynı şekilde çalışır (CLI 1.7+).
|
|
39
|
+
|
|
28
40
|
## Yayınlama
|
|
29
41
|
|
|
30
42
|
```bash
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const { version } = require('./package.json');
|
|
|
8
8
|
const { detectLayout } = require('./lib/layout');
|
|
9
9
|
const { migrateV1 } = require('./lib/migrate');
|
|
10
10
|
const { publish } = require('./lib/publish');
|
|
11
|
+
const { insertOverrides, readExistingOverrides } = require('./lib/overrides');
|
|
11
12
|
|
|
12
13
|
// PROSICHT_TEMPLATES_URL: sablonlari push etmeden yerel bir sunucudan denemek icin
|
|
13
14
|
const BASE_URL = (process.env.PROSICHT_TEMPLATES_URL || 'https://raw.githubusercontent.com/ProSicht/ai-standards/main/templates').replace(/\/+$/, '');
|
|
@@ -71,6 +72,26 @@ function withTemplateTag(content, templateKey) {
|
|
|
71
72
|
return `<!-- template: ${templateKey} -->\n` + content.replace(TAG_PATTERN, '');
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
// Yeni AGENTS.md: şablon + etiket + projedeki mevcut AGENTS.md'nin proje bloğu (varsa)
|
|
76
|
+
function buildAgentsMd(content, templateKey, overrides) {
|
|
77
|
+
return withTemplateTag(overrides ? insertOverrides(content, overrides) : content, templateKey);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Mevcut AGENTS.md'nin proje bloğu; işaretler bozuksa hatayı yazar ve undefined döner (hiçbir şey yazılmaz)
|
|
81
|
+
function loadOverrides() {
|
|
82
|
+
try {
|
|
83
|
+
return readExistingOverrides(process.cwd());
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(`Hata: ${error.message} AGENTS.md degistirilmedi.`);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function reportOverrides(overrides) {
|
|
92
|
+
if (overrides) console.log('Projeye ozel blok (project-overrides) korundu.');
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
async function download(url) {
|
|
75
96
|
const response = await fetch(url);
|
|
76
97
|
if (!response.ok) {
|
|
@@ -117,14 +138,17 @@ async function askTemplate(message) {
|
|
|
117
138
|
async function fetchAndSaveTemplate(templateKey) {
|
|
118
139
|
const selected = APP_TEMPLATES[templateKey];
|
|
119
140
|
const fileUrl = `${BASE_URL}/${selected.file}`;
|
|
141
|
+
const overrides = loadOverrides();
|
|
142
|
+
if (overrides === undefined) return;
|
|
120
143
|
console.log(`\n[Pro Sicht] "${selected.name}" sablonu indiriliyor...`);
|
|
121
144
|
|
|
122
145
|
try {
|
|
123
146
|
const content = (await download(fileUrl)).toString('utf8');
|
|
124
147
|
const targetPath = path.join(process.cwd(), 'AGENTS.md');
|
|
125
|
-
fs.writeFileSync(targetPath,
|
|
148
|
+
fs.writeFileSync(targetPath, buildAgentsMd(content, templateKey, overrides), 'utf8');
|
|
126
149
|
|
|
127
150
|
console.log(`Basarili: AGENTS.md kaydedildi! (Sablon: ${templateKey})`);
|
|
151
|
+
reportOverrides(overrides);
|
|
128
152
|
console.log(`Konum: ${targetPath}\n`);
|
|
129
153
|
} catch (error) {
|
|
130
154
|
console.error('Indirme hatasi:', error.message);
|
|
@@ -169,6 +193,8 @@ async function installKit(key, mode, options = {}) {
|
|
|
169
193
|
}
|
|
170
194
|
}
|
|
171
195
|
|
|
196
|
+
const overrides = loadOverrides();
|
|
197
|
+
if (overrides === undefined) return;
|
|
172
198
|
console.log(`\n[Pro Sicht] ${kit.name} ${mode === 'update' ? 'guncelleniyor' : 'indiriliyor'}...`);
|
|
173
199
|
|
|
174
200
|
try {
|
|
@@ -188,7 +214,7 @@ async function installKit(key, mode, options = {}) {
|
|
|
188
214
|
const url = `${base}/${job.file.split('/').map(encodeURIComponent).join('/')}`;
|
|
189
215
|
let data = await download(url);
|
|
190
216
|
if (job.file === 'AGENTS.md') {
|
|
191
|
-
data = Buffer.from(
|
|
217
|
+
data = Buffer.from(buildAgentsMd(data.toString('utf8'), key, overrides), 'utf8');
|
|
192
218
|
}
|
|
193
219
|
return { ...job, data };
|
|
194
220
|
}));
|
|
@@ -211,6 +237,7 @@ async function installKit(key, mode, options = {}) {
|
|
|
211
237
|
for (const job of kept) console.log(` = ${job.file} (mevcut, korundu)`);
|
|
212
238
|
|
|
213
239
|
console.log(`Basarili: ${files.length} dosya yazildi (${kit.name} v${manifest.version || '?'}).`);
|
|
240
|
+
if (files.some((file) => file.file === 'AGENTS.md')) reportOverrides(overrides);
|
|
214
241
|
if (mode === 'init') {
|
|
215
242
|
console.log('\nSonraki adimlar:');
|
|
216
243
|
for (const step of kit.nextSteps) console.log(` ${step}`);
|
package/lib/overrides.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Projeye özel kurallar AGENTS.md içinde bu işaretler arasında durur; init ve update
|
|
5
|
+
// şablonu yeniden yazarken bloğu olduğu gibi korur (ör. Next.js şablonunu Nuxt'a uyarlayan kurallar)
|
|
6
|
+
const BEGIN = '<!-- BEGIN:project-overrides -->';
|
|
7
|
+
const END = '<!-- END:project-overrides -->';
|
|
8
|
+
|
|
9
|
+
function count(text, marker) {
|
|
10
|
+
return text.split(marker).length - 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Bloğu (işaretler dahil) döndürür; blok yoksa null. Bozuk işaretlerde hata fırlatır:
|
|
14
|
+
// yazmaya devam etmek bloğu sessizce siler.
|
|
15
|
+
function extractOverrides(content) {
|
|
16
|
+
const begins = count(content, BEGIN);
|
|
17
|
+
const ends = count(content, END);
|
|
18
|
+
if (begins === 0 && ends === 0) return null;
|
|
19
|
+
const start = content.indexOf(BEGIN);
|
|
20
|
+
const end = content.indexOf(END);
|
|
21
|
+
if (begins !== 1 || ends !== 1 || end < start) {
|
|
22
|
+
throw new Error(`AGENTS.md icindeki proje blogu bozuk: tam olarak bir "${BEGIN}" ve ondan sonra bir "${END}" olmali.`);
|
|
23
|
+
}
|
|
24
|
+
return content.slice(start, end + END.length);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Bloğu şablonun ilk "## " başlığının önüne koyar (başlık ve giriş paragrafından sonra);
|
|
28
|
+
// başlık yoksa sona ekler
|
|
29
|
+
function insertOverrides(content, block) {
|
|
30
|
+
const heading = content.search(/^## /m);
|
|
31
|
+
if (heading === -1) return `${content.replace(/\n*$/, '')}\n\n${block}\n`;
|
|
32
|
+
return `${content.slice(0, heading)}${block}\n\n${content.slice(heading)}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Projedeki mevcut AGENTS.md'den blok; dosya yoksa null
|
|
36
|
+
function readExistingOverrides(root) {
|
|
37
|
+
const file = path.join(root, 'AGENTS.md');
|
|
38
|
+
if (!fs.existsSync(file)) return null;
|
|
39
|
+
return extractOverrides(fs.readFileSync(file, 'utf8'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { BEGIN, END, extractOverrides, insertOverrides, readExistingOverrides };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosicht",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Pro Sicht AI Standards CLI: AGENTS.md sablonlari, sunum ve blog altyapisi",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=18"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"test": "
|
|
17
|
+
"test": "node --test"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"ai",
|