create-principles-disciple 1.105.0 → 1.107.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 (60) hide show
  1. package/console/dist/server/index.js +16 -0
  2. package/console/dist/server/routes/update.js +126 -9
  3. package/console/dist/server/utils/pd-backups.d.ts +24 -0
  4. package/console/dist/server/utils/pd-backups.js +125 -0
  5. package/console/dist/web/assets/app.css +3 -0
  6. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +10 -1
  7. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  8. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +22 -1
  9. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
  10. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +12 -1
  11. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  12. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +8 -1
  13. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
  14. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts +2 -0
  15. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.d.ts.map +1 -0
  16. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js +42 -0
  17. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-block-copy-flag.test.js.map +1 -0
  18. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts +2 -0
  19. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.d.ts.map +1 -0
  20. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js +42 -0
  21. package/core/dist/runtime-v2/feature-flags/__tests__/principle-receipt-ledger-flag.test.js.map +1 -0
  22. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  23. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +18 -0
  24. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  25. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  26. package/core/dist/runtime-v2/store/sqlite-connection.js +27 -0
  27. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  28. package/dist/installer.d.ts +22 -0
  29. package/dist/installer.d.ts.map +1 -1
  30. package/dist/installer.js +67 -5
  31. package/dist/installer.js.map +1 -1
  32. package/dist/mvp-config.d.ts +8 -0
  33. package/dist/mvp-config.d.ts.map +1 -1
  34. package/dist/mvp-config.js +10 -0
  35. package/dist/mvp-config.js.map +1 -1
  36. package/dist/skill-language.d.ts +32 -0
  37. package/dist/skill-language.d.ts.map +1 -0
  38. package/dist/skill-language.js +107 -0
  39. package/dist/skill-language.js.map +1 -0
  40. package/dist/updater.d.ts.map +1 -1
  41. package/dist/updater.js +29 -4
  42. package/dist/updater.js.map +1 -1
  43. package/host-runtime/dist/active-principle-prompt.js +5 -1
  44. package/package.json +1 -1
  45. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  46. package/pd-cli/dist/commands/console.js +2 -0
  47. package/pd-cli/dist/commands/console.js.map +1 -1
  48. package/pd-cli/dist/services/console-launcher.d.ts +6 -0
  49. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  50. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  51. package/plugin/dist/bundle.js +550 -477
  52. package/plugin/dist/core/principle-application-ledger.d.ts +45 -0
  53. package/plugin/dist/core/principle-receipt-metadata.d.ts +15 -0
  54. package/plugin/dist/hooks/gate-block-helper.d.ts +4 -0
  55. package/plugin/dist/openclaw-sdk.d.ts +23 -1
  56. package/plugin/dist/openclaw.plugin.json +0 -1
  57. package/plugin/openclaw.plugin.json +1 -2
  58. package/plugin/package.json +1 -1
  59. package/plugin/scripts/sync-plugin.mjs +17 -8
  60. package/plugin/scripts/verify-build.mjs +19 -8
@@ -0,0 +1,45 @@
1
+ export type PrincipleApplicationLevel = 'effect' | 'presence';
2
+ export type PrincipleApplicationKind = 'rule_blocked' | 'auto_correct_applied' | 'self_reported' | 'prompt_injected';
3
+ export interface PrincipleApplicationInput {
4
+ principleId: string;
5
+ activationId?: string;
6
+ ruleId?: string;
7
+ channel: 'code_tool_hook' | 'prompt';
8
+ level: PrincipleApplicationLevel;
9
+ kind: PrincipleApplicationKind;
10
+ sessionId?: string;
11
+ toolName?: string;
12
+ filePath?: string;
13
+ digest?: string;
14
+ }
15
+ /**
16
+ * Record one application event. Returns true when a row was written (or
17
+ * deduped), false on failure — callers must surface the reason (rc-9).
18
+ */
19
+ export declare function recordPrincipleApplication(workspaceDir: string, input: PrincipleApplicationInput): boolean;
20
+ /**
21
+ * Align activation ids with the actually-injected principle subset (PRI-531
22
+ * review fix). Budget truncation can drop principles from the tail of the
23
+ * full list — pairing by raw index would attach the wrong activation_id to a
24
+ * presence row (rc-6-adjacent data pairing).
25
+ */
26
+ export declare function alignActivationIds(principles: ReadonlyArray<{
27
+ principleId: string;
28
+ activationId?: string;
29
+ }>, injectedIds: ReadonlySet<string>): string[];
30
+ /**
31
+ * Presence rows for a prompt injection event — one per principle, deduped per
32
+ * session×principle by the partial unique index (restarts included).
33
+ * Returns the number of NEW rows written (0 when all were already present).
34
+ * Failures are warned via the optional logger (rc-9) — never thrown.
35
+ */
36
+ export declare function recordInjectionPresence(workspaceDir: string, principleIds: readonly string[], sessionId: string | undefined, activationIds?: readonly string[], logger?: {
37
+ warn?: (message: string) => void;
38
+ info?: (message: string) => void;
39
+ }): number;
40
+ export declare function recordSelfReportFromText(workspaceDir: string, text: unknown, sessionId: string | undefined, logger?: {
41
+ warn?: (message: string) => void;
42
+ info?: (message: string) => void;
43
+ }): number;
44
+ /** Test hook: close cached connections and reset the retention sweep clock. */
45
+ export declare function clearPrincipleApplicationLedgerCache(): void;
@@ -0,0 +1,15 @@
1
+ export interface PrincipleReceiptMetadata {
2
+ /** Resolved display title (fallback chain result; never empty). */
3
+ title: string;
4
+ /** Owner approval date (ISO string) — approvals.decided_at, fallback activations.activated_at. */
5
+ approvedAt?: string;
6
+ /** Source correction summary — only present when the artifact carries painReasonSummary. */
7
+ sourceSummary?: string;
8
+ }
9
+ /**
10
+ * Resolve receipt metadata for a blocked rule. Returns undefined when nothing
11
+ * useful can be resolved (caller degrades to the generic copy).
12
+ */
13
+ export declare function loadPrincipleReceiptMetadata(workspaceDir: string, ruleId: string | undefined, principleId: string | undefined): PrincipleReceiptMetadata | undefined;
14
+ /** Test hook: clear caches between tests. */
15
+ export declare function clearPrincipleReceiptMetadataCache(): void;
@@ -21,6 +21,10 @@ export interface BlockContext {
21
21
  sessionId?: string;
22
22
  /** Source module that triggered the block (for audit trail) */
23
23
  blockSource?: string;
24
+ /** RuleHost rule id — enables PRI-530 receipt copy attribution */
25
+ ruleId?: string;
26
+ /** Principle id from the rule result — enables PRI-530 receipt copy attribution */
27
+ principleId?: string;
24
28
  }
