ultra-builder-pro-cli 5.0.1 → 6.0.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 (159) hide show
  1. package/CHANGELOG.md +103 -3
  2. package/README.md +67 -478
  3. package/README.zh-CN.md +49 -422
  4. package/adapters/_shared/frontmatter.cjs +1 -18
  5. package/adapters/_shared/plugin-core.cjs +17 -83
  6. package/adapters/_shared/runtime-assets.cjs +6 -120
  7. package/adapters/claude.js +8 -24
  8. package/adapters/codex.js +13 -32
  9. package/bin/install.js +35 -57
  10. package/docs/PLUGIN-ISOLATION-CONTRACT.md +13 -101
  11. package/docs/examples/drive/claude-reviewer.sh +53 -0
  12. package/docs/examples/drive/claude-writer.sh +43 -0
  13. package/engine/FORMATS.md +1051 -0
  14. package/engine/checks.cjs +139 -0
  15. package/engine/cli.cjs +148 -0
  16. package/engine/completion.cjs +48 -0
  17. package/engine/context.cjs +94 -0
  18. package/engine/drive.cjs +220 -0
  19. package/engine/expect-worker.cjs +5 -0
  20. package/engine/expect.cjs +33 -0
  21. package/engine/formats.cjs +189 -0
  22. package/engine/git-state.cjs +112 -0
  23. package/engine/ledger.cjs +205 -0
  24. package/engine/loading.cjs +28 -0
  25. package/engine/merge.cjs +273 -0
  26. package/engine/milestone.cjs +89 -0
  27. package/engine/plan.cjs +232 -0
  28. package/engine/project.cjs +5 -0
  29. package/engine/signals.cjs +3 -0
  30. package/engine/states.cjs +175 -0
  31. package/hooks/session-start.cjs +54 -0
  32. package/package.json +17 -52
  33. package/skills/ultra/SKILL.md +395 -0
  34. package/.ultra-template/changes/abandoned/.gitkeep +0 -0
  35. package/.ultra-template/changes/active/.gitkeep +0 -1
  36. package/.ultra-template/changes/archive/.gitkeep +0 -1
  37. package/.ultra-template/contexts/TEMPLATE.md +0 -135
  38. package/.ultra-template/decisions/.gitkeep +0 -1
  39. package/.ultra-template/evidence/.gitkeep +0 -1
  40. package/.ultra-template/north-star.md +0 -52
  41. package/.ultra-template/project-brief.md +0 -28
  42. package/.ultra-template/research/.gitkeep +0 -1
  43. package/.ultra-template/specs/architecture.md +0 -81
  44. package/.ultra-template/specs/discovery.md +0 -74
  45. package/.ultra-template/specs/product.md +0 -80
  46. package/.ultra-template/specs/research-distillate.md +0 -57
  47. package/.ultra-template/tasks.json +0 -4
  48. package/.ultra-template/test-report.json +0 -44
  49. package/adapters/_shared/host-profile.cjs +0 -5
  50. package/adapters/grok.js +0 -242
  51. package/adapters/kimi.js +0 -232
  52. package/adapters/opencode.js +0 -408
  53. package/adapters/zcode.js +0 -375
  54. package/bin/delegate-worker.cjs +0 -5
  55. package/bin/delegate.cjs +0 -5
  56. package/docs/ARCHITECTURE.md +0 -274
  57. package/docs/ARTIFACT-AUTHORITY.md +0 -305
  58. package/docs/DECISIONS.md +0 -229
  59. package/docs/PHILOSOPHY.md +0 -261
  60. package/docs/RUNTIME-COMPAT-MATRIX.md +0 -316
  61. package/docs/SKILL-AUTHORING.md +0 -113
  62. package/docs/WORKFLOW-LIFECYCLE.md +0 -350
  63. package/docs/evals/adversarial-review-2026-08-14.md +0 -84
  64. package/docs/evals/ultra-5-0-journey-results.md +0 -62
  65. package/docs/evals/ultra-5-0-live-acp-conformance.md +0 -93
  66. package/docs/evals/ultra-5-0-route-journeys.md +0 -145
  67. package/docs/evals/zcode-automation-2026-08-14.md +0 -103
  68. package/hooks/README.md +0 -52
  69. package/hooks/_common.py +0 -1779
  70. package/hooks/adapters/codex.py +0 -295
  71. package/hooks/adapters/grok.py +0 -134
  72. package/hooks/adapters/kimi.py +0 -156
  73. package/hooks/adapters/zcode.py +0 -227
  74. package/hooks/block_dangerous_commands.py +0 -201
  75. package/hooks/compact_context.py +0 -224
  76. package/hooks/mid_workflow_recall.py +0 -47
  77. package/hooks/post_edit_guard.py +0 -215
  78. package/hooks/session_context.py +0 -741
  79. package/skills/ultra-change/SKILL.md +0 -165
  80. package/skills/ultra-change/references/change-contract.md +0 -199
  81. package/skills/ultra-change/references/execution-grant.md +0 -109
  82. package/skills/ultra-change/references/primary-transfer.md +0 -273
  83. package/skills/ultra-change/scripts/validate_primary_transfer.cjs +0 -1928
  84. package/skills/ultra-delegate/SKILL.md +0 -195
  85. package/skills/ultra-delegate/patches/zcode-acp-0.1.0-zcode-0.16.5.patch +0 -184
  86. package/skills/ultra-delegate/references/delegation-contract.md +0 -138
  87. package/skills/ultra-delegate/scripts/acp-conformance.cjs +0 -287
  88. package/skills/ultra-delegate/scripts/acp-driver.cjs +0 -762
  89. package/skills/ultra-delegate/scripts/agent-execution-driver.cjs +0 -320
  90. package/skills/ultra-delegate/scripts/cli-driver.cjs +0 -61
  91. package/skills/ultra-delegate/scripts/delegate-profiles/kimi-read-only.md +0 -15
  92. package/skills/ultra-delegate/scripts/delegate-profiles/kimi-write.md +0 -17
  93. package/skills/ultra-delegate/scripts/delegate-worker.cjs +0 -328
  94. package/skills/ultra-delegate/scripts/delegate.cjs +0 -690
  95. package/skills/ultra-delegate/scripts/delegate_wait.py +0 -86
  96. package/skills/ultra-delegate/scripts/host-profile.cjs +0 -267
  97. package/skills/ultra-deliver/SKILL.md +0 -194
  98. package/skills/ultra-deliver/references/baseline-reconciliation.md +0 -41
  99. package/skills/ultra-dev/SKILL.md +0 -265
  100. package/skills/ultra-dev/references/debugging.md +0 -22
  101. package/skills/ultra-domain-modeling/SKILL.md +0 -79
  102. package/skills/ultra-grilling/SKILL.md +0 -121
  103. package/skills/ultra-grilling/references/reframing.md +0 -76
  104. package/skills/ultra-init/SKILL.md +0 -143
  105. package/skills/ultra-init/references/brownfield-adoption.md +0 -32
  106. package/skills/ultra-init/scripts/init_project.cjs +0 -1031
  107. package/skills/ultra-plan/SKILL.md +0 -160
  108. package/skills/ultra-plan/references/task-evidence-v2.md +0 -300
  109. package/skills/ultra-plan/scripts/validate_task_evidence.cjs +0 -859
  110. package/skills/ultra-research/SKILL.md +0 -167
  111. package/skills/ultra-research/references/00-problem-validation.md +0 -36
  112. package/skills/ultra-research/references/01-opportunity-discovery.md +0 -33
  113. package/skills/ultra-research/references/02-market-assessment.md +0 -31
  114. package/skills/ultra-research/references/03-alternatives.md +0 -31
  115. package/skills/ultra-research/references/04-product-strategy.md +0 -41
  116. package/skills/ultra-research/references/05-assumptions-validation.md +0 -31
  117. package/skills/ultra-research/references/10-user-personas.md +0 -30
  118. package/skills/ultra-research/references/11-user-scenarios.md +0 -28
  119. package/skills/ultra-research/references/20-user-stories.md +0 -31
  120. package/skills/ultra-research/references/21-features-scope.md +0 -38
  121. package/skills/ultra-research/references/22-success-metrics.md +0 -33
  122. package/skills/ultra-research/references/30-architecture-context.md +0 -30
  123. package/skills/ultra-research/references/31-solution-strategy.md +0 -28
  124. package/skills/ultra-research/references/32-building-blocks.md +0 -28
  125. package/skills/ultra-research/references/40-deployment.md +0 -29
  126. package/skills/ultra-research/references/41-quality-risks.md +0 -28
  127. package/skills/ultra-research/references/99-synthesis.md +0 -59
  128. package/skills/ultra-research/references/north-star-v2.md +0 -168
  129. package/skills/ultra-research/references/wayfinding.md +0 -50
  130. package/skills/ultra-research/scripts/validate_north_star.cjs +0 -1174
  131. package/skills/ultra-review/SKILL.md +0 -275
  132. package/skills/ultra-review/references/adversarial-evaluation.md +0 -31
  133. package/skills/ultra-review/references/code.md +0 -17
  134. package/skills/ultra-review/references/comments.md +0 -12
  135. package/skills/ultra-review/references/design.md +0 -12
  136. package/skills/ultra-review/references/errors.md +0 -13
  137. package/skills/ultra-review/references/review-modes.md +0 -29
  138. package/skills/ultra-review/references/spec.md +0 -18
  139. package/skills/ultra-review/references/tests.md +0 -12
  140. package/skills/ultra-review/references/unified-schema.md +0 -284
  141. package/skills/ultra-review/references/worker-packet.md +0 -183
  142. package/skills/ultra-review/scripts/review_wait.py +0 -2943
  143. package/skills/ultra-status/SKILL.md +0 -209
  144. package/skills/ultra-status/references/route-contract.md +0 -100
  145. package/skills/ultra-tdd/SKILL.md +0 -91
  146. package/skills/ultra-tdd/references/templates/README.md +0 -20
  147. package/skills/ultra-tdd/references/templates/feature-flag-default-audit.sh +0 -79
  148. package/skills/ultra-tdd/references/templates/persistence-real.ts +0 -78
  149. package/skills/ultra-tdd/references/templates/testcontainer-postgres.py +0 -78
  150. package/skills/ultra-tdd/references/templates/testcontainer-postgres.ts +0 -73
  151. package/skills/ultra-tdd/references/templates/vertical-slice.ts +0 -66
  152. package/skills/ultra-tdd/references/test-execution.md +0 -23
  153. package/skills/ultra-test/SKILL.md +0 -244
  154. package/skills/ultra-test/references/export-syntax.md +0 -18
  155. package/skills/ultra-test/scripts/validate_review_transport.cjs +0 -549
  156. package/skills/ultra-test/scripts/worktree_digest.cjs +0 -576
  157. package/skills/ultra-think/SKILL.md +0 -56
  158. package/skills/ultra-think/references/autonomy-boundary.md +0 -48
  159. package/skills/ultra-think/references/interaction-boundary.md +0 -42
