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.
Files changed (50) hide show
  1. package/console/dist/server/routes/update.js +91 -0
  2. package/console/dist/web/assets/app.css +3 -0
  3. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +10 -1
  4. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  5. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +22 -1
  6. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
  7. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +12 -1
  8. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  9. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +8 -1
  10. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
  11. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts +2 -0
  12. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts.map +1 -0
  13. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js +42 -0
  14. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js.map +1 -0
  15. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts +2 -0
  16. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts.map +1 -0
  17. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js +42 -0
  18. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js.map +1 -0
  19. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  20. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +18 -0
  21. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  22. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  23. package/core/dist/runtime-v2/store/sqlite-connection.js +27 -0
  24. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  25. package/dist/installer.d.ts +2 -0
  26. package/dist/installer.d.ts.map +1 -1
  27. package/dist/installer.js +11 -2
  28. package/dist/installer.js.map +1 -1
  29. package/dist/skill-language.d.ts +32 -0
  30. package/dist/skill-language.d.ts.map +1 -0
  31. package/dist/skill-language.js +107 -0
  32. package/dist/skill-language.js.map +1 -0
  33. package/host-runtime/dist/active-principle-prompt.js +5 -1
  34. package/package.json +1 -1
  35. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  36. package/pd-cli/dist/commands/console.js +2 -0
  37. package/pd-cli/dist/commands/console.js.map +1 -1
  38. package/pd-cli/dist/services/console-launcher.d.ts +6 -0
  39. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  40. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  41. package/plugin/dist/bundle.js +550 -477
  42. package/plugin/dist/core/principle-application-ledger.d.ts +45 -0
  43. package/plugin/dist/core/principle-receipt-metadata.d.ts +15 -0
  44. package/plugin/dist/hooks/gate-block-helper.d.ts +4 -0
  45. package/plugin/dist/openclaw-sdk.d.ts +23 -1
  46. package/plugin/dist/openclaw.plugin.json +0 -1
  47. package/plugin/openclaw.plugin.json +1 -2
  48. package/plugin/package.json +1 -1
  49. package/plugin/scripts/sync-plugin.mjs +17 -8
  50. 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
@@ -2234,6 +2234,9 @@
2234
2234
  -moz-user-select: none;
2235
2235
  user-select: none;
2236
2236
  }
2237
+ .\[pd-console\:update\] {
2238
+ pd-console: update;
2239
+ }
2237
2240
  @media (hover: hover) {
2238
2241
  .group-hover\:opacity-100:is(:where(.group):hover *) {
2239
2242
  opacity: 100%;
@@ -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
- expect(KNOWN_PLUGIN_CORE_FILES.size).toBe(94);
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 = [