ultra-builder-pro-cli 0.8.1 → 0.10.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 (61) hide show
  1. package/CHANGELOG.md +79 -1
  2. package/README.md +45 -26
  3. package/adapters/_shared/codex-assets.cjs +38 -0
  4. package/adapters/_shared/handbook.cjs +10 -1
  5. package/adapters/_shared/path-rewrite.cjs +3 -0
  6. package/adapters/_shared/runtime-assets.cjs +3 -1
  7. package/adapters/_shared/tests/handbook.test.cjs +9 -1
  8. package/adapters/_shared/tests/path-rewrite.test.cjs +3 -1
  9. package/adapters/_shared/tests/runtime-assets.test.cjs +5 -1
  10. package/adapters/kimi.js +642 -0
  11. package/adapters/opencode.js +46 -17
  12. package/adapters/tests/claude.test.cjs +4 -1
  13. package/adapters/tests/codex.test.cjs +4 -3
  14. package/adapters/tests/kimi-hook.test.cjs +122 -0
  15. package/adapters/tests/kimi.test.cjs +259 -0
  16. package/adapters/tests/opencode.test.cjs +46 -3
  17. package/bin/handbook.js +2 -2
  18. package/bin/install.js +9 -4
  19. package/bin/orchestrator.js +1 -1
  20. package/docs/AGENT-CONTEXT.md +39 -15
  21. package/docs/ARCHITECTURE.md +35 -9
  22. package/docs/PLAN.zh-CN.md +5 -4
  23. package/docs/ROADMAP.md +8 -7
  24. package/docs/RUNTIME-COMPAT-MATRIX.md +110 -64
  25. package/docs/USER-HANDBOOK-CONTRACT.md +13 -3
  26. package/hooks/README.md +6 -4
  27. package/hooks/active_task_context.py +14 -0
  28. package/hooks/adapters/kimi.py +162 -0
  29. package/hooks/context_spine.py +218 -0
  30. package/hooks/health_check.py +1 -1
  31. package/hooks/workflow_context.py +16 -123
  32. package/hooks/workflow_resume.py +21 -0
  33. package/mcp-server/lib/change-workflow.cjs +89 -11
  34. package/mcp-server/lib/change-workflow.test.cjs +202 -7
  35. package/mcp-server/lib/context-spine.cjs +331 -0
  36. package/mcp-server/lib/context-spine.test.cjs +73 -0
  37. package/mcp-server/lib/spec-learning.cjs +191 -0
  38. package/mcp-server/lib/spec-learning.test.cjs +62 -0
  39. package/mcp-server/lib/state-db.cjs +149 -4
  40. package/mcp-server/lib/state-db.test.cjs +61 -0
  41. package/mcp-server/server.cjs +31 -1
  42. package/mcp-server/tests/db-ops.test.cjs +3 -3
  43. package/mcp-server/tests/init-project.test.cjs +2 -2
  44. package/mcp-server/tests/server-contract.test.cjs +74 -0
  45. package/mcp-server/tests/state-db.test.cjs +20 -3
  46. package/package.json +4 -2
  47. package/skills/learn/SKILL.md +1 -0
  48. package/skills/ultra-change/SKILL.md +91 -118
  49. package/skills/ultra-deliver/SKILL.md +93 -221
  50. package/skills/ultra-dev/SKILL.md +81 -310
  51. package/skills/ultra-doctor/SKILL.md +1 -0
  52. package/skills/ultra-init/SKILL.md +1 -0
  53. package/skills/ultra-plan/SKILL.md +72 -292
  54. package/skills/ultra-review/SKILL.md +79 -407
  55. package/skills/ultra-status/SKILL.md +55 -168
  56. package/skills/ultra-test/SKILL.md +64 -183
  57. package/skills/ultra-think/SKILL.md +1 -0
  58. package/spec/cli-protocol.md +3 -0
  59. package/spec/mcp-tools.yaml +136 -7
  60. package/spec/schemas/skill-manifest.schema.json +2 -2
  61. package/spec/schemas/state-db.sql +35 -2
