create-principles-disciple 1.153.2 → 1.153.4

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 (105) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/worker/workspace-worker.js +5 -1
  3. package/codex-adapter/package.json +1 -1
  4. package/console/dist/server/index.js +8 -1
  5. package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +9 -1
  6. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +19 -1
  7. package/console/dist/server/models/IntentPageModel.d.ts +37 -1
  8. package/console/dist/server/models/IntentPageModel.js +53 -1
  9. package/console/dist/server/routes/update-history.d.ts +32 -0
  10. package/console/dist/server/routes/update-history.js +215 -1
  11. package/console/dist/web/assets/app.css +106 -0
  12. package/console/dist/web/assets/app.js +118 -32
  13. package/console/dist/web/assets/intent-reflection.webp +3 -0
  14. package/core/dist/runtime/config/index.d.ts +1 -1
  15. package/core/dist/runtime/config/index.d.ts.map +1 -1
  16. package/core/dist/runtime/config/index.js +1 -1
  17. package/core/dist/runtime/config/index.js.map +1 -1
  18. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  19. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +4 -1
  20. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  21. package/core/dist/runtime/index.d.ts +3 -3
  22. package/core/dist/runtime/index.d.ts.map +1 -1
  23. package/core/dist/runtime/index.js +2 -2
  24. package/core/dist/runtime/index.js.map +1 -1
  25. package/core/dist/runtime/intent/intent-browser.d.ts +2 -2
  26. package/core/dist/runtime/intent/intent-browser.d.ts.map +1 -1
  27. package/core/dist/runtime/intent/intent-browser.js +5 -1
  28. package/core/dist/runtime/intent/intent-browser.js.map +1 -1
  29. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  30. package/core/dist/runtime/pain-signal-bridge.js +58 -11
  31. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  32. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  33. package/core/dist/runtime/pain-signal-runtime-factory.js +11 -2
  34. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  35. package/core/package.json +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +12 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/installer.d.ts +24 -0
  40. package/dist/installer.d.ts.map +1 -1
  41. package/dist/installer.js +59 -5
  42. package/dist/installer.js.map +1 -1
  43. package/dist/installers/codex-host-installer.d.ts +7 -0
  44. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  45. package/dist/installers/codex-host-installer.js +62 -14
  46. package/dist/installers/codex-host-installer.js.map +1 -1
  47. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  48. package/dist/installers/workbuddy-host-installer.js +44 -8
  49. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  50. package/dist/prompts.d.ts +6 -0
  51. package/dist/prompts.d.ts.map +1 -1
  52. package/dist/prompts.js +17 -7
  53. package/dist/prompts.js.map +1 -1
  54. package/dist/utils/env.d.ts +19 -2
  55. package/dist/utils/env.d.ts.map +1 -1
  56. package/dist/utils/env.js +55 -14
  57. package/dist/utils/env.js.map +1 -1
  58. package/dist/utils/host-workspace-ownership.d.ts +25 -0
  59. package/dist/utils/host-workspace-ownership.d.ts.map +1 -0
  60. package/dist/utils/host-workspace-ownership.js +69 -0
  61. package/dist/utils/host-workspace-ownership.js.map +1 -0
  62. package/host-runtime/dist/diagnostician-auto-run.js +6 -0
  63. package/host-runtime/dist/governance-signal-admission.js +7 -0
  64. package/host-runtime/dist/index.d.ts +1 -0
  65. package/host-runtime/dist/index.js +4 -0
  66. package/host-runtime/dist/intent-doc-reader.d.ts +70 -0
  67. package/host-runtime/dist/intent-doc-reader.js +292 -0
  68. package/host-runtime/package.json +1 -1
  69. package/install-layout/dist/index.d.ts +24 -1
  70. package/install-layout/dist/index.js +58 -1
  71. package/install-layout/dist/mcp-binding-contract.d.ts +27 -0
  72. package/install-layout/dist/mcp-binding-contract.js +62 -0
  73. package/install-layout/package.json +1 -1
  74. package/package.json +3 -3
  75. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  76. package/pd-cli/dist/commands/diagnose.js +7 -1
  77. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  78. package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
  79. package/pd-cli/dist/commands/health-mcp.js +20 -2
  80. package/pd-cli/dist/commands/health-mcp.js.map +1 -1
  81. package/pd-cli/dist/commands/mcp-probe.d.ts +11 -0
  82. package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -1
  83. package/pd-cli/dist/commands/mcp-probe.js +24 -2
  84. package/pd-cli/dist/commands/mcp-probe.js.map +1 -1
  85. package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
  86. package/pd-cli/dist/commands/pain-record.js +6 -0
  87. package/pd-cli/dist/commands/pain-record.js.map +1 -1
  88. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  89. package/pd-cli/dist/commands/pain-retry.js +8 -1
  90. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  91. package/pd-cli/package.json +1 -1
  92. package/plugin/dist/bundle.js +473 -473
  93. package/plugin/dist/openclaw.plugin.json +1 -1
  94. package/plugin/mcp/launcher.cjs +132 -5
  95. package/plugin/openclaw.plugin.json +1 -1
  96. package/plugin/package.json +1 -1
  97. package/release-manager/dist/installer.js +59 -5
  98. package/release-manager/dist/installers/codex-host-installer.js +62 -14
  99. package/release-manager/dist/installers/workbuddy-host-installer.js +44 -8
  100. package/release-manager/dist/utils/env.js +55 -14
  101. package/release-manager/dist/utils/host-workspace-ownership.js +69 -0
  102. package/release-manager/package.json +1 -1
  103. package/workbuddy-adapter/dist/worker/workspace-worker.js +5 -1
  104. package/workbuddy-adapter/package.json +1 -1
  105. package/workbuddy-adapter/plugin/mcp/launcher.cjs +132 -5
