create-principles-disciple 1.105.0 → 1.106.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/console/dist/server/routes/update.js +91 -0
- package/console/dist/web/assets/app.css +3 -0
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +10 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +22 -1
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +12 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +8 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js +42 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts +2 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js +42 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +18 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +27 -0
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/dist/installer.d.ts +2 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +11 -2
- package/dist/installer.js.map +1 -1
- package/dist/skill-language.d.ts +32 -0
- package/dist/skill-language.d.ts.map +1 -0
- package/dist/skill-language.js +107 -0
- package/dist/skill-language.js.map +1 -0
- package/host-runtime/dist/active-principle-prompt.js +5 -1
- package/package.json +1 -1
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +2 -0
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +6 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/plugin/dist/bundle.js +550 -477
- package/plugin/dist/core/principle-application-ledger.d.ts +45 -0
- package/plugin/dist/core/principle-receipt-metadata.d.ts +15 -0
- package/plugin/dist/hooks/gate-block-helper.d.ts +4 -0
- package/plugin/dist/openclaw-sdk.d.ts +23 -1
- package/plugin/dist/openclaw.plugin.json +0 -1
- package/plugin/openclaw.plugin.json +1 -2
- package/plugin/package.json +1 -1
- package/plugin/scripts/sync-plugin.mjs +17 -8
- package/plugin/scripts/verify-build.mjs +19 -8
|
@@ -128,6 +128,85 @@ function copyFileTo(src, dest) {
|
|
|
128
128
|
fs.mkdirSync(dir, { recursive: true });
|
|
129
129
|
fs.copyFileSync(src, dest);
|
|
130
130
|
}
|
|
131
|
+
// --- Plugin skill-language preservation (PR #1332 companion) -----------------
|
|
132
|
+
// OpenClaw publishes plugin skills by directory name (first declaration
|
|
133
|
+
// wins, same-name roots only warn — no locale mechanism), so a manifest must
|
|
134
|
+
// declare exactly ONE language root. The shipped manifest declares zh
|
|
135
|
+
// (product default); installs made with --lang en have their installed
|
|
136
|
+
// manifest rewritten to the en root by the installer. Updates ship a fresh
|
|
137
|
+
// zh-default manifest and would silently revert that choice — so capture the
|
|
138
|
+
// installed language BEFORE any mutation and re-apply it after the new
|
|
139
|
+
// manifest lands. Mirrors create-principles-disciple/src/skill-language.ts
|
|
140
|
+
// (keep the two transforms in sync).
|
|
141
|
+
const SKILL_LANGUAGE_ROOTS = {
|
|
142
|
+
zh: 'templates/langs/zh/skills',
|
|
143
|
+
en: 'templates/langs/en/skills',
|
|
144
|
+
};
|
|
145
|
+
function isLanguageSkillRoot(entry) {
|
|
146
|
+
if (typeof entry !== 'string')
|
|
147
|
+
return false;
|
|
148
|
+
const normalized = entry.replaceAll('\\', '/');
|
|
149
|
+
return normalized === SKILL_LANGUAGE_ROOTS.zh || normalized === SKILL_LANGUAGE_ROOTS.en;
|
|
150
|
+
}
|
|
151
|
+
function detectInstalledSkillLanguage(extDir) {
|
|
152
|
+
try {
|
|
153
|
+
const manifestPath = path.join(extDir, 'openclaw.plugin.json');
|
|
154
|
+
if (!fs.existsSync(manifestPath))
|
|
155
|
+
return 'zh';
|
|
156
|
+
const raw = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
157
|
+
if (!isRecord(raw) || !Array.isArray(raw.skills))
|
|
158
|
+
return 'zh';
|
|
159
|
+
const languages = new Set();
|
|
160
|
+
for (const entry of raw.skills) {
|
|
161
|
+
if (typeof entry !== 'string')
|
|
162
|
+
continue;
|
|
163
|
+
const normalized = entry.replaceAll('\\', '/');
|
|
164
|
+
if (normalized === SKILL_LANGUAGE_ROOTS.zh)
|
|
165
|
+
languages.add('zh');
|
|
166
|
+
else if (normalized === SKILL_LANGUAGE_ROOTS.en)
|
|
167
|
+
languages.add('en');
|
|
168
|
+
}
|
|
169
|
+
// Exactly one language root → that is the user's selection. Zero or both
|
|
170
|
+
// (pre-ERR-097 legacy install) → product default.
|
|
171
|
+
if (languages.size !== 1)
|
|
172
|
+
return 'zh';
|
|
173
|
+
for (const language of languages)
|
|
174
|
+
return language;
|
|
175
|
+
return 'zh';
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return 'zh';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function reapplySkillLanguage(extDir, language) {
|
|
182
|
+
try {
|
|
183
|
+
const manifestPath = path.join(extDir, 'openclaw.plugin.json');
|
|
184
|
+
if (!fs.existsSync(manifestPath))
|
|
185
|
+
return;
|
|
186
|
+
// Defense in depth: only rewrite when the selected language's templates
|
|
187
|
+
// actually exist — otherwise the host would warn "plugin skill path not
|
|
188
|
+
// found" and publish nothing.
|
|
189
|
+
if (!fs.existsSync(path.join(extDir, SKILL_LANGUAGE_ROOTS[language]))) {
|
|
190
|
+
console.error(`[pd-console:update] skill language "${language}" templates missing — keeping shipped manifest skills`);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const raw = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
194
|
+
if (!isRecord(raw) || !Array.isArray(raw.skills))
|
|
195
|
+
return;
|
|
196
|
+
const skills = raw.skills;
|
|
197
|
+
const kept = skills.filter((entry) => typeof entry === 'string' && !isLanguageSkillRoot(entry));
|
|
198
|
+
const next = [...kept, SKILL_LANGUAGE_ROOTS[language]];
|
|
199
|
+
const unchanged = next.length === skills.length && next.every((entry, i) => entry === skills[i]);
|
|
200
|
+
if (unchanged)
|
|
201
|
+
return;
|
|
202
|
+
raw.skills = next;
|
|
203
|
+
fs.writeFileSync(manifestPath, JSON.stringify(raw, null, 2) + '\n', 'utf-8');
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
// rc-9: degrade observably, never fail the whole update over skill language.
|
|
207
|
+
console.error(`[pd-console:update] failed to re-apply skill language "${language}": ${error instanceof Error ? error.message : String(error)}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
131
210
|
function getAllFilesLocal(dir, skipDirs) {
|
|
132
211
|
const skip = skipDirs ?? new Set();
|
|
133
212
|
const result = [];
|
|
@@ -293,6 +372,9 @@ async function doApplyUpdate(options, workspaceDir) {
|
|
|
293
372
|
try {
|
|
294
373
|
// 0. Save current version BEFORE any changes
|
|
295
374
|
const fromVersion = readCurrentVersion(targetDir) ?? 'unknown';
|
|
375
|
+
// Capture the installed skill language before the tarball's manifest
|
|
376
|
+
// overwrites it (PR #1332 companion — see reapplySkillLanguage).
|
|
377
|
+
const skillLanguage = detectInstalledSkillLanguage(targetDir);
|
|
296
378
|
// 1. Fetch latest package info (with timeout + retry)
|
|
297
379
|
const response = await fetchWithRetry(NPM_REGISTRY_LATEST, 'Registry check');
|
|
298
380
|
const rawData = await response.json();
|
|
@@ -355,6 +437,9 @@ async function doApplyUpdate(options, workspaceDir) {
|
|
|
355
437
|
copyFileTo(path.join(tempDir, file), path.join(targetDir, file));
|
|
356
438
|
updatedFiles.push(file);
|
|
357
439
|
}
|
|
440
|
+
// 4b. The incoming manifest declares the product-default skill language
|
|
441
|
+
// (zh); restore the language this install was materialized with.
|
|
442
|
+
reapplySkillLanguage(targetDir, skillLanguage);
|
|
358
443
|
// Fix 3: deletions intentionally skipped — see comment above.
|
|
359
444
|
// 5. Update package.json version
|
|
360
445
|
const pkgPath = path.join(targetDir, 'package.json');
|
|
@@ -487,6 +572,9 @@ async function doInlineFullUpdate(workspaceDir) {
|
|
|
487
572
|
}
|
|
488
573
|
// Capture version before changes
|
|
489
574
|
const fromVersion = readCurrentVersion(extDir) ?? 'unknown';
|
|
575
|
+
// Capture the installed skill language before the tarball's manifest
|
|
576
|
+
// overwrites it (PR #1332 companion — see reapplySkillLanguage).
|
|
577
|
+
const skillLanguage = detectInstalledSkillLanguage(extDir);
|
|
490
578
|
let tempDir;
|
|
491
579
|
try {
|
|
492
580
|
// 2. Fetch installer package info from npm
|
|
@@ -527,6 +615,9 @@ async function doInlineFullUpdate(workspaceDir) {
|
|
|
527
615
|
const pluginSrc = path.join(tempDir, 'plugin');
|
|
528
616
|
if (fs.existsSync(pluginSrc)) {
|
|
529
617
|
copyDirRecursive(pluginSrc, extDir, SKIP_DIRS);
|
|
618
|
+
// The incoming manifest declares the product-default skill language
|
|
619
|
+
// (zh); restore the language this install was materialized with.
|
|
620
|
+
reapplySkillLanguage(extDir, skillLanguage);
|
|
530
621
|
}
|
|
531
622
|
// b. console/ → extDir/console/ (overwrite dist/ files; do NOT rmSync —
|
|
532
623
|
// console/node_modules/ may contain locked native modules like
|
|
@@ -328,6 +328,12 @@ const KNOWN_PLUGIN_CORE_FILES = new Set([
|
|
|
328
328
|
// I/O shell: reads .pd/config.yaml, constructs PiAiRuntimeAdapter, writes trajectory.
|
|
329
329
|
// Pure detection logic lives in @principles/core/runtime-v2/signal-collector/.
|
|
330
330
|
'signal-collector-host.ts',
|
|
331
|
+
// PRI-530: Plugin I/O boundary — sync readonly state.db reads resolving principle
|
|
332
|
+
// receipt attribution (title fallback chain / approval date / source summary).
|
|
333
|
+
'principle-receipt-metadata.ts',
|
|
334
|
+
// PRI-531: Plugin I/O boundary — durable receipt ledger writes (state.db
|
|
335
|
+
// principle_applications inserts + 90-day retention sweep).
|
|
336
|
+
'principle-application-ledger.ts',
|
|
331
337
|
'pain-lifecycle.ts',
|
|
332
338
|
'session-tracker.ts',
|
|
333
339
|
// PRI-459: now a thin re-export adapter over @principles/core/principle-tree-ledger.
|
|
@@ -429,7 +435,10 @@ describe('PRI-212 plugin core anti-growth guard', () => {
|
|
|
429
435
|
// collection I/O host (correction + empathy upstream merge). Reads
|
|
430
436
|
// .pd/config.yaml, constructs PiAiRuntimeAdapter, writes trajectory. Pure
|
|
431
437
|
// detection logic lives in @principles/core/runtime-v2/signal-collector/.
|
|
432
|
-
|
|
438
|
+
// PRI-530: Added principle-receipt-metadata.ts (94 → 95) — plugin I/O boundary
|
|
439
|
+
// for principle receipt attribution reads (readonly state.db joins).
|
|
440
|
+
// PRI-531: Added principle-application-ledger.ts (95 → 96) — receipt ledger writer.
|
|
441
|
+
expect(KNOWN_PLUGIN_CORE_FILES.size).toBe(96);
|
|
433
442
|
});
|
|
434
443
|
});
|
|
435
444
|
const REQUIRED_TEST_FILES = [
|