@@ -3,7 +3,7 @@
3
3
  # Validated by spec/schemas/mcp-tools.schema.json (run `npm run test:spec`).
4
4
  # Trace: PLAN §7.3, decisions D12 / D29 / D31-D34.
5
5
 
6
- version: '1.0'
6
+ version: '1.1'
7
7
 
8
8
  info:
9
9
  title: Ultra Builder Pro MCP tool contracts
@@ -367,7 +367,7 @@ tools:
367
367
  task_id: { type: string }
368
368
  change_id: { type: string }
369
369
  session_id: { type: string }
370
- runtime: { type: string, enum: [claude, opencode, codex] }
370
+ runtime: { type: string, enum: [claude, opencode, codex, kimi] }
371
371
  type:
372
372
  type: string
373
373
  enum:
@@ -398,6 +398,8 @@ tools:
398
398
  - change_blocked
399
399
  - change_converged
400
400
  - change_archived
401
+ - spec_learning_proposed
402
+ - spec_learning_resolved
401
403
  payload: { type: object }
402
404
  output_schema:
403
405
  type: object
@@ -452,7 +454,7 @@ tools:
452
454
  additionalProperties: false
453
455
  properties:
454
456
  task_id: { type: string }
455
- runtime: { type: string, enum: [claude, opencode, codex] }
457
+ runtime: { type: string, enum: [claude, opencode, codex, kimi] }
456
458
  takeover: { type: boolean, default: false, description: 'override active lease (D33 takeover strategy)' }
457
459
  worktree_base: { type: string }
458
460
  output_schema:
@@ -554,7 +556,7 @@ tools:
554
556
  additionalProperties: false
555
557
  properties:
556
558
  task_id: { type: string }
557
- runtime: { type: string, enum: [claude, opencode, codex] }
559
+ runtime: { type: string, enum: [claude, opencode, codex, kimi] }
558
560
  output_schema:
559
561
  type: object
560
562
  required: [can_spawn, recommended_action]
@@ -759,7 +761,7 @@ tools:
759
761
 
760
762
  - name: change.get
761
763
  family: change
762
- description: Read one continuous change unit from authoritative state.
764
+ description: Read one continuous change unit and its specification-learning candidates from authoritative state.
763
765
  phase: '9'
764
766
  readonly: true
765
767
  input_schema:
@@ -805,8 +807,8 @@ tools:
805
807
 
806
808
  - name: change.context
807
809
  family: change
808
- description: Compile an inspectable task context manifest from Ultra state and external provider metadata references.
809
- phase: '9'
810
+ description: Compile a role-scoped Context Spine manifest with readiness, budget, execution seam, and next-action evidence.
811
+ phase: '10'
810
812
  writer_role: mcp
811
813
  input_schema:
812
814
  type: object
@@ -815,7 +817,37 @@ tools:
815
817
  properties:
816
818
  id: { type: string }
817
819
  task_id: { type: string }
820
+ role: { type: string, enum: [plan, implement, check, review] }
821
+ gate: { type: string, enum: [alignment, planning, implementation, verification, review, convergence, recovery] }
822
+ next_action: { type: string, minLength: 3 }
818
823
  spec_refs: { type: array, items: { type: object } }
