@nexusclawhq/cli 0.3.55 → 0.3.57

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 (168) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/build-info.json +5 -5
  3. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/agent-executable-assets/employee-eval-cases.types.d.ts +6 -0
  4. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/agent-executable-assets/employee-eval-cases.types.js +11 -0
  5. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/agent-executable-assets/employee-eval-cases.types.js.map +1 -1
  6. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/effective-agent-manifest.d.ts +103 -0
  7. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/effective-agent-manifest.js +128 -0
  8. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/effective-agent-manifest.js.map +1 -0
  9. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/index.d.ts +1 -0
  10. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/index.js +6 -1
  11. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/index.js.map +1 -1
  12. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/validator.d.ts +1 -0
  13. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/validator.js +13 -2
  14. package/dist/nexus-cli/node_modules/@nexusclaw/shared/dist/employee-package/validator.js.map +1 -1
  15. package/dist/nexus-cli/src/cli.js +1 -1
  16. package/dist/nexus-cli/src/cli.js.map +1 -1
  17. package/dist/nexus-cli/src/commands/ai/help.test.js +4 -4
  18. package/dist/nexus-cli/src/commands/commands.test.js +2 -2
  19. package/dist/nexus-cli/src/commands/commands.test.js.map +1 -1
  20. package/dist/nexus-cli/src/commands/dx-pages.js +2 -1
  21. package/dist/nexus-cli/src/commands/dx-pages.js.map +1 -1
  22. package/dist/nexus-cli/src/commands/dx-release-boundary.e2e.test.js +11 -7
  23. package/dist/nexus-cli/src/commands/dx-release-boundary.e2e.test.js.map +1 -1
  24. package/dist/nexus-cli/src/commands/dx-workflows.e2e.test.js +12 -4
  25. package/dist/nexus-cli/src/commands/dx-workflows.e2e.test.js.map +1 -1
  26. package/dist/nexus-cli/src/commands/dx.js +3 -1
  27. package/dist/nexus-cli/src/commands/dx.js.map +1 -1
  28. package/dist/nexus-cli/src/commands/employee/bundle.js +1 -1
  29. package/dist/nexus-cli/src/commands/employee/bundle.js.map +1 -1
  30. package/dist/nexus-cli/src/commands/generate/class.js +13 -5
  31. package/dist/nexus-cli/src/commands/generate/class.js.map +1 -1
  32. package/dist/nexus-cli/src/commands/generate/component.js +15 -5
  33. package/dist/nexus-cli/src/commands/generate/component.js.map +1 -1
  34. package/dist/nexus-cli/src/commands/generate/project.js +32 -0
  35. package/dist/nexus-cli/src/commands/generate/project.js.map +1 -1
  36. package/dist/nexus-cli/src/commands/generate/project.test.js +25 -0
  37. package/dist/nexus-cli/src/commands/generate/project.test.js.map +1 -1
  38. package/dist/nexus-cli/src/commands/generate/trigger.js +13 -5
  39. package/dist/nexus-cli/src/commands/generate/trigger.js.map +1 -1
  40. package/dist/nexus-cli/src/commands/package/pack.js +3 -0
  41. package/dist/nexus-cli/src/commands/package/pack.js.map +1 -1
  42. package/dist/nexus-cli/src/commands/package/package-lifecycle.e2e.test.js +19 -0
  43. package/dist/nexus-cli/src/commands/package/package-lifecycle.e2e.test.js.map +1 -1
  44. package/dist/nexus-cli/src/commands/project/deploy-start.js +2 -0
  45. package/dist/nexus-cli/src/commands/project/deploy-start.js.map +1 -1
  46. package/dist/nexus-cli/src/commands/project/index.js +57 -0
  47. package/dist/nexus-cli/src/commands/project/index.js.map +1 -1
  48. package/dist/nexus-cli/src/commands/source/get.js +3 -1
  49. package/dist/nexus-cli/src/commands/source/get.js.map +1 -1
  50. package/dist/nexus-cli/src/commands/source/pull.js +66 -87
  51. package/dist/nexus-cli/src/commands/source/pull.js.map +1 -1
  52. package/dist/nexus-cli/src/commands/source/push.js +91 -1
  53. package/dist/nexus-cli/src/commands/source/push.js.map +1 -1
  54. package/dist/nexus-cli/src/commands/source/source-sync.e2e.test.js +48 -28
  55. package/dist/nexus-cli/src/commands/source/source-sync.e2e.test.js.map +1 -1
  56. package/dist/nexus-cli/src/commands/source/status.js +2 -0
  57. package/dist/nexus-cli/src/commands/source/status.js.map +1 -1
  58. package/dist/nexus-cli/src/commands/workforce/cognition.js +14 -0
  59. package/dist/nexus-cli/src/commands/workforce/cognition.js.map +1 -1
  60. package/dist/nexus-cli/src/commands/workforce/observe.js +11 -0
  61. package/dist/nexus-cli/src/commands/workforce/observe.js.map +1 -1
  62. package/dist/nexus-cli/src/commands/workforce/provider.js +2 -2
  63. package/dist/nexus-cli/src/commands/workforce/provider.js.map +1 -1
  64. package/dist/nexus-cli/src/contracts/command-contract-coverage-baseline.json +5 -5
  65. package/dist/nexus-cli/src/contracts/command-contract-matrix.generated.test.js +69 -28
  66. package/dist/nexus-cli/src/contracts/command-contract-matrix.generated.test.js.map +1 -1
  67. package/dist/nexus-cli/src/contracts/command-contract-matrix.scenarios.js +4 -3
  68. package/dist/nexus-cli/src/contracts/command-contract-matrix.scenarios.js.map +1 -1
  69. package/dist/nexus-cli/src/contracts/command-contract.registry.js +1 -1
  70. package/dist/nexus-cli/src/contracts/command-contract.registry.js.map +1 -1
  71. package/dist/nexus-cli/src/contracts/command-inventory.test.js +4 -4
  72. package/dist/nexus-cli/src/contracts/command-policy.exporter.test.js +2 -2
  73. package/dist/nexus-cli/src/contracts/command-policy.registry.js +7 -1
  74. package/dist/nexus-cli/src/contracts/command-policy.registry.js.map +1 -1
  75. package/dist/nexus-cli/src/contracts/command-policy.registry.test.js +5 -5
  76. package/dist/nexus-cli/src/contracts/command-policy.validator.test.js +3 -3
  77. package/dist/nexus-cli/src/contracts/workforce-contracts.js +3 -0
  78. package/dist/nexus-cli/src/contracts/workforce-contracts.js.map +1 -1
  79. package/dist/nexus-cli/src/runtime/failure-normalizer.d.ts +1 -0
  80. package/dist/nexus-cli/src/runtime/failure-normalizer.js +46 -3
  81. package/dist/nexus-cli/src/runtime/failure-normalizer.js.map +1 -1
  82. package/dist/nexus-cli/src/runtime/failure-normalizer.test.js +15 -0
  83. package/dist/nexus-cli/src/runtime/failure-normalizer.test.js.map +1 -1
  84. package/dist/nexus-cli/src/services/api-client.d.ts +4 -1
  85. package/dist/nexus-cli/src/services/api-client.js +12 -0
  86. package/dist/nexus-cli/src/services/api-client.js.map +1 -1
  87. package/dist/nexus-cli/src/services/revision-ledger/types.d.ts +2 -2
  88. package/dist/nexus-cli/src/services/source-command-governance.d.ts +9 -0
  89. package/dist/nexus-cli/src/services/source-command-governance.js +82 -0
  90. package/dist/nexus-cli/src/services/source-command-governance.js.map +1 -0
  91. package/dist/nexus-cli/src/services/source-command-governance.test.d.ts +1 -0
  92. package/dist/nexus-cli/src/services/source-command-governance.test.js +104 -0
  93. package/dist/nexus-cli/src/services/source-command-governance.test.js.map +1 -0
  94. package/dist/nexus-cli/src/services/source-layout-migration.d.ts +27 -0
  95. package/dist/nexus-cli/src/services/source-layout-migration.js +315 -0
  96. package/dist/nexus-cli/src/services/source-layout-migration.js.map +1 -0
  97. package/dist/nexus-cli/src/services/source-layout-migration.test.d.ts +1 -0
  98. package/dist/nexus-cli/src/services/source-layout-migration.test.js +149 -0
  99. package/dist/nexus-cli/src/services/source-layout-migration.test.js.map +1 -0
  100. package/dist/nexus-cli/src/services/source-pull-plan.d.ts +36 -0
  101. package/dist/nexus-cli/src/services/source-pull-plan.js +269 -0
  102. package/dist/nexus-cli/src/services/source-pull-plan.js.map +1 -0
  103. package/dist/nexus-cli/src/services/source-pull-plan.test.d.ts +1 -0
  104. package/dist/nexus-cli/src/services/source-pull-plan.test.js +252 -0
  105. package/dist/nexus-cli/src/services/source-pull-plan.test.js.map +1 -0
  106. package/dist/nexus-cli/src/services/source-taxonomy.d.ts +25 -0
  107. package/dist/nexus-cli/src/services/source-taxonomy.js +109 -0
  108. package/dist/nexus-cli/src/services/source-taxonomy.js.map +1 -0
  109. package/dist/nexus-cli/src/services/source-tracker.d.ts +2 -2
  110. package/dist/nexus-cli/src/services/source-tracker.js +26 -10
  111. package/dist/nexus-cli/src/services/source-tracker.js.map +1 -1
  112. package/dist/nexus-cli/src/services/source-tracker.test.js +34 -0
  113. package/dist/nexus-cli/src/services/source-tracker.test.js.map +1 -1
  114. package/dist/nexus-cli/src/services/workforce-bundle-archive.js +2 -0
  115. package/dist/nexus-cli/src/services/workforce-bundle-archive.js.map +1 -1
  116. package/dist/nexus-cli/src/services/workforce-bundle-archive.test.js +24 -5
  117. package/dist/nexus-cli/src/services/workforce-bundle-archive.test.js.map +1 -1
  118. package/dist/nexus-cli/src/services/workforce-bundle-local.d.ts +4 -1
  119. package/dist/nexus-cli/src/services/workforce-bundle-local.js +19 -1
  120. package/dist/nexus-cli/src/services/workforce-bundle-local.js.map +1 -1
  121. package/dist/nexus-cli/src/services/workforce-bundle-local.test.js +31 -0
  122. package/dist/nexus-cli/src/services/workforce-bundle-local.test.js.map +1 -1
  123. package/dist/nexus-cli/src/services/workforce-bundle-remote.js +3 -2
  124. package/dist/nexus-cli/src/services/workforce-bundle-remote.js.map +1 -1
  125. package/dist/nexus-cli/src/services/workforce-cognition-remote.d.ts +13 -0
  126. package/dist/nexus-cli/src/services/workforce-cognition-remote.js +23 -0
  127. package/dist/nexus-cli/src/services/workforce-cognition-remote.js.map +1 -1
  128. package/dist/nexus-cli/src/services/workforce-observe-remote.d.ts +4 -0
  129. package/dist/nexus-cli/src/services/workforce-observe-remote.js +10 -0
  130. package/dist/nexus-cli/src/services/workforce-observe-remote.js.map +1 -1
  131. package/dist/nexus-cli/src/services/workforce-provider-remote.d.ts +2 -2
  132. package/dist/nexus-cli/src/services/workforce-provider-remote.js +14 -31
  133. package/dist/nexus-cli/src/services/workforce-provider-remote.js.map +1 -1
  134. package/dist/nexus-cli/src/services/workforce-test-remote.d.ts +1 -1
  135. package/dist/nexus-cli/src/services/workforce-test-remote.js +1 -1
  136. package/dist/nexus-cli/src/services/workforce-test-remote.test.js +2 -2
  137. package/dist/nexus-cli/src/services/workspace-contract.d.ts +12 -2
  138. package/dist/nexus-cli/src/services/workspace-contract.js +201 -42
  139. package/dist/nexus-cli/src/services/workspace-contract.js.map +1 -1
  140. package/dist/nexus-cli/src/services/workspace-contract.test.js +150 -0
  141. package/dist/nexus-cli/src/services/workspace-contract.test.js.map +1 -1
  142. package/dist/nexus-cli/src/services/workspace-dx.d.ts +2 -1
  143. package/dist/nexus-cli/src/services/workspace-dx.js +1 -0
  144. package/dist/nexus-cli/src/services/workspace-dx.js.map +1 -1
  145. package/dist/nexus-cli/src/templates/project/templates/base-crm/nexus-project.json.tpl +2 -1
  146. package/dist/nexus-cli/src/templates/project/templates/base-crm/nexus-project.yaml.tpl +1 -0
  147. package/dist/nexus-cli/src/templates/project/templates/demo-public-channel-store-delivery/nexus-project.json.tpl +2 -1
  148. package/dist/nexus-cli/src/templates/project/templates/demo-public-channel-store-delivery/nexus-project.yaml.tpl +1 -0
  149. package/dist/nexus-cli/src/templates/project/templates/drill-code-extension-page/nexus-project.json.tpl +2 -1
  150. package/dist/nexus-cli/src/templates/project/templates/drill-code-extension-page/nexus-project.yaml.tpl +1 -0
  151. package/dist/nexus-cli/src/templates/project/templates/empty/nexus-project.json.tpl +2 -1
  152. package/dist/nexus-cli/src/templates/project/templates/empty/nexus-project.yaml.tpl +1 -0
  153. package/dist/nexus-cli/src/templates/project/templates/executable-workforce/README.md.tpl +8 -1
  154. package/dist/nexus-cli/src/templates/project/templates/executable-workforce/nexus-project.json.tpl +2 -1
  155. package/dist/nexus-cli/src/templates/project/templates/executable-workforce/nexus-project.yaml.tpl +1 -0
  156. package/dist/nexus-cli/src/templates/project/templates/executable-workforce/scripts/init-bundle.mjs +0 -1
  157. package/dist/nexus-cli/src/templates/project/templates/industry-education/nexus-project.json.tpl +2 -1
  158. package/dist/nexus-cli/src/templates/project/templates/industry-education/nexus-project.yaml.tpl +1 -0
  159. package/dist/nexus-cli/src/templates/project/templates/industry-finance/nexus-project.json.tpl +2 -1
  160. package/dist/nexus-cli/src/templates/project/templates/industry-finance/nexus-project.yaml.tpl +1 -0
  161. package/dist/nexus-cli/src/templates/project/templates/industry-healthcare/nexus-project.json.tpl +2 -1
  162. package/dist/nexus-cli/src/templates/project/templates/industry-healthcare/nexus-project.yaml.tpl +1 -0
  163. package/dist/nexus-cli/src/templates/project/templates/industry-partner-cloud/nexus-project.json.tpl +2 -1
  164. package/dist/nexus-cli/src/templates/project/templates/industry-partner-cloud/nexus-project.yaml.tpl +1 -0
  165. package/dist/nexus-cli/src/templates/project/templates/industry-retail/nexus-project.json.tpl +2 -1
  166. package/dist/nexus-cli/src/templates/project/templates/industry-retail/nexus-project.yaml.tpl +1 -0
  167. package/dist/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +1 -1
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const strict_1 = __importDefault(require("node:assert/strict"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_os_1 = __importDefault(require("node:os"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const node_test_1 = __importDefault(require("node:test"));
11
+ const commander_1 = require("commander");
12
+ const source_layout_migration_1 = require("./source-layout-migration");
13
+ const workspace_contract_1 = require("./workspace-contract");
14
+ const project_1 = require("../commands/project");
15
+ (0, node_test_1.default)('external polluted-project plan classifies all pairs and performs zero writes', () => {
16
+ const root = createLegacyWorkspace();
17
+ try {
18
+ write(root, 'objects/Account/object.json', '{"name":"Account"}\n');
19
+ write(root, 'layouts/Account.layout-meta.xml', '<Layout/>\n');
20
+ write(root, `${workspace_contract_1.NEXUS_APP_SOURCE_ROOT}/layouts/Account.layout-meta.xml`, '<Layout/>\n');
21
+ write(root, 'flows/Route.flow-meta.xml', '<Flow>legacy</Flow>\n');
22
+ write(root, `${workspace_contract_1.NEXUS_APP_SOURCE_ROOT}/flows/Route.flow-meta.xml`, '<Flow>canonical</Flow>\n');
23
+ write(root, `${workspace_contract_1.NEXUS_APP_SOURCE_ROOT}/tabs/Only.tab-meta.xml`, '<Tab/>\n');
24
+ const before = snapshot(root);
25
+ const plan = (0, source_layout_migration_1.buildSourceLayoutMigrationPlan)(root);
26
+ strict_1.default.deepEqual(plan.summary, {
27
+ 'exact-duplicate': 1,
28
+ 'legacy-only': 1,
29
+ 'target-only': 1,
30
+ divergent: 1,
31
+ });
32
+ strict_1.default.equal(plan.applyAllowed, false);
33
+ strict_1.default.match(plan.planDigest, /^sha256:[0-9a-f]{64}$/);
34
+ strict_1.default.deepEqual(snapshot(root), before);
35
+ }
36
+ finally {
37
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
38
+ }
39
+ });
40
+ (0, node_test_1.default)('digest-authorized apply moves source atomically and preserves a recoverable backup', () => {
41
+ const root = createLegacyWorkspace();
42
+ try {
43
+ write(root, 'objects/Account/object.json', '{"name":"Account"}\n');
44
+ write(root, 'layouts/Account.layout-meta.xml', '<Layout/>\n');
45
+ write(root, `${workspace_contract_1.NEXUS_APP_SOURCE_ROOT}/layouts/Account.layout-meta.xml`, '<Layout/>\n');
46
+ const plan = (0, source_layout_migration_1.buildSourceLayoutMigrationPlan)(root);
47
+ strict_1.default.equal(plan.applyAllowed, true);
48
+ const receipt = (0, source_layout_migration_1.applySourceLayoutMigration)({
49
+ workspaceDir: root,
50
+ expectedPlanDigest: plan.planDigest,
51
+ });
52
+ strict_1.default.equal(node_fs_1.default.readFileSync(node_path_1.default.join(root, workspace_contract_1.NEXUS_APP_SOURCE_ROOT, 'objects/Account/object.json'), 'utf8'), '{"name":"Account"}\n');
53
+ strict_1.default.equal(node_fs_1.default.existsSync(node_path_1.default.join(root, 'objects/Account/object.json')), false);
54
+ strict_1.default.equal(node_fs_1.default.existsSync(node_path_1.default.join(root, 'layouts/Account.layout-meta.xml')), false);
55
+ strict_1.default.equal(node_fs_1.default.existsSync(node_path_1.default.join(receipt.backupRoot, 'legacy-backup/objects/Account/object.json')), true);
56
+ strict_1.default.equal(node_fs_1.default.existsSync(node_path_1.default.join(receipt.backupRoot, 'legacy-backup/layouts/Account.layout-meta.xml')), true);
57
+ const manifest = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(root, 'nexus-project.json'), 'utf8'));
58
+ strict_1.default.equal(manifest.sourceRoot, workspace_contract_1.NEXUS_APP_SOURCE_ROOT);
59
+ strict_1.default.equal(receipt.migratedFiles, 1);
60
+ strict_1.default.equal(receipt.deduplicatedFiles, 1);
61
+ }
62
+ finally {
63
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
64
+ }
65
+ });
66
+ (0, node_test_1.default)('raw legacy Agent projection blocks apply as incomplete Employee source', () => {
67
+ const root = createLegacyWorkspace();
68
+ try {
69
+ write(root, 'agents/SalesOps.agent.json', '{"apiName":"SalesOps"}\n');
70
+ const before = snapshot(root);
71
+ const plan = (0, source_layout_migration_1.buildSourceLayoutMigrationPlan)(root);
72
+ strict_1.default.equal(plan.applyAllowed, false);
73
+ strict_1.default.match(plan.entries[0]?.blockedReason ?? '', /EMPLOYEE_SOURCE_INCOMPLETE/);
74
+ strict_1.default.throws(() => (0, source_layout_migration_1.applySourceLayoutMigration)({ workspaceDir: root, expectedPlanDigest: plan.planDigest }), (error) => error.code === 'SOURCE_MIGRATION_CONFLICT');
75
+ strict_1.default.deepEqual(snapshot(root), before);
76
+ }
77
+ finally {
78
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
79
+ }
80
+ });
81
+ (0, node_test_1.default)('invalid migrated closure rolls back files and manifests', () => {
82
+ const root = createLegacyWorkspace();
83
+ try {
84
+ write(root, 'nwc/incomplete/incomplete.js', 'export default class {}\n');
85
+ const before = snapshot(root);
86
+ const plan = (0, source_layout_migration_1.buildSourceLayoutMigrationPlan)(root);
87
+ strict_1.default.equal(plan.applyAllowed, true);
88
+ strict_1.default.throws(() => (0, source_layout_migration_1.applySourceLayoutMigration)({ workspaceDir: root, expectedPlanDigest: plan.planDigest }), (error) => error.code === 'SOURCE_MIGRATION_RESULT_INVALID');
89
+ strict_1.default.deepEqual(snapshot(root), before);
90
+ }
91
+ finally {
92
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
93
+ }
94
+ });
95
+ (0, node_test_1.default)('project migrate exposes separate plan/apply modes and digest binding rejects stale plans', () => {
96
+ const program = new commander_1.Command();
97
+ (0, project_1.registerProjectCommands)(program);
98
+ const migrate = program.commands
99
+ .find((command) => command.name() === 'project')?.commands
100
+ .find((command) => command.name() === 'migrate');
101
+ strict_1.default.ok(migrate);
102
+ strict_1.default.deepEqual(migrate.options.map((option) => option.long).sort(), ['--apply', '--expected-plan-digest', '--json', '--plan', '--workspace']);
103
+ const root = createLegacyWorkspace();
104
+ try {
105
+ write(root, 'objects/Account/object.json', '{"name":"Account"}\n');
106
+ const before = snapshot(root);
107
+ strict_1.default.throws(() => (0, source_layout_migration_1.applySourceLayoutMigration)({
108
+ workspaceDir: root,
109
+ expectedPlanDigest: `sha256:${'f'.repeat(64)}`,
110
+ }), (error) => error.code === 'SOURCE_MIGRATION_PLAN_CHANGED');
111
+ strict_1.default.deepEqual(snapshot(root), before);
112
+ }
113
+ finally {
114
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
115
+ }
116
+ });
117
+ function createLegacyWorkspace() {
118
+ const root = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'nexus-external-polluted-'));
119
+ write(root, 'nexus-project.json', `${JSON.stringify({
120
+ schemaVersion: 'dx-workspace/v1',
121
+ projectName: 'external-fixture',
122
+ compatibleCoreVersion: '0.1.x',
123
+ sourceRoots: [{ path: '.', kind: 'metadata-runtime', writeTarget: true }],
124
+ localPackages: [],
125
+ environments: [],
126
+ }, null, 2)}\n`);
127
+ return root;
128
+ }
129
+ function write(root, relativePath, content) {
130
+ const target = node_path_1.default.join(root, relativePath);
131
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(target), { recursive: true });
132
+ node_fs_1.default.writeFileSync(target, content, 'utf8');
133
+ }
134
+ function snapshot(root) {
135
+ const result = {};
136
+ const visit = (directory) => {
137
+ for (const name of node_fs_1.default.readdirSync(directory).sort()) {
138
+ const absolute = node_path_1.default.join(directory, name);
139
+ const stat = node_fs_1.default.lstatSync(absolute);
140
+ if (stat.isDirectory())
141
+ visit(absolute);
142
+ else
143
+ result[node_path_1.default.relative(root, absolute).split(node_path_1.default.sep).join('/')] = node_fs_1.default.readFileSync(absolute, 'utf8');
144
+ }
145
+ };
146
+ visit(root);
147
+ return result;
148
+ }
149
+ //# sourceMappingURL=source-layout-migration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-layout-migration.test.js","sourceRoot":"","sources":["../../../../src/services/source-layout-migration.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AACxC,sDAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAC7B,0DAA6B;AAC7B,yCAAoC;AACpC,uEAGmC;AACnC,6DAA6D;AAC7D,iDAA8D;AAE9D,IAAA,mBAAI,EAAC,8EAA8E,EAAE,GAAG,EAAE;IACxF,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;IACrC,IAAI,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,6BAA6B,EAAE,sBAAsB,CAAC,CAAC;QACnE,KAAK,CAAC,IAAI,EAAE,iCAAiC,EAAE,aAAa,CAAC,CAAC;QAC9D,KAAK,CAAC,IAAI,EAAE,GAAG,0CAAqB,kCAAkC,EAAE,aAAa,CAAC,CAAC;QACvF,KAAK,CAAC,IAAI,EAAE,2BAA2B,EAAE,uBAAuB,CAAC,CAAC;QAClE,KAAK,CAAC,IAAI,EAAE,GAAG,0CAAqB,4BAA4B,EAAE,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AC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,CAAC;IACZ,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { SourceFilesResult, SourceStatusResult } from './api-client';
2
+ import { type SourceStatusEntry } from './source-tracker';
3
+ export interface SourceSelectionMember {
4
+ type: string;
5
+ name: string;
6
+ }
7
+ export interface SourceSelectionManifestV1 {
8
+ schemaVersion: 'nexus-source-selection/v1';
9
+ members: SourceSelectionMember[];
10
+ }
11
+ export interface SourcePullSelectors {
12
+ all?: boolean;
13
+ paths?: string[];
14
+ metadata?: string[];
15
+ metadataDirs?: string[];
16
+ manifestMembers?: SourceSelectionMember[];
17
+ }
18
+ export interface SourcePullSelection {
19
+ mode: 'all' | 'selected';
20
+ entries: SourceStatusEntry[];
21
+ metadataSelectors: string[];
22
+ normalizedPaths: string[];
23
+ normalizedDirectories: string[];
24
+ }
25
+ export declare function loadSourceSelectionManifest(filePath: string): SourceSelectionManifestV1;
26
+ export declare function resolveSourcePullSelection(statuses: SourceStatusEntry[], selectors: SourcePullSelectors): SourcePullSelection;
27
+ export declare function validateFetchedSourceSet(input: {
28
+ status: SourceStatusResult;
29
+ fetched: SourceFilesResult;
30
+ entries: SourceStatusEntry[];
31
+ }): Map<string, string>;
32
+ export declare function applyPulledSourceFilesAtomically(input: {
33
+ baseDir: string;
34
+ entries: SourceStatusEntry[];
35
+ contentByRemotePath: Map<string, string>;
36
+ }): void;
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadSourceSelectionManifest = loadSourceSelectionManifest;
7
+ exports.resolveSourcePullSelection = resolveSourcePullSelection;
8
+ exports.validateFetchedSourceSet = validateFetchedSourceSet;
9
+ exports.applyPulledSourceFilesAtomically = applyPulledSourceFilesAtomically;
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const js_yaml_1 = __importDefault(require("js-yaml"));
13
+ const shared_1 = require("@nexusclaw/shared");
14
+ const source_tracker_1 = require("./source-tracker");
15
+ const workspace_contract_1 = require("./workspace-contract");
16
+ function selectionError(code, message, details) {
17
+ const error = new Error(message);
18
+ Object.assign(error, { code, details });
19
+ return error;
20
+ }
21
+ function assertPlainObject(value) {
22
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
23
+ throw selectionError('SOURCE_MANIFEST_INVALID', 'Source selection manifest must be an object.');
24
+ }
25
+ }
26
+ function assertExactKeys(value, allowed, context) {
27
+ const unexpected = Object.keys(value).filter((key) => !allowed.includes(key));
28
+ if (unexpected.length > 0) {
29
+ throw selectionError('SOURCE_MANIFEST_INVALID', `${context} contains unsupported keys: ${unexpected.sort().join(', ')}`);
30
+ }
31
+ }
32
+ function loadSourceSelectionManifest(filePath) {
33
+ const absolutePath = node_path_1.default.resolve(filePath);
34
+ if (!node_fs_1.default.existsSync(absolutePath) || !node_fs_1.default.statSync(absolutePath).isFile()) {
35
+ throw selectionError('SOURCE_MANIFEST_NOT_FOUND', `Source selection manifest not found: ${filePath}`);
36
+ }
37
+ let value;
38
+ try {
39
+ const content = node_fs_1.default.readFileSync(absolutePath, 'utf8');
40
+ value = filePath.endsWith('.json') ? JSON.parse(content) : js_yaml_1.default.load(content);
41
+ }
42
+ catch (error) {
43
+ throw selectionError('SOURCE_MANIFEST_INVALID', `Unable to parse source selection manifest ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
44
+ }
45
+ assertPlainObject(value);
46
+ assertExactKeys(value, ['schemaVersion', 'members'], 'Source selection manifest');
47
+ if (value.schemaVersion !== 'nexus-source-selection/v1' || !Array.isArray(value.members)) {
48
+ throw selectionError('SOURCE_MANIFEST_INVALID', 'Source selection manifest requires schemaVersion nexus-source-selection/v1 and members[].');
49
+ }
50
+ const members = value.members.map((member, index) => {
51
+ assertPlainObject(member);
52
+ assertExactKeys(member, ['type', 'name'], `members[${index}]`);
53
+ if (typeof member.type !== 'string'
54
+ || !member.type.trim()
55
+ || typeof member.name !== 'string'
56
+ || !member.name.trim()) {
57
+ throw selectionError('SOURCE_MANIFEST_INVALID', `members[${index}] requires non-empty type and name strings.`);
58
+ }
59
+ if (node_path_1.default.posix.isAbsolute(member.name.replace(/\\/g, '/'))
60
+ || member.name.replace(/\\/g, '/').split('/').includes('..')) {
61
+ throw selectionError('SOURCE_PATH_ESCAPE', `members[${index}].name must be a stable component identity, not a path: ${member.name}`);
62
+ }
63
+ return { type: member.type.trim(), name: member.name.trim() };
64
+ });
65
+ if (members.length === 0) {
66
+ throw selectionError('SOURCE_MANIFEST_INVALID', 'Source selection manifest members must not be empty.');
67
+ }
68
+ return { schemaVersion: 'nexus-source-selection/v1', members };
69
+ }
70
+ function normalizeNarrowPath(candidate, label) {
71
+ const slashPath = candidate.replace(/\\/g, '/');
72
+ if (node_path_1.default.posix.isAbsolute(slashPath)
73
+ || /^[A-Za-z]:\//u.test(slashPath)
74
+ || slashPath.split('/').includes('..')) {
75
+ throw selectionError('SOURCE_PATH_ESCAPE', `${label} must stay inside the workspace source root: ${candidate}`);
76
+ }
77
+ const normalized = (0, source_tracker_1.normalizeSourceSelectionPath)(candidate);
78
+ if (!normalized || normalized === '.') {
79
+ throw selectionError('SOURCE_SELECTOR_REQUIRED', `${label} cannot select the complete source root; use explicit --all for a full retrieve.`);
80
+ }
81
+ return normalized;
82
+ }
83
+ function resolveSourcePullSelection(statuses, selectors) {
84
+ const paths = (selectors.paths ?? []).map((entry) => normalizeNarrowPath(entry, '--path'));
85
+ const directories = (selectors.metadataDirs ?? [])
86
+ .map((entry) => normalizeNarrowPath(entry, '--metadata-dir'));
87
+ const manifestSelectors = (selectors.manifestMembers ?? [])
88
+ .map((member) => `${member.type}:${member.name}`);
89
+ const metadataSelectors = Array.from(new Set([
90
+ ...(selectors.metadata ?? []).map((entry) => entry.trim()).filter(Boolean),
91
+ ...manifestSelectors,
92
+ ])).sort();
93
+ const hasNarrowSelector = paths.length > 0 || directories.length > 0 || metadataSelectors.length > 0;
94
+ if (selectors.all && hasNarrowSelector) {
95
+ throw selectionError('SOURCE_SELECTOR_CONFLICT', '--all is mutually exclusive with --path, --metadata, --metadata-dir and --manifest.');
96
+ }
97
+ if (!selectors.all && !hasNarrowSelector) {
98
+ throw selectionError('SOURCE_SELECTOR_REQUIRED', 'Source pull requires --path, --metadata, --metadata-dir, --manifest, or explicit --all.');
99
+ }
100
+ if (selectors.all) {
101
+ return {
102
+ mode: 'all',
103
+ entries: [...statuses].sort((left, right) => left.path.localeCompare(right.path)),
104
+ metadataSelectors: [],
105
+ normalizedPaths: [],
106
+ normalizedDirectories: [],
107
+ };
108
+ }
109
+ const selected = new Map();
110
+ for (const entry of statuses) {
111
+ if (paths.some((selectedPath) => entry.path === selectedPath || entry.path.startsWith(`${selectedPath}/`))) {
112
+ selected.set(entry.path, entry);
113
+ }
114
+ }
115
+ if (metadataSelectors.length > 0) {
116
+ for (const entry of (0, source_tracker_1.filterByMetadataSelector)(statuses, metadataSelectors)) {
117
+ selected.set(entry.path, entry);
118
+ }
119
+ }
120
+ if (directories.length > 0) {
121
+ for (const entry of (0, source_tracker_1.filterByDirectory)(statuses, directories)) {
122
+ selected.set(entry.path, entry);
123
+ }
124
+ }
125
+ const selectedEmployeeKeys = new Set(Array.from(selected.values())
126
+ .map((entry) => entry.componentKey)
127
+ .filter((key) => key.startsWith('employee:')));
128
+ for (const entry of statuses) {
129
+ if (selectedEmployeeKeys.has(entry.componentKey))
130
+ selected.set(entry.path, entry);
131
+ }
132
+ return {
133
+ mode: 'selected',
134
+ entries: Array.from(selected.values()).sort((left, right) => left.path.localeCompare(right.path)),
135
+ metadataSelectors,
136
+ normalizedPaths: Array.from(new Set(paths)).sort(),
137
+ normalizedDirectories: Array.from(new Set(directories)).sort(),
138
+ };
139
+ }
140
+ function validateFetchedSourceSet(input) {
141
+ if (input.fetched.remoteRevision
142
+ && input.status.remoteRevision
143
+ && input.fetched.remoteRevision !== input.status.remoteRevision) {
144
+ throw selectionError('SOURCE_REMOTE_REVISION_CHANGED', `Remote source revision changed during pull: expected ${input.status.remoteRevision}, received ${input.fetched.remoteRevision}.`);
145
+ }
146
+ const expected = new Map(input.entries
147
+ .filter((entry) => Boolean(entry.remoteHash))
148
+ .map((entry) => [entry.aliases?.remote[0] ?? entry.path, entry.remoteHash]));
149
+ const fetched = new Map();
150
+ const duplicates = [];
151
+ for (const file of input.fetched.files) {
152
+ if (fetched.has(file.path))
153
+ duplicates.push(file.path);
154
+ fetched.set(file.path, file);
155
+ }
156
+ const extra = Array.from(fetched.keys()).filter((filePath) => !expected.has(filePath)).sort();
157
+ const missing = Array.from(expected.keys()).filter((filePath) => !fetched.has(filePath)).sort();
158
+ const digestMismatches = Array.from(expected.entries())
159
+ .filter(([filePath, expectedHash]) => fetched.get(filePath)?.hash !== expectedHash)
160
+ .map(([filePath]) => filePath)
161
+ .sort();
162
+ if (duplicates.length || extra.length || missing.length || digestMismatches.length) {
163
+ throw selectionError('SOURCE_FETCH_SET_MISMATCH', 'Fetched source set does not exactly match the selected, digest-attested inventory.', { duplicates: duplicates.sort(), extra, missing, digestMismatches });
164
+ }
165
+ validateEmployeeSourceAttestation(input, fetched);
166
+ return new Map(Array.from(fetched.entries()).map(([filePath, file]) => [filePath, file.content]));
167
+ }
168
+ function validateEmployeeSourceAttestation(input, fetched) {
169
+ const selectedPaths = new Set(input.entries.map((entry) => entry.aliases?.remote[0] ?? entry.path));
170
+ const groups = new Map();
171
+ for (const file of input.status.files) {
172
+ if (!selectedPaths.has(file.path) || !file.componentKey?.startsWith('employee:'))
173
+ continue;
174
+ const group = groups.get(file.componentKey) ?? [];
175
+ group.push(file);
176
+ groups.set(file.componentKey, group);
177
+ }
178
+ for (const [componentKey, files] of groups) {
179
+ const agentApiName = componentKey.slice('employee:'.length);
180
+ const prefix = `employees/${agentApiName}/`;
181
+ const aggregateDigests = new Set(files.map((file) => file.aggregateDigest).filter(Boolean));
182
+ const releaseSetIds = new Set(files.map((file) => file.releaseSetId).filter(Boolean));
183
+ const incomplete = files.some((file) => !file.semanticHash || !file.aggregateDigest || !file.releaseSetId
184
+ || fetched.get(file.path)?.semanticHash !== file.semanticHash
185
+ || fetched.get(file.path)?.aggregateDigest !== file.aggregateDigest
186
+ || fetched.get(file.path)?.releaseSetId !== file.releaseSetId);
187
+ const rows = files
188
+ .filter((file) => !file.path.slice(prefix.length).startsWith('bindings/'))
189
+ .map((file) => ({
190
+ path: file.path.slice(prefix.length),
191
+ semanticEntryDigest: file.semanticHash,
192
+ }));
193
+ if (incomplete
194
+ || aggregateDigests.size !== 1
195
+ || releaseSetIds.size !== 1
196
+ || rows.some((row) => !row.path || row.path.startsWith('../'))
197
+ || (0, shared_1.portableBundleDigest)(rows) !== Array.from(aggregateDigests)[0]) {
198
+ throw selectionError('EMPLOYEE_SOURCE_INCOMPLETE', `Employee ${agentApiName} did not return one complete, release-attested portable bundle.`);
199
+ }
200
+ }
201
+ }
202
+ function assertSafeTrackedPath(trackedPath) {
203
+ const slashPath = trackedPath.replace(/\\/g, '/');
204
+ if (node_path_1.default.posix.isAbsolute(slashPath)
205
+ || /^[A-Za-z]:\//u.test(slashPath)
206
+ || slashPath.split('/').includes('..')) {
207
+ throw selectionError('SOURCE_PATH_ESCAPE', `Remote source path escapes the workspace: ${trackedPath}`);
208
+ }
209
+ }
210
+ function applyPulledSourceFilesAtomically(input) {
211
+ const workspaceRoot = (0, workspace_contract_1.findWorkspaceRoot)(input.baseDir);
212
+ const tempRoot = node_path_1.default.join(workspaceRoot, '.nexusclaw', 'tmp');
213
+ node_fs_1.default.mkdirSync(tempRoot, { recursive: true });
214
+ const operationRoot = node_fs_1.default.mkdtempSync(node_path_1.default.join(tempRoot, 'source-pull-'));
215
+ const stagedRoot = node_path_1.default.join(operationRoot, 'staged');
216
+ const backupRoot = node_path_1.default.join(operationRoot, 'backup');
217
+ const operations = [];
218
+ try {
219
+ for (const [index, entry] of input.entries.entries()) {
220
+ assertSafeTrackedPath(entry.path);
221
+ const targetPath = (0, source_tracker_1.resolveTrackedFilePath)(input.baseDir, entry.path);
222
+ const resolvedTarget = node_path_1.default.resolve(targetPath);
223
+ if (resolvedTarget !== workspaceRoot && !resolvedTarget.startsWith(`${workspaceRoot}${node_path_1.default.sep}`)) {
224
+ throw selectionError('SOURCE_PATH_ESCAPE', `Resolved source path escapes the workspace: ${entry.path}`);
225
+ }
226
+ const remotePath = entry.aliases?.remote[0] ?? entry.path;
227
+ const stagedPath = node_path_1.default.join(stagedRoot, String(index));
228
+ const backupPath = node_path_1.default.join(backupRoot, String(index));
229
+ const existed = node_fs_1.default.existsSync(targetPath);
230
+ if (entry.remoteHash) {
231
+ const content = input.contentByRemotePath.get(remotePath);
232
+ if (content === undefined) {
233
+ throw selectionError('SOURCE_FETCH_SET_MISMATCH', `Missing staged content for ${remotePath}.`);
234
+ }
235
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(stagedPath), { recursive: true });
236
+ node_fs_1.default.writeFileSync(stagedPath, content, 'utf8');
237
+ }
238
+ if (existed) {
239
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(backupPath), { recursive: true });
240
+ node_fs_1.default.copyFileSync(targetPath, backupPath);
241
+ }
242
+ operations.push({ targetPath, stagedPath, backupPath, existed, deleted: !entry.remoteHash });
243
+ }
244
+ for (const operation of operations) {
245
+ if (operation.deleted) {
246
+ if (node_fs_1.default.existsSync(operation.targetPath))
247
+ node_fs_1.default.rmSync(operation.targetPath);
248
+ continue;
249
+ }
250
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(operation.targetPath), { recursive: true });
251
+ node_fs_1.default.renameSync(operation.stagedPath, operation.targetPath);
252
+ }
253
+ }
254
+ catch (error) {
255
+ for (const operation of operations) {
256
+ if (node_fs_1.default.existsSync(operation.targetPath))
257
+ node_fs_1.default.rmSync(operation.targetPath);
258
+ if (operation.existed && node_fs_1.default.existsSync(operation.backupPath)) {
259
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(operation.targetPath), { recursive: true });
260
+ node_fs_1.default.copyFileSync(operation.backupPath, operation.targetPath);
261
+ }
262
+ }
263
+ throw error;
264
+ }
265
+ finally {
266
+ node_fs_1.default.rmSync(operationRoot, { recursive: true, force: true });
267
+ }
268
+ }
269
+ //# sourceMappingURL=source-pull-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-pull-plan.js","sourceRoot":"","sources":["../../../../src/services/source-pull-plan.ts"],"names":[],"mappings":";;;;;AAmEA,kEAoDC;AAqBD,gEA0EC;AAED,4DAyCC;AAwDD,4EAkEC;AA3XD,sDAAyB;AACzB,0DAA6B;AAC7B,sDAA2B;AAC3B,8CAAyD;AAGzD,qDAM0B;AAC1B,6DAAyD;AA4BzD,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe,EAAE,OAAiB;IACtE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,cAAc,CAAC,yBAAyB,EAAE,8CAA8C,CAAC,CAAC;IAClG,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CACtB,KAA8B,EAC9B,OAA0B,EAC1B,OAAe;IAEf,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9E,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC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