25
29
  /**
26
30
  * Single authoritative block helper.
@@ -195,14 +195,28 @@ export interface PluginHookBeforePromptBuildResult {
195
195
  }
196
196
  export interface PluginHookBeforeToolCallEvent {
197
197
  toolName: string;
198
+ /** Host-provided tool call arguments (OpenClaw 2026.7.x sends `params`). */
198
199
  params?: Record<string, unknown>;
200
+ /** @deprecated Host sends `params`; kept for older adapter shims. */
199
201
  toolArgs?: Record<string, unknown>;
200
202
  agentId?: string;
201
203
  sessionId?: string;
202
204
  [key: string]: unknown;
203
205
  }
204
206
  export interface PluginHookBeforeToolCallResult {
207
+ /**
208
+ * Host merge contract (OpenClaw 2026.7.x, hook-before-tool-call-result.ts):
209
+ * only `params`, `block`, `blockReason`, `requireApproval` are read from the
210
+ * hook result. New code must use these fields.
211
+ */
212
+ params?: Record<string, unknown>;
213
+ block?: boolean;
214
+ blockReason?: string;
215
+ /** Shape is host-defined (approval request details). */
216
+ requireApproval?: unknown;
217
+ /** @deprecated Use `params`. Host does not read `toolArgs`. */
205
218
  toolArgs?: Record<string, unknown>;
219
+ /** @deprecated Blocking is expressed via `block: true`. Host does not read `skipToolCall`. */
206
220
  skipToolCall?: boolean;
207
221
  [key: string]: unknown;
208
222
  }
@@ -250,15 +264,21 @@ export interface PluginHookSubagentEndedEvent {
250
264
  [key: string]: unknown;
251
265
  }
252
266
  export interface PluginHookLlmOutputEvent {
253
- output: string;
267
+ /**
268
+ * @deprecated Host (OpenClaw 2026.7.x) does not send `output`. It fires once
269
+ * per model-loop attempt with `assistantTexts` + `lastAssistant`; read those.
270
+ */
271
+ output?: string;
254
272
  agentId?: string;
255
273
  sessionId?: string;
256
274
  runId?: string;
257
275
  provider?: string;
258
276
  model?: string;
259
277
  usage?: TokenUsage;
278
+ /** Host-provided full assistant texts for this model-loop attempt. */
260
279
  assistantTexts?: string[];
261
280
  trigger?: string;
281
+ /** Last complete assistant message object (host-defined shape). */
262
282
  lastAssistant?: unknown;
263
283
  [key: string]: unknown;
264
284
  }
@@ -314,6 +334,8 @@ export interface PluginHookBeforeMessageWriteResult {
314
334
  role?: string;
315
335
  content?: unknown;
316
336
  };
337
+ /** Host contract: `block: true` prevents the transcript write entirely. */
338
+ block?: boolean;
317
339
  [key: string]: unknown;
318
340
  }
319
341
  export interface OpenClawPluginHttpRouteParams {
@@ -9,7 +9,6 @@
9
9
  ]
