@cleocode/core 2026.3.44 → 2026.3.46

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 (166) hide show
  1. package/dist/admin/import-tasks.d.ts +10 -2
  2. package/dist/admin/import-tasks.d.ts.map +1 -1
  3. package/dist/bootstrap.d.ts.map +1 -1
  4. package/dist/index.js +1890 -504
  5. package/dist/index.js.map +4 -4
  6. package/dist/init.d.ts.map +1 -1
  7. package/dist/injection.d.ts +1 -1
  8. package/dist/injection.d.ts.map +1 -1
  9. package/dist/internal.d.ts +3 -1
  10. package/dist/internal.d.ts.map +1 -1
  11. package/dist/nexus/index.d.ts +2 -0
  12. package/dist/nexus/index.d.ts.map +1 -1
  13. package/dist/nexus/transfer-types.d.ts +123 -0
  14. package/dist/nexus/transfer-types.d.ts.map +1 -0
  15. package/dist/nexus/transfer.d.ts +31 -0
  16. package/dist/nexus/transfer.d.ts.map +1 -0
  17. package/dist/routing/capability-matrix.d.ts +6 -4
  18. package/dist/routing/capability-matrix.d.ts.map +1 -1
  19. package/dist/scaffold.d.ts +16 -9
  20. package/dist/scaffold.d.ts.map +1 -1
  21. package/dist/skills/agents/install.d.ts.map +1 -1
  22. package/dist/skills/routing-table.d.ts +17 -16
  23. package/dist/skills/routing-table.d.ts.map +1 -1
  24. package/dist/skills/skill-paths.d.ts.map +1 -1
  25. package/dist/store/brain-sqlite.d.ts +4 -1
  26. package/dist/store/brain-sqlite.d.ts.map +1 -1
  27. package/dist/store/nexus-sqlite.d.ts +4 -1
  28. package/dist/store/nexus-sqlite.d.ts.map +1 -1
  29. package/dist/store/sqlite.d.ts +4 -1
  30. package/dist/store/sqlite.d.ts.map +1 -1
  31. package/dist/store/tasks-schema.d.ts +3 -3
  32. package/dist/store/tasks-schema.d.ts.map +1 -1
  33. package/dist/store/validation-schemas.d.ts +5 -4
  34. package/dist/store/validation-schemas.d.ts.map +1 -1
  35. package/dist/system/health.d.ts.map +1 -1
  36. package/dist/ui/index.d.ts +0 -1
  37. package/dist/ui/index.d.ts.map +1 -1
  38. package/package.json +9 -4
  39. package/schemas/adr-frontmatter.schema.json +72 -0
  40. package/schemas/agent-configs.schema.json +120 -0
  41. package/schemas/agent-registry.json +243 -0
  42. package/schemas/agent-registry.schema.json +132 -0
  43. package/schemas/archive/research-manifest.schema.json +257 -0
  44. package/schemas/archive.schema.json +450 -0
  45. package/schemas/brain-decision.schema.json +69 -0
  46. package/schemas/brain-learning.schema.json +57 -0
  47. package/schemas/brain-pattern.schema.json +72 -0
  48. package/schemas/config.schema.json +2606 -0
  49. package/schemas/context-state.schema.json +137 -0
  50. package/schemas/contribution.schema.json +722 -0
  51. package/schemas/critical-path.schema.json +246 -0
  52. package/schemas/deps-cache.schema.json +97 -0
  53. package/schemas/doctor-output.schema.json +283 -0
  54. package/schemas/error.schema.json +161 -0
  55. package/schemas/export-package.schema.json +375 -0
  56. package/schemas/global-config.schema.json +219 -0
  57. package/schemas/grade.schema.json +49 -0
  58. package/schemas/log.schema.json +250 -0
  59. package/schemas/metrics.schema.json +328 -0
  60. package/schemas/migrations.schema.json +150 -0
  61. package/schemas/nexus-registry.schema.json +90 -0
  62. package/schemas/operation-constitution.schema.json +438 -0
  63. package/schemas/output.schema.json +164 -0
  64. package/schemas/project-context.schema.json +164 -0
  65. package/schemas/project-info.schema.json +180 -0
  66. package/schemas/projects-registry.schema.json +107 -0
  67. package/schemas/protocol-frontmatter.schema.json +72 -0
  68. package/schemas/rcasd-consensus-report.schema.json +10 -0
  69. package/schemas/rcasd-evidence.schema.json +42 -0
  70. package/schemas/rcasd-gate-result.schema.json +46 -0
  71. package/schemas/rcasd-hitl-resolution.schema.json +10 -0
  72. package/schemas/rcasd-index.schema.json +10 -0
  73. package/schemas/rcasd-manifest.schema.json +10 -0
  74. package/schemas/rcasd-research-output.schema.json +10 -0
  75. package/schemas/rcasd-spec-frontmatter.schema.json +10 -0
  76. package/schemas/rcasd-stage-transition.schema.json +38 -0
  77. package/schemas/releases.schema.json +267 -0
  78. package/schemas/skills-manifest.schema.json +91 -0
  79. package/schemas/skillsmp.schema.json +208 -0
  80. package/schemas/spec-index.schema.json +196 -0
  81. package/schemas/system-flow-atlas.schema.json +125 -0
  82. package/src/__tests__/injection-chain.test.ts +11 -10
  83. package/src/__tests__/injection-mvi-tiers.test.ts +4 -2
  84. package/src/admin/import-tasks.ts +53 -29
  85. package/src/agents/__tests__/capacity.test.d.ts +7 -0
  86. package/src/agents/__tests__/capacity.test.d.ts.map +1 -0
  87. package/src/agents/__tests__/capacity.test.js +173 -0
  88. package/src/agents/__tests__/capacity.test.js.map +1 -0
  89. package/src/agents/__tests__/registry.test.d.ts +8 -0
  90. package/src/agents/__tests__/registry.test.d.ts.map +1 -0
  91. package/src/agents/__tests__/registry.test.js +348 -0
  92. package/src/agents/__tests__/registry.test.js.map +1 -0
  93. package/src/agents/__tests__/retry.test.d.ts +7 -0
  94. package/src/agents/__tests__/retry.test.d.ts.map +1 -0
  95. package/src/agents/__tests__/retry.test.js +225 -0
  96. package/src/agents/__tests__/retry.test.js.map +1 -0
  97. package/src/bootstrap.ts +3 -1
  98. package/src/init.ts +63 -18
  99. package/src/injection.ts +11 -5
  100. package/src/intelligence/__tests__/impact.test.d.ts +15 -0
  101. package/src/intelligence/__tests__/impact.test.d.ts.map +1 -0
  102. package/src/intelligence/__tests__/impact.test.js +384 -0
  103. package/src/intelligence/__tests__/impact.test.js.map +1 -0
  104. package/src/intelligence/__tests__/patterns.test.d.ts +8 -0
  105. package/src/intelligence/__tests__/patterns.test.d.ts.map +1 -0
  106. package/src/intelligence/__tests__/patterns.test.js +370 -0
  107. package/src/intelligence/__tests__/patterns.test.js.map +1 -0
  108. package/src/intelligence/__tests__/prediction.test.d.ts +8 -0
  109. package/src/intelligence/__tests__/prediction.test.d.ts.map +1 -0
  110. package/src/intelligence/__tests__/prediction.test.js +314 -0
  111. package/src/intelligence/__tests__/prediction.test.js.map +1 -0
  112. package/src/internal.ts +7 -1
  113. package/src/nexus/__tests__/nexus-e2e.test.d.ts +12 -0
  114. package/src/nexus/__tests__/nexus-e2e.test.d.ts.map +1 -0
  115. package/src/nexus/__tests__/nexus-e2e.test.js +1220 -0
  116. package/src/nexus/__tests__/nexus-e2e.test.js.map +1 -0
  117. package/src/nexus/__tests__/transfer.test.d.ts +8 -0
  118. package/src/nexus/__tests__/transfer.test.d.ts.map +1 -0
  119. package/src/nexus/__tests__/transfer.test.js +372 -0
  120. package/src/nexus/__tests__/transfer.test.js.map +1 -0
  121. package/src/nexus/__tests__/transfer.test.ts +446 -0
  122. package/src/nexus/index.ts +14 -0
  123. package/src/nexus/transfer-types.ts +129 -0
  124. package/src/nexus/transfer.ts +314 -0
  125. package/src/routing/capability-matrix.ts +1435 -205
  126. package/src/scaffold.ts +18 -11
  127. package/src/skills/__tests__/routing-table.test.ts +53 -33
  128. package/src/skills/agents/install.ts +9 -1
  129. package/src/skills/routing-table.ts +39 -253
  130. package/src/skills/skill-paths.ts +3 -2
  131. package/src/store/__tests__/project-detect.test.ts +1 -1
  132. package/src/store/brain-sqlite.ts +7 -3
  133. package/src/store/nexus-sqlite.ts +7 -3
  134. package/src/store/sqlite.ts +9 -3
  135. package/src/store/tasks-schema.ts +1 -1
  136. package/src/system/health.ts +18 -7
  137. package/src/ui/index.ts +0 -6
  138. package/src/validation/operation-gate-validators.ts +2 -2
  139. package/templates/CLEO-INJECTION.md +120 -0
  140. package/templates/README.md +29 -0
  141. package/templates/agent-registry.json +305 -0
  142. package/templates/cleo-gitignore +74 -0
  143. package/templates/config.template.json +187 -0
  144. package/templates/git-hooks/commit-msg +149 -0
  145. package/templates/git-hooks/pre-commit +40 -0
  146. package/templates/git-hooks/pre-push +79 -0
  147. package/templates/github/ISSUE_TEMPLATE/bug_report.yml +143 -0
  148. package/templates/github/ISSUE_TEMPLATE/config.yml +8 -0
  149. package/templates/github/ISSUE_TEMPLATE/feature_request.yml +125 -0
  150. package/templates/github/ISSUE_TEMPLATE/help_question.yml +99 -0
  151. package/templates/global-config.template.json +56 -0
  152. package/templates/hooks/precompact-safestop.sh +89 -0
  153. package/templates/issue-templates/bug_report.yml +143 -0
  154. package/templates/issue-templates/config.yml +8 -0
  155. package/templates/issue-templates/feature_request.yml +125 -0
  156. package/templates/issue-templates/help_question.yml +99 -0
  157. package/templates/skillsmp.json.example +28 -0
  158. package/templates/skillsmp.json.example.md +214 -0
  159. package/dist/ui/injection-legacy.d.ts +0 -26
  160. package/dist/ui/injection-legacy.d.ts.map +0 -1
  161. package/src/ui/__tests__/injection-registry.test.d.ts +0 -11
  162. package/src/ui/__tests__/injection-registry.test.d.ts.map +0 -1
  163. package/src/ui/__tests__/injection-registry.test.js +0 -46
  164. package/src/ui/__tests__/injection-registry.test.js.map +0 -1
  165. package/src/ui/__tests__/injection-registry.test.ts +0 -57
  166. package/src/ui/injection-legacy.ts +0 -44
