@agimon-ai/po 0.0.0-alpha.94 → 0.0.0-alpha.95

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.
@@ -2,7 +2,7 @@
2
2
  "version": 1,
3
3
  "packages": {
4
4
  "@agimon-ai/po": {
5
- "version": "0.0.0-alpha.94",
5
+ "version": "0.0.0-alpha.95",
6
6
  "dependencies": [
7
7
  "@agimon-ai/po-approval",
8
8
  "@agimon-ai/po-artifact",
@@ -28,14 +28,14 @@
28
28
  ]
29
29
  },
30
30
  "@agimon-ai/po-approval": {
31
- "version": "0.0.0-alpha.93",
31
+ "version": "0.0.0-alpha.94",
32
32
  "dependencies": [
33
33
  "@agimon-ai/po-core",
34
34
  "@agimon-ai/po-web-components"
35
35
  ]
36
36
  },
37
37
  "@agimon-ai/po-artifact": {
38
- "version": "0.0.0-alpha.92",
38
+ "version": "0.0.0-alpha.93",
39
39
  "dependencies": [
40
40
  "@agimon-ai/po-core",
41
41
  "@agimon-ai/po-web-components",
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  },
45
45
  "@agimon-ai/po-author": {
46
- "version": "0.0.0-alpha.93",
46
+ "version": "0.0.0-alpha.94",
47
47
  "dependencies": [
48
48
  "@agimon-ai/po-artifact",
49
49
  "@agimon-ai/po-core",
@@ -53,7 +53,7 @@
53
53
  ]
54
54
  },
55
55
  "@agimon-ai/po-autocompact": {
56
- "version": "0.0.0-alpha.93",
56
+ "version": "0.0.0-alpha.94",
57
57
  "dependencies": [
58
58
  "@agimon-ai/po-artifact",
59
59
  "@agimon-ai/po-config",
@@ -62,24 +62,24 @@
62
62
  ]
63
63
  },
64
64
  "@agimon-ai/po-autostop": {
65
- "version": "0.0.0-alpha.93",
65
+ "version": "0.0.0-alpha.94",
66
66
  "dependencies": [
67
67
  "@agimon-ai/po-core"
68
68
  ]
69
69
  },
70
70
  "@agimon-ai/po-browse": {
71
- "version": "0.0.1-alpha.91",
71
+ "version": "0.0.1-alpha.92",
72
72
  "dependencies": [
73
73
  "@agimon-ai/po-core",
74
74
  "@agimon-ai/po-web-components"
75
75
  ]
76
76
  },
77
77
  "@agimon-ai/po-build": {
78
- "version": "0.0.0-alpha.93",
78
+ "version": "0.0.0-alpha.94",
79
79
  "dependencies": []
80
80
  },
81
81
  "@agimon-ai/po-cache": {
82
- "version": "0.0.0-alpha.93",
82
+ "version": "0.0.0-alpha.94",
83
83
  "dependencies": [
84
84
  "@agimon-ai/po-config",
85
85
  "@agimon-ai/po-core",
@@ -87,7 +87,7 @@
87
87
  ]
88
88
  },
89
89
  "@agimon-ai/po-calendar": {
90
- "version": "0.0.1-alpha.52",
90
+ "version": "0.0.1-alpha.53",
91
91
  "dependencies": [
92
92
  "@agimon-ai/po-config",
93
93
  "@agimon-ai/po-core",
@@ -98,11 +98,11 @@
98
98
  ]
99
99
  },
100
100
  "@agimon-ai/po-claude-bridge": {
101
- "version": "0.1.1-alpha.73",
101
+ "version": "0.1.1-alpha.74",
102
102
  "dependencies": []
103
103
  },
104
104
  "@agimon-ai/po-codemode": {
105
- "version": "0.0.1-alpha.66",
105
+ "version": "0.0.1-alpha.67",
106
106
  "dependencies": [
107
107
  "@agimon-ai/po-config",
108
108
  "@agimon-ai/po-core",
@@ -110,7 +110,7 @@
110
110
  ]
111
111
  },
112
112
  "@agimon-ai/po-computer-use": {
113
- "version": "0.0.0-alpha.93",
113
+ "version": "0.0.0-alpha.94",
114
114
  "dependencies": [
115
115
  "@agimon-ai/po-config",
116
116
  "@agimon-ai/po-core",
@@ -120,26 +120,26 @@
120
120
  ]
121
121
  },
122
122
  "@agimon-ai/po-config": {
123
- "version": "0.0.0-alpha.93",
123
+ "version": "0.0.0-alpha.94",
124
124
  "dependencies": [
125
125
  "@agimon-ai/po-core",
126
126
  "@agimon-ai/po-web-components"
127
127
  ]
128
128
  },
129
129
  "@agimon-ai/po-core": {
130
- "version": "0.0.0-alpha.93",
130
+ "version": "0.0.0-alpha.94",
131
131
  "dependencies": [
132
132
  "@agimon-ai/po-web-security"
133
133
  ]
134
134
  },
135
135
  "@agimon-ai/po-db": {
136
- "version": "0.0.0-alpha.93",
136
+ "version": "0.0.0-alpha.94",
137
137
  "dependencies": [
138
138
  "@agimon-ai/po-core"
139
139
  ]
140
140
  },
141
141
  "@agimon-ai/po-domain": {
142
- "version": "0.0.0-alpha.93",
142
+ "version": "0.0.0-alpha.94",
143
143
  "dependencies": [
144
144
  "@agimon-ai/po-config",
145
145
  "@agimon-ai/po-core",
@@ -147,7 +147,7 @@
147
147
  ]
148
148
  },
149
149
  "@agimon-ai/po-edit": {
150
- "version": "0.0.0-alpha.93",
150
+ "version": "0.0.0-alpha.94",
151
151
  "dependencies": [
152
152
  "@agimon-ai/po-core",
153
153
  "@agimon-ai/po-hashline",
@@ -156,7 +156,7 @@
156
156
  ]
157
157
  },
158
158
  "@agimon-ai/po-file-edit": {
159
- "version": "0.0.0-alpha.93",
159
+ "version": "0.0.0-alpha.94",
160
160
  "dependencies": [
161
161
  "@agimon-ai/po-config",
162
162
  "@agimon-ai/po-core",
@@ -166,7 +166,7 @@
166
166
  ]
167
167
  },
168
168
  "@agimon-ai/po-git": {
169
- "version": "0.0.0-alpha.93",
169
+ "version": "0.0.0-alpha.94",
170
170
  "dependencies": [
171
171
  "@agimon-ai/po-core",
172
172
  "@agimon-ai/po-session",
@@ -175,7 +175,7 @@
175
175
  ]
176
176
  },
177
177
  "@agimon-ai/po-goal": {
178
- "version": "0.0.0-alpha.93",
178
+ "version": "0.0.0-alpha.94",
179
179
  "dependencies": [
180
180
  "@agimon-ai/po-core",
181
181
  "@agimon-ai/po-minor-mode",
@@ -184,7 +184,7 @@
184
184
  ]
185
185
  },
186
186
  "@agimon-ai/po-grep": {
187
- "version": "0.0.0-alpha.93",
187
+ "version": "0.0.0-alpha.94",
188
188
  "dependencies": [
189
189
  "@agimon-ai/po-core",
190
190
  "@agimon-ai/po-hashline",
@@ -193,11 +193,11 @@
193
193
  ]
194
194
  },
195
195
  "@agimon-ai/po-hashline": {
196
- "version": "0.0.0-alpha.93",
196
+ "version": "0.0.0-alpha.94",
197
197
  "dependencies": []
198
198
  },
199
199
  "@agimon-ai/po-help": {
200
- "version": "0.0.0-alpha.93",
200
+ "version": "0.0.0-alpha.94",
201
201
  "dependencies": [
202
202
  "@agimon-ai/po-core",
203
203
  "@agimon-ai/po-minor-mode",
@@ -205,14 +205,14 @@
205
205
  ]
206
206
  },
207
207
  "@agimon-ai/po-identity": {
208
- "version": "0.0.2-alpha.40",
208
+ "version": "0.0.2-alpha.41",
209
209
  "dependencies": [
210
210
  "@agimon-ai/po-core",
211
211
  "@agimon-ai/po-web-security"
212
212
  ]
213
213
  },
214
214
  "@agimon-ai/po-image-gen": {
215
- "version": "0.0.0-alpha.92",
215
+ "version": "0.0.0-alpha.93",
216
216
  "dependencies": [
217
217
  "@agimon-ai/po-core",
218
218
  "@agimon-ai/po-web-components",
@@ -220,7 +220,7 @@
220
220
  ]
221
221
  },
222
222
  "@agimon-ai/po-ios": {
223
- "version": "0.0.1-alpha.28",
223
+ "version": "0.0.1-alpha.29",
224
224
  "dependencies": [
225
225
  "@agimon-ai/po-artifact",
226
226
  "@agimon-ai/po-config",
@@ -230,7 +230,7 @@
230
230
  ]
231
231
  },
232
232
  "@agimon-ai/po-log": {
233
- "version": "0.0.0-alpha.93",
233
+ "version": "0.0.0-alpha.94",
234
234
  "dependencies": [
235
235
  "@agimon-ai/po-core",
236
236
  "@agimon-ai/po-web-components",
@@ -238,7 +238,7 @@
238
238
  ]
239
239
  },
240
240
  "@agimon-ai/po-major-mode": {
241
- "version": "0.0.0-alpha.93",
241
+ "version": "0.0.0-alpha.94",
242
242
  "dependencies": [
243
243
  "@agimon-ai/po-config",
244
244
  "@agimon-ai/po-core",
@@ -246,7 +246,7 @@
246
246
  ]
247
247
  },
248
248
  "@agimon-ai/po-mcp": {
249
- "version": "0.0.0-alpha.93",
249
+ "version": "0.0.0-alpha.94",
250
250
  "dependencies": [
251
251
  "@agimon-ai/po-config",
252
252
  "@agimon-ai/po-core",
@@ -257,43 +257,43 @@
257
257
  ]
258
258
  },
259
259
  "@agimon-ai/po-mcp-proxy": {
260
- "version": "0.0.1-alpha.72",
260
+ "version": "0.0.1-alpha.73",
261
261
  "dependencies": []
262
262
  },
263
263
  "@agimon-ai/po-minor-mode": {
264
- "version": "0.0.0-alpha.93",
264
+ "version": "0.0.0-alpha.94",
265
265
  "dependencies": [
266
266
  "@agimon-ai/po-core"
267
267
  ]
268
268
  },
269
269
  "@agimon-ai/po-model-guidance": {
270
- "version": "0.0.0-alpha.93",
270
+ "version": "0.0.0-alpha.94",
271
271
  "dependencies": [
272
272
  "@agimon-ai/po-config",
273
273
  "@agimon-ai/po-core"
274
274
  ]
275
275
  },
276
276
  "@agimon-ai/po-native-components": {
277
- "version": "0.0.0-alpha.93",
277
+ "version": "0.0.0-alpha.94",
278
278
  "dependencies": [
279
279
  "@agimon-ai/po-web-components"
280
280
  ]
281
281
  },
282
282
  "@agimon-ai/po-network": {
283
- "version": "0.0.2-alpha.40",
283
+ "version": "0.0.2-alpha.41",
284
284
  "dependencies": [
285
285
  "@agimon-ai/po-core",
286
286
  "@agimon-ai/po-web-security"
287
287
  ]
288
288
  },
289
289
  "@agimon-ai/po-notification": {
290
- "version": "0.0.0-alpha.93",
290
+ "version": "0.0.0-alpha.94",
291
291
  "dependencies": [
292
292
  "@agimon-ai/po-core"
293
293
  ]
294
294
  },
295
295
  "@agimon-ai/po-plan": {
296
- "version": "0.0.0-alpha.93",
296
+ "version": "0.0.0-alpha.94",
297
297
  "dependencies": [
298
298
  "@agimon-ai/po-config",
299
299
  "@agimon-ai/po-core",
@@ -303,7 +303,7 @@
303
303
  ]
304
304
  },
305
305
  "@agimon-ai/po-profile": {
306
- "version": "0.0.0-alpha.93",
306
+ "version": "0.0.0-alpha.94",
307
307
  "dependencies": [
308
308
  "@agimon-ai/po-config",
309
309
  "@agimon-ai/po-core",
@@ -311,7 +311,7 @@
311
311
  ]
312
312
  },
313
313
  "@agimon-ai/po-prompt": {
314
- "version": "0.0.0-alpha.93",
314
+ "version": "0.0.0-alpha.94",
315
315
  "dependencies": [
316
316
  "@agimon-ai/po-core",
317
317
  "@agimon-ai/po-web-components",
@@ -319,7 +319,7 @@
319
319
  ]
320
320
  },
321
321
  "@agimon-ai/po-read": {
322
- "version": "0.0.0-alpha.93",
322
+ "version": "0.0.0-alpha.94",
323
323
  "dependencies": [
324
324
  "@agimon-ai/po-config",
325
325
  "@agimon-ai/po-core",
@@ -329,7 +329,7 @@
329
329
  ]
330
330
  },
331
331
  "@agimon-ai/po-runner": {
332
- "version": "0.0.0-alpha.93",
332
+ "version": "0.0.0-alpha.94",
333
333
  "dependencies": [
334
334
  "@agimon-ai/po-core",
335
335
  "@agimon-ai/po-ui",
@@ -338,13 +338,13 @@
338
338
  ]
339
339
  },
340
340
  "@agimon-ai/po-sandbox": {
341
- "version": "0.0.0-alpha.93",
341
+ "version": "0.0.0-alpha.94",
342
342
  "dependencies": [
343
343
  "@agimon-ai/po-core"
344
344
  ]
345
345
  },
346
346
  "@agimon-ai/po-session": {
347
- "version": "0.0.0-alpha.93",
347
+ "version": "0.0.0-alpha.94",
348
348
  "dependencies": [
349
349
  "@agimon-ai/po-config",
350
350
  "@agimon-ai/po-core",
@@ -352,7 +352,7 @@
352
352
  ]
353
353
  },
354
354
  "@agimon-ai/po-skill": {
355
- "version": "0.0.0-alpha.93",
355
+ "version": "0.0.0-alpha.94",
356
356
  "dependencies": [
357
357
  "@agimon-ai/po-config",
358
358
  "@agimon-ai/po-core",
@@ -361,7 +361,7 @@
361
361
  ]
362
362
  },
363
363
  "@agimon-ai/po-style-system": {
364
- "version": "0.0.0-alpha.93",
364
+ "version": "0.0.0-alpha.94",
365
365
  "dependencies": [
366
366
  "@agimon-ai/po-core",
367
367
  "@agimon-ai/po-web-components",
@@ -369,7 +369,7 @@
369
369
  ]
370
370
  },
371
371
  "@agimon-ai/po-task": {
372
- "version": "0.0.0-alpha.93",
372
+ "version": "0.0.0-alpha.94",
373
373
  "dependencies": [
374
374
  "@agimon-ai/po-core",
375
375
  "@agimon-ai/po-ui",
@@ -377,7 +377,7 @@
377
377
  ]
378
378
  },
379
379
  "@agimon-ai/po-team": {
380
- "version": "0.0.0-alpha.93",
380
+ "version": "0.0.0-alpha.94",
381
381
  "dependencies": [
382
382
  "@agimon-ai/po-cache",
383
383
  "@agimon-ai/po-config",
@@ -389,7 +389,7 @@
389
389
  ]
390
390
  },
391
391
  "@agimon-ai/po-template-advanced": {
392
- "version": "0.0.0-alpha.93",
392
+ "version": "0.0.0-alpha.94",
393
393
  "dependencies": [
394
394
  "@agimon-ai/po-core",
395
395
  "@agimon-ai/po-web-components",
@@ -397,7 +397,7 @@
397
397
  ]
398
398
  },
399
399
  "@agimon-ai/po-template-elegant": {
400
- "version": "0.0.0-alpha.93",
400
+ "version": "0.0.0-alpha.94",
401
401
  "dependencies": [
402
402
  "@agimon-ai/po-core",
403
403
  "@agimon-ai/po-web-components",
@@ -405,7 +405,7 @@
405
405
  ]
406
406
  },
407
407
  "@agimon-ai/po-ui": {
408
- "version": "0.0.0-alpha.93",
408
+ "version": "0.0.0-alpha.94",
409
409
  "dependencies": [
410
410
  "@agimon-ai/po-core",
411
411
  "@agimon-ai/po-hashline",
@@ -414,7 +414,7 @@
414
414
  ]
415
415
  },
416
416
  "@agimon-ai/po-user-feedback": {
417
- "version": "0.0.0-alpha.93",
417
+ "version": "0.0.0-alpha.94",
418
418
  "dependencies": [
419
419
  "@agimon-ai/po-core",
420
420
  "@agimon-ai/po-minor-mode",
@@ -423,14 +423,14 @@
423
423
  ]
424
424
  },
425
425
  "@agimon-ai/po-vault": {
426
- "version": "0.0.0-alpha.93",
426
+ "version": "0.0.0-alpha.94",
427
427
  "dependencies": [
428
428
  "@agimon-ai/po-core",
429
429
  "@agimon-ai/po-db"
430
430
  ]
431
431
  },
432
432
  "@agimon-ai/po-vibe-lint": {
433
- "version": "0.0.1-alpha.62",
433
+ "version": "0.0.1-alpha.63",
434
434
  "dependencies": [
435
435
  "@agimon-ai/po-config",
436
436
  "@agimon-ai/po-core",
@@ -440,7 +440,7 @@
440
440
  ]
441
441
  },
442
442
  "@agimon-ai/po-voice": {
443
- "version": "0.0.0-alpha.93",
443
+ "version": "0.0.0-alpha.94",
444
444
  "dependencies": [
445
445
  "@agimon-ai/po-config",
446
446
  "@agimon-ai/po-core",
@@ -452,11 +452,11 @@
452
452
  ]
453
453
  },
454
454
  "@agimon-ai/po-web-components": {
455
- "version": "0.0.0-alpha.93",
455
+ "version": "0.0.0-alpha.94",
456
456
  "dependencies": []
457
457
  },
458
458
  "@agimon-ai/po-web-dashboard": {
459
- "version": "0.0.0-alpha.93",
459
+ "version": "0.0.0-alpha.94",
460
460
  "dependencies": [
461
461
  "@agimon-ai/po-core",
462
462
  "@agimon-ai/po-web-components",
@@ -464,18 +464,18 @@
464
464
  ]
465
465
  },
466
466
  "@agimon-ai/po-web-search": {
467
- "version": "0.0.0-alpha.92",
467
+ "version": "0.0.0-alpha.93",
468
468
  "dependencies": [
469
469
  "@agimon-ai/po-core",
470
470
  "@agimon-ai/po-web-components"
471
471
  ]
472
472
  },
473
473
  "@agimon-ai/po-web-security": {
474
- "version": "0.0.0-alpha.93",
474
+ "version": "0.0.0-alpha.94",
475
475
  "dependencies": []
476
476
  },
477
477
  "@agimon-ai/po-workflow": {
478
- "version": "0.0.0-alpha.93",
478
+ "version": "0.0.0-alpha.94",
479
479
  "dependencies": [
480
480
  "@agimon-ai/po-core",
481
481
  "@agimon-ai/po-ui",
package/dist/package.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.0-alpha.94";
2
+ var version = "0.0.0-alpha.95";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.0-alpha.94";
2
+ var version = "0.0.0-alpha.95";
3
3
  //#endregion
4
4
  export { version };
5
5
 
@@ -50,12 +50,12 @@ function resolveHarnessProfile(options) {
50
50
  async function buildHarnessContext(options, telemetry = (0, _agimon_ai_po_core_runtimeLogSinkTelemetry.createHarnessTelemetry)({
51
51
  cwd: options.cwd,
52
52
  env: options.environment ?? process.env
53
- })) {
53
+ }), initialProfile) {
54
54
  const configRoot = options.configRoot ?? options.repoRoot;
55
55
  const configured = await telemetry.runInSpan(`po_pi.${RESOLVE_CONFIG_PHASE}`, { "harness.phase": RESOLVE_CONFIG_PHASE }, async () => {
56
56
  const majorModesConfig = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfig)(configRoot, options.homeDirectory, options.environment);
57
57
  const selectedLayers = (0, _agimon_ai_po_config_majorModes.resolveLayers)(majorModesConfig, options.majorMode);
58
- const profile = resolveHarnessProfile(options);
58
+ const profile = initialProfile === void 0 ? resolveHarnessProfile(options) : initialProfile.definition;
59
59
  if (!(await node_fs_promises.default.stat(options.cwd).catch((error) => {
60
60
  if (error.code === "ENOENT") return void 0;
61
61
  throw error;
@@ -111,7 +111,7 @@ async function buildHarnessContext(options, telemetry = (0, _agimon_ai_po_core_r
111
111
  environment.CODEX_REPO_ROOT = options.repoRoot;
112
112
  environment.ORIGINAL_REPO_PATH ||= options.repoRoot;
113
113
  environment.MCP_UI_VIEWER ??= "";
114
- const personaPrompt = personaDirectory ? (0, _agimon_ai_po_config_profiles.buildPersonaPrompt)(personaRoot, personaDirectory) : void 0;
114
+ const personaPrompt = profile?.personaPrompt ?? (personaDirectory ? (0, _agimon_ai_po_config_profiles.buildPersonaPrompt)(personaRoot, personaDirectory) : void 0);
115
115
  let personaFile;
116
116
  if (personaPrompt) {
117
117
  personaFile = node_path.default.join(resources.temporaryDirectory, "persona.md");
@@ -152,6 +152,7 @@ async function buildHarnessContext(options, telemetry = (0, _agimon_ai_po_core_r
152
152
  resources,
153
153
  plugins,
154
154
  profile: profile?.name,
155
+ ...initialProfile === void 0 ? {} : { initialProfileOutcome: initialProfile.outcome },
155
156
  personaDirectory,
156
157
  personaRoot,
157
158
  mcpAllowlist,
@@ -1 +1 @@
1
- {"version":3,"file":"harnessContext.cjs","names":["resolveProfile","createHarnessTelemetry","loadMajorModesConfig","resolveLayers","fs","materializePluginEntries","resolvePluginEntries","resolveMcpAllowlist","resolveSharedSkills","HARNESS_EVENT","collectResources","path","globalPoConfigDirectory","os","crypto","PO_USER_MCP_CONFIG_FILE","writeDefaultTheme","PO_MCP_SESSION_ENV_VAR","applyProfileEnvironment","DEFAULT_THEME_NAME","buildPersonaPrompt"],"sources":["../../../../src/builders/cli/harnessContext.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/po-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/po-config/domains';\nimport { loadMajorModesConfig, resolveLayers } from '@agimon-ai/po-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/po-config/profiles';\nimport { PO_USER_MCP_CONFIG_FILE } from '@agimon-ai/po-core/mcpProjection';\nimport { PO_MCP_SESSION_ENV_VAR } from '@agimon-ai/po-core/mcpSession';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '@agimon-ai/po-core/runtimeLogSinkTelemetry';\nimport { resolveMcpAllowlist } from '@agimon-ai/po-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/po-domain/resources';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/po-ui/theme';\n\nimport { createHarnessSession } from '../../composition/harnessState';\nimport type { HarnessOptions } from '../../composition/types/harness';\n\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported so a session server can apply the same rules before anything reads them.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.configRoot ?? options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry({ cwd: options.cwd, env: options.environment ?? process.env }),\n): Promise<HarnessContext> {\n // A worktree reads its workspace's configuration; resources still come from the checkout.\n const configRoot = options.configRoot ?? options.repoRoot;\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`po_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(configRoot, options.homeDirectory, options.environment);\n const selectedLayers = resolveLayers(majorModesConfig, options.majorMode);\n const profile = resolveHarnessProfile(options);\n if (\n !(\n await fs.stat(options.cwd).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n })\n )?.isDirectory()\n ) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(configRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(configRoot, options.domains),\n sharedSkills: resolveSharedSkills(configRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? configRoot;\n const resources = await telemetry\n .runInSpan(\n `po_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by a caller that stages into a directory it owns.\n temporaryDirectory: options.resourceDirectory,\n // Per repository, under the global home, so it outlives this process's resources.\n skillCacheDirectory:\n options.resourceDirectory === undefined\n ? path.join(\n globalPoConfigDirectory(options.homeDirectory ?? os.homedir()),\n 'cache',\n 'skills',\n crypto.createHash('sha256').update(path.resolve(options.repoRoot)).digest('hex').slice(0, 32),\n )\n : path.join(options.resourceDirectory, 'cache', 'skills'),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalPoConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n userMcpConfigPath: path.join(\n globalPoConfigDirectory(options.homeDirectory ?? os.homedir()),\n PO_USER_MCP_CONFIG_FILE,\n ),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...(options.environment ?? process.env) };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Po session.\n delete environment[PO_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment.PO_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER ??= '';\n\n const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined;\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileIdentity: profile?.identity,\n profileVoice: profile?.voice,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n }\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {}),\n });\n await resources.cleanup();\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;;;;;;AA8B5B,SAAgB,gBACd,SACA,aACM;CACN,IAAI,QAAQ,WAAW,QAAQ;EAC7B,IAAI,CAAC,YAAY,gBAAgB,YAAY,mBAC3C,YAAY,eAAe,YAAY;EAEzC,IAAI,CAAC,YAAY,cACf,MAAM,IAAI,MAAM,mEAAmE;CAEvF;AACF;;AAGA,SAAgB,s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AAA,QAAK,SAAS;EAC3F;EAEA,OAAO;GACL;GACA;GACA;GACA;GACA,SAAS,SAAS;GAClB;GACA;GACA;GACA;GACA;GACA;GACA,SAAS,UAAU,QAAQ,KAAK,SAAS;EAC3C;CACF,SAAS,OAAO;EAGd,MAAM,UAAU,YAAYF,2CAAAA,cAAc,oBAAoB,OAAO;GACnE,iBAAiB;GACjB,sBAAsB,QAAQ;GAC9B,GAAI,SAAS,OAAO,EAAE,mBAAmB,QAAQ,KAAK,IAAI,CAAC;EAC7D,CAAC;EACD,MAAM,UAAU,QAAQ;EACxB,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"harnessContext.cjs","names":["resolveProfile","createHarnessTelemetry","loadMajorModesConfig","resolveLayers","fs","materializePluginEntries","resolvePluginEntries","resolveMcpAllowlist","resolveSharedSkills","HARNESS_EVENT","collectResources","path","globalPoConfigDirectory","os","crypto","PO_USER_MCP_CONFIG_FILE","writeDefaultTheme","PO_MCP_SESSION_ENV_VAR","applyProfileEnvironment","DEFAULT_THEME_NAME","buildPersonaPrompt"],"sources":["../../../../src/builders/cli/harnessContext.ts"],"sourcesContent":["import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { resolvePluginEntries, resolveSharedSkills } from '@agimon-ai/po-config/domains';\nimport type { DomainMcpAllowlist, PluginEntry } from '@agimon-ai/po-config/domains';\nimport { loadMajorModesConfig, resolveLayers } from '@agimon-ai/po-config/majorModes';\nimport type { MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nimport { applyProfileEnvironment, buildPersonaPrompt, resolveProfile } from '@agimon-ai/po-config/profiles';\nimport type { AgentProfile } from '@agimon-ai/po-config/profiles';\nimport { PO_USER_MCP_CONFIG_FILE } from '@agimon-ai/po-core/mcpProjection';\nimport { PO_MCP_SESSION_ENV_VAR } from '@agimon-ai/po-core/mcpSession';\nimport {\n createHarnessTelemetry,\n HARNESS_EVENT,\n type HarnessTelemetry,\n} from '@agimon-ai/po-core/runtimeLogSinkTelemetry';\nimport { resolveMcpAllowlist } from '@agimon-ai/po-domain/mcp';\nimport { materializePluginEntries } from '@agimon-ai/po-domain/plugins';\nimport { collectResources, type HarnessResources } from '@agimon-ai/po-domain/resources';\nimport type { InitialProfileOutcome } from '@agimon-ai/po-profile';\nimport { DEFAULT_THEME_NAME, writeDefaultTheme } from '@agimon-ai/po-ui/theme';\n\nimport { createHarnessSession } from '../../composition/harnessState';\nimport type { HarnessOptions } from '../../composition/types/harness';\n\nconst PRIVATE_FILE_MODE = 0o600;\nconst RESOLVE_CONFIG_PHASE = 'resolve_config';\nconst COLLECT_RESOURCES_PHASE = 'collect_resources';\nconst BUILD_CONTEXT_PHASE = 'build_context';\n\n/**\n * Everything a command needs, resolved once.\n *\n * All three commands need the same expensive preparation (domains resolved,\n * plugins collected into a temp directory, environment assembled), so it is\n * built here and handed to whichever command runs.\n */\nexport interface HarnessContext {\n options: HarnessOptions;\n environment: NodeJS.ProcessEnv;\n resources: HarnessResources;\n plugins: PluginEntry[];\n profile?: string;\n /** Completed source-aware launch decision, passed into the session's Cordis scope. */\n initialProfileOutcome?: InitialProfileOutcome;\n personaDirectory?: string;\n /** Root personaDirectory resolves against, when a profile supplied one. */\n personaRoot?: string;\n mcpAllowlist?: DomainMcpAllowlist;\n majorModesConfig: MajorModesConfig;\n selectedLayers: string[];\n defaultThemePath: string;\n cleanup(): Promise<void>;\n}\n\n/**\n * Applies the provider environment a preset needs.\n *\n * Exported so a session server can apply the same rules before anything reads them.\n */\nexport function configurePreset(\n options: Pick<HarnessOptions, 'preset' | 'piArgs'>,\n environment: NodeJS.ProcessEnv,\n): void {\n if (options.preset === 'kimi') {\n if (!environment.KIMI_API_KEY && environment.KIMI_CODE_API_KEY) {\n environment.KIMI_API_KEY = environment.KIMI_CODE_API_KEY;\n }\n if (!environment.KIMI_API_KEY) {\n throw new Error('KIMI_API_KEY or KIMI_CODE_API_KEY is required for the kimi preset');\n }\n }\n}\n\n/** Resolves the optional persona and environment profile selected for this run. */\nexport function resolveHarnessProfile(options: HarnessOptions): AgentProfile | undefined {\n return options.profile ? resolveProfile(options.configRoot ?? options.repoRoot, options.profile) : undefined;\n}\n\n/**\n * Resolves the full matrix and stages every resource Pi will need.\n *\n * The caller owns the returned cleanup(): the temporary directory holding\n * skills, agents, and the generated MCP config has to outlive this function\n * and be removed once the selected command is done with it.\n */\nexport async function buildHarnessContext(\n options: HarnessOptions,\n telemetry: HarnessTelemetry = createHarnessTelemetry({ cwd: options.cwd, env: options.environment ?? process.env }),\n initialProfile?: { readonly outcome: InitialProfileOutcome; readonly definition?: AgentProfile },\n): Promise<HarnessContext> {\n // A worktree reads its workspace's configuration; resources still come from the checkout.\n const configRoot = options.configRoot ?? options.repoRoot;\n // Everything up to collectResources reads configuration off disk, so a single\n // malformed modes.yaml or profiles.yaml surfaces here as a failed launch\n // with no other record.\n const configured = await telemetry\n .runInSpan(`po_pi.${RESOLVE_CONFIG_PHASE}`, { 'harness.phase': RESOLVE_CONFIG_PHASE }, async () => {\n const majorModesConfig = loadMajorModesConfig(configRoot, options.homeDirectory, options.environment);\n const selectedLayers = resolveLayers(majorModesConfig, options.majorMode);\n const profile = initialProfile === undefined ? resolveHarnessProfile(options) : initialProfile.definition;\n if (\n !(\n await fs.stat(options.cwd).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n })\n )?.isDirectory()\n ) {\n throw new Error(`Working directory does not exist: ${options.cwd}`);\n }\n return {\n majorModesConfig,\n selectedLayers,\n profile,\n plugins: await materializePluginEntries(\n resolvePluginEntries(configRoot, options.domains, options.pluginDirectories),\n ),\n mcpAllowlist: resolveMcpAllowlist(configRoot, options.domains),\n sharedSkills: resolveSharedSkills(configRoot, options.domains),\n };\n })\n .catch(async (error: unknown) => {\n await telemetry.recordError(HARNESS_EVENT.configLoadFailed, error, {\n 'harness.phase': RESOLVE_CONFIG_PHASE,\n 'harness.major_mode': options.majorMode,\n 'harness.domain_count': options.domains.length,\n });\n throw error;\n });\n\n const { majorModesConfig, selectedLayers, profile, plugins, mcpAllowlist } = configured;\n const personaDirectory = profile?.persona;\n // A global profile's persona lives beside the global config, not in the repo.\n const personaRoot = profile?.personaRoot ?? configRoot;\n const resources = await telemetry\n .runInSpan(\n `po_pi.${COLLECT_RESOURCES_PHASE}`,\n { 'harness.plugin.count': plugins.length, 'harness.agents': options.agents, 'harness.mcp': options.mcp },\n () =>\n collectResources(options.repoRoot, plugins, {\n agents: options.agents,\n mcp: options.mcp,\n // Set by a caller that stages into a directory it owns.\n temporaryDirectory: options.resourceDirectory,\n // Per repository, under the global home, so it outlives this process's resources.\n skillCacheDirectory:\n options.resourceDirectory === undefined\n ? path.join(\n globalPoConfigDirectory(options.homeDirectory ?? os.homedir()),\n 'cache',\n 'skills',\n crypto.createHash('sha256').update(path.resolve(options.repoRoot)).digest('hex').slice(0, 32),\n )\n : path.join(options.resourceDirectory, 'cache', 'skills'),\n mcpAllowlist,\n sharedSkills: configured.sharedSkills,\n pluginDataRoot: path.join(globalPoConfigDirectory(options.homeDirectory ?? os.homedir()), 'plugin-data'),\n userMcpConfigPath: path.join(\n globalPoConfigDirectory(options.homeDirectory ?? os.homedir()),\n PO_USER_MCP_CONFIG_FILE,\n ),\n }),\n )\n .catch(async (error: unknown) => {\n // Conflicting skills, agents, or MCP servers all fail here, and the plugin\n // that caused it is only identifiable from the message.\n await telemetry.recordError(HARNESS_EVENT.resourceCollectionFailed, error, {\n 'harness.phase': COLLECT_RESOURCES_PHASE,\n 'harness.plugin.count': plugins.length,\n });\n throw error;\n });\n\n try {\n const defaultThemePath = await writeDefaultTheme(resources.temporaryDirectory);\n const environment = { ...(options.environment ?? process.env) };\n // The file-backed projection published through Cordis is authoritative.\n // Never let a legacy parent-process projection leak into this Po session.\n delete environment[PO_MCP_SESSION_ENV_VAR];\n const profileEnvironment = applyProfileEnvironment(environment, profile?.env ?? {});\n\n configurePreset(options, environment);\n environment.NX_DAEMON ??= 'false';\n environment.PO_THEME ||= DEFAULT_THEME_NAME;\n environment.CLAUDE_PROJECT_DIR = options.repoRoot;\n environment.CODEX_REPO_ROOT = options.repoRoot;\n environment.ORIGINAL_REPO_PATH ||= options.repoRoot;\n environment.MCP_UI_VIEWER ??= '';\n\n const personaPrompt =\n profile?.personaPrompt ?? (personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : undefined);\n let personaFile: string | undefined;\n if (personaPrompt) {\n personaFile = path.join(resources.temporaryDirectory, 'persona.md');\n await fs.writeFile(personaFile, `${personaPrompt}\\n`, { mode: PRIVATE_FILE_MODE });\n }\n\n // One write, describing the child rather than this process. The state file\n // is the child's authority and the environment is what it projects for the\n // hooks and packages that can only read an environment.\n createHarnessSession(\n {\n root: options.repoRoot,\n majorMode: options.majorMode,\n temporaryDirectory: resources.temporaryDirectory,\n domains: options.domains,\n layers: selectedLayers,\n profile: profile?.name,\n profileIdentity: profile?.identity,\n profileVoice: profile?.voice,\n profileEnvironment,\n personaFile,\n skillDirectories: resources.skillDirectories,\n agentDirectories: resources.agentDirectories,\n additionalDirectories: options.additionalDirectories,\n childExtensions: [],\n pluginDirectories: options.pluginDirectories,\n agents: options.agents,\n mcp: options.mcp,\n mcpConfigPath: resources.mcpConfigPath,\n mcpProjection: resources.mcpProjection,\n allowProtectedWrites: options.allowProtectedWrites,\n },\n { directory: resources.temporaryDirectory, environment },\n );\n if (options.agents) {\n environment.PI_SUBAGENT_EXTRA_AGENT_DIRS = resources.agentDirectories.join(path.delimiter);\n environment.PI_SUBAGENT_EXTRA_SKILL_DIRS = resources.skillDirectories.join(path.delimiter);\n }\n\n return {\n options,\n environment,\n resources,\n plugins,\n profile: profile?.name,\n ...(initialProfile === undefined ? {} : { initialProfileOutcome: initialProfile.outcome }),\n personaDirectory,\n personaRoot,\n mcpAllowlist,\n majorModesConfig,\n selectedLayers,\n defaultThemePath,\n cleanup: resources.cleanup.bind(resources),\n };\n } catch (error) {\n // Preparation failed after the temp directory existed, so nothing will be\n // handed back to clean it up.\n await telemetry.recordError(HARNESS_EVENT.contextBuildFailed, error, {\n 'harness.phase': BUILD_CONTEXT_PHASE,\n 'harness.major_mode': options.majorMode,\n ...(profile?.name ? { 'harness.profile': profile.name } : {}),\n });\n await resources.cleanup();\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAChC,MAAM,sBAAsB;;;;;;AAgC5B,SAAgB,gBACd,SACA,aACM;CACN,IAAI,QAAQ,WAAW,QAAQ;EAC7B,IAAI,CAAC,YAAY,gBAAgB,YAAY,mBAC3C,YAAY,eAAe,YAAY;EAEzC,IAAI,CAAC,YAAY,cACf,MAAM,IAAI,MAAM,mEAAmE;CAEvF;AACF;;AAGA,SAAgB,sBAAsB,SAAmD;CACvF,OAAO,QAAQ,WAAA,GAAUA,8BAAAA,eAAAA,CAAe,QAAQ,cAAc,QAAQ,UAAU,QAAQ,OAAO,IAAI,KAAA;AACrG;;;;;;;;AASA,eAAsB,oBACpB,SACA,aAAA,GAA8BC,2CAAAA,uBAAAA,CAAuB;CAAE,KAAK,QAAQ;CAAK,KAAK,QAAQ,eAAe,QAAQ;AAAI,CAAC,GAClH,gBACyB;CAEzB,MAAM,aAAa,QAAQ,cAAc,QAAQ;CAIjD,MAAM,aAAa,MAAM,UACtB,UAAU,SAAS,wBAAwB,EAAE,iBAAiB,qBAAqB,GAAG,YAAY;EACjG,MAAM,oBAAA,GAAmBC,gCAAAA,qBAAAA,CAAqB,YAAY,QAAQ,eAAe,QAAQ,WAAW;EACpG,MAAM,kBAAA,GAAiBC,gCAAAA,cAAAA,CAAc,kBAAkB,QAAQ,SAAS;EACxE,MAAM,UAAU,mBAAmB,KAAA,IAAY,sBAAsB,OAAO,IAAI,eAAe;EAC/F,IACE,EACE,MAAMC,iBAAAA,QAAG,KAAK,QAAQ,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EAAE,MAAM,kBAAkB,CAAC;EACnF;EAKA,CAAA,GAAA,kCAAA,qBAAA,CACE;GACE,MAAM,QAAQ;GACd,WAAW,QAAQ;GACnB,oBAAoB,UAAU;GAC9B,SAAS,QAAQ;GACjB,QAAQ;GACR,SAAS,SAAS;GAClB,iBAAiB,SAAS;GAC1B,cAAc,SAAS;GACvB;GACA;GACA,kBAAkB,UAAU;GAC5B,kBAAkB,UAAU;GAC5B,uBAAuB,QAAQ;GAC/B,iBAAiB,CAAC;GAClB,mBAAmB,QAAQ;GAC3B,QAAQ,QAAQ;GAChB,KAAK,QAAQ;GACb,eAAe,UAAU;GACzB,eAAe,UAAU;GACzB,sBAAsB,QAAQ;EAChC,GACA;GAAE,WAAW,UAAU;GAAoB;EAAY,CACzD;EACA,IAAI,QAAQ,QAAQ;GAClB,YAAY,+BAA+B,UAAU,iBAAiB,KAAKO,UAAAA,QAAK,SAAS;GACzF,YAAY,+BAA+B,UAAU,iBAAiB,KAAKA,UAAAA,QAAK,SAAS;EAC3F;EAEA,OAAO;GACL;GACA;GACA;GACA;GACA,SAAS,SAAS;GAClB,GAAI,mBAAmB,KAAA,IAAY,CAAC,IAAI,EAAE,uBAAuB,eAAe,QAAQ;GACxF;GACA;GACA;GACA;GACA;GACA;GACA,SAAS,UAAU,QAAQ,KAAK,SAAS;EAC3C;CACF,SAAS,OAAO;EAGd,MAAM,UAAU,YAAYF,2CAAAA,cAAc,oBAAoB,OAAO;GACnE,iBAAiB;GACjB,sBAAsB,QAAQ;GAC9B,GAAI,SAAS,OAAO,EAAE,mBAAmB,QAAQ,KAAK,IAAI,CAAC;EAC7D,CAAC;EACD,MAAM,UAAU,QAAQ;EACxB,MAAM;CACR;AACF"}
@@ -4,6 +4,7 @@ import { MajorModesConfig } from "@agimon-ai/po-config/majorModes";
4
4
  import { AgentProfile } from "@agimon-ai/po-config/profiles";
5
5
  import { HarnessTelemetry } from "@agimon-ai/po-core/runtimeLogSinkTelemetry";
6
6
  import { HarnessResources } from "@agimon-ai/po-domain/resources";
7
+ import { InitialProfileOutcome } from "@agimon-ai/po-profile";
7
8
  //#region src/builders/cli/harnessContext.d.ts
8
9
  /**
9
10
  * Everything a command needs, resolved once.
@@ -18,6 +19,8 @@ export interface HarnessContext {
18
19
  resources: HarnessResources;
19
20
  plugins: PluginEntry[];
20
21
  profile?: string;
22
+ /** Completed source-aware launch decision, passed into the session's Cordis scope. */
23
+ initialProfileOutcome?: InitialProfileOutcome;
21
24
  personaDirectory?: string;
22
25
  /** Root personaDirectory resolves against, when a profile supplied one. */
23
26
  personaRoot?: string;
@@ -42,6 +45,9 @@ export declare function resolveHarnessProfile(options: HarnessOptions): AgentPro
42
45
  * skills, agents, and the generated MCP config has to outlive this function
43
46
  * and be removed once the selected command is done with it.
44
47
  */
45
- export declare function buildHarnessContext(options: HarnessOptions, telemetry?: HarnessTelemetry): Promise<HarnessContext>;
48
+ export declare function buildHarnessContext(options: HarnessOptions, telemetry?: HarnessTelemetry, initialProfile?: {
49
+ readonly outcome: InitialProfileOutcome;
50
+ readonly definition?: AgentProfile;
51
+ }): Promise<HarnessContext>;
46
52
  //#endregion
47
53
  //# sourceMappingURL=harnessContext.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"harnessContext.d.mts","names":[],"sources":["../../../../src/builders/cli/harnessContext.ts"],"mappings":";;;;;;;;;;;;;;iBAuCiB;EACf,SAAS;EACT,aAAa,OAAO;EACpB,WAAW;EACX,SAAS;EACT;EACA;;EAEA;EACA,eAAe;EACf,kBAAkB;EAClB;EACA;EACA,WAAW;;;;;;;wBAQG,gBACd,SAAS,KAAK,sCACd,aAAa,OAAO;;wBAaN,sBAAsB,SAAS,iBAAiB;;;;;;;;wBAW1C,oBACpB,SAAS,gBACT,YAAW,mBACV,QAAQ"}
1
+ {"version":3,"file":"harnessContext.d.mts","names":[],"sources":["../../../../src/builders/cli/harnessContext.ts"],"mappings":";;;;;;;;;;;;;;;iBAwCiB;EACf,SAAS;EACT,aAAa,OAAO;EACpB,WAAW;EACX,SAAS;EACT;;EAEA,wBAAwB;EACxB;;EAEA;EACA,eAAe;EACf,kBAAkB;EAClB;EACA;EACA,WAAW;;;;;;;wBAQG,gBACd,SAAS,KAAK,sCACd,aAAa,OAAO;;wBAaN,sBAAsB,SAAS,iBAAiB;;;;;;;;wBAW1C,oBACpB,SAAS,gBACT,YAAW,kBACX;WAA4B,SAAS;WAAgC,aAAa;IACjF,QAAQ"}
@@ -44,12 +44,12 @@ function resolveHarnessProfile(options) {
44
44
  async function buildHarnessContext(options, telemetry = createHarnessTelemetry({
45
45
  cwd: options.cwd,
46
46
  env: options.environment ?? process.env
47
- })) {
47
+ }), initialProfile) {
48
48
  const configRoot = options.configRoot ?? options.repoRoot;
49
49
  const configured = await telemetry.runInSpan(`po_pi.${RESOLVE_CONFIG_PHASE}`, { "harness.phase": RESOLVE_CONFIG_PHASE }, async () => {
50
50
  const majorModesConfig = loadMajorModesConfig(configRoot, options.homeDirectory, options.environment);
51
51
  const selectedLayers = resolveLayers(majorModesConfig, options.majorMode);
52
- const profile = resolveHarnessProfile(options);
52
+ const profile = initialProfile === void 0 ? resolveHarnessProfile(options) : initialProfile.definition;
53
53
  if (!(await fs.stat(options.cwd).catch((error) => {
54
54
  if (error.code === "ENOENT") return void 0;
55
55
  throw error;
@@ -105,7 +105,7 @@ async function buildHarnessContext(options, telemetry = createHarnessTelemetry({
105
105
  environment.CODEX_REPO_ROOT = options.repoRoot;
106
106
  environment.ORIGINAL_REPO_PATH ||= options.repoRoot;
107
107
  environment.MCP_UI_VIEWER ??= "";
108
- const personaPrompt = personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : void 0;
108
+ const personaPrompt = profile?.personaPrompt ?? (personaDirectory ? buildPersonaPrompt(personaRoot, personaDirectory) : void 0);
109
109
  let personaFile;
110
110
  if (personaPrompt) {
111
111
  personaFile = path.join(resources.temporaryDirectory, "persona.md");
@@ -146,6 +146,7 @@ async function buildHarnessContext(options, telemetry = createHarnessTelemetry({
146
146
  resources,
147
147
  plugins,
148
148
  profile: profile?.name,
149
+ ...initialProfile === void 0 ? {} : { initialProfileOutcome: initialProfile.outcome },
149
150
  personaDirectory,
150
151
  personaRoot,
151
152
  mcpAllowlist,