824
+ context_refs:
825
+ type: array
826
+ maxItems: 64
827
+ items:
828
+ type: object
829
+ required: [ref, reason]
830
+ additionalProperties: false
831
+ properties:
832
+ ref: { type: string, minLength: 1 }
833
+ kind: { type: string, enum: [spec, source, test, docs, external], default: source }
834
+ reason: { type: string, minLength: 3 }
835
+ required: { type: boolean, default: true }
836
+ digest: { type: string, pattern: '^[0-9a-f]{64}$' }
837
+ budget:
838
+ type: object
839
+ additionalProperties: false
840
+ properties:
841
+ max_tokens: { type: integer, minimum: 1, default: 12000 }
842
+ max_files: { type: integer, minimum: 1, default: 12 }
843
+ execution_contract:
844
+ type: object
845
+ additionalProperties: false
846
+ properties:
847
+ slice_kind: { type: string, enum: [tracer_bullet, expand_contract, integration_checkpoint], default: tracer_bullet }
848
+ public_seam: { type: string }
849
+ verification_command: { type: string }
850
+ context_budget_percent: { type: integer, minimum: 1, maximum: 100, default: 40 }
819
851
  allowed_paths: { type: array, items: { type: string } }
820
852
  provider_refs:
821
853
  type: object
@@ -852,12 +884,96 @@ tools:
852
884
  manifest_hash: { type: string, pattern: '^[0-9a-f]{64}$' }
853
885
  manifest: { type: object }
854
886
  errors:
887
+ - { code: VALIDATION_ERROR, description: 'context role, gate, references, budget, or execution contract is invalid' }
855
888
  - { code: CHANGE_NOT_FOUND, description: 'change id does not exist' }
856
889
  - { code: CHANGE_TERMINAL, description: 'terminal change cannot compile a new context' }
890
+ - { code: TASK_NOT_FOUND, description: 'task id is not linked to the change' }
857
891
  - { code: PROVIDER_CONTENT_FORBIDDEN, description: 'provider payload content must remain external' }
858
892
  cli_subcommand: change context
859
893
  emits_events: [context_updated]
860
894
 
895
+ - name: change.breadcrumb
896
+ family: change
897
+ description: Read the compact DB-derived Context Spine position, readiness, and single recommended next action.
898
+ phase: '10'
899
+ readonly: true
900
+ writer_role: any
901
+ input_schema:
902
+ type: object
903
+ additionalProperties: false
904
+ properties:
905
+ id: { type: string }
906
+ output_schema:
907
+ type: object
908
+ required: [breadcrumb]
909
+ additionalProperties: false
910
+ properties:
911
+ breadcrumb: { type: object }
912
+ errors:
913
+ - { code: CHANGE_NOT_FOUND, description: 'explicit change id does not exist' }
914
+ - { code: STATE_DB_ERROR, description: 'runtime state could not be read' }
915
+ cli_subcommand: change breadcrumb
916
+ emits_events: []
917
+
918
+ - name: change.learning_propose
919
+ family: change
920
+ description: Propose one stable implementation discovery for approval-gated baseline specification convergence.
921
+ phase: '10'
922
+ writer_role: mcp
923
+ input_schema:
924
+ type: object
925
+ required: [change_id, target_ref, summary]
926
+ additionalProperties: false
927
+ properties:
928
+ id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
929
+ change_id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
930
+ task_id: { type: string }
931
+ target_ref: { type: string, minLength: 1 }
932
+ summary: { type: string, minLength: 3 }
933
+ evidence: { type: array, items: { type: string, minLength: 1 } }
934
+ output_schema:
935
+ type: object
936
+ required: [candidate]
937
+ additionalProperties: false
938
+ properties:
939
+ candidate: { type: object }
940
+ errors:
941
+ - { code: VALIDATION_ERROR, description: 'candidate id, target, summary, or evidence is invalid' }
942
+ - { code: CHANGE_NOT_FOUND, description: 'change id does not exist' }
943
+ - { code: CHANGE_NOT_MUTABLE, description: 'learning must resolve before convergence' }
944
+ - { code: TASK_NOT_FOUND, description: 'task is not linked to the change' }
945
+ - { code: DUPLICATE_LEARNING_ID, description: 'candidate id already exists' }
946
+ cli_subcommand: change learning-propose
947
+ emits_events: [spec_learning_proposed]
948
+
949
+ - name: change.learning_resolve
950
+ family: change
951
+ description: Approve, reject, or mark applied one specification-learning candidate through a guarded state transition.
952
+ phase: '10'
953
+ writer_role: mcp
954
+ input_schema:
955
+ type: object
956
+ required: [change_id, candidate_id, decision]
957
+ additionalProperties: false
958
+ properties:
959
+ change_id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
960
+ candidate_id: { type: string, pattern: '^[a-zA-Z0-9_\-]+$' }
961
+ decision: { type: string, enum: [approve, reject, apply] }
962
+ resolution: { type: string }
963
+ output_schema:
964
+ type: object
965
+ required: [candidate]
966
+ additionalProperties: false
967
+ properties:
968
+ candidate: { type: object }
969
+ errors:
970
+ - { code: VALIDATION_ERROR, description: 'decision or required resolution is invalid' }
971
+ - { code: CHANGE_NOT_FOUND, description: 'change id does not exist' }
972
+ - { code: LEARNING_NOT_FOUND, description: 'candidate id does not exist for the change' }
973
+ - { code: ILLEGAL_LEARNING_TRANSITION, description: 'candidate state transition is not permitted' }
974
+ cli_subcommand: change learning-resolve
975
+ emits_events: [spec_learning_resolved]
976
+
861
977
  - name: change.converge