10
10
  },
11
11
  "skills": [
12
- "templates/langs/en/skills",
13
12
  "templates/langs/zh/skills"
14
13
  ],
15
14
  "configSchema": {
@@ -2,14 +2,13 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles. Stop correcting the same AI behavior across sessions.",
5
- "version": "1.203.0",
5
+ "version": "1.207.1",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
9
9
  ]
10
10
  },
11
11
  "skills": [
12
- "templates/langs/en/skills",
13
12
  "templates/langs/zh/skills"
14
13
  ],
15
14
  "configSchema": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.203.0",
3
+ "version": "1.207.1",
4
4
  "description": "Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles. Stop correcting the same AI behavior across sessions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -686,24 +686,33 @@ function syncFilteredManifest(lang) {
686
686
  process.exit(1);
687
687
  }
688
688
 
689
- const filtered = manifest.skills.filter(sp => {
690
- if (typeof sp !== 'string') return false;
691
- return sp.includes(`/langs/${selectedLang}/`);
692
- });
689
+ // PR #1332 companion: the source manifest declares exactly one root
690
+ // (zh, product default). REPLACE language roots with the selected one
691
+ // instead of only filtering, so `--lang en` works against a zh-default
692
+ // source manifest. Mirrors the production transform in
693
+ // create-principles-disciple/src/skill-language.ts.
694
+ const langRoots = {
695
+ zh: 'templates/langs/zh/skills',
696
+ en: 'templates/langs/en/skills',
697
+ };
698
+ const isLangRoot = (sp) =>
699
+ typeof sp === 'string' &&
700
+ (sp.replaceAll('\\', '/') === langRoots.zh || sp.replaceAll('\\', '/') === langRoots.en);
693
701
 
694
- if (filtered.length === 0) {
695
- console.error(`❌ No skills match language "${selectedLang}" in source manifest`);
702
+ if (!existsSync(join(SOURCE_DIR, langRoots[selectedLang]))) {
703
+ console.error(`❌ Skill templates missing for language "${selectedLang}": ${langRoots[selectedLang]}`);
696
704
  process.exit(1);
697
705
  }
698
706
 
699
- manifest.skills = filtered;
707
+ const kept = manifest.skills.filter((sp) => !isLangRoot(sp));
708
+ manifest.skills = [...kept, langRoots[selectedLang]];
700
709
 
701
710
  // Use syncItem semantics: remove target, then write freshly
702
711
  if (existsSync(targetPath)) {
703
712
  rmSync(targetPath, { force: true });
704
713
  }
705
714
  writeFileSync(targetPath, JSON.stringify(manifest, null, 2) + '\n', 'utf-8');
706
- console.log(` ✅ skills filtered to lang: ${selectedLang} (${filtered.length} path(s))`);
715
+ console.log(` ✅ skills filtered to lang: ${selectedLang} (${manifest.skills.length} path(s))`);
707
716
  }
708
717
 
709
718
  /**
@@ -94,14 +94,25 @@ for (const [path, config] of Object.entries(expectedCounts)) {
94
94
  }
95
95
  }
96
96
 
97
- // 3. List skill files for visibility (agents migrated to skills in templates/)
98
- const skillsDir = join(rootDir, 'dist/templates/langs/zh/skills');
99
- if (existsSync(skillsDir)) {
100
- const skillFiles = readdirSync(skillsDir)
101
- .filter(f => f.endsWith('.md'));
102
-
103
- if (skillFiles.length > 0) {
104
- console.log(`\n📦 Skills available: ${skillFiles.length} (in dist/templates/langs/zh/skills/)`);
97
+ // 3. Verify skill template roots for BOTH languages ship in dist — the
98
+ // installer rewrites the installed manifest per --lang (PR #1332 companion),
99
+ // so a missing root breaks install-time language selection. A "publishable"
100
+ // skill is an immediate child directory containing SKILL.md (what OpenClaw
101
+ // links into ~/.openclaw/plugin-skills).
102
+ for (const lang of ['zh', 'en']) {
103
+ const skillsDir = join(rootDir, 'dist/templates/langs', lang, 'skills');
104
+ if (!existsSync(skillsDir)) {
105
+ console.error(`❌ Missing skill templates: dist/templates/langs/${lang}/skills`);
106
+ hasError = true;
107
+ continue;
108
+ }
109
+ const publishable = readdirSync(skillsDir, { withFileTypes: true })
110
+ .filter((e) => e.isDirectory() && existsSync(join(skillsDir, e.name, 'SKILL.md')));
111
+ if (publishable.length < 20) {
112
+ console.error(`❌ dist/templates/langs/${lang}/skills has only ${publishable.length} publishable skills (expected at least 20)`);
113
+ hasError = true;
114
+ } else {
115
+ console.log(`✅ ${lang} skills: ${publishable.length} (dist/templates/langs/${lang}/skills/)`);
105
116
  }
106
117
  }
107
118