package/adapters/zcode.js DELETED
@@ -1,375 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('node:fs');
4
- const os = require('node:os');
5
- const path = require('node:path');
6
- const { spawnSync } = require('node:child_process');
7
-
8
- const {
9
- copyHooks,
10
- copySkills,
11
- inspectPlugin,
12
- markManaged,
13
- publishManagedTrees,
14
- removeManaged,
15
- writePluginProvenance,
16
- } = require('./_shared/plugin-core.cjs');
17
- const {
18
- captureAbsent,
19
- ensureDir,
20
- isManaged,
21
- managedMetadata,
22
- pruneCreatedEmpty,
23
- removeTree,
24
- writeAtomic,
25
- } = require('./_shared/file-ops.cjs');
26
- const { zcodeBinary } = require('./_shared/host-profile.cjs');
27
-
28
- const PLUGIN_NAME = 'ultra-builder-pro';
29
- const INLINE_PLUGIN_ID = `${PLUGIN_NAME}@inline`;
30
-
31
- function resolveTarget(ctx = {}) {
32
- if (ctx.configDir) return path.resolve(ctx.configDir);
33
- const configured = ctx.zcodeHome || ctx.env?.ZCODE_HOME || process.env.ZCODE_HOME;
34
- return configured ? path.resolve(configured) : path.join(ctx.homeDir || os.homedir(), '.zcode');
35
- }
36
-
37
- function resolveCliRoot(ctx = {}) {
38
- return path.join(resolveTarget(ctx), 'cli');
39
- }
40
-
41
- function resolveConfigFile(ctx = {}) {
42
- return path.join(resolveCliRoot(ctx), 'config.json');
43
- }
44
-
45
- function resolveMarketplaceRoot(ctx = {}) {
46
- return path.join(resolveCliRoot(ctx), 'plugins', 'marketplaces', PLUGIN_NAME);
47
- }
48
-
49
- function resolveMarketplaceFile(ctx = {}) {
50
- return path.join(resolveMarketplaceRoot(ctx), 'marketplace.json');
51
- }
52
-
53
- function resolvePluginRoot(ctx = {}) {
54
- return path.join(resolveMarketplaceRoot(ctx), 'plugin');
55
- }
56
-
57
- function resolveRepoRoot(ctx = {}) {
58
- return ctx.repoRoot || path.resolve(__dirname, '..');
59
- }
60
-
61
- function assertPluginScope(ctx = {}) {
62
- if (ctx.scope === 'local' && !ctx.configDir) {
63
- throw new Error('ZCode plugins are user-scoped; use global scope or an isolated configDir');
64
- }
65
- }
66
-
67
- function hookProcess(name) {
68
- return {
69
- type: 'process',
70
- command: 'python3',
71
- args: [`\${ZCODE_PLUGIN_ROOT}/hooks/adapters/zcode.py`, name],
72
- timeoutMs: 10000,
73
- };
74
- }
75
-
76
- function buildHooksManifest() {
77
- return {
78
- hooks: {
79
- SessionStart: [
80
- { matcher: 'startup|resume|clear', hooks: [hookProcess('session_context.py')] },
81
- { matcher: 'compact', hooks: [hookProcess('compact_context.py')] },
82
- ],
83
- PreToolUse: [
84
- { matcher: 'Write|Edit|ApplyPatch|Grep', hooks: [hookProcess('mid_workflow_recall.py')] },
85
- { matcher: 'Bash', hooks: [hookProcess('block_dangerous_commands.py')] },
86
- ],
87
- PostToolUse: [
88
- { matcher: 'Write|Edit|ApplyPatch', hooks: [hookProcess('post_edit_guard.py')] },
89
- ],
90
- },
91
- };
92
- }
93
-
94
- function loadConfig(file) {
95
- if (!fs.existsSync(file)) return {};
96
- const value = JSON.parse(fs.readFileSync(file, 'utf8'));
97
- if (!value || Array.isArray(value) || typeof value !== 'object') {
98
- throw new Error(`invalid ZCode config: ${file}`);
99
- }
100
- if (value.plugins !== undefined && (
101
- !value.plugins || Array.isArray(value.plugins) || typeof value.plugins !== 'object'
102
- )) throw new Error(`invalid ZCode plugins config: ${file}`);
103
- if (value.plugins?.dirs !== undefined && (
104
- !Array.isArray(value.plugins.dirs)
105
- || !value.plugins.dirs.every((entry) => typeof entry === 'string' && entry)
106
- )) throw new Error(`invalid ZCode plugins.dirs config: ${file}`);
107
- if (value.plugins?.enabled !== undefined && typeof value.plugins.enabled !== 'boolean') {
108
- throw new Error(`invalid ZCode plugins.enabled config: ${file}`);
109
- }
110
- return value;
111
- }
112
-
113
- function configOwnership(file, pluginRoot) {
114
- const exists = fs.existsSync(file);
115
- const config = loadConfig(file);
116
- const plugins = config.plugins;
117
- return {
118
- file_created: !exists,
119
- plugins_created: plugins === undefined,
120
- enabled_created: plugins === undefined || !Object.hasOwn(plugins, 'enabled'),
121
- enabled_previous: plugins?.enabled,
122
- dirs_created: plugins === undefined || !Object.hasOwn(plugins, 'dirs'),
123
- dir_preexisting: Array.isArray(plugins?.dirs) && plugins.dirs.includes(pluginRoot),
124
- };
125
- }
126
-
127
- function registeredConfig(config, pluginRoot) {
128
- const plugins = config.plugins ? { ...config.plugins } : {};
129
- const dirs = Array.isArray(plugins.dirs) ? [...plugins.dirs] : [];
130
- if (!dirs.includes(pluginRoot)) dirs.push(pluginRoot);
131
- plugins.enabled = true;
132
- plugins.dirs = dirs;
133
- return { ...config, plugins };
134
- }
135
-
136
- function unregisteredConfig(config, pluginRoot, ownership) {
137
- if (!config.plugins || Array.isArray(config.plugins) || typeof config.plugins !== 'object') {
138
- throw new Error('cannot unregister Ultra from an invalid ZCode plugins config');
139
- }
140
- const next = { ...config, plugins: { ...config.plugins } };
141
- if (!ownership.dir_preexisting && Array.isArray(next.plugins.dirs)) {
142
- next.plugins.dirs = next.plugins.dirs.filter((entry) => entry !== pluginRoot);
143
- }
144
- if (ownership.dirs_created && next.plugins.dirs?.length === 0) delete next.plugins.dirs;
145
-
146
- if (ownership.enabled_created) {
147
- if (next.plugins.enabled === true) delete next.plugins.enabled;
148
- } else if (next.plugins.enabled === true && ownership.enabled_previous !== true) {
149
- next.plugins.enabled = ownership.enabled_previous;
150
- }
151
- if (ownership.plugins_created && Object.keys(next.plugins).length === 0) delete next.plugins;
152
- return next;
153
- }
154
-
155
- function buildStaging(repoRoot, staging, publishedRoot) {
156
- const plugin = path.join(staging, 'plugin');
157
- const skills = copySkills({ runtime: 'zcode', repoRoot, skillRoot: path.join(plugin, 'skills') });
158
- copyHooks({
159
- runtime: 'zcode', repoRoot, hookRoot: path.join(plugin, 'hooks'),
160
- hooksManifest: buildHooksManifest(),
161
- });
162
- const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, 'package.json'), 'utf8'));
163
- writeAtomic(path.join(plugin, '.zcode-plugin', 'plugin.json'), `${JSON.stringify({
164
- name: PLUGIN_NAME,
165
- version: pkg.version,
166
- description: 'File-first Ultra Builder Pro workflows for ZCode.',
167
- author: { name: pkg.author },
168
- homepage: pkg.homepage,
169
- repository: pkg.repository?.url || pkg.repository,
170
- license: pkg.license,
171
- skills: './skills',
172
- hooks: './hooks/hooks.json',
173
- }, null, 2)}\n`);
174
- writeAtomic(path.join(staging, 'marketplace.json'), `${JSON.stringify({
175
- name: PLUGIN_NAME,
176
- plugins: [{
177
- name: PLUGIN_NAME,
178
- version: pkg.version,
179
- description: 'File-first Ultra Builder Pro workflows for ZCode.',
180
- source: './plugin',
181
- }],
182
- }, null, 2)}\n`);
183
- markManaged(plugin, { adapter: 'zcode', plugin: PLUGIN_NAME, version: pkg.version });
184
- writePluginProvenance({
185
- adapter: 'zcode', repoRoot, stagingRoot: plugin, publishedRoot,
186
- contracts: {
187
- plugin_manifest: { root: 'plugin', path: '.zcode-plugin/plugin.json' },
188
- hooks_manifest: { root: 'plugin', path: 'hooks/hooks.json' },
189
- hook_adapter: { root: 'plugin', path: 'hooks/adapters/zcode.py' },
190
- },
191
- });
192
- return { skills };
193
- }
194
-
195
- function shouldRunHostCli(ctx = {}) {
196
- if (typeof ctx.runHostCli === 'boolean') return ctx.runHostCli;
197
- return ctx.scope === 'global' && !ctx.configDir;
198
- }
199
-
200
- function zcodeCommand(ctx, args) {
201
- const selected = ctx.zcodeBin || process.env.ZCODE_BIN || zcodeBinary();
202
- const command = selected.endsWith('.cjs') || selected.endsWith('.js') ? process.execPath : selected;
203
- const argv = command === selected ? args : [selected, ...args];
204
- const result = spawnSync(command, argv, {
205
- encoding: 'utf8',
206
- timeout: ctx.hostCliTimeoutMs || 30000,
207
- env: { ...process.env, HOME: ctx.homeDir || os.homedir() },
208
- });
209
- if (result.error) throw result.error;
210
- if (result.status !== 0) {
211
- throw new Error((result.stderr || result.stdout || '').trim() || `zcode ${args.join(' ')} failed`);
212
- }
213
- return result.stdout;
214
- }
215
-
216
- function nativePlugin(ctx) {
217
- const value = JSON.parse(zcodeCommand(ctx, ['plugins', 'list', '--json']));
218
- if (!Array.isArray(value.plugins)) throw new Error('zcode plugins list --json must include plugins');
219
- return value.plugins.find((entry) => entry?.id === INLINE_PLUGIN_ID) || null;
220
- }
221
-
222
- function install(ctx = {}) {
223
- assertPluginScope(ctx);
224
- const target = resolveMarketplaceRoot(ctx);
225
- const pluginRoot = resolvePluginRoot(ctx);
226
- const configRoot = resolveTarget(ctx);
227
- const configFile = resolveConfigFile(ctx);
228
- const repoRoot = resolveRepoRoot(ctx);
229
- if (fs.existsSync(target) && !isManaged(target)) {
230
- throw new Error(`refusing to replace unmanaged ZCode marketplace: ${target}`);
231
- }
232
- const previousMetadata = managedMetadata(target) || {};
233
- const cleanupAbsent = previousMetadata.cleanup_absent || captureAbsent(configRoot, [
234
- '.', 'cli', path.join('cli', 'plugins'), path.join('cli', 'plugins', 'marketplaces'),
235
- path.join('cli', 'config.json'),
236
- ]);
237
- const ownership = previousMetadata.config_ownership || configOwnership(configFile, pluginRoot);
238
- const configExisted = fs.existsSync(configFile);
239
- const configBefore = configExisted ? fs.readFileSync(configFile, 'utf8') : null;
240
- const nextConfig = registeredConfig(loadConfig(configFile), pluginRoot);
241
- ensureDir(path.dirname(target));
242
- const staging = fs.mkdtempSync(path.join(path.dirname(target), `.${PLUGIN_NAME}-staging-`));
243
- const recovery = fs.existsSync(target)
244
- ? fs.mkdtempSync(path.join(path.dirname(target), `.${PLUGIN_NAME}-recovery-`))
245
- : null;
246
- if (recovery) fs.cpSync(target, recovery, { recursive: true });
247
- try {
248
- const copied = buildStaging(repoRoot, staging, pluginRoot);
249
- markManaged(staging, {
250
- adapter: 'zcode', plugin: PLUGIN_NAME,
251
- cleanup_absent: cleanupAbsent,
252
- config_ownership: ownership,
253
- });
254
- publishManagedTrees([{ source: staging, target, label: 'ZCode marketplace' }]);
255
- writeAtomic(configFile, `${JSON.stringify(nextConfig, null, 2)}\n`);
256
- if (shouldRunHostCli(ctx)) {
257
- const plugin = nativePlugin(ctx);
258
- if (!plugin || plugin.enabled !== true || path.resolve(plugin.rootPath) !== path.resolve(pluginRoot)) {
259
- throw new Error('ZCode did not activate the managed Ultra inline plugin');
260
- }
261
- }
262
- if (recovery) removeTree(recovery);
263
- return {
264
- target,
265
- marketplaceRoot: target,
266
- marketplaceFile: resolveMarketplaceFile(ctx),
267
- pluginRoot,
268
- skillRoot: path.join(pluginRoot, 'skills'),
269
- hookRoot: path.join(pluginRoot, 'hooks'),
270
- configFile,
271
- copied,
272
- };
273
- } catch (error) {
274
- const rollback = [];
275
- try {
276
- if (configExisted) writeAtomic(configFile, configBefore);
277
- else if (fs.existsSync(configFile)) fs.unlinkSync(configFile);
278
- } catch (rollbackError) { rollback.push(rollbackError); }
279
- try {
280
- if (fs.existsSync(target)) removeTree(target);
281
- if (recovery) fs.renameSync(recovery, target);
282
- } catch (rollbackError) { rollback.push(rollbackError); }
283
- if (fs.existsSync(staging)) removeTree(staging);
284
- pruneCreatedEmpty(configRoot, cleanupAbsent);
285
- if (rollback.length) throw new AggregateError([error, ...rollback], 'ZCode install and rollback failed');
286
- throw error;
287
- }
288
- }
289
-
290
- function doctor(ctx = {}) {
291
- assertPluginScope(ctx);
292
- const pluginRoot = resolvePluginRoot(ctx);
293
- const report = inspectPlugin({
294
- adapter: 'zcode', repoRoot: resolveRepoRoot(ctx), pluginRoot,
295
- skillRoot: path.join(pluginRoot, 'skills'), hookRoot: path.join(pluginRoot, 'hooks'),
296
- manifestFile: path.join(pluginRoot, '.zcode-plugin', 'plugin.json'),
297
- });
298
- let marketplaceValid = false;
299
- try {
300
- const marketplace = JSON.parse(fs.readFileSync(resolveMarketplaceFile(ctx), 'utf8'));
301
- marketplaceValid = marketplace?.name === PLUGIN_NAME
302
- && Array.isArray(marketplace.plugins)
303
- && marketplace.plugins.some((entry) => entry?.name === PLUGIN_NAME && entry?.source === './plugin');
304
- } catch {}
305
- report.checks.marketplace = { status: marketplaceValid ? 'pass' : 'fail' };
306
- if (!marketplaceValid) report.issues.push({ code: 'ZCODE_MARKETPLACE_INVALID' });
307
-
308
- let registered = false;
309
- try {
310
- const config = loadConfig(resolveConfigFile(ctx));
311
- registered = config.plugins?.enabled !== false
312
- && Array.isArray(config.plugins?.dirs)
313
- && config.plugins.dirs.includes(pluginRoot);
314
- } catch {}
315
- report.checks.registration = { status: registered ? 'pass' : 'fail' };
316
- if (!registered) report.issues.push({ code: 'ZCODE_PLUGIN_NOT_REGISTERED' });
317
-
318
- if (shouldRunHostCli(ctx)) {
319
- let discovered = false;
320
- try {
321
- const plugin = nativePlugin(ctx);
322
- discovered = !!plugin && plugin.enabled === true
323
- && path.resolve(plugin.rootPath) === path.resolve(pluginRoot)
324
- && plugin.skillCount === 14;
325
- } catch {}
326
- report.checks.native_registry = { status: discovered ? 'pass' : 'fail' };
327
- if (!discovered) report.issues.push({ code: 'ZCODE_NATIVE_DISCOVERY_FAILED' });
328
- }
329
- report.status = report.issues.length === 0 ? 'healthy' : 'degraded';
330
- return report;
331
- }
332
-
333
- function uninstall(ctx = {}) {
334
- assertPluginScope(ctx);
335
- const target = resolveMarketplaceRoot(ctx);
336
- const pluginRoot = resolvePluginRoot(ctx);
337
- const configRoot = resolveTarget(ctx);
338
- const metadata = managedMetadata(target) || {};
339
- const ownership = metadata.config_ownership;
340
- const cleanupAbsent = metadata.cleanup_absent || [];
341
- if (fs.existsSync(target) && !ownership) {
342
- throw new Error(`missing ZCode config ownership in ${target}`);
343
- }
344
- const configFile = resolveConfigFile(ctx);
345
- const configBefore = fs.existsSync(configFile) ? fs.readFileSync(configFile, 'utf8') : null;
346
- if (ownership) {
347
- const next = unregisteredConfig(loadConfig(configFile), pluginRoot, ownership);
348
- if (ownership.file_created && Object.keys(next).length === 0) fs.unlinkSync(configFile);
349
- else writeAtomic(configFile, `${JSON.stringify(next, null, 2)}\n`);
350
- }
351
- try {
352
- const removed = removeManaged(target, 'ZCode marketplace');
353
- const cleaned = pruneCreatedEmpty(configRoot, cleanupAbsent);
354
- return { target, marketplaceRoot: target, pluginRoot, removed: { marketplace: removed }, cleaned };
355
- } catch (error) {
356
- if (configBefore !== null) writeAtomic(configFile, configBefore);
357
- throw error;
358
- }
359
- }
360
-
361
- module.exports = {
362
- name: 'zcode',
363
- PLUGIN_NAME,
364
- INLINE_PLUGIN_ID,
365
- buildHooksManifest,
366
- resolveTarget,
367
- resolveCliRoot,
368
- resolveConfigFile,
369
- resolveMarketplaceRoot,
370
- resolveMarketplaceFile,
371
- resolvePluginRoot,
372
- install,
373
- doctor,
374
- uninstall,
375
- };
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- // Compatibility surface for callers that still resolve the historical path.
5
- require('../skills/ultra-delegate/scripts/delegate-worker.cjs');
package/bin/delegate.cjs DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- // Compatibility surface for one release cycle. The installed Skill owns the
4
- // implementation used by both `ubp delegate` and direct Skill invocation.
5
- module.exports = require('../skills/ultra-delegate/scripts/delegate.cjs');
@@ -1,274 +0,0 @@
1
- # Ultra Builder Pro architecture
2
-
3
- Ultra Builder Pro is a file-first workflow asset package for six coding-agent hosts,
4
- implementing the provider-neutral **Ultra Core Protocol**: cognitive alignment,
5
- per-fact authority, explicit work-package grants, typed evidence, bounded effects,
6
- checkpoints, and terminal review convergence — carried entirely by Skills,
7
- owner-readable files, Git, host adapters, and optional Hooks. The host model owns
8
- meaning and strategy; Ultra mechanizes only portable prompts, observable files,
9
- bounded effects, and recovery.
10
-
11
- ## System boundary
12
-
13
- ```text
14
- Owner request
15
- │ explicit selection or verified execution grant (session-local / durable)
16
- ▼
17
- Public Skill mode ───────── stops at the next owner boundary
18
- │
19
- ├── model-invoked disciplines (reasoning methods)
20
- ├── source / tests / runtime / primary documentation
21
- └── canonical project files + Git
22
- │
23
- ├── optional five hooks (derived context and effect guard)
24
- └── optional delegation (ACP-first driver or CLI fallback)
25
- ```
26
-
27
- Ultra has no semantic runtime supervisor. Reading the files is the recovery protocol;
28
- editing the files is the state transition; Git is the journal and rollback mechanism.
29
-
30
- ## Four planes
31
-
32
- ### Method plane
33
-
34
- Fourteen `skills/*/SKILL.md` files carry the workflow:
35
-
36
- - eight owner-invoked workflows;
37
- - five model-invoked reusable disciplines;
38
- - one read-only router.
39
-
40
- The exact allowlists and per-mode invocation map live in
41
- `adapters/_shared/runtime-assets.cjs`. Public modes are `explicit-entry`,
42
- `grant-continuable`, or read-only `router`. Under an accepted Change-scoped Execution
43
- Grant, change-scoped Research, same-Change reconciliation, Plan, Dev, Test, and Deliver
44
- reconciliation may be selected by the model only while `session-local` activation is
45
- live or a fresh Agent has stably verified a `durable work-package` grant. Host metadata
46
- does not preserve session activation: a fresh session, Host switch, or compaction stops
47
- `session-local` continuation until the Owner activates it again. Host metadata
48
- is a coarse discovery bit; each loaded Skill rechecks its mode, Change, effects, and
49
- material checkpoints. Stored text alone grants nothing, and neither mode grants Change
50
- intake/acceptance, primary transfer, Deliver finalization or archive; every external
51
- effect still stops. The derived Route Card makes each boundary owner-visible without
52
- becoming workflow state or authority. The router itself remains owner-invoked; public
53
- Skills derive their own cards from the shared Route Contract instead of invoking it.
54
-
55
- Research's seventeen references are workflow-owned semantic lenses. Its optional
56
- `wayfinding.md` maps a multi-lens question without becoming a new Skill or authority.
57
- The reusable mechanics remain separate: Grilling owns the interaction loop, Think owns
58
- one consequential decision, and Domain Modeling owns vocabulary promotion.
59
-
60
- ### Authority plane
61
-
62
- Canonical semantic authority consists of:
63
-
64
- - `.ultra/project-brief.md` for raw owner intake and the initial outline;
65
- - `.ultra/north-star.md` for the accepted direction, outcome or metric decision, hard
66
- constraints, and exclusions established by Research;
67
- - `.ultra/specs/*.md` for product, architecture, discovery, and research distillate;
68
- - `.ultra/changes/{active,archive,abandoned}/<id>/intent.md` for bounded outcomes, North
69
- Star Trace, and a required Execution Grant (`session-local` and inert without current-
70
- session activation by default) with one stable id across directory moves;
71
- - append-only `.ultra/tasks.json` v2 rows carrying `change_id` and the sole task status,
72
- plus each task's status-free `context_file`;
73
- - `.ultra/decisions/*.md`, typed `.ultra/evidence/`, `.ultra/test-report.json`, and research;
74
- - repository-root `CONTEXT.md` for ubiquitous language;
75
- - Git for revision identity, history, moves, diff, and rollback.
76
-
77
- Each semantic fact has one canonical representation. A summary can point to authority,
78
- but cannot become a second authority merely because it is convenient to read.
79
- Task status therefore lives only in `.ultra/tasks.json`. Legacy context Status and
80
- Complexity fields are migration observations; readers report them and the ledger wins.
81
- Current task evidence uses `ultra-task-evidence-v2`, whose typed command, inspection,
82
- owner-judgment, and external-observation entries retain distinct authorities. Only the
83
- owner can supply an owner-judgment result. Structural validators report exact facts and
84
- never decide semantic acceptance. Command and external evidence store a safe
85
- repository-relative raw ref plus `raw_evidence_sha256`; structural validation does not
86
- open that ref. Dev binds bounded stable ordinary non-symlink receipt bytes before record
87
- publication, while Test, Status, and Deliver recheck the raw digest and then the exact
88
- record `evidence_digest`. The product-worktree digest excludes `.ultra/evidence/**`, so
89
- evidence publication cannot invalidate the freshness value it records.
90
-
91
- One primary host model writes this authority in a worktree. Native subagents are
92
- read-only sensors; delegated CLIs write isolated non-`.ultra` roots and return receipts.
93
- Sequential Changes share the ledger by stable id, while current readers filter by the
94
- one unique active Change. This keeps concurrency explicit in Git instead of adding a
95
- semantic lock service or workflow engine. When the canonical writer itself changes
96
- Agent, an owner-granted primary transfer moves the role exclusively — a derived
97
- OFFER binding canonical refs/hashes, HEAD, and worktree digest; a receiver ACK that
98
- is ready only on full stable-read match; sole-writer execution; a frozen terminal
99
- RESULT — with receipts under `.ultra/.runtime/handoffs/` kept as rebuildable
100
- observations and delegated workers never acquiring canonical write authority
101
- (`skills/ultra-change/references/primary-transfer.md`).
102
-
103
- Autonomous coding uses the host's existing model-tool loop, one canonical writer, and
104
- the same task/evidence/review files. Ultra adds no persisted route position: budgets are
105
- hard ceilings, while the model interprets whether acceptance and stop conditions hold.
106
-
107
- ### Adaptation plane
108
-
109
- `adapters/*.js` translates the shared package into native host surfaces:
110
-
111
- - skill frontmatter and Codex `agents/openai.yaml` policy;
112
- - plugin manifests and host registries;
113
- - hook command paths and wire normalization;
114
- - atomic managed installation, provenance, doctor, and uninstall behavior.
115
-
116
- `adapters/_shared/plugin-core.cjs` owns the common copy, managed publication, and
117
- delegation-runner inventory and driver-reporting checks. The canonical six-host
118
- non-interactive profile lives
119
- beside the installed launcher at `skills/ultra-delegate/scripts/host-profile.cjs`;
120
- `adapters/_shared/host-profile.cjs` is a one-release compatibility re-export. Adapters
121
- never rewrite workflow meaning.
122
-
123
- ### Why the old Agents are Skill assets now
124
-
125
- The retired custom-agent files did not own product authority. They contained reusable
126
- review lenses, debugging, test execution, and review coordination. v0.26 keeps those
127
- methods on the common surface all six hosts actually share:
128
-
129
- - six review workers map to `ultra-review/references/{code,design,errors,tests,spec,comments}.md`;
130
- - review coordination and the former general code reviewer map to the parent
131
- `ultra-review` workflow, immutable Worker Packet, and shared schemas;
132
- - debugging maps to `ultra-dev/references/debugging.md`;
133
- - test execution maps to `ultra-tdd/references/test-execution.md`.
134
-
135
- The references are copied as assets of their parent Skill. Native bounded subagents are
136
- an execution option, not an installed Ultra authority. When a host has no equivalent,
137
- the parent model runs the same references sequentially.
138
-
139
- ### Observation plane
140
-
141
- Five hooks read canonical files and emit bounded context or observations. Their output
142
- under `.ultra/.runtime/` and `.ultra/progress/`, and review artifacts under
143
- `.ultra/reviews/`, are derived rather than semantic authority. A current strict review
144
- session contains `WORKER-PACKET.json`, `ADMISSION.json`, every selected specialist
145
- artifact, and `SUMMARY.json`; retain it until aggregate Test and Deliver have both consumed it
146
- successfully, then it may be garbage-collected. Premature loss requires a fresh Review
147
- and Test; never reconstruct the old receipt. The dangerous-command hook is the only
148
- hard effect guard; it classifies a small named destructive set and provides an
149
- exact-command authorization repair.
150
-
151
- ACP `session/update` telemetry follows the same rule. The Skill-local driver stores only
152
- bounded redacted event metadata under the delegation directory, drops hidden thought
153
- chunks and raw tool payloads, and exposes the latest safe observation through status.
154
- The journal, session id, capability report, permission decision, and stop reason are all
155
- disposable execution observations; none can select a route or establish completion.
156
- Additive protected-branch publication remains advisory when portable host wiring cannot
157
- project a trusted owner-approval receipt; history rewrites and branch deletion remain
158
- guarded.
159
-
160
- ## Completion and recovery
161
-
162
- An operation is complete only when its accepted user outcome works through the real
163
- public seam. Route/schema/UI shells, local unit green, or an edited ledger status are not
164
- end-to-end evidence by themselves. A task remains `in_progress` through its task review;
165
- only after blocking findings are resolved or authoritatively dispositioned and affected
166
- v2 evidence is refreshed may the primary model write `completed` to the ledger.
167
-
168
- Every user Skill starts by reading:
169
-
170
- 1. zero or one active `change_id`, diagnosing more than one;
171
- 2. `.ultra/tasks.json` tasks whose `change_id` matches it, treating that ledger as the
172
- sole task-status authority;
173
- 3. the matching frontier task's `context_file` and closing `## Resume Note`;
174
- 4. `CONTEXT.md` and relevant decisions;
175
- 5. the active Change, specifications, current v2 task evidence and retained task-review
176
- provenance, and current Git state.
177
-
178
- That same sequence works after compaction, a fresh process, disabled hooks, or a host
179
- change. Compact snapshots can accelerate recovery but never outrank the source files.
180
-
181
- ## Integration defence
182
-
183
- Three independent Skills protect the vertical path:
184
-
185
- 1. `ultra-plan` records model-selected technical seams, asks the owner only for a
186
- public-contract or material trade-off, and rejects horizontal feature tasks.
187
- 2. `ultra-dev` records six separate evidence dimensions, including real persistence,
188
- default-on behavior, vertical execution, and spec trace.
189
- 3. `ultra-test` searches exports for real consumers, exercises the primary flow, and
190
- binds the result to Change id, task ids, intent, HEAD, product-worktree digest, exact
191
- raw receipt SHA-256 values, and the containing task-evidence digests.
192
-
193
- These are independent sensors. None rewrites a finding into product truth.
194
-
195
- ## Delegation
196
-
197
- The canonical installed `ultra-delegate/scripts/delegate.cjs` validates all paths inside
198
- the selected project, reads a bounded instruction and permission JSON, probes the
199
- Skill-local Host profile, and starts the Skill-local background worker. One
200
- `AgentExecutionDriver` boundary selects stable ACP v1 stdio only after the exact Host's
201
- versioned conformance row passes with a non-empty evidence reference and the declared
202
- executable and bounded candidate-identity probes succeed; otherwise the same packet
203
- runs through `CliDriver` and records the fallback reason. Capability inspection uses
204
- local version commands only and does not start a provider task. The
205
- one-release `ubp delegate` surface imports those same functions and owns no forked
206
- behavior. Declared writable roots must already exist inside the delegated
207
- worktree; no readable-root or external-effect grant can widen the host's native
208
- sandbox. Empty writable roots select native read-only mode. The model returns a
209
- schema-constrained final response; `AcpDriver` reconstructs only agent-message text as
210
- that same validator input, while ACP stop reasons remain observations. It accepts a
211
- bounded set of creation-time session metadata that some agents emit before
212
- `session/new` resolves, then validates every buffered session identity before exposing
213
- derived events; early message/tool content and unbounded startup traffic fail closed.
214
- The Node worker validates `finished`, `blocked`, or
215
- `failed` and atomically publishes `result.json` beside the instruction. The model never
216
- writes its own receipt; stdout, stderr, native final output, and the launch receipt
217
- remain diagnostic files.
218
-
219
- `ULTRA_DELEGATE_FORCE_CLI=1` is a per-run recovery seam that selects the same bounded
220
- CLI validator path and records `acp_forced_cli`; it does not erase conformance evidence.
221
- An `acp_auth_required` error from `session/new` before `session/prompt` also selects that
222
- already-bound CLI path once. The terminal result retains redacted ACP fallback metadata;
223
- no post-prompt or other ACP failure is automatically retried.
224
- ZCode uses the independently installed, source-pinned `zcode-acp` bridge plus the
225
- digest-bound 0.16.5 runtime-preferences patch to translate stable ACP v1 to the installed
226
- Desktop runtime. Ultra ships only the patch, neither the bridge binary nor App bytes.
227
- The profile verifies an Ultra build marker on that bridge plus the exact installed
228
- runtime version before ACP selection.
229
- The Host/runtime is ZCode Desktop while provider identity remains owner-controlled; the
230
- verified local receipt uses domestic BigModel rather than international Z.AI OAuth. The
231
- headless ZCode transport remains explicitly experimental even after conformance.
232
-
233
- The instruction binds the active `change_id` and one of three semantic scopes: task
234
- execution/continuation, scoped Research evidence, or aggregate Change
235
- review/verification. Only task execution requires a task row. The read-only Research
236
- and aggregate scopes preserve the same process boundary without inventing work merely
237
- to make delegation reachable.
238
-
239
- Delegation does not grant authority or copy semantic state into another store. The
240
- worker reads and writes the same repository files in the specified worktree.
241
-
242
- ## Optional Graph/Loop control plane
243
-
244
- Long-running, multi-Agent, cross-Host work can justify an external coordination
245
- layer (for example a LoopX-style kernel) that owns goal/todo identity, claims and
246
- leases, attention queues, quotas, human-gate records, handoff receipts, and
247
- append-only run/effect observations. Such a layer is **optional and currently not
248
- integrated**: no adapter, dependency, daemon, or scaffold for one ships in this
249
- package, and the Ultra Core Protocol remains fully usable on files plus Git with
250
- every optional layer absent.
251
-
252
- The boundary is fixed regardless of future integration: the control plane may
253
- observe and coordinate — it may never own the North Star, product meaning,
254
- acceptance, semantic severity, architecture or scope decisions, a "quality is
255
- sufficient" verdict, or the authority to start an unauthorized Agent. Enabling it
256
- requires a real coordination problem the owner accepts (multi-session parallel
257
- frontiers, claim/write conflicts, long external waits, explicit quotas, cross-Host
258
- handoff) plus an adapter with a live consumer; deleting or disabling it must always
259
- leave canonical project truth and human recovery intact.
260
-
261
- ## Deliberate absences
262
-
263
- The architecture does not include:
264
-
265
- - an Ultra database or SQLite dependency;
266
- - an MCP server or tool protocol;
267
- - a workflow state machine or semantic validator;
268
- - a background orchestration daemon;
269
- - a resident ACP service, ACP session store, or semantic route ledger;
270
- - command or custom-agent prompt projections;
271
- - general memory, code graph, browser, deployment, or framework packages.
272
-
273
- Adding one of these requires a reproduced failure that the file-first path cannot
274
- repair, a named authority boundary, and a primary-path regression test.