@@ -0,0 +1,196 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "schemaVersion": "1.0.0",
4
+ "$id": "https://cleo-dev.com/schemas/v1/spec-index.schema.json",
5
+ "title": "Claude-TODO Specification Index",
6
+ "description": "Schema for the authoritative specification index. LLM-agent-first design: structured, queryable, schema-validated.",
7
+ "type": "object",
8
+ "required": ["$schema", "_meta", "authorities", "specs"],
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "const": "https://cleo-dev.com/schemas/v1/spec-index.schema.json"
13
+ },
14
+ "_meta": {
15
+ "type": "object",
16
+ "description": "Index metadata for version tracking and integrity",
17
+ "required": ["version", "lastUpdated", "totalSpecs", "totalReports"],
18
+ "properties": {
19
+ "version": {
20
+ "type": "string",
21
+ "pattern": "^\\d+\\.\\d+\\.\\d+$",
22
+ "description": "Semantic version of the index format"
23
+ },
24
+ "lastUpdated": {
25
+ "type": "string",
26
+ "format": "date",
27
+ "description": "ISO date of last index update"
28
+ },
29
+ "totalSpecs": {
30
+ "type": "integer",
31
+ "minimum": 0,
32
+ "description": "Count of specification documents"
33
+ },
34
+ "totalReports": {
35
+ "type": "integer",
36
+ "minimum": 0,
37
+ "description": "Count of implementation reports"
38
+ },
39
+ "checksum": {
40
+ "type": "string",
41
+ "description": "Optional SHA256 for integrity verification"
42
+ }
43
+ }
44
+ },
45
+ "authorities": {
46
+ "type": "object",
47
+ "description": "Domain to authoritative specification mapping. Query: 'What is the authoritative source for X?'",
48
+ "additionalProperties": {
49
+ "type": "string",
50
+ "description": "Filename of authoritative spec for this domain"
51
+ }
52
+ },
53
+ "specs": {
54
+ "type": "array",
55
+ "description": "All specification documents with metadata",
56
+ "items": {
57
+ "$ref": "#/definitions/specEntry"
58
+ }
59
+ },
60
+ "reports": {
61
+ "type": "array",
62
+ "description": "All implementation reports with progress tracking",
63
+ "items": {
64
+ "$ref": "#/definitions/reportEntry"
65
+ }
66
+ },
67
+ "recentChanges": {
68
+ "type": "array",
69
+ "description": "Last 20 changes for change tracking",
70
+ "maxItems": 20,
71
+ "items": {
72
+ "$ref": "#/definitions/changeEntry"
73
+ }
74
+ }
75
+ },
76
+ "definitions": {
77
+ "specEntry": {
78
+ "type": "object",
79
+ "required": ["file", "version", "status", "type", "domain", "synopsis", "lastUpdated"],
80
+ "properties": {
81
+ "file": {
82
+ "type": "string",
83
+ "pattern": "^[A-Z0-9-]+\\.(md|json)$",
84
+ "description": "Filename (not path)"
85
+ },
86
+ "version": {
87
+ "type": "string",
88
+ "description": "Semantic version or version string"
89
+ },
90
+ "status": {
91
+ "type": "string",
92
+ "enum": ["DRAFT", "APPROVED", "ACTIVE", "IMMUTABLE", "DEPRECATED", "PLANNING", "IMPLEMENTED"],
93
+ "description": "Document lifecycle status"
94
+ },
95
+ "type": {
96
+ "type": "string",
97
+ "enum": ["SPEC", "GUIDELINES", "PLAN"],
98
+ "description": "Document type classification"
99
+ },
100
+ "domain": {
101
+ "type": "string",
102
+ "description": "Primary domain this spec covers"
103
+ },
104
+ "category": {
105
+ "type": "string",
106
+ "enum": ["core-system", "feature", "design-philosophy", "integration", "process"],
107
+ "description": "Organizational category"
108
+ },
109
+ "synopsis": {
110
+ "type": "string",
111
+ "maxLength": 200,
112
+ "description": "1-2 sentence purpose summary"
113
+ },
114
+ "lastUpdated": {
115
+ "type": "string",
116
+ "format": "date",
117
+ "description": "ISO date of last document update"
118
+ },
119
+ "dependsOn": {
120
+ "type": "array",
121
+ "items": {"type": "string"},
122
+ "description": "Specs this document depends on (filenames)"
123
+ },
124
+ "dependedOnBy": {
125
+ "type": "array",
126
+ "items": {"type": "string"},
127
+ "description": "Specs that depend on this document (filenames)"
128
+ },
129
+ "implementationReport": {
130
+ "type": "string",
131
+ "description": "Filename of associated implementation report"
132
+ },
133
+ "isAuthoritativeFor": {
134
+ "type": "array",
135
+ "items": {"type": "string"},
136
+ "description": "Domains this spec is authoritative for"
137
+ }
138
+ }
139
+ },
140
+ "reportEntry": {
141
+ "type": "object",
142
+ "required": ["file", "relatedSpec", "progress", "lastUpdated"],
143
+ "properties": {
144
+ "file": {
145
+ "type": "string",
146
+ "pattern": "^[A-Z0-9-]+-IMPLEMENTATION-REPORT\\.md$"
147
+ },
148
+ "relatedSpec": {
149
+ "type": "string",
150
+ "description": "Filename of the spec this tracks"
151
+ },
152
+ "progress": {
153
+ "type": "string",
154
+ "description": "Progress indicator (e.g., '85%', '16/18', 'Varies')"
155
+ },
156
+ "phase": {
157
+ "type": "string",
158
+ "description": "Current implementation phase"
159
+ },
160
+ "lastUpdated": {
161
+ "type": "string",
162
+ "format": "date"
163
+ },
164
+ "notes": {
165
+ "type": "string",
166
+ "maxLength": 100,
167
+ "description": "Brief status note"
168
+ }
169
+ }
170
+ },
171
+ "changeEntry": {
172
+ "type": "object",
173
+ "required": ["date", "file", "changeType", "description"],
174
+ "properties": {
175
+ "date": {
176
+ "type": "string",
177
+ "format": "date"
178
+ },
179
+ "file": {
180
+ "type": "string"
181
+ },
182
+ "changeType": {
183
+ "type": "string",
184
+ "enum": ["Created", "Updated", "StatusChange", "Deprecated"]
185
+ },
186
+ "version": {
187
+ "type": "string"
188
+ },
189
+ "description": {
190
+ "type": "string",
191
+ "maxLength": 100
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "CLEO System Flow Atlas Structure",
4
+ "description": "Validates that a System Flow Atlas document contains all required sections",
5
+ "type": "object",
6
+ "properties": {
7
+ "title": {
8
+ "type": "string",
9
+ "const": "CLEO System Flow Atlas",
10
+ "description": "Document title"
11
+ },
12
+ "version": {
13
+ "type": "string",
14
+ "pattern": "^\\d{4}\\.\\d{1,2}\\.\\d{1,2}$",
15
+ "description": "CalVer version (YYYY.M.D)"
16
+ },
17
+ "status": {
18
+ "type": "string",
19
+ "enum": ["DRAFT", "REVIEW", "APPROVED", "STABLE", "SUPERSEDED", "ARCHIVED"],
20
+ "description": "Document lifecycle status"
21
+ },
22
+ "sections": {
23
+ "type": "object",
24
+ "description": "Required sections in the atlas document",
25
+ "properties": {
26
+ "purpose": {
27
+ "type": "boolean",
28
+ "description": "Section 1: Purpose exists"
29
+ },
30
+ "systemDomainMapping": {
31
+ "type": "boolean",
32
+ "description": "Section 2: Four systems mapped to 10 domains"
33
+ },
34
+ "requestFlow": {
35
+ "type": "boolean",
36
+ "description": "Section 3: End-to-end request flow diagram"
37
+ },
38
+ "domainInteractionGraph": {
39
+ "type": "boolean",
40
+ "description": "Section 4: Domain interaction graph"
41
+ },
42
+ "dataStores": {
43
+ "type": "boolean",
44
+ "description": "Section 5: Data stores and ownership boundaries"
45
+ },
46
+ "distillationFlow": {
47
+ "type": "boolean",
48
+ "description": "Section 6: LOOM distillation flow"
49
+ },
50
+ "flowExamples": {
51
+ "type": "boolean",
52
+ "description": "Section 7: Query/mutate flow examples"
53
+ },
54
+ "progressiveDisclosure": {
55
+ "type": "boolean",
56
+ "description": "Section 8: Progressive disclosure in practice"
57
+ },
58
+ "failureRecovery": {
59
+ "type": "boolean",
60
+ "description": "Section 9: Failure and recovery paths"
61
+ },
62
+ "observability": {
63
+ "type": "boolean",
64
+ "description": "Section 10: Observability and audit trails"
65
+ },
66
+ "invariants": {
67
+ "type": "boolean",
68
+ "description": "Section 11: Canonical invariants"
69
+ },
70
+ "glossary": {
71
+ "type": "boolean",
72
+ "description": "Section 12: Glossary"
73
+ }
74
+ },
75
+ "required": [
76
+ "purpose",
77
+ "systemDomainMapping",
78
+ "requestFlow",
79
+ "domainInteractionGraph",
80
+ "dataStores",
81
+ "distillationFlow",
82
+ "flowExamples",
83
+ "progressiveDisclosure",
84
+ "failureRecovery",
85
+ "observability",
86
+ "invariants",
87
+ "glossary"
88
+ ]
89
+ },
90
+ "domains": {
91
+ "type": "array",
92
+ "items": {
93
+ "type": "string",
94
+ "enum": [
95
+ "tasks",
96
+ "session",
97
+ "memory",
98
+ "check",
99
+ "pipeline",
100
+ "orchestrate",
101
+ "tools",
102
+ "admin",
103
+ "nexus",
104
+ "sticky"
105
+ ]
106
+ },
107
+ "minItems": 10,
108
+ "maxItems": 10,
109
+ "uniqueItems": true,
110
+ "description": "All 10 canonical domains MUST be referenced"
111
+ },
112
+ "systems": {
113
+ "type": "array",
114
+ "items": {
115
+ "type": "string",
116
+ "enum": ["BRAIN", "LOOM", "NEXUS", "LAFS"]
117
+ },
118
+ "minItems": 4,
119
+ "maxItems": 4,
120
+ "uniqueItems": true,
121
+ "description": "All 4 conceptual systems MUST be documented"
122
+ }
123
+ },
124
+ "required": ["title", "version", "status", "sections", "domains", "systems"]
125
+ }
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * Verifies the new AGENTS.md hub injection architecture:
5
5
  * 1. Provider files (CLAUDE.md, GEMINI.md) reference @AGENTS.md
6
- * 2. AGENTS.md references @~/.cleo/templates/CLEO-INJECTION.md
7
- * 3. No references to @.cleo/templates/AGENT-INJECTION.md anywhere
8
- * 4. No CLEO:START markers anywhere (CAAMP uses CAAMP:START/END)
6
+ * 2. Project AGENTS.md references @~/.agents/AGENTS.md (global hub)
7
+ * 3. Global ~/.agents/AGENTS.md references @~/.cleo/templates/CLEO-INJECTION.md
8
+ * 4. No references to @.cleo/templates/AGENT-INJECTION.md anywhere
9
+ * 5. No CLEO:START markers anywhere (CAAMP uses CAAMP:START/END)
9
10
  *
10
11
  * Since CAAMP functions depend on actual provider installations,
11
12
  * they are mocked via vi.mock to isolate the init logic.
@@ -159,13 +160,13 @@ describe('E2E: injection chain validation (T4694)', () => {
159
160
  expect(geminiContent).toContain('@AGENTS.md');
160
161
  });
161
162
 
162
- it('AGENTS.md references @~/.cleo/templates/CLEO-INJECTION.md', async () => {
163
+ it('AGENTS.md references @~/.agents/AGENTS.md (global hub)', async () => {
163
164
  await initProject({ name: 'chain-test' });
164
165
 
165
166
  const agentsPath = join(testDir, 'AGENTS.md');
166
167
  expect(existsSync(agentsPath)).toBe(true);
167
168
  const agentsContent = await readFile(agentsPath, 'utf-8');
168
- expect(agentsContent).toContain('@~/.cleo/templates/CLEO-INJECTION.md');
169
+ expect(agentsContent).toContain('@~/.agents/AGENTS.md');
169
170
  });
170
171
 
171
172
  it('no references to @.cleo/templates/AGENT-INJECTION.md in generated files', async () => {
@@ -216,7 +217,7 @@ describe('E2E: injection chain validation (T4694)', () => {
216
217
  expect(createdStr).toContain('AGENTS.md');
217
218
  });
218
219
 
219
- it('injection chain: provider -> AGENTS.md -> CLEO-INJECTION.md', async () => {
220
+ it('injection chain: provider -> AGENTS.md -> ~/.agents/AGENTS.md -> CLEO-INJECTION.md', async () => {
220
221
  await initProject({ name: 'chain-test' });
221
222
 
222
223
  // Verify the full chain:
@@ -224,9 +225,9 @@ describe('E2E: injection chain validation (T4694)', () => {
224
225
  const claudeContent = await readFile(join(testDir, 'CLAUDE.md'), 'utf-8');
225
226
  expect(claudeContent).toContain('@AGENTS.md');
226
227
 
227
- // AGENTS.md -> @~/.cleo/templates/CLEO-INJECTION.md (via inject)
228
+ // AGENTS.md -> @~/.agents/AGENTS.md (project hub references global hub)
228
229
  const agentsContent = await readFile(join(testDir, 'AGENTS.md'), 'utf-8');
229
- expect(agentsContent).toContain('@~/.cleo/templates/CLEO-INJECTION.md');
230
+ expect(agentsContent).toContain('@~/.agents/AGENTS.md');
230
231
 
231
232
  // Neither should reference the old AGENT-INJECTION.md pattern
232
233
  expect(claudeContent).not.toContain('AGENT-INJECTION.md');
@@ -241,11 +242,11 @@ describe('E2E: injection chain validation (T4694)', () => {
241
242
 
242
243
  await initProject({ name: 'no-provider-test' });
243
244
 
244
- // AGENTS.md should still exist and reference CLEO-INJECTION.md
245
+ // AGENTS.md should still exist and reference the global hub
245
246
  const agentsPath = join(testDir, 'AGENTS.md');
246
247
  expect(existsSync(agentsPath)).toBe(true);
247
248
  const agentsContent = await readFile(agentsPath, 'utf-8');
248
- expect(agentsContent).toContain('@~/.cleo/templates/CLEO-INJECTION.md');
249
+ expect(agentsContent).toContain('@~/.agents/AGENTS.md');
249
250
  });
250
251
 
251
252
  it('updateDocs refreshes injection without full reinit', async () => {
@@ -17,8 +17,10 @@ import { fileURLToPath } from 'node:url';
17
17
  import { describe, expect, it } from 'vitest';
18
18
 
19
19
  const thisFile = fileURLToPath(import.meta.url);
20
- const monorepoRoot = resolve(dirname(thisFile), '..', '..', '..', '..');
21
- const injectionPath = join(monorepoRoot, 'templates', 'CLEO-INJECTION.md');
20
+ // Template moved to packages/core/templates/ (was at monorepo root templates/)
21
+ // thisFile is at packages/core/src/__tests__/, go up two levels to reach packages/core/
22
+ const corePackageRoot = resolve(dirname(thisFile), '..', '..');
23
+ const injectionPath = join(corePackageRoot, 'templates', 'CLEO-INJECTION.md');
22
24
 
23
25
  const templateExists = existsSync(injectionPath);
24
26
 
@@ -3,13 +3,14 @@
3
3
  *
4
4
  * Extracted from CLI import-tasks command for dispatch layer access.
5
5
  *
6
- * @task T5323, T5328
6
+ * @task T5323, T5328, T046
7
7
  * @epic T4545
8
8
  */
9
9
 
10
10
  import { constants as fsConstants } from 'node:fs';
11
11
  import { access, readFile } from 'node:fs/promises';
12
12
  import type { Task, TaskStatus } from '@cleocode/contracts';
13
+ import type { ImportFromPackageOptions, ImportFromPackageResult } from '../nexus/transfer-types.js';
13
14
  import { getAccessor } from '../store/data-accessor.js';
14
15
  import type { ExportPackage } from '../store/export.js';
15
16
  import {
@@ -74,25 +75,13 @@ export interface ImportTasksResult {
74
75
  }
75
76
 
76
77
  /**
77
- * Import tasks from a cross-project export package with ID remapping.
78
+ * Import tasks from an in-memory ExportPackage with ID remapping.
79
+ * Core logic extracted from importTasksPackage for reuse by transfer engine.
78
80
  */
79
- export async function importTasksPackage(params: ImportTasksParams): Promise<ImportTasksResult> {
80
- const { file } = params;
81
-
82
- try {
83
- await access(file, fsConstants.R_OK);
84
- } catch {
85
- throw new Error(`Export file not found: ${file}`);
86
- }
87
-
88
- const content = await readFile(file, 'utf-8');
89
- let exportPkg: ExportPackage;
90
- try {
91
- exportPkg = JSON.parse(content) as ExportPackage;
92
- } catch {
93
- throw new Error(`Invalid JSON in: ${file}`);
94
- }
95
-
81
+ export async function importFromPackage(
82
+ exportPkg: ExportPackage,
83
+ options: ImportFromPackageOptions = {},
84
+ ): Promise<ImportFromPackageResult> {
96
85
  if (exportPkg._meta?.format !== 'cleo-export') {
97
86
  throw new Error(
98
87
  `Invalid export format (expected 'cleo-export', got '${exportPkg._meta?.format}')`,
@@ -103,17 +92,17 @@ export async function importTasksPackage(params: ImportTasksParams): Promise<Imp
103
92
  throw new Error('Export package contains no tasks');
104
93
  }
105
94
 
106
- const accessor = await getAccessor(params.cwd);
95
+ const accessor = await getAccessor(options.cwd);
107
96
  const { tasks: existingTasks } = await accessor.queryTasks({});
108
97
 
109
- const onConflict: OnConflict = params.onConflict ?? 'fail';
110
- const onMissingDep: OnMissingDep = params.onMissingDep ?? 'strip';
111
- const force = params.force ?? false;
112
- const parentId = params.parent;
113
- const phaseOverride = params.phase;
114
- const addLabel = params.addLabel;
115
- const resetStatus = params.resetStatus;
116
- const addProvenance = params.provenance !== false;
98
+ const onConflict: OnConflict = options.onConflict ?? 'fail';
99
+ const onMissingDep: OnMissingDep = options.onMissingDep === 'fail' ? 'fail' : 'strip';
100
+ const force = options.force ?? false;
101
+ const parentId = options.parent;
102
+ const phaseOverride = options.phase;
103
+ const addLabel = options.addLabel;
104
+ const resetStatus = options.resetStatus;
105
+ const addProvenance = options.provenance !== false;
117
106
 
118
107
  if (parentId) {
119
108
  const parentExists = existingTasks.some((t) => t.id === parentId);
@@ -195,7 +184,7 @@ export async function importTasksPackage(params: ImportTasksParams): Promise<Imp
195
184
  existingIds.add(remapped.id);
196
185
  }
197
186
 
198
- if (params.dryRun) {
187
+ if (options.dryRun) {
199
188
  return {
200
189
  imported: transformed.length,
201
190
  skipped: skipped.length,
@@ -217,3 +206,38 @@ export async function importTasksPackage(params: ImportTasksParams): Promise<Imp
217
206
  idRemap: idRemapJson,
218
207
  };
219
208
  }
209
+
210
+ /**
211
+ * Import tasks from a cross-project export package file with ID remapping.
212
+ * Thin wrapper around importFromPackage that handles file I/O.
213
+ */
214
+ export async function importTasksPackage(params: ImportTasksParams): Promise<ImportTasksResult> {
215
+ const { file } = params;
216
+
217
+ try {
218
+ await access(file, fsConstants.R_OK);
219
+ } catch {
220
+ throw new Error(`Export file not found: ${file}`);
221
+ }
222
+
223
+ const content = await readFile(file, 'utf-8');
224
+ let exportPkg: ExportPackage;
225
+ try {
226
+ exportPkg = JSON.parse(content) as ExportPackage;
227
+ } catch {
228
+ throw new Error(`Invalid JSON in: ${file}`);
229
+ }
230
+
231
+ return importFromPackage(exportPkg, {
232
+ cwd: params.cwd,
233
+ dryRun: params.dryRun,
234
+ parent: params.parent,
235
+ phase: params.phase,
236
+ addLabel: params.addLabel,
237
+ provenance: params.provenance,
238
+ resetStatus: params.resetStatus,
239
+ onConflict: params.onConflict,
240
+ onMissingDep: params.onMissingDep === 'placeholder' ? 'strip' : params.onMissingDep,
241
+ force: params.force,
242
+ });
243
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tests for capacity tracking and load balancing.
3
+ *
4
+ * @module agents/__tests__/capacity.test
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=capacity.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacity.test.d.ts","sourceRoot":"","sources":["capacity.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}