prizmkit 1.1.184 → 1.1.185
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/bundled/VERSION.json +3 -3
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
- package/src/gitignore-template.js +40 -9
- package/src/scaffold.js +26 -29
package/bundled/VERSION.json
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate
|
|
2
|
+
* Generate install-time gitignore text.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Install appends the exact `.prizmkit/*` line and any explicit private
|
|
5
|
+
* host-memory filenames. Upgrade and config must not write `.gitignore`.
|
|
6
|
+
* Cleanup removes only private host-memory entries.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
const FRAMEWORK_HEADER = '# PrizmKit';
|
|
10
|
+
const FRAMEWORK_ENTRY = '.prizmkit/*';
|
|
11
|
+
const PRIVATE_MEMORY_HEADER = '# PrizmKit private host memory';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string[] | undefined} values
|
|
15
|
+
* @returns {string[]}
|
|
16
|
+
*/
|
|
17
|
+
function uniqueGitignoreEntries(values) {
|
|
18
|
+
return Array.isArray(values) ? [...new Set(values.filter(Boolean))] : [];
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
/**
|
|
10
22
|
* @param {Object} options - { privateMemoryFiles?: string[] }
|
|
11
23
|
* @returns {string}
|
|
12
24
|
*/
|
|
13
25
|
export function generateGitignore(options = {}) {
|
|
14
|
-
const privateMemoryFiles =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
const privateMemoryFiles = uniqueGitignoreEntries(options.privateMemoryFiles);
|
|
27
|
+
const lines = [FRAMEWORK_HEADER, FRAMEWORK_ENTRY];
|
|
28
|
+
if (privateMemoryFiles.length > 0) {
|
|
29
|
+
lines.push(PRIVATE_MEMORY_HEADER, ...privateMemoryFiles);
|
|
30
|
+
}
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sections appended independently so an existing private-memory header
|
|
36
|
+
* is not treated as the framework header.
|
|
37
|
+
*
|
|
38
|
+
* @param {Object} options - { privateMemoryFiles?: string[] }
|
|
39
|
+
* @returns {{ header: string, entries: string[] }[]}
|
|
40
|
+
*/
|
|
41
|
+
export function gitignoreSections(options = {}) {
|
|
42
|
+
const privateMemoryFiles = uniqueGitignoreEntries(options.privateMemoryFiles);
|
|
43
|
+
const sections = [
|
|
44
|
+
{ header: FRAMEWORK_HEADER, entries: [FRAMEWORK_ENTRY] },
|
|
45
|
+
];
|
|
46
|
+
if (privateMemoryFiles.length > 0) {
|
|
47
|
+
sections.push({ header: PRIVATE_MEMORY_HEADER, entries: privateMemoryFiles });
|
|
48
|
+
}
|
|
49
|
+
return sections;
|
|
19
50
|
}
|
package/src/scaffold.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* 全部使用 Copy 模式(不使用 symlink),项目完全独立于框架仓库。
|
|
5
5
|
* 通过 adapters 转换 core/ 资源为平台特定格式。
|
|
6
6
|
* 不安装框架开发文件(docs、tests、scripts 等)。
|
|
7
|
-
*
|
|
7
|
+
* 安装时追加精确的 `.prizmkit/*` 行和所选平台的私有记忆文件 ignore。
|
|
8
|
+
* upgrade 与 config 不写 `.gitignore`。
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import chalk from 'chalk';
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
loadRulesMetadata,
|
|
25
26
|
getSkillCandidatePaths,
|
|
26
27
|
} from './metadata.js';
|
|
27
|
-
import { generateGitignore } from './gitignore-template.js';
|
|
28
|
+
import { generateGitignore, gitignoreSections } from './gitignore-template.js';
|
|
28
29
|
import { buildManifest, readManifestForLifecycle, writeManifest } from './manifest.js';
|
|
29
30
|
import { canonicalizePlatformSelection, defaultCliForPlatform, expandPlatforms, isKnownPlatform, nativeSkillRoot, payloadSkillRoots, platformLabel, privateProjectMemoryFile, privateProjectMemoryFiles, projectMemoryFile, resolvePayloadPlatforms, unknownPlatformMessage } from './platforms.js';
|
|
30
31
|
import { normalizeRuntime, runtimeLabel } from './runtimes.js';
|
|
@@ -1374,46 +1375,42 @@ export async function installPipeline(projectRoot, dryRun, options = {}) {
|
|
|
1374
1375
|
*/
|
|
1375
1376
|
export async function installGitignore(projectRoot, options = {}, dryRun) {
|
|
1376
1377
|
const targetPath = path.join(projectRoot, '.gitignore');
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
});
|
|
1378
|
+
const sectionOptions = { privateMemoryFiles: options.privateMemoryFiles || [] };
|
|
1379
|
+
const templateContent = generateGitignore(sectionOptions);
|
|
1380
|
+
const sections = gitignoreSections(sectionOptions);
|
|
1381
1381
|
const existed = await fs.pathExists(targetPath);
|
|
1382
1382
|
|
|
1383
1383
|
if (dryRun) {
|
|
1384
|
-
|
|
1385
|
-
if (!existed) console.log(chalk.gray(' [dry-run] .gitignore (no managed private-memory entries)'));
|
|
1386
|
-
return;
|
|
1387
|
-
}
|
|
1388
|
-
console.log(chalk.gray(' [dry-run] .gitignore (private host memory only)'));
|
|
1384
|
+
console.log(chalk.gray(' [dry-run] .gitignore (.prizmkit/* and private host memory)'));
|
|
1389
1385
|
return;
|
|
1390
1386
|
}
|
|
1391
1387
|
|
|
1392
|
-
if (!
|
|
1393
|
-
|
|
1388
|
+
if (!existed) {
|
|
1389
|
+
await fs.writeFile(targetPath, `${templateContent}\n`);
|
|
1390
|
+
console.log(chalk.green(' ✓ .gitignore'));
|
|
1394
1391
|
return;
|
|
1395
1392
|
}
|
|
1396
1393
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1394
|
+
const current = await fs.readFile(targetPath, 'utf-8');
|
|
1395
|
+
const existingLines = new Set(current.split('\n').map(line => line.trim()));
|
|
1396
|
+
const chunks = [];
|
|
1397
|
+
let missingCount = 0;
|
|
1398
|
+
for (const section of sections) {
|
|
1399
|
+
const missing = section.entries.filter(line => !existingLines.has(line));
|
|
1400
|
+
if (missing.length === 0) continue;
|
|
1401
|
+
missingCount += missing.length;
|
|
1402
|
+
const header = existingLines.has(section.header) ? '' : `${section.header}\n`;
|
|
1403
|
+
chunks.push(header + missing.join('\n'));
|
|
1404
|
+
}
|
|
1402
1405
|
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
const managedHeader = '# PrizmKit private host memory';
|
|
1406
|
-
const header = existingLines.has(managedHeader) ? '' : `${managedHeader}\n`;
|
|
1407
|
-
await fs.appendFile(targetPath, separator + '\n' + header + missing.join('\n') + '\n');
|
|
1408
|
-
console.log(chalk.green(` ✓ .gitignore (added ${missing.length} entries)`));
|
|
1409
|
-
} else {
|
|
1410
|
-
console.log(chalk.green(' ✓ .gitignore (up-to-date)'));
|
|
1411
|
-
}
|
|
1406
|
+
if (missingCount === 0) {
|
|
1407
|
+
console.log(chalk.green(' ✓ .gitignore (up-to-date)'));
|
|
1412
1408
|
return;
|
|
1413
1409
|
}
|
|
1414
1410
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1411
|
+
const separator = current.endsWith('\n') ? '' : '\n';
|
|
1412
|
+
await fs.appendFile(targetPath, `${separator}\n${chunks.join('\n')}\n`);
|
|
1413
|
+
console.log(chalk.green(` ✓ .gitignore (added ${missingCount} entries)`));
|
|
1417
1414
|
}
|
|
1418
1415
|
|
|
1419
1416
|
// ============================================================
|