862
978
  family: change
863
979
  description: Deterministically verify task, spec, test, documentation, review, context, and incident diagnosis structure before closure.
@@ -880,6 +996,19 @@ tools:
880
996
  category: { type: string, enum: [diagnosis, diff, tests, spec, docs, review] }
881
997
  status: { type: string, enum: [pass, fail, not_applicable] }
882
998
  evidence: { type: string, minLength: 3 }
999
+ axis: { type: string, enum: [spec_fidelity, engineering_standards] }
1000
+ seam: { type: string, minLength: 3 }
1001
+ signal:
1002
+ type: object
1003
+ additionalProperties: false
1004
+ required: [command, expected_red, observed_red, observed_green, deterministic]
1005
+ properties:
1006
+ command: { type: string, minLength: 3 }
1007
+ expected_red: { type: string, minLength: 3 }
1008
+ observed_red: { type: boolean }
1009
+ observed_green: { type: boolean }
1010
+ deterministic: { type: boolean }
1011
+ duration_ms: { type: number, minimum: 0 }
883
1012
  output_schema:
884
1013
  type: object
885
1014
  required: [ready, status, blockers]
@@ -19,10 +19,10 @@
19
19
  },
20
20
  "runtime": {
21
21
  "oneOf": [
22
- { "type": "string", "enum": ["claude", "opencode", "codex", "all"] },
22
+ { "type": "string", "enum": ["claude", "opencode", "codex", "kimi", "all"] },
23
23
  {
24
24
  "type": "array",
25
- "items": { "type": "string", "enum": ["claude", "opencode", "codex"] },
25
+ "items": { "type": "string", "enum": ["claude", "opencode", "codex", "kimi"] },
26
26
  "minItems": 1,
27
27
  "uniqueItems": true
28
28
  }
@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS events (
79
79
  task_id TEXT,
80
80
  change_id TEXT,
81
81
  session_id TEXT,
82
- runtime TEXT CHECK (runtime IS NULL OR runtime IN ('claude', 'opencode', 'codex')),
82
+ runtime TEXT CHECK (runtime IS NULL OR runtime IN ('claude', 'opencode', 'codex', 'kimi')),
83
83
  payload_json TEXT
84
84
  );
85
85
 
@@ -95,7 +95,7 @@ CREATE INDEX IF NOT EXISTS events_change ON events(change_id, id);
95
95
  CREATE TABLE IF NOT EXISTS sessions (
96
96
  sid TEXT PRIMARY KEY,
97
97
  task_id TEXT NOT NULL REFERENCES tasks(id),
98
- runtime TEXT NOT NULL CHECK (runtime IN ('claude', 'opencode', 'codex')),
98
+ runtime TEXT NOT NULL CHECK (runtime IN ('claude', 'opencode', 'codex', 'kimi')),
99
99
  pid INTEGER,
100
100
  worktree_path TEXT NOT NULL,
101
101
  artifact_dir TEXT NOT NULL,
@@ -197,11 +197,40 @@ CREATE TABLE IF NOT EXISTS context_snapshots (
197
197
  provider_refs_json TEXT NOT NULL DEFAULT '{}',
198
198
  manifest_path TEXT NOT NULL,
199
199
  manifest_hash TEXT NOT NULL,
200
+ role TEXT NOT NULL DEFAULT 'plan'
201
+ CHECK (role IN ('plan', 'implement', 'check', 'review')),
202
+ gate TEXT NOT NULL DEFAULT 'alignment'
203
+ CHECK (gate IN ('alignment', 'planning', 'implementation', 'verification', 'review', 'convergence', 'recovery')),
204
+ next_action TEXT NOT NULL DEFAULT 'Resolve the next Ultra workflow action.',
205
+ readiness TEXT NOT NULL DEFAULT 'ready'
206
+ CHECK (readiness IN ('ready', 'blocked')),
207
+ blockers_json TEXT NOT NULL DEFAULT '[]',
208
+ context_json TEXT NOT NULL DEFAULT '{}',
209
+ token_estimate INTEGER NOT NULL DEFAULT 0 CHECK (token_estimate >= 0),
210
+ token_budget INTEGER NOT NULL DEFAULT 12000 CHECK (token_budget > 0),
200
211
  created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
201
212
  );
202
213
 
203
214
  CREATE INDEX IF NOT EXISTS context_snapshots_change ON context_snapshots(change_id, created_at);
204
215
 
216
+ CREATE TABLE IF NOT EXISTS spec_learning_candidates (
217
+ id TEXT PRIMARY KEY,
218
+ change_id TEXT NOT NULL REFERENCES changes(id) ON DELETE CASCADE,
219
+ task_id TEXT REFERENCES tasks(id) ON DELETE SET NULL,
220
+ target_ref TEXT NOT NULL,
221
+ summary TEXT NOT NULL,
222
+ evidence_json TEXT NOT NULL DEFAULT '[]',
223
+ status TEXT NOT NULL DEFAULT 'proposed'
224
+ CHECK (status IN ('proposed', 'approved', 'rejected', 'applied')),
225
+ resolution TEXT,
226
+ proposed_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
227
+ resolved_at TEXT,
228
+ applied_at TEXT
229
+ );
230
+
231
+ CREATE INDEX IF NOT EXISTS spec_learning_change
232
+ ON spec_learning_candidates(change_id, status, proposed_at);
233
+
205
234
  CREATE TABLE IF NOT EXISTS trace_links (
206
235
  id INTEGER PRIMARY KEY AUTOINCREMENT,
207
236
  change_id TEXT NOT NULL REFERENCES changes(id) ON DELETE CASCADE,
@@ -272,3 +301,7 @@ INSERT OR IGNORE INTO schema_version (version, description)
272
301
  VALUES ('8A.2', 'Phase 8A.2 — tasks.estimated_days preserved across MCP and v4.4 migration');
273
302
  INSERT OR IGNORE INTO schema_version (version, description)
274
303
  VALUES ('9.0', 'Continuous change units, context snapshots, trace links, incidents, projection outbox, and durable consumers');
304
+ INSERT OR IGNORE INTO schema_version (version, description)
305
+ VALUES ('9.1', 'Kimi runtime support in durable events and sessions');
306
+ INSERT OR IGNORE INTO schema_version (version, description)
307
+ VALUES ('10.0', 'Role-scoped context snapshots, deterministic breadcrumbs, and approval-gated specification learning');