@@ -0,0 +1,69 @@
1
+ import * as path from 'node:path';
2
+ import * as installLayout from '@principles/install-layout';
3
+ const BINDING_HOSTS = ['openclaw', 'codex', 'workbuddy'];
4
+ function hostOwnedWorkspaces(host, options) {
5
+ const home = path.resolve(options.homeDir);
6
+ const codexHome = options.codexHome !== undefined
7
+ ? path.resolve(options.codexHome)
8
+ : path.join(home, '.codex');
9
+ switch (host) {
10
+ case 'openclaw':
11
+ return [path.join(home, 'clawd'), path.join(home, '.openclaw', 'workspace')];
12
+ case 'codex':
13
+ return [path.join(codexHome, 'pd-workspace')];
14
+ case 'workbuddy':
15
+ return [path.join(home, '.workbuddy', 'pd-workspace')];
16
+ }
17
+ }
18
+ function isSameOrInside(parent, child, platform) {
19
+ const normalize = (value) => {
20
+ const resolved = path.resolve(value);
21
+ return platform === 'win32' ? resolved.toLowerCase() : resolved;
22
+ };
23
+ const base = normalize(parent);
24
+ const target = normalize(child);
25
+ if (base === target)
26
+ return true;
27
+ const relative = path.relative(base, target);
28
+ return relative !== ''
29
+ && !path.isAbsolute(relative)
30
+ && relative !== '..'
31
+ && !relative.startsWith('..' + path.sep);
32
+ }
33
+ /**
34
+ * Pre-publish fallback mirroring `findForeignWorkspaceHost` in
35
+ * `@principles/install-layout`.
36
+ *
37
+ * The installer's top-level module graph is loaded by `npx
38
+ * create-principles-disciple` against the CURRENT registry version of
39
+ * install-layout. A named import of a not-yet-published export would crash that
40
+ * load (PRI-669 shape), so the wrapper below probes the namespace and falls
41
+ * back to this implementation only until the version that carries the shared
42
+ * rule is published. A parity test pins both sides together.
43
+ */
44
+ export function findForeignWorkspaceHostFallback(host, workspaceDir, options) {
45
+ if (workspaceDir.trim().length === 0)
46
+ return null;
47
+ for (const other of BINDING_HOSTS) {
48
+ if (other === host)
49
+ continue;
50
+ for (const owned of hostOwnedWorkspaces(other, options)) {
51
+ if (isSameOrInside(owned, workspaceDir, options.platform))
52
+ return other;
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+ /**
58
+ * Resolve the single cross-host ownership verdict: the shared install-layout
59
+ * implementation when the resolved package provides it, otherwise the
60
+ * byte-equivalent local fallback above.
61
+ */
62
+ export function findForeignWorkspaceHost(host, workspaceDir, options) {
63
+ const shared = installLayout
64
+ .findForeignWorkspaceHost;
65
+ if (typeof shared === 'function')
66
+ return shared(host, workspaceDir, options);
67
+ return findForeignWorkspaceHostFallback(host, workspaceDir, options);
68
+ }
69
+ //# sourceMappingURL=host-workspace-ownership.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.153.2",
3
+ "version": "1.153.4",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  import fs from 'node:fs';
33
33
  import path from 'node:path';
34
34
  import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
35
- import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
35
+ import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createHostIntentDocReader, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
36
36
  import { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS } from '../tool-semantics.js';
37
37
  import { catchUpWorkbuddyIngestion } from '../ingestion/catch-up.js';
38
38
  const WORKER_OWNER = 'companion-worker';
@@ -165,6 +165,10 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
165
165
  owner: WORKER_OWNER,
166
166
  effectiveConfig: config.effective,
167
167
  getEnvVar: (name) => process.env[name],
168
+ // PRI-1233 / SPEC §9.2: this worker is where Stage A actually runs
169
+ // for governance-admitted WorkBuddy pains — the neutral host reader
170
+ // must ride along (flag-off = zero filesystem access inside it).
171
+ intentDocReader: createHostIntentDocReader({ workspaceDir, effectiveConfig: config.effective }),
168
172
  });
169
173
  const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
170
174
  diagnostician = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/workbuddy-adapter",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -84,6 +84,7 @@ const INITIAL_ENV_PRESENCE = Object.freeze({
84
84
  const logState = {
85
85
  host: 'unknown',
86
86
  bindingPathExists: false,
87
+ bindingSource: 'not_checked',
87
88
  workspaceResolution: 'not_checked',
88
89
  seq: 0,
89
90
  runId: null,
@@ -354,6 +355,86 @@ function isInside(parent, child) {
354
355
  return relative !== '' && relative !== '..' && !relative.startsWith('..' + path.sep) && !path.isAbsolute(relative);
355
356
  }
356
357
 
358
+ // PRI-1247: a binding must never point one host at ANOTHER host's owned default
359
+ // governance workspace (the Codex installer used to inherit the OpenClaw
360
+ // detection result). This mirrors `findForeignWorkspaceHost` in
361
+ // @principles/install-layout; the parity test pins both sides together.
362
+ function hostOwnedWorkspaces(bindingHost, homeDir, codexHome) {
363
+ switch (bindingHost) {
364
+ case 'openclaw':
365
+ return [path.join(homeDir, 'clawd'), path.join(homeDir, '.openclaw', 'workspace')];
366
+ case 'codex':
367
+ return [path.join(codexHome, 'pd-workspace')];
368
+ case 'workbuddy':
369
+ return [path.join(homeDir, '.workbuddy', 'pd-workspace')];
370
+ default:
371
+ return [];
372
+ }
373
+ }
374
+
375
+ function findForeignWorkspaceOwner(bindingHost, workspaceDir, homeDir, codexHome) {
376
+ const normalize = (value) => {
377
+ const resolved = path.resolve(value);
378
+ return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
379
+ };
380
+ const target = normalize(workspaceDir);
381
+ for (const other of KNOWN_HOSTS) {
382
+ if (other === bindingHost) continue;
383
+ for (const owned of hostOwnedWorkspaces(other, homeDir, codexHome)) {
384
+ if (isInsideOrSame(normalize(owned), target)) return other;
385
+ }
386
+ }
387
+ return null;
388
+ }
389
+
390
+ /**
391
+ * Derive the Codex home from this launcher's own payload path:
392
+ * `<codexHome>/plugins/cache/<marketplace>/principles-disciple/<version>`.
393
+ * Returns null for any other layout (tests, OpenClaw/WorkBuddy payloads), so
394
+ * the persistent-binding lookup is inert where it does not apply.
395
+ */
396
+ function deriveCodexHomeFromPayload(root) {
397
+ const pluginDir = path.dirname(root);
398
+ const marketplaceDir = path.dirname(pluginDir);
399
+ const cacheDir = path.dirname(marketplaceDir);
400
+ const pluginsDir = path.dirname(cacheDir);
401
+ if (path.basename(pluginDir) !== 'principles-disciple') return null;
402
+ if (path.basename(cacheDir) !== 'cache' || path.basename(pluginsDir) !== 'plugins') return null;
403
+ const home = path.dirname(pluginsDir);
404
+ return path.isAbsolute(home) ? home : null;
405
+ }
406
+
407
+ /**
408
+ * PRI-1248: host-persistent binding candidates, in authority order. A Codex
409
+ * cache refresh deletes anything inside the versioned payload, so the copy in
410
+ * PLUGIN_DATA must be authoritative; the payload-local file stays as the
411
+ * legacy fallback for bindings written before this change.
412
+ */
413
+ function codexPersistentBindingCandidates(root) {
414
+ const candidates = [];
415
+ const pluginData = typeof process.env.PLUGIN_DATA === 'string' ? process.env.PLUGIN_DATA.trim() : '';
416
+ if (pluginData.length > 0 && path.isAbsolute(pluginData)) {
417
+ candidates.push(path.join(path.resolve(pluginData), 'mcp-binding.json'));
418
+ }
419
+ const codexHome = deriveCodexHomeFromPayload(root);
420
+ if (codexHome !== null) {
421
+ const marketplace = path.basename(path.dirname(path.dirname(root)));
422
+ const dataRoot = path.join(codexHome, 'plugins', 'data');
423
+ let matches = [];
424
+ try {
425
+ matches = fs.readdirSync(dataRoot).filter((name) => name.startsWith('principles-disciple-'));
426
+ } catch {
427
+ // First run before PLUGIN_DATA exists: fall through to the canonical name.
428
+ }
429
+ if (matches.length === 1) {
430
+ candidates.push(path.join(dataRoot, matches[0], 'mcp-binding.json'));
431
+ } else if (/^[A-Za-z0-9._-]+$/.test(marketplace)) {
432
+ candidates.push(path.join(dataRoot, `principles-disciple-${marketplace}`, 'mcp-binding.json'));
433
+ }
434
+ }
435
+ return [...new Set(candidates)];
436
+ }
437
+
357
438
  const PD_CONFIG_FILENAME = 'principles-disciple.json';
358
439
 
359
440
  /** A declared workspace must be one fixed, real directory — never HOME or a drive root. */
@@ -448,11 +529,35 @@ logState.host = host;
448
529
 
449
530
  // rc-1/rc-3/rc-5: the binding file is read as untrusted; every field is
450
531
  // validated before use and unknown content is never coerced.
451
- const bindingPath = path.join(pluginRoot, 'mcp-binding.json');
452
- try {
453
- logState.bindingPathExists = fs.statSync(bindingPath).isFile();
454
- } catch {
455
- logState.bindingPathExists = false;
532
+ // PRI-1248: a Codex payload directory is replaceable, so the host-persistent
533
+ // copy in PLUGIN_DATA is authoritative; the payload-local file remains the
534
+ // legacy fallback for bindings written before the durable location existed.
535
+ const legacyBindingPath = path.join(pluginRoot, 'mcp-binding.json');
536
+ const bindingCandidates = host === 'codex'
537
+ ? [...codexPersistentBindingCandidates(pluginRoot), legacyBindingPath]
538
+ : [legacyBindingPath];
539
+ let bindingPath = null;
540
+ for (const candidate of bindingCandidates) {
541
+ try {
542
+ if (fs.statSync(candidate).isFile()) {
543
+ bindingPath = candidate;
544
+ break;
545
+ }
546
+ } catch {
547
+ // Absent candidate — try the next location.
548
+ }
549
+ }
550
+ logState.bindingPathExists = bindingPath !== null;
551
+ logState.bindingSource = bindingPath === null
552
+ ? 'missing'
553
+ : (bindingPath === legacyBindingPath ? 'payload' : 'persistent');
554
+ if (bindingPath === null) {
555
+ fail(
556
+ 'binding_missing',
557
+ host === 'codex'
558
+ ? `Re-run the PD host setup (Codex: $pd-control setup) so mcp-binding.json is written for this host (checked ${bindingCandidates.join(' and ')}).`
559
+ : 'Re-run the PD host setup (Codex: $pd-control setup) so mcp-binding.json is written into the plugin directory.',
560
+ );
456
561
  }
457
562
  let raw;
458
563
  try {
@@ -568,6 +673,27 @@ if (!workspaceStat.isDirectory()) {
568
673
  }
569
674
  logState.workspaceResolution = 'ok';
570
675
 
676
+ // PRI-1247: "exists and is a directory" is not ownership. A binding left by
677
+ // the old OpenClaw-oriented detection points Codex at OpenClaw's governance
678
+ // tree, so pain evidence would land in the wrong database. Refuse that before
679
+ // any MCP traffic; the OpenClaw declaration gate below is unchanged.
680
+ // The payload-derived Codex home is only meaningful when THIS payload is a
681
+ // Codex payload: WorkBuddy/OpenClaw caches share the same
682
+ // `<root>/plugins/cache/<marketplace>/principles-disciple/<version>` shape, and
683
+ // deriving from them would invent a Codex workspace inside the host's own tree.
684
+ const ownershipHome = os.homedir();
685
+ const ownershipCodexHome = (host === 'codex' ? deriveCodexHomeFromPayload(pluginRoot) : null)
686
+ ?? (typeof process.env.CODEX_HOME === 'string' && path.isAbsolute(process.env.CODEX_HOME)
687
+ ? path.resolve(process.env.CODEX_HOME)
688
+ : path.join(ownershipHome, '.codex'));
689
+ const foreignWorkspaceHost = findForeignWorkspaceOwner(host, binding.workspaceDir, ownershipHome, ownershipCodexHome);
690
+ if (foreignWorkspaceHost !== null) {
691
+ fail(
692
+ `binding_workspace_foreign_host:${foreignWorkspaceHost}`,
693
+ `mcp-binding.json binds ${foreignWorkspaceHost}'s default governance workspace. Re-run the PD host setup for ${host} with ITS OWN workspace (or an explicit supported --workspace), so pain evidence is not written into another host's database.`,
694
+ );
695
+ }
696
+
571
697
  // P0 (2026-11-13): an experiment must never bind a workspace outside its own
572
698
  // root. The binding is untrusted input written by another process generation;
573
699
  // a stale one (or one produced from an inherited production pointer) keeps the
@@ -622,6 +748,7 @@ writeLogEvent('info', 'launcher_start', {
622
748
  launcherVersion: LAUNCHER_VERSION,
623
749
  mcpServerVersion: packageManifest.version,
624
750
  bindingPathExists: logState.bindingPathExists,
751
+ bindingSource: logState.bindingSource,
625
752
  workspaceResolution: logState.workspaceResolution,
626
753
  envPresence: INITIAL_ENV_PRESENCE,
627
754
  });