@event4u/agent-config 9.28.0 → 9.29.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/AGENTS.md +6 -6
- package/CHANGELOG.md +66 -0
- package/README.md +1 -1
- package/agents/templates/.ai-council.yml.example +55 -24
- package/dist/agent-src/commands/cost/report.md +2 -2
- package/dist/agent-src/commands/team/adversarial.md +8 -7
- package/dist/agent-src/commands/team/delegate.md +13 -12
- package/dist/agent-src/commands/team/review.md +9 -8
- package/dist/agent-src/commands/team/status.md +9 -8
- package/dist/agent-src/commands/team.md +29 -19
- package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +88 -2
- package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +29 -21
- package/dist/agent-src/contexts/execution/host-capability-manifest.md +26 -15
- package/dist/agent-src/contexts/execution/orchestration-telemetry.md +18 -0
- package/dist/agent-src/contexts/execution/subagent-response-contract.md +54 -0
- package/dist/agent-src/contexts/execution/subagent-routing.md +13 -11
- package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +25 -0
- package/dist/agent-src/contexts/execution/subagent-steering.md +6 -3
- package/dist/agent-src/rules/delegation-policy.md +11 -7
- package/dist/agent-src/rules/settings-ask-protocol.md +8 -7
- package/dist/agent-src/rules/token-budget-discipline.md +1 -1
- package/dist/agent-src/skills/forensics-report/SKILL.md +114 -0
- package/dist/agent-src/skills/forensics-report/evals/triggers.json +17 -0
- package/dist/agent-src/skills/premortem/SKILL.md +30 -1
- package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +2 -1
- package/dist/agent-src/skills/subagent-orchestration/SKILL.md +7 -5
- package/dist/agent-src/skills/subagent-orchestration/schemas/subagent-status.json +61 -3
- package/dist/agent-src/skills/test-case-discovery/SKILL.md +1 -1
- package/dist/agent-src/templates/AGENTS.md +4 -4
- package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/dist/agent-src/templates/roadmaps.md +23 -0
- package/dist/cli-delegate/{chunk-22GCIJ2O.js → chunk-66OVWGB5.js} +1 -1
- package/dist/cli-delegate/{chunk-GB2FSUEE.js → chunk-LCFJIQ4J.js} +32 -0
- package/dist/cli-delegate/{chunk-VSYT7OHO.js → chunk-LVRYBKTI.js} +31 -2
- package/dist/cli-delegate/{chunk-DVRS2KVR.js → chunk-MMXA5GY7.js} +10 -17
- package/dist/cli-delegate/{chunk-JXARCGVN.js → chunk-MP3JT3IU.js} +1 -1
- package/dist/cli-delegate/{chunk-PQSAQKHW.js → chunk-NZ5N2XQL.js} +3 -3
- package/dist/cli-delegate/{chunk-7OMQCH4V.js → chunk-OJM3MBJM.js} +1 -1
- package/dist/cli-delegate/{chunk-2BE5I2MN.js → chunk-RCIA67XN.js} +111 -90
- package/dist/cli-delegate/cmd_analyze_session.js +1 -1
- package/dist/cli-delegate/cmd_brand_status.js +1 -1
- package/dist/cli-delegate/cmd_conformance.js +6 -43
- package/dist/cli-delegate/cmd_doctor.js +9 -5
- package/dist/cli-delegate/cmd_explain.js +2 -2
- package/dist/cli-delegate/cmd_export.js +4 -4
- package/dist/cli-delegate/cmd_handoff.js +3 -3
- package/dist/cli-delegate/cmd_mcp_available.js +1 -1
- package/dist/cli-delegate/cmd_migrate.js +2 -2
- package/dist/cli-delegate/cmd_packs_active.js +2 -2
- package/dist/cli-delegate/cmd_prune.js +4 -4
- package/dist/cli-delegate/cmd_route_audit.js +2 -2
- package/dist/cli-delegate/cmd_route_explain.js +1 -1
- package/dist/cli-delegate/cmd_settings_get.js +1 -7
- package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
- package/dist/cli-delegate/cmd_settings_set.js +1 -1
- package/dist/cli-delegate/cmd_sync.js +4 -4
- package/dist/cli-delegate/cmd_uninstall.js +4 -4
- package/dist/cli-delegate/cmd_update.js +1 -1
- package/dist/cli-delegate/cmd_upgrade.js +1 -1
- package/dist/cli-delegate/cmd_validate.js +4 -4
- package/dist/cli-delegate/cmd_versions.js +1 -1
- package/dist/discovery/deprecation-report.md +1 -1
- package/dist/discovery/discovery-manifest.json +69 -20
- package/dist/discovery/discovery-manifest.json.sha256 +1 -1
- package/dist/discovery/discovery-manifest.summary.md +3 -2
- package/dist/discovery/orphan-report.md +1 -1
- package/dist/discovery/packs.json +39 -2
- package/dist/discovery/trust-report.md +2 -2
- package/dist/discovery/workspaces.json +12 -4
- package/dist/hooks/dispatch.js +373 -35
- package/dist/install/install.mjs +42 -17
- package/dist/mcp/registry-manifest.json +2 -2
- package/dist/mcp/server.json +2 -2
- package/dist/mcp/server.mjs +651 -262
- package/dist/router.json +1 -1
- package/dist/scripts/_lib/agent_settings.js +54 -0
- package/dist/scripts/_lib/agent_settings.js.map +1 -1
- package/dist/scripts/condense.js +147 -2
- package/dist/scripts/condense.js.map +1 -1
- package/dist/server/schemas/settings.js +6 -7
- package/dist/server/schemas/settings.js.map +1 -1
- package/dist/shared/settingsCarveOut.js +0 -9
- package/dist/shared/settingsCarveOut.js.map +1 -1
- package/dist/shared/settingsClasses.js +11 -9
- package/dist/shared/settingsClasses.js.map +1 -1
- package/dist/ui/assets/{index-DmR0mbk4.js → index-JDAF00bC.js} +2 -2
- package/dist/ui/assets/{index-DmR0mbk4.js.map → index-JDAF00bC.js.map} +1 -1
- package/dist/ui/index.html +1 -1
- package/docs/contracts/settings-classes.md +39 -9
- package/package.json +1 -1
- package/src/agent-src/templates/AGENTS.md +4 -4
- package/src/config/agent-settings.template.yml +52 -66
- package/src/config/discovery/packs.yml +11 -0
- package/src/config/discovery/workspaces.yml +1 -1
- package/src/config/gate-violation-baselines.json +3 -3
- package/src/scripts/_cli/cmd_conformance.ts +14 -42
- package/src/scripts/_cli/cmd_doctor.ts +65 -48
- package/src/scripts/_lib/agent_settings.ts +58 -0
- package/src/scripts/_lib/auto_dispatch.corpus.test.ts +1 -1
- package/src/scripts/_lib/auto_dispatch.ts +23 -18
- package/src/scripts/_lib/capsule_trigger.ts +124 -0
- package/src/scripts/_lib/host_capability.ts +63 -6
- package/src/scripts/_lib/judgment_ladder.ts +382 -0
- package/src/scripts/_lib/orchestration_gate.ts +8 -0
- package/src/scripts/_lib/orchestration_record.ts +37 -0
- package/src/scripts/_lib/orchestration_savings.ts +1 -1
- package/src/scripts/_lib/self_repair.ts +160 -13
- package/src/scripts/_lib/self_repair_store.ts +28 -0
- package/src/scripts/_lib/subagent_capsule.ts +182 -0
- package/src/scripts/_lib/subagent_response.ts +19 -0
- package/src/scripts/_lib/subagent_spawn.ts +13 -0
- package/src/scripts/_lib/subagent_steering.ts +9 -4
- package/src/scripts/_lib/tier_budget_routing.ts +6 -1
- package/src/scripts/_lib/worker_budget.ts +37 -2
- package/src/scripts/ai_council/clients.ts +76 -54
- package/src/scripts/ai_council/config.ts +94 -6
- package/src/scripts/ai_council/handoff.ts +113 -0
- package/src/scripts/ai_council/modes.ts +19 -4
- package/src/scripts/ai_council/orchestrator.ts +105 -0
- package/src/scripts/ai_council/quorum.ts +84 -0
- package/src/scripts/ai_council/session.ts +44 -0
- package/src/scripts/ai_council/transport_resolver.ts +127 -1
- package/src/scripts/ai_team/availability.ts +110 -0
- package/src/scripts/ai_team/config.ts +34 -14
- package/src/scripts/ai_team/team_dispatch.ts +71 -29
- package/src/scripts/bench_critic_protocol.ts +396 -0
- package/src/scripts/check_detector_corpus.ts +202 -0
- package/src/scripts/check_hook_bundle_freshness.ts +4 -1
- package/src/scripts/condense.ts +162 -2
- package/src/scripts/council_cli.ts +401 -25
- package/src/scripts/forensics_report.ts +333 -0
- package/src/scripts/hooks/delegation_nudge_hook.ts +69 -35
- package/src/scripts/lint_discovery_vocabulary.ts +2 -0
- package/src/scripts/lint_never_silent.ts +276 -0
- package/src/scripts/lint_no_activation_gates.ts +271 -0
- package/src/scripts/orchestration_record.ts +8 -0
- package/src/scripts/rebuild_hook_bundle.ts +177 -0
- package/src/scripts/release.ts +74 -2
- package/src/scripts/routing_doctor.ts +21 -36
- package/src/scripts/score_skill_selection.ts +19 -5
- package/src/scripts/self_repair_cli.ts +287 -57
- package/src/scripts/team_events_spike.ts +271 -0
- package/src/scripts/team_review_gate_hook.ts +31 -9
- package/src/server/schemas/settings.ts +10 -17
- package/src/shared/settingsCarveOut.ts +0 -10
- package/src/shared/settingsClasses.ts +11 -9
|
@@ -22,5 +22,5 @@ ${e.mark.snippet}`),`${e.reason} ${t}`):e.reason}var Kn=class extends Error{reas
|
|
|
22
22
|
`.repeat(g):c+=`
|
|
23
23
|
`.repeat(d?1+g:g),c+=_,d=!0,g=0}return r===3?c+=`
|
|
24
24
|
`.repeat(d?1+g:g):r!==2&&d&&(c+=`
|
|
25
|
-
`),c}function us(e,n){if(n.valueStart===is)return"";const{valueStart:t,valueEnd:i}=n;if(n.fast)return e.slice(t,i);switch(n.style){case 2:return ss(e,t,i);case 3:return cs(e,t,i);case 4:return ba(e,t,i,n.indent,n.chomping,!1);case 5:return ba(e,t,i,n.indent,n.chomping,!0);default:return os(e,t,i)}}var ds={"!":"!","!!":"tag:yaml.org,2002:"};function Sr(e,n){if(e.startsWith("!<")&&e.endsWith(">"))return decodeURIComponent(e.slice(2,-1));const t=e.indexOf("!",1),i=t===-1?"!":e.slice(0,t+1),r=n?.[i]??ds[i]??i;return decodeURIComponent(r)+decodeURIComponent(e.slice(i.length))}var Pe=-1,Li={filename:"",schema:Qo,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};function fs(e){return"tagStart"in e&&e.tagStart!==Pe?e.tagStart:"anchorStart"in e&&e.anchorStart!==Pe?e.anchorStart:"valueStart"in e&&e.valueStart!==Pe?e.valueStart:"start"in e?e.start:0}function U(e,n){wt(e.source,e.position,n,e.filename)}function Cr(e,n,t,i){try{return t.finalize(i)}catch(r){if(r instanceof Kn)throw r;wt(e.source,n,r instanceof Error?r.message:String(r),e.filename)}}function In(e,n,t){const i=e[t];if(i)return i;for(const r of n)if(t.startsWith(r.tagName))return r}function hs(e,n,t,i,r){const l=In(n,t,i);if(l)return l;U(e,`unknown ${r} tag !<${i}>`)}function ps(e,n){const t=us(e.source,n),i=n.tagStart===Pe?"":e.source.slice(n.tagStart,n.tagEnd),r=e.schema.defaultScalarTag;if(i!==""){if(i==="!")return{value:t,tag:r};const l=Sr(i,e.tagHandlers),o=In(e.schema.exact.scalar,e.schema.prefix.scalar,l);if(o){const u=o.resolve(t,!0,l);return u===S&&U(e,`cannot resolve a node with !<${l}> explicit tag`),{value:u,tag:o}}const s=In(e.schema.exact.mapping,e.schema.prefix.mapping,l)??In(e.schema.exact.sequence,e.schema.prefix.sequence,l);if(s){t!==""&&U(e,`cannot resolve a node with !<${l}> explicit tag`);const u=s.create(l);return{value:s.carrierIsResult?u:Cr(e,e.position,s,u),tag:s}}U(e,`unknown scalar tag !<${l}>`)}if(n.style===1){const l=e.schema.implicitScalarByFirstChar.get(t.charAt(0))??e.schema.implicitScalarAnyFirstChar;for(const o of l){const s=o.resolve(t,!1,o.tagName);if(s!==S)return{value:s,tag:o}}}return{value:r.resolve(t,!1,r.tagName),tag:r}}function ka(e,n,t,i,r,l){const o=n.tagStart===Pe?"":e.source.slice(n.tagStart,n.tagEnd),s=o===""||o==="!"?r:Sr(o,e.tagHandlers);return{tagName:s,tag:hs(e,t,i,s,l)}}function Tr(e){return e.nodeKind==="mapping"}function wa(e,n,t,i){for(const r of i.keys(t)){if(e.maxTotalMergeKeys!==-1&&++e.totalMergeKeys>e.maxTotalMergeKeys&&U(e,`merge keys exceeded maxTotalMergeKeys (${e.maxTotalMergeKeys})`),n.tag.has(n.value,r))continue;const l=n.tag.addPair(n.value,r,i.get(t,r));l&&U(e,l),(n.overridable??=new Set).add(r)}}function vs(e,n,t,i){if(e.position=n.keyPosition,Tr(i))wa(e,n,t,i);else if(i.nodeKind==="sequence"&&Array.isArray(t))for(const r of t)wa(e,n,r,n.tag);else U(e,"cannot merge mappings; the provided source object is unacceptable")}function gs(e,n,t,i,r){if(e.position=n.keyPosition,t===Ii){vs(e,n,i,r);return}!e.json&&n.tag.has(n.value,t)&&!n.overridable?.has(t)&&U(e,"duplicated mapping key");const l=n.tag.addPair(n.value,t,i);l&&U(e,l),n.overridable?.delete(t)}function Dt(e,n,t){const i=e.frames[e.frames.length-1];if(i.kind==="document")i.value=n,i.hasValue=!0;else if(i.kind==="sequence"){i.merge&&(Tr(t)||U(e,"cannot merge mappings; the provided source object is unacceptable"));const r=i.tag.addItem(i.value,n,i.index++);r&&U(e,r)}else if(i.hasKey){const r=i.key;i.key=void 0,i.hasKey=!1,gs(e,i,r,n,t)}else i.key=n,i.keyPosition=e.position,i.hasKey=!0}function Ut(e,n,t,i,r){if(n.anchorStart!==Pe){const l={value:t,tag:i,isValueFinal:r};return e.anchors.set(e.source.slice(n.anchorStart,n.anchorEnd),l),l}return null}function _s(e,n){const t={...Li,...n,events:e,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,tagHandlers:Object.create(null),totalMergeKeys:0,aliasCount:0};for(;t.eventIndex<t.events.length;){const i=t.events[t.eventIndex++];switch(t.position=fs(i),i.type){case 1:t.anchors=new Map,t.aliasCount=0,t.tagHandlers=Object.create(null);for(const r of i.directives)r.kind==="tag"&&(t.tagHandlers[r.handle]=r.prefix);t.frames.push({kind:"document",position:t.position,value:void 0,hasValue:!1});break;case 4:{const{value:r,tag:l}=ps(t,i);Ut(t,i,r,l,!0),Dt(t,r,l);break}case 2:{const r=ka(t,i,t.schema.exact.sequence,t.schema.prefix.sequence,"tag:yaml.org,2002:seq","sequence"),l=r.tag.create(r.tagName),o=Ut(t,i,l,r.tag,r.tag.carrierIsResult),s=t.frames[t.frames.length-1],u=s!==void 0&&s.kind==="mapping"&&s.hasKey&&s.key===Ii;t.frames.push({kind:"sequence",position:t.position,value:l,tag:r.tag,anchor:o,index:0,merge:u});break}case 3:{const r=ka(t,i,t.schema.exact.mapping,t.schema.prefix.mapping,"tag:yaml.org,2002:map","mapping"),l=r.tag.create(r.tagName),o=Ut(t,i,l,r.tag,r.tag.carrierIsResult);t.frames.push({kind:"mapping",position:t.position,value:l,tag:r.tag,anchor:o,key:void 0,keyPosition:t.position,hasKey:!1,overridable:null});break}case 5:{t.maxAliases!==-1&&++t.aliasCount>t.maxAliases&&U(t,`aliases exceeded maxAliases (${t.maxAliases})`);const r=t.source.slice(i.anchorStart,i.anchorEnd),l=t.anchors.get(r);l||U(t,`unidentified alias "${r}"`),l.isValueFinal||U(t,`recursive alias "${r}" is not supported for tag ${l.tag.tagName} because it uses finalize()`),Dt(t,l.value,l.tag);break}case 6:{const r=t.frames.pop();if(r.kind==="document")t.documents.push(r.value);else{const l=r.tag.carrierIsResult?r.value:Cr(t,r.position,r.tag,r.value);r.anchor&&(r.anchor.value=l,r.anchor.isValueFinal=!0),Dt(t,l,r.tag)}break}}}return t.documents}var C=-1,Ar=Object.prototype.hasOwnProperty,Be=1,Zt=2,xr=3,Gn=4,ms=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,ys=/[,\[\]{}]/,Nr=/^(?:!|!!|![0-9A-Za-z-]+!)$/,Qt=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,Er=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,bs=new RegExp(`^(?:${Qt})*$`),ks=new RegExp(`^(?:${Er})+$`),ws=new RegExp(`^(?:!(?:${Qt})*|${Er}(?:${Qt})*)$`),Ri={filename:"",maxDepth:100};function Ss(e,n,t){e.events.push({type:1,explicitStart:n,explicitEnd:t,directives:e.directives})}function Ir(e,n,t,i,r,l,o){e.events.push({type:2,start:n,anchorStart:t,anchorEnd:i,tagStart:r,tagEnd:l,style:o})}function ei(e,n,t,i,r,l,o){e.events.push({type:3,start:n,anchorStart:t,anchorEnd:i,tagStart:r,tagEnd:l,style:o})}function Sa(e,n){e.events.splice(n.eventsLength,0,{type:3,start:n.position,anchorStart:C,anchorEnd:C,tagStart:C,tagEnd:C,style:2})}function qe(e,n,t,i,r,l,o,s,u=1,c=-1,d=!1){e.events.push({type:4,valueStart:n,valueEnd:t,anchorStart:i,anchorEnd:r,tagStart:l,tagEnd:o,style:s,chomping:u,indent:c,fast:d})}function Cs(e,n,t){e.events.push({type:5,anchorStart:n,anchorEnd:t})}function Le(e){e.events.push({type:6})}function M(e){qe(e,C,C,C,C,C,C,1)}function Ca(){return{anchorStart:C,anchorEnd:C,tagStart:C,tagEnd:C}}function en(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,eventsLength:e.events.length}}function Re(e,n){e.position=n.position,e.line=n.line,e.lineStart=n.lineStart,e.lineIndent=n.lineIndent,e.firstTabInLine=n.firstTabInLine,e.events.length=n.eventsLength}function m(e,n){wt(e.input.slice(0,e.length),e.position,n,e.filename)}function O(e){return e===10||e===13}function _e(e){return e===9||e===32}function H(e){return _e(e)||O(e)}function G(e){return e===0||H(e)}function me(e){return e===44||e===91||e===93||e===123||e===125}function Ts(e){return e>=48&&e<=57?e-48:-1}function As(e){if(e>=48&&e<=57)return e-48;const n=e|32;return n>=97&&n<=102?n-97+10:-1}function xs(e){return e===120?2:e===117?4:e===85?8:0}function Ns(e){return e===48||e===97||e===98||e===116||e===9||e===110||e===118||e===102||e===114||e===101||e===32||e===34||e===47||e===92||e===78||e===95||e===76||e===80}function Jn(e){e.input.charCodeAt(e.position)===10?e.position++:(e.position++,e.input.charCodeAt(e.position)===10&&e.position++),e.line++,e.lineStart=e.position,e.lineIndent=0,e.firstTabInLine=-1}function j(e,n){let t=0,i=e.input.charCodeAt(e.position),r=e.position===e.lineStart||H(e.input.charCodeAt(e.position-1));for(;i!==0;){for(;_e(i);)r=!0,i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(n&&r&&i===35)do i=e.input.charCodeAt(++e.position);while(!O(i)&&i!==0);if(!O(i))break;for(Jn(e),t++,r=!0,i=e.input.charCodeAt(e.position);i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return t}function le(e,n=e.position){const t=e.input.charCodeAt(n);if((t===45||t===46)&&t===e.input.charCodeAt(n+1)&&t===e.input.charCodeAt(n+2)){const i=e.input.charCodeAt(n+3);return i===0||H(i)}return!1}function Ta(e){let n=e.input.charCodeAt(e.position);for(;n!==0&&!O(n);)n=e.input.charCodeAt(++e.position)}function $r(e,n,t){ms.test(e.input.slice(n,t))&&m(e,"the stream contains non-printable characters")}function Es(e,n,t){if(e.input.charCodeAt(e.position)!==33)return!1;n.tagStart!==C&&m(e,"duplication of a tag property");const i=e.position;let r=!1,l=!1,o="!",s=e.input.charCodeAt(++e.position);s===60?(r=!0,s=e.input.charCodeAt(++e.position)):s===33&&(l=!0,o="!!",s=e.input.charCodeAt(++e.position));let u=e.position,c;if(r){for(;s!==0&&s!==62;)s=e.input.charCodeAt(++e.position);s!==62&&m(e,"unexpected end of the stream within a verbatim tag"),c=e.input.slice(u,e.position),e.position++}else{for(;s!==0&&!H(s)&&!(t&&me(s));)s===33&&(l?m(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(u-1,e.position+1),Nr.test(o)||m(e,"named tag handle cannot contain such characters"),l=!0,u=e.position+1)),s=e.input.charCodeAt(++e.position);c=e.input.slice(u,e.position),ys.test(c)&&m(e,"tag suffix cannot contain flow indicator characters")}return c&&!(r?bs.test(c):ks.test(c))&&m(e,`tag name cannot contain such characters: ${c}`),!r&&o!=="!"&&o!=="!!"&&!Ar.call(e.tagHandlers,o)&&m(e,`undeclared tag handle "${o}"`),n.tagStart=i,n.tagEnd=e.position,!0}function Is(e,n){if(e.input.charCodeAt(e.position)!==38)return!1;n.anchorStart!==C&&m(e,"duplication of an anchor property"),e.position++;const t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position))&&!me(e.input.charCodeAt(e.position));)e.position++;return e.position===t&&m(e,"name of an anchor node must contain at least one character"),n.anchorStart=t,n.anchorEnd=e.position,!0}function $s(e,n){if(e.input.charCodeAt(e.position)!==42)return!1;(n.anchorStart!==C||n.tagStart!==C)&&m(e,"alias node should not have any properties"),e.position++;const t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position))&&!me(e.input.charCodeAt(e.position));)e.position++;return e.position===t&&m(e,"name of an alias node must contain at least one character"),Cs(e,t,e.position),!0}function ni(e,n){j(e,!1),e.lineIndent<n&&m(e,"deficient indentation")}function Os(e,n,t){if(e.input.charCodeAt(e.position)!==39)return!1;e.position++;const i=e.position;let r=!0;for(;e.input.charCodeAt(e.position)!==0;){const l=e.input.charCodeAt(e.position);if(l===39){if(e.input.charCodeAt(e.position+1)===39){r=!1,e.position+=2;continue}const o=e.position;return e.position++,qe(e,i,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2,1,-1,r),!0}O(l)?(r=!1,ni(e,n)):e.position===e.lineStart&&le(e)?m(e,"unexpected end of the document within a single quoted scalar"):l!==9&&l<32?m(e,"expected valid JSON character"):e.position++}m(e,"unexpected end of the stream within a single quoted scalar")}function Ps(e,n,t){if(e.input.charCodeAt(e.position)!==34)return!1;e.position++;const i=e.position;let r=!0;for(;e.input.charCodeAt(e.position)!==0;){const l=e.input.charCodeAt(e.position);if(l===34){const o=e.position;return e.position++,qe(e,i,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,3,1,-1,r),!0}if(l===92){r=!1;const o=e.input.charCodeAt(++e.position);if(O(o))ni(e,n);else if(Ns(o))e.position++;else{let s=xs(o);for(s===0&&m(e,"unknown escape sequence");s-- >0;)e.position++,As(e.input.charCodeAt(e.position))<0&&m(e,"expected hexadecimal character");e.position++}}else O(l)?(r=!1,ni(e,n)):e.position===e.lineStart&&le(e)?m(e,"unexpected end of the document within a double quoted scalar"):l!==9&&l<32?m(e,"expected valid JSON character"):e.position++}m(e,"unexpected end of the stream within a double quoted scalar")}function Ls(e,n,t){const i=e.input.charCodeAt(e.position);let r=1,l=-1,o=!1;if(i!==124&&i!==62)return!1;const s=i===124?4:5;for(e.position++;e.input.charCodeAt(e.position)!==0;){const p=e.input.charCodeAt(e.position),v=Ts(p);if(p===43||p===45)r!==1&&m(e,"repeat of a chomping mode identifier"),r=p===43?3:2,e.position++;else if(v>=0)v===0&&m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"),o&&m(e,"repeat of an indentation width identifier"),l=n+v-1,o=!0,e.position++;else break}let u=!1;for(;_e(e.input.charCodeAt(e.position));)u=!0,e.position++;u&&e.input.charCodeAt(e.position)===35&&Ta(e),O(e.input.charCodeAt(e.position))?Jn(e):e.input.charCodeAt(e.position)!==0&&m(e,"a line break is expected");let c=o?l:-1,d=0;const g=e.position;let f=e.position;for(;e.input.charCodeAt(e.position)!==0;){const p=e.position;let v=0;for(;e.input.charCodeAt(p+v)===32;)v++;const _=e.input.charCodeAt(p+v);if(_===0){c>=0?v>c&&(f=p+v):v>0&&(f=p+v);break}if(p===e.lineStart&&le(e,p))break;if(!o&&c===-1&&O(_)&&(d=Math.max(d,v)),!o&&c===-1&&!O(_)&&(_===9&&v<n&&(e.position=p+v,m(e,"tab characters must not be used in indentation")),v<d&&(e.position=p+v,m(e,"bad indentation of a mapping entry"))),c===-1&&_!==0&&!O(_)&&v<n){e.lineIndent=v,e.position=p+v;break}!o&&_!==0&&!O(_)&&c===-1&&(c=v);const k=c===-1?n+1:c;if(_!==0&&!O(_)&&v<k){e.lineIndent=v,e.position=p+v;break}Ta(e),f=e.position,O(e.input.charCodeAt(e.position))&&(Jn(e),f=e.position)}return $r(e,g,f),qe(e,g,f,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,s,r,c),!0}function Rs(e,n){const t=e.input.charCodeAt(e.position),i=n===Be;if(t===0||H(t)||t===35||t===38||t===42||t===33||t===124||t===62||t===39||t===34||t===37||t===64||t===96||i&&me(t))return!1;if(t===63||t===45){const r=e.input.charCodeAt(e.position+1);if(G(r)||i&&me(r))return!1}return!0}function Fs(e,n,t,i){if(!Rs(e,t))return!1;const r=e.position;let l=e.position,o=e.input.charCodeAt(e.position);const s=t===Be;let u=!1;for(;o!==0&&!(e.position===e.lineStart&&le(e));){if(o===58){const c=e.input.charCodeAt(e.position+1);if(G(c)||s&&me(c))break}else if(o===35){if(H(e.input.charCodeAt(e.position-1)))break}else{if(s&&me(o))break;if(O(o)){const c=e.position,d=e.line,g=e.lineStart,f=e.lineIndent;if(j(e,!1),e.lineIndent>=n){u=!0,o=e.input.charCodeAt(e.position);continue}e.position=c,e.line=d,e.lineStart=g,e.lineIndent=f;break}}_e(o)||(l=e.position+1),o=e.input.charCodeAt(++e.position)}return l===r?!1:($r(e,r,l),qe(e,r,l,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1,1,-1,!u),!0)}function Ge(e,n){const t=e.line;j(e,!0),(e.line>t&&e.lineIndent<n||e.firstTabInLine!==-1&&e.lineIndent<n)&&m(e,"deficient indentation")}function Ms(e,n,t){const i=e.input.charCodeAt(e.position),r=i===123,l=e.position;let o=!0;if(i!==91&&i!==123)return!1;const s=r?125:93;for(r?ei(e,l,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2):Ir(e,l,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2),e.position++;e.input.charCodeAt(e.position)!==0;){Ge(e,n);let u=e.input.charCodeAt(e.position);if(u===s)return e.position++,Le(e),!0;o?u===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries");let c=!1,d=!1;u===63&&H(e.input.charCodeAt(e.position+1))&&(c=d=!0,e.position+=1,Ge(e,n));const g=e.line,f=en(e),p=ce(e,n,Be,!1,!0);Ge(e,n),u=e.input.charCodeAt(e.position),(r||d||e.line===g)&&u===58?(c=!0,e.position++,Ge(e,n),r||Sa(e,f),p||M(e),ce(e,n,Be,!1,!0)||M(e),Ge(e,n),r||Le(e)):r&&c?(p||M(e),M(e)):r?M(e):c&&(Sa(e,f),p||M(e),M(e),Le(e)),u=e.input.charCodeAt(e.position),u===44?(o=!0,e.position++):o=!1}m(e,"unexpected end of the stream within a flow collection")}function Aa(e,n,t){if(e.firstTabInLine!==-1||e.input.charCodeAt(e.position)!==45||!G(e.input.charCodeAt(e.position+1)))return!1;for(Ir(e,e.position,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,1);e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1));){e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation"));const i=e.line;e.position++;const r=j(e,!0)>0;if(e.firstTabInLine!==-1&&e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1))&&m(e,"bad indentation of a sequence entry"),r&&e.lineIndent<=n?M(e):ce(e,n,xr,!1,!0),j(e,!0),e.lineIndent<n||e.position>=e.length)break;e.lineIndent>n&&m(e,"bad indentation of a sequence entry"),e.line===i&&e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1))&&m(e,"bad indentation of a sequence entry")}return Le(e),!0}function Bt(e,n,t,i){let r=!1,l=!1,o=!1,s=!1;if(e.firstTabInLine!==-1)return!1;let u=e.input.charCodeAt(e.position);for(;u!==0;){!r&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation"));const c=e.input.charCodeAt(e.position+1),d=e.line;if((u===63||u===58)&&G(c))o||(ei(e,e.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1),o=!0),u===63?(r&&M(e),l=!0,r=!0):(r||(M(e),l=!0),r=!1),e.position+=1,s=!0;else{r&&(M(e),r=!1);const g=en(e);if(!ce(e,t,Zt,!1,!0))break;if(e.line===d){for(u=e.input.charCodeAt(e.position);_e(u);)u=e.input.charCodeAt(++e.position);if(u===58){if(u=e.input.charCodeAt(++e.position),G(u)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),!o){for(Re(e,g),ei(e,g.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1),o=!0,ce(e,t,Zt,!1,!0),u=e.input.charCodeAt(e.position);_e(u);)u=e.input.charCodeAt(++e.position);e.position++}l=!0,r=!1,s=!1}else if(l)m(e,"expected ':' after a mapping key");else return i.anchorStart!==C||i.tagStart!==C?(Re(e,g),!1):!0}else if(l)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return i.anchorStart!==C||i.tagStart!==C?(Re(e,g),!1):!0}if(ce(e,n,Gn,!0,s)&&(s=!1),r||s&&(M(e),s=!1),j(e,!0),u=e.input.charCodeAt(e.position),(e.line===d||e.lineIndent>n)&&u!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return l?(r&&M(e),o&&Le(e),!0):!1}function ce(e,n,t,i,r,l=!0){e.depth>=e.maxDepth&&m(e,`nesting exceeded maxDepth (${e.maxDepth})`),e.depth++;let o=1,s=!1,u=!1,c=null;const d=Ca();let g=t===Gn||t===xr,f=g;const p=g;if(i&&j(e,!0)&&(s=!0,e.lineIndent>n?o=1:e.lineIndent===n?o=0:o=-1),e.position===e.lineStart&&le(e))return e.depth--,!1;if(o===1)for(;;){const v=e.input.charCodeAt(e.position),_=en(e);if(s&&o!==1&&(v===33||v===38))break;if(s&&p&&(d.tagStart!==C||d.anchorStart!==C)&&(v===33||v===38)){const k=en(e),w=n+1;if(Bt(e,e.position-e.lineStart,w,d)&&e.events[k.eventsLength]?.type===3)return e.depth--,!0;Re(e,k)}if(s&&(v===33&&d.tagStart!==C||v===38&&d.anchorStart!==C)||!Es(e,d,t===Be)&&!Is(e,d))break;c===null&&(c=_),j(e,!0)?(s=!0,f=p,e.lineIndent>n?o=1:e.lineIndent===n?o=0:o=-1):f=!1}if(f&&(f=s||r),o===1||t===Gn){const v=t===Be||t===Zt?n:n+1,_=e.position-e.lineStart;if(o===1)if(f&&(Aa(e,_,d)||Bt(e,_,v,d))||Ms(e,v,d))u=!0;else{const k=e.input.charCodeAt(e.position);if(c!==null&&l&&p&&!f&&k!==124&&k!==62){const w=en(e),b=c.position-c.lineStart;Re(e,c),Bt(e,b,v,Ca())&&e.events[w.eventsLength]?.type===3?u=!0:Re(e,w)}!u&&(g&&Ls(e,v,d)||Os(e,v,d)||Ps(e,v,d)||$s(e,d)||Fs(e,v,t,d))&&(u=!0)}else o===0&&(u=f&&Aa(e,_,d))}return g=g&&!u,!u&&(d.anchorStart!==C||d.tagStart!==C||g)&&(qe(e,C,C,d.anchorStart,d.anchorEnd,d.tagStart,d.tagEnd,1),u=!0),e.depth--,u||d.anchorStart!==C||d.tagStart!==C}function js(e){if(e.lineIndent>0||e.input.charCodeAt(e.position)!==37)return!1;e.position++;const n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position));)e.position++;const t=e.input.slice(n,e.position),i=[];for(t.length===0&&m(e,"directive name must not be less than one character in length");e.input.charCodeAt(e.position)!==0&&!O(e.input.charCodeAt(e.position));){for(;_e(e.input.charCodeAt(e.position));)e.position++;if(e.input.charCodeAt(e.position)===35||O(e.input.charCodeAt(e.position))||e.input.charCodeAt(e.position)===0)break;const r=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position));)e.position++;i.push(e.input.slice(r,e.position))}if(O(e.input.charCodeAt(e.position))&&Jn(e),t==="YAML"){e.directives.some(l=>l.kind==="yaml")&&m(e,"duplication of %YAML directive"),i.length!==1&&m(e,"YAML directive accepts exactly one argument");const r=/^([0-9]+)\.([0-9]+)$/.exec(i[0]);r===null&&m(e,"ill-formed argument of the YAML directive"),parseInt(r[1],10)!==1&&m(e,"unacceptable YAML version of the document"),e.directives.push({kind:"yaml",version:i[0]})}else if(t==="TAG"){i.length!==2&&m(e,"TAG directive accepts exactly two arguments");const[r,l]=i;Nr.test(r)||m(e,"ill-formed tag handle (first argument) of the TAG directive"),Ar.call(e.tagHandlers,r)&&m(e,`there is a previously declared suffix for "${r}" tag handle`),ws.test(l)||m(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagHandlers[r]=l,e.directives.push({kind:"tag",handle:r,prefix:l})}return!0}function Ds(e){e.directives=[],e.tagHandlers=Object.create(null);let n=!1;for(j(e,!0);js(e);)n=!0,j(e,!0);let t=!1,i=!1,r=!0;if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45&&G(e.input.charCodeAt(e.position+3))){t=!0;const s=e.line;e.position+=3,j(e,!0),r=e.line>s}else n&&m(e,"directives end mark is expected");const l=e.events.length;if(!t&&e.position===e.lineStart&&e.input.charCodeAt(e.position)===46&&le(e)){e.position+=3,j(e,!0);return}if(Ss(e,t,!1),ce(e,e.lineIndent-1,Gn,!1,r,r)||M(e),j(e,!0),e.position===e.lineStart&&le(e)&&(i=e.input.charCodeAt(e.position)===46,i)){const s=e.line;e.position+=3,j(e,!0),e.line===s&&e.position<e.length&&m(e,"end of the stream or a document separator is expected")}const o=e.events[l];o?.type===1&&(o.explicitEnd=i),Le(e),!i&&e.position<e.length&&!(e.position===e.lineStart&&le(e))&&m(e,"end of the stream or a document separator is expected")}function Us(e,n){const t=e.length,i={...Ri,...n,input:`${e}\0`,length:t,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]},r=e.indexOf("\0");for(r!==-1&&wt(e,r,"null byte is not allowed in input",i.filename),i.input.charCodeAt(i.position)===65279&&i.position++;i.position<i.length&&(j(i,!0),!(i.position>=i.length));){const l=i.position;Ds(i),i.position===l&&m(i,"can not read a document")}return i.events}var Bs={...Ri,...Li};function zs(e,n={}){const t={...Bs,...n},i=String(e),r=Object.keys(Ri),l=Object.keys(Li);return _s(Us(i,ga(t,r)),{...ga(t,l),source:i})}function Ws(e,n){const t=zs(e,n);if(t.length===0)throw new Kn("expected a document, but the input is empty");if(t.length===1)return t[0];throw new Kn("expected a single document in the stream, but found more")}es.withTags({...Jt,resolve:(e,n,t)=>{const i=Jt.resolve(e,n,t);return i===S?mr.resolve(e,n,t):i}},{...Xt,resolve:(e,n,t)=>{const i=Xt.resolve(e,n,t);return i===S?yr.resolve(e,n,t):i}});function Hs(e){if(e.trim()==="")return{};const t=Ws(e);if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new Error(".agent-user.yml must parse to an object");return t}const xa={id:"welcome",title:"Welcome — who are you?",navLabel:"You",subtitle:"Your name and language. Stored in .agent-user.yml; we pre-fill what we can detect.",kind:"welcome"},Na={id:"profile",title:"Which experience?",navLabel:"Experience",subtitle:"Pick the experience that fits you — developer · content · founder · agency · finance · ops. It selects your default command/skill surface and persona pre-selection. Cost tier is a secondary knob on a later step. You can switch later with `agent-config use --profile=<id>`.",kind:"form",paths:["profile.id"]},Ys=[{id:"ai-tools",title:"Which AI tools do you use?",navLabel:"AI tools",subtitle:"Pick the editors and CLIs that should pick up this config. Auto-detect runs first; you can override.",kind:"aiTools"},{id:"roles",title:"What do you work on?",navLabel:"Roles",subtitle:"Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in .agent-user.yml.",kind:"roles"},{id:"packs",title:"Which capability packs do you want?",navLabel:"Packs",subtitle:"Founder-strategy, finance-basic, gtm-sales, ops-people, ai-video — pick zero or more. You can change this later.",kind:"packs"},{id:"legal-consent",title:"Legal review-prep — not legal advice",navLabel:"Legal consent",subtitle:"Only relevant if you picked the legal-review-prep pack. It provides templates and general information, never legal advice — check the box to acknowledge before it activates. Leave unchecked otherwise; the pack stays inactive.",kind:"form",paths:["legal_review_prep.acknowledged"]}],Ea=[{id:"identity",title:"Editor & behaviour",navLabel:"Preferences",subtitle:"Your IDE plus how the agent behaves: autonomy, output verbosity, PR-comment style. rtk presence is auto-detected (see the rtk row). Your name lives in .agent-user.yml (later step).",kind:"form",paths:["personal.ide","personal.open_edited_files","personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon"]},{id:"cost",title:"Budgets, rules & cadence",navLabel:"Budgets & cadence",subtitle:"Independent levers: rule_loading_tier (how many behavioural rules load — token footprint), cost.budgets (optional USD ceilings), model.auto_switch (per-skill model tier), plus quality/roadmap cadence and memory thresholds.",kind:"form",paths:["rule_loading_tier","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch","tokens.rich_skills","roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci","memory.review_threshold","memory.redact_patterns"]},{id:"user-md",title:"Your .agent-user.yml",navLabel:"User profile",subtitle:"Identity, voice, preferences. Stored at agents/settings/.agent-user.yml. Skip to leave empty.",kind:"userMd"},{id:"review",title:"Review & finish",navLabel:"Review",subtitle:"These keys will change. Confirm to write .agent-settings.yml and .agent-user.yml atomically.",kind:"review"}];function Or(e={}){return e.extended===!0?[xa,Na,...Ys,...Ea]:[xa,Na,...Ea]}function St(e,n={}){const t=Or(n),i=Math.max(0,Math.min(t.length-1,e));return t[i]}function qs(e){const n={},t=i=>{n[i]=!0;const r=e.clusterOf.get(i);r!==void 0&&(n[r]=!0)};for(const i of e.installed)t(i);for(const i of e.roleDefaults)t(i);for(const i of e.detected)t(i);return n}function Ks(e,n){const t=new Set(n);return e.filter(i=>i!=="engineering-base"&&!t.has(i)).sort()}function Vs(e,n){const t={type:"object",properties:{},...e.description!==void 0?{description:e.description}:{}},i=t.properties,r=e.properties??{};for(const l of n){const o=l.split(".").filter(F=>F.length>0);if(o.length===0)continue;const[s,u,c]=o;if(s===void 0)continue;const d=r[s];if(d===void 0)continue;if(u===void 0){i[s]=d;continue}const g=d.properties?.[u];if(g===void 0)continue;const p=i[s]??{type:"object",properties:{},...d.description!==void 0?{description:d.description}:{}},v=p.properties??={};if(c===void 0){v[u]=g,i[s]=p;continue}const _=g.properties?.[c];if(_===void 0)continue;const w=v[u]??{type:"object",properties:{},...g.description!==void 0?{description:g.description}:{}},b=w.properties??={};b[c]=_,v[u]=w,i[s]=p}return t}function Gs({current:e,total:n}){const t=Math.max(1,n),i=Math.max(0,Math.min(t-1,e)),r=Array.from({length:t},(o,s)=>s<=i),l=Math.round((i+1)/t*100);return a("div",{class:"ac-wizard__progress",role:"progressbar","aria-valuenow":i+1,"aria-valuemin":1,"aria-valuemax":t,"aria-valuetext":`Step ${i+1} of ${t} (${l}%)`,children:r.map((o,s)=>a("span",{class:`ac-wizard__progress-segment${o?" ac-wizard__progress-segment--filled":""}`,"aria-hidden":"true"},s))})}function Js({step:e,index:n,total:t}){return a("header",{class:"ac-page__header ac-wizard__header",children:[a("p",{class:"ac-wizard__step-count",children:["Step ",n+1," of ",t]}),a("div",{class:"ac-wizard__header-text",children:[a("h1",{children:e.title}),a("p",{class:"ac-wizard__subtitle",children:e.subtitle})]}),a(Gs,{current:n,total:t})]})}function Xs(e){const n=e.canFinish??!0,t=e.completed??!1;return a("div",{class:"ac-form__actions ac-wizard__nav",children:[a("button",{type:"button",class:"ac-button",disabled:!e.canGoPrev||e.busy,onClick:e.onPrev,children:"Back"}),e.canSkip&&e.onSkip!==void 0?a("button",{type:"button",class:"ac-button ac-wizard__skip",disabled:e.busy,onClick:e.onSkip,children:e.skipLabel??"Skip"}):null,e.isLast?t?null:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy||!n,onClick:e.onFinish,children:e.busy?"Saving…":"Finish & save"}):a("button",{type:"button",class:"ac-button ac-button--primary",disabled:!e.canGoNext||e.busy,onClick:e.onNext,children:e.nextLabel??"Next"})]})}function Pr(e,n){return e.kind!=="form"||e.paths===void 0?!1:!!(e.paths.includes(n)||e.id==="cost"&&(n.startsWith("telegraph.")||n.startsWith("verbosity.")))}function Zs(e,n){return e.kind==="userMd"?n==="body"||n.startsWith("body."):Pr(e,n)}function Qs(e,n){for(const t of Object.keys(n.errors))if(Zs(e,t))return!0;return!1}function ec(e,n){if(Qs(e,n))return{label:"needs attention",tone:"error"};if(e.kind==="userMd")return n.userMdChanged?{label:n.userMdAction==="create"?"will create":"will replace",tone:"changed"}:{label:"",tone:"idle"};if(e.kind==="form"){const t=n.changes.filter(i=>Pr(e,i.path)).length;return t===0?{label:"",tone:"idle"}:{label:`${t} change${t===1?"":"s"}`,tone:"changed"}}if(e.kind==="aiTools"){const t=n.selectedToolsCount??0;return t===0?{label:"",tone:"idle"}:{label:`${t} tool${t===1?"":"s"}`,tone:"changed"}}if(e.kind==="packs"){const t=n.selectedPacksCount??0;return t===0?{label:"",tone:"idle"}:{label:`${t} pack${t===1?"":"s"}`,tone:"changed"}}return{label:"",tone:"idle"}}function nc(e){const n=e.steps.filter((s,u)=>u!==e.currentIndex),t=e.packRemovals??[],i=e.selectedToolIds??[],r=e.packAdditions??[],l=e.changes.length,o=i.length>0||r.length>0||l>0||e.userMdChanged;return a(L,{children:[o?a("section",{class:"ac-review-summary","aria-label":"What happens on Finish",children:[a("h2",{class:"ac-review-summary__title",children:"What happens on Finish"}),a("ul",{class:"ac-review-summary__list",children:[l>0?a("li",{children:[a("strong",{children:l})," setting",l===1?"":"s"," will change"," ","in ",a("code",{children:".agent-settings.yml"}),"."]}):a("li",{children:"No settings change."}),e.userMdChanged?a("li",{children:[a("code",{children:".agent-user.yml"})," will be"," ",e.userMdAction==="create"?"created":"updated","."]}):null,i.length>0?a("li",{children:["Config is installed for ",i.length," tool",i.length===1?"":"s",":",a("span",{class:"ac-review-summary__chips",children:i.map(s=>a("code",{class:"ac-review-summary__chip",children:s},s))})]}):null,r.length>0?a("li",{children:["New pack",r.length===1?"":"s",":",a("span",{class:"ac-review-summary__chips",children:r.map(s=>a("code",{class:"ac-review-summary__chip",children:s},s))})]}):null]})]}):null,t.length>0?a("div",{class:"ac-review-removals",role:"alert",children:[a("p",{class:"ac-review-removals__title",children:["⚠️ ",t.length===1?"1 installed pack will be removed":`${t.length} installed packs will be removed`]}),a("ul",{class:"ac-review-removals__list",children:t.map(s=>a("li",{children:a("code",{children:s})},s))}),a("label",{class:"ac-review-removals__confirm",children:[a("input",{type:"checkbox",checked:e.removalsConfirmed??!1,onChange:s=>{e.onConfirmRemovals?.(s.currentTarget.checked)}}),a("span",{children:"I understand these packs will no longer be installed. Re-check them on the packs step to keep them."})]})]}):null,a("nav",{class:"ac-wizard__review-nav","aria-label":"Jump back to a step",children:[a("p",{class:"ac-wizard__review-nav-label",children:"Jump back to a step:"}),a("ul",{class:"ac-wizard__review-nav-list",children:n.map(s=>{const u=e.steps.indexOf(s),c=ec(s,e),d=c.tone==="error"?"ac-wizard__review-nav-button ac-wizard__review-nav-button--error":"ac-wizard__review-nav-button";return a("li",{children:a("button",{type:"button",class:d,onClick:()=>{e.onJump(u)},children:[a("span",{class:"ac-wizard__review-nav-index",children:u+1}),a("span",{class:"ac-wizard__review-nav-text",children:s.navLabel}),c.label!==""?a("span",{class:`ac-wizard__review-nav-status ac-wizard__review-nav-status--${c.tone}`,children:c.label}):null]})},s.id)})})]})]})}function tc(e){const n=e.abortedAt??"unknown time",t=e.abortNote??"no further detail recorded",i=e.writesSinceRollback;return a("aside",{class:"ac-banner ac-banner--recovery",role:"alert",children:[a("strong",{children:"Previous install was interrupted."}),a("p",{children:["Aborted at ",a("code",{children:n})," — ",t,". ",i," write",i===1?"":"s"," landed before the abort marker."]}),a("p",{children:"Pick how to recover before continuing. Resume reopens the wizard fresh, Rollback discards the abort state, Ignore hides this banner without touching the log."}),a("div",{class:"ac-banner__actions",children:[a("button",{type:"button",disabled:e.busy,onClick:()=>e.onResume(),children:"Resume install"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onRollback(),children:"Rollback"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onIgnore(),children:"Ignore"})]})]})}function ic(){return a("section",{class:"ac-continue-screen","aria-labelledby":"ac-continue-title",children:[a("h2",{id:"ac-continue-title",children:"Install complete — continue with setup?"}),a("p",{children:"Your install selections (AI tools, roles, capability packs) are captured. Use the footer to continue:"}),a("ul",{children:[a("li",{children:[a("strong",{children:"Next"})," — go through the remaining personalisation steps: editor + tooling, personality, cost profile, roadmap & quality, memory, your",a("code",{children:" .agent-user.yml"}),", and finally the project module roots."]}),a("li",{children:[a("strong",{children:"Finish install here"})," — skip the rest and write ",a("code",{children:".agent-settings.yml"})," with the install-only selections. You can re-run ",a("code",{children:"agent-config setup"}),"later to pick up the personalisation steps."]})]})]})}function ac(e){const n=e.version??"unknown";return a("section",{class:"ac-backup-screen","aria-labelledby":"ac-backup-title",children:[a("h2",{id:"ac-backup-title",children:"Existing v3 install detected"}),a("p",{children:["Found a v3.x install at ",a("code",{children:e.sourcePath})," ","(VERSION: ",a("code",{children:n}),"). v4 is a hard-cut release with no auto-migration — settings, identity, and history layouts changed. The wizard can back up the v3 tree before writing the v4 layout so you can roll back manually if needed."]}),e.error!==null?a("p",{class:"ac-banner ac-banner--error",children:["Backup failed: ",e.error]}):null,a("ul",{children:[a("li",{children:[a("strong",{children:"Backup v3 and proceed"})," — copies the tree to ",a("code",{children:e.backupTarget}),", then runs the v4 install. Restore later with",a("code",{children:[" mv ",e.backupTarget," ",e.sourcePath]}),"."]}),a("li",{children:[a("strong",{children:"Abort, uninstall v3 first"})," — closes the wizard. You decide what to keep."]})]}),a("div",{class:"ac-backup-screen__actions",children:[a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy,onClick:()=>e.onBackupAndProceed(),children:e.busy?"Backing up…":"Backup v3 and proceed"}),a("button",{type:"button",class:"ac-button",disabled:e.busy,onClick:()=>e.onAbort(),children:"Abort, uninstall v3 first"})]})]})}const rc=[{title:"Restart your AI tools",detail:"Editors and CLIs pick up the new skills, rules, and commands on their next start."},{title:"Verify the installation",detail:"A read-only health report — scope, deployed files, drift.",command:"agent-config doctor"},{title:"Tune your settings any time",detail:"Opens the configuration GUI (global settings; --project for a project).",command:"agent-config config"},{title:"Initialize a project",detail:"Adds the minimal agents/ bridge + .gitignore block to a repository.",command:"agent-config init --project"},{title:"Stay up to date",detail:"Upgrades the global install and additively syncs your settings.",command:"agent-config upgrade"}];function lc({text:e}){const[n,t]=Ni(!1);return a("button",{type:"button",class:"ac-button ac-checklist__copy",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{t(!0),setTimeout(()=>{t(!1)},1500)})},children:n?"Copied ✓":"Copy"})}function oc({message:e}){return a("div",{class:"ac-checklist",children:[a("div",{class:"ac-checklist__hero",children:[a("h2",{class:"ac-checklist__headline",children:"Setup complete"}),e!==null?a("p",{class:"ac-checklist__message",children:e}):null]}),a("ol",{class:"ac-checklist__items",children:rc.map(n=>a("li",{class:"ac-checklist__item",children:[a("div",{class:"ac-checklist__text",children:[a("span",{class:"ac-checklist__item-title",children:n.title}),a("span",{class:"ac-checklist__item-detail",children:n.detail})]}),n.command!==void 0?a("div",{class:"ac-checklist__cmd-row",children:[a("code",{class:"ac-checklist__cmd",children:n.command}),a(lc,{text:n.command})]}):null]},n.title))}),a("p",{class:"ac-checklist__close-hint",children:"You can close this browser window — the local server shuts down on its own."})]})}const Lr=h(!1),nn=h(null),x=h(null),Xn=h(!1),Zn=h(!1),ye=h(0),Fi=h(null),W=h({}),Rr=h({}),Fr=h(0),Fe=h({}),$=h(null),ue=h(null),Mi=h(!1),ti=h(!1),Ct=h(!1),Mr=h({}),Tt=h([]);h("global");const Ee=h(!1),D=h(!1),sc=h(!1),Qn=h(!1),et=h(null),ji=h([]),nt=h({}),tt=h(!0),it=h(""),at=h("agents");h(!1);const jr=h(null),cc=[{id:"claude-code",label:"Claude Code"},{id:"claude-desktop",label:"Claude Desktop"},{id:"cursor",label:"Cursor"},{id:"windsurf",label:"Windsurf"},{id:"cline",label:"Cline"},{id:"gemini-cli",label:"Gemini CLI"},{id:"copilot",label:"GitHub Copilot"},{id:"augment",label:"Augment"},{id:"aider",label:"Aider"},{id:"codex",label:"Codex"},{id:"roocode",label:"Roo Code"},{id:"continue",label:"Continue"},{id:"kilocode",label:"Kilo Code"},{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"},{id:"kiro",label:"Kiro"},{id:"qoder",label:"Qoder"},{id:"opencode",label:"OpenCode"},{id:"trae",label:"Trae"},{id:"antigravity",label:"Antigravity"},{id:"codebuddy",label:"CodeBuddy"},{id:"droid",label:"Droid"},{id:"warp",label:"Warp"}],ii=h(!1),Me=h(!1),de=h(null),At=h([]),xt=h([]),be=h([]),ai=h(!1),bn=h([]),Z=h({}),Dr=h(!1),ri=h(!1),$n=h(!1),Di=h({}),Ia=h(!1),Ur=h(null),Br=h(null),zr=h(null),Wr=h(null),li=h(null),Hr=h(null),oi=h("https://github.com/rtk-ai/rtk"),si=h(!1),Yr=h(null),uc=h(null),ci=h(null),qr=h("event4u-app/agent-switch"),Ui=h(!1);h(!1);h(null);h([]);h({});h({});const ee=h({}),ae=h({}),ui=h(!1),$a=h(!1);h({});h(null);h(null);h(!1);h(null);const rt=h(null),Kr=h(!1),di=h(null),fi=h(!1),hi=h(!1),pi=h(null),je=h(null),On=h(!1),Bi=h(!1);function Vr(){return Or({extended:D.value})}function ze(){return Vr().length}function dc(e){return e??new Date().toISOString()}function zi(e){return Math.max(0,Math.min(ze()-1,e))}function fc(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),t=e.definitions[n];if(t!==void 0)return t}return e}async function hc(){try{return await y("/api/v1/settings")}catch(e){if(e instanceof E&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0)return{values:n.defaults,lastModified:n.lastModified??0,path:n.path??".agent-settings.yml",schema:n.schema};const t=await y("/api/v1/schema");return{values:{},lastModified:0,path:".agent-settings.yml",schema:t.settings}}throw e}}async function pc(){try{const e=await y("/api/v1/install/recovery");rt.value=e.incomplete?e:null}catch{rt.value=null}}async function vc(){try{const e=await y("/api/v1/install/legacy-v3");di.value=e.present?e:null}catch{di.value=null}}async function gc(){hi.value=!0,pi.value=null;try{await y("/api/v1/install/backup-v3",{method:"POST"}),fi.value=!0}catch(e){pi.value=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{hi.value=!1}}async function zt(e){try{await y("/api/v1/install/recovery/dismiss",{method:"POST",body:{reason:e}})}catch(n){x.value={message:n instanceof Error?n.message:String(n),tone:"error"};return}rt.value=null,Kr.value=!0}async function _c(){nn.value=null;try{pc(),vc();const[e,n]=await Promise.all([y("/api/v1/wizard/state"),hc()]);Fi.value=fc(n.schema),Fr.value=n.lastModified,Rr.value=n.values,Mr.value=n.legacyHints??{},D.value=e.extendedSteps===!0,je.value=e.wizardMode??null;const t=Object.keys(e.partial??{});W.value=t.length>0?{...n.values,...e.partial}:n.values,ye.value=zi(e.step),Ee.value=!1,Lr.value=!0;const i=St(ye.value,{extended:D.value});(i.kind==="welcome"||i.kind==="userMd"||i.kind==="review")&&Wi(),(i.kind==="roles"||i.kind==="aiTools"||i.kind==="packs")&&kn(),i.kind==="roles"&&Hi(),i.kind==="aiTools"&&Nt(),i.id==="identity"&&(Gr(),Jr()),i.kind==="review"&&Xr()}catch(e){e instanceof E?nn.value=z(e.body.error??{code:"UNKNOWN",message:e.message}):nn.value=e instanceof Error?e.message:String(e)}}function mc(e,n){return e.identity.name.trim()!==""?e:{...e,identity:{...e.identity,name:n}}}async function Wi(){if(!ti.value)try{const e=await y("/api/v1/user-md");if(Mi.value=e.exists,e.exists&&e.identity!==null){const n=va(e.identity);ue.value=n,$.value=n}else{let n;try{const i=await y("/api/v1/user-md/template");n=va(Hs(i.body))}catch{n=_r()}const t=Mr.value.user_name;typeof t=="string"&&t.trim()!==""&&(n=mc(n,t)),ue.value=n,$.value=n}}catch(e){x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{ti.value=!0}}const yc=new Set(["python"]);async function kn(){if(!(ii.value||Me.value)){Me.value=!0,de.value=null;try{const[e,n]=await Promise.all([y("/api/v1/wizard/manifest"),y("/api/v1/wizard/auto-detect")]),t=(e.packs??[]).map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",requires_hint:l.requires_hint,cluster:l.cluster??void 0,workspaces:l.workspaces}));At.value=t,bn.value=(e.workspaces??[]).filter(l=>l.id!=="agent-config-maintainer").map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",default_packs:l.default_packs??[],optional_packs:l.optional_packs??[],...l.example_roles!==void 0?{example_roles:l.example_roles}:{}}));const i=new Set(t.map(l=>l.id)),r=n.signals.map(l=>l.id.startsWith("pack-")?l.id.slice(5):l.id).filter(l=>i.has(l)).filter(l=>!yc.has(l));xt.value=r,be.value=(e.installedPacks??[]).filter(l=>i.has(l))}catch(e){e instanceof E?de.value=z(e.body.error??{code:"UNKNOWN",message:e.message}):de.value=e instanceof Error?e.message:String(e)}finally{Me.value=!1,ii.value=!0}}}async function Nt(){if(!(ri.value||$n.value)){$n.value=!0;try{const e=await y("/api/v1/wizard/detect-tools"),n=e.tools??{},t=e.configured??[];if(Di.value=n,Object.keys(ee.value).length===0){const i={};if(t.length>0)for(const r of t)i[r]=!0;else for(const[r,l]of Object.entries(n))l&&(i[r]=!0);ee.value=i}}catch{}finally{$n.value=!1,ri.value=!0}}}async function Gr(){if(!Ia.value){Ia.value=!0;try{const e=await y("/api/v1/wizard/detect-rtk"),n=e.installed===!0;Ur.value=n,Br.value=e.present===!0,zr.value=e.identity??null,Wr.value=e.version??null,li.value=e.installCommand??null,Hr.value=e.installCommands??null,typeof e.repo=="string"&&(oi.value=e.repo);const t=W.value.personal??{};W.value={...W.value,personal:{...t,rtk_installed:n}}}catch{}}}async function Jr(){if(!si.value){si.value=!0;try{const e=await y("/api/v1/wizard/detect-agent-switch");Yr.value=e.installed===!0,uc.value=e.version??null,ci.value=e.installCommand??null,typeof e.repo=="string"&&(qr.value=e.repo),Ui.value=e.dismissed===!0}catch{}}}async function bc(e,n){try{await y("/api/v1/wizard/state",{method:"POST",body:{step:e,totalSteps:ze(),partial:n,startedAt:dc(null)}})}catch(t){x.value={message:t instanceof Error?t.message:String(t),tone:"error"}}}async function Xr(){Zn.value=!0;try{const e=await y("/api/v1/settings/diff",{method:"POST",body:{values:W.value,ifUnmodifiedSince:Fr.value}});Tt.value=e.changes,Fe.value={}}catch(e){e instanceof E?(Fe.value=mt(e.body.error??{message:e.message}),x.value={message:z(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Zn.value=!1}}function lt(){return Ct.value?!1:$.value===null||ue.value===null?$.value!==ue.value:JSON.stringify($.value)!==JSON.stringify(ue.value)}async function Ie(e){const n=zi(e);await bc(n,W.value),ye.value=n,x.value=null;const t=St(n,{extended:D.value});(t.kind==="welcome"||t.kind==="userMd")&&Wi(),(t.kind==="roles"||t.kind==="aiTools"||t.kind==="packs")&&kn(),t.kind==="roles"&&Hi(),t.kind==="packs"&&It(),t.kind==="aiTools"&&Nt(),t.id==="identity"&&(Gr(),Jr()),t.kind==="review"&&Xr()}function Et(){const e=ae.value,n=new Map(At.value.map(l=>[l.id,l])),t=Object.entries(e).filter(([,l])=>l===!0).map(([l])=>l).filter(l=>{const o=n.get(l)?.cluster;return o===void 0||e[o]===!0}),i=new Set,r=l=>{if(!i.has(l)){i.add(l);for(const o of n.get(l)?.requires_hint??[])r(o)}};for(const l of t)r(l);return[...i].sort()}async function Hi(){if(await Promise.all([kn(),Wi()]),Dr.value||Object.values(Z.value).some(Boolean))return;const e=$.value?.role??[];if(e.length===0)return;const n=new Set(bn.value.map(i=>i.id)),t={};for(const i of e)n.has(i)&&(t[i]=!0);Object.keys(t).length!==0&&(Z.value=t,It())}function It(){if(ui.value)return;const e=Object.entries(Z.value).filter(([,r])=>r===!0).map(([r])=>r),n=new Map(bn.value.map(r=>[r.id,r])),t=[];for(const r of e)for(const l of n.get(r)?.default_packs??[])t.push(l);const i=new Map;for(const r of At.value)r.cluster!==void 0&&i.set(r.id,r.cluster);ae.value=qs({installed:be.value,roleDefaults:t,detected:xt.value,clusterOf:i})}function kc(){const e=Object.entries(ee.value).filter(([,i])=>i===!0).map(([i])=>i);if(e.length===0)return null;const n=Et(),t={schema_version:"wizard-v2",tools:e,packs:n,settings:W.value};return ge.value?.dryRun===!0&&(t.dry_run=!0),t}async function wc(){Xn.value=!0,x.value=null;try{const e={settings:W.value},n=Object.entries(Z.value).filter(([,u])=>u===!0).map(([u])=>u),t=$.value!==null&&typeof $.value.identity?.name=="string"&&$.value.identity.name.trim().length>0;$.value!==null&&t&&(lt()||n.length>0)&&(e.identity=n.length>0?{...$.value,role:n}:$.value);const i=await y("/api/v1/wizard/finish",{method:"POST",body:e}),r="You can close this browser window now.",l=i.dryRun===!0?"Dry-run complete — no files written. Settings would be saved.":Array.isArray(i.writtenPaths)?`Saved (${i.writtenPaths.join(", ")}). Wizard complete.`:"Wizard complete.",o=D.value?kc():null;let s="";if(o!==null&&o.dry_run===!0)try{await y("/api/v1/wizard/apply",{method:"POST",body:o}),s=" Installer preview OK (dry-run) — no files written."}catch(u){s=` Installer preview failed: ${u instanceof E?z(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}.`}else if(o!==null)try{let u=null;await Ol("/api/v1/wizard/apply",o,g=>{g.type==="error"&&(u=typeof g.message=="string"?g.message:"install failed")});const c=o.tools.length,d=o.packs.length;s=u!==null?` Installer failed: ${u}. Settings were saved; re-run the wizard to retry.`:` Installer applied ${c} tool${c===1?"":"s"}`+(d>0?` and ${d} pack${d===1?"":"s"}.`:".")}catch(u){s=` Installer bridge failed: ${u instanceof E?z(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}. Settings were saved; re-run the wizard to retry the install plan.`}x.value={message:`${l}${s} ${r}`,tone:"success"},ye.value=zi(ze()-1),Rr.value=W.value,ue.value=lt()?$.value:ue.value,Tt.value=[],Ee.value=!0}catch(e){e instanceof E?(Fe.value=mt(e.body.error??{message:e.message}),x.value={message:z(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Xn.value=!1}}async function Sc(){Bi.value=!0,await Promise.all([kn(),Nt()]),await Hi(),It(),await Ie(ze()-1)}function Cc(){ne(()=>{kn(),Nt()},[]);const e=Me.value||$n.value||!ii.value||!ri.value,n=Object.values(Di.value).filter(Boolean).length,t=be.value.length,i=xt.value.filter(r=>!be.value.includes(r)).length;return a("div",{class:"ac-start",children:[a("section",{class:"ac-start__card ac-start__card--primary",children:[a("h2",{class:"ac-start__title",children:"Recommended setup"}),a("p",{class:"ac-start__desc",children:"The fastest path — we pre-select everything we can detect and you confirm one review screen before anything is written."}),a("ul",{class:"ac-start__facts",children:[a("li",{children:e?"Detecting your AI tools…":n===0?"No AI tools detected — pick them on the review screen.":`${n} AI tool${n===1?"":"s"} detected and pre-selected.`}),a("li",{children:e?"Detecting capability packs…":t>0?`${t} installed pack${t===1?"":"s"} kept${i>0?`, ${i} more auto-detected`:""}.`:i>0?`${i} capability pack${i===1?"":"s"} auto-detected.`:"No packs pre-selected — add them any time later."}),a("li",{children:"Settings keep their current values (or safe defaults on a first run)."}),a("li",{children:"Nothing is written until you confirm the review screen."})]}),a("button",{type:"button",class:"ac-button ac-button--primary ac-start__cta",disabled:e,onClick:()=>{Sc()},children:e?"Detecting…":"Use recommended setup"})]}),a("section",{class:"ac-start__card",children:[a("h2",{class:"ac-start__title",children:"Customize"}),a("p",{class:"ac-start__desc",children:"Walk through every step — tools, roles, packs, behaviour, budgets — and tune each choice yourself."}),a("button",{type:"button",class:"ac-button ac-start__cta",onClick:()=>{Bi.value=!0},children:"Customize step by step"})]})]})}const Tc=["de","en","en-US","en-GB","fr","es","it","nl","pt","pt-BR"];function Ac(){if($a.value)return;const e=$.value;if(e===null)return;$a.value=!0;let n=e;if(e.identity.name.trim()===""){const t=ge.value?.systemUser;t!==void 0&&t.trim()!==""&&(n={...n,identity:{...n.identity,name:t}})}if(!Mi.value&&typeof navigator<"u"){const t=(navigator.language||"").split("-")[0];t.length>=2&&(n={...n,language:t})}n!==e&&($.value=n)}function xc(){const e=$.value;if(ne(()=>{Ac()},[e]),e===null)return a("p",{children:"Loading…"});const n=t=>{$.value={...t,last_updated:new Date().toISOString().slice(0,10)},Ct.value=!1};return a("div",{class:"ac-wizard-step-stub ac-wizard__module-fields",children:[a("p",{children:["Tell the agent who you are. We pre-filled what we could detect — adjust freely. Stored in ",a("code",{children:".agent-user.yml"}),"."]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-name",children:"Name"}),a("input",{class:"ac-input",id:"welcome-name",type:"text",placeholder:"How should the agent address you?",value:e.identity.name,onInput:t=>n({...e,identity:{...e.identity,name:t.currentTarget.value}})})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-lang",children:"Language"}),a("input",{class:"ac-input",id:"welcome-lang",type:"text",list:"welcome-lang-list",placeholder:"BCP-47 code, e.g. de, en, en-US",value:e.language,onInput:t=>n({...e,language:t.currentTarget.value})}),a("datalist",{id:"welcome-lang-list",children:Tc.map(t=>a("option",{value:t},t))})]})]})}function Nc(){const e=ee.value,n=Di.value;return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the AI tools you use. Tools detected on this machine are pre-selected on first run. The installer wires each selected tool's surface (skills, rules, commands) on apply; you can change this list later by re-running the wizard."}),a("ul",{class:"ac-wizard__tool-list",children:cc.map(t=>{const i=n[t.id]===!0;return a("li",{class:"ac-wizard__tool-row",children:[a("label",{class:"ac-wizard__tool-label",children:[a("input",{type:"checkbox",checked:e[t.id]??!1,onChange:r=>{const l=r.currentTarget.checked;ee.value={...e,[t.id]:l}}})," ",t.label]}),a("span",{class:`ac-badge ${i?"ac-badge--installed":"ac-badge--missing"}`,title:i?"Detected on this machine":"Not detected on this machine",children:i?"installed":"not installed"})]},t.id)})})]})}function Ec(){if(Me.value)return a("p",{children:"Loading roles…"});if(de.value!==null)return a("div",{class:"ac-wizard-step-stub",children:a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",de.value]})});const e=Z.value,n=bn.value,t=(i,r)=>{Dr.value=!0,Z.value={...Z.value,[i]:r},It()};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:["Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in",a("code",{children:" .agent-user.yml"}),"."]}),n.length===0?a("p",{children:a("em",{children:"No roles available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:n.map(i=>a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:e[i.id]??!1,onChange:r=>{t(i.id,r.currentTarget.checked)}}),a("span",{class:"ac-pack-tile__title",children:i.label})]}),(i.example_roles??[]).length>0?a("p",{class:"ac-pack-tile__role",children:["e.g. ",(i.example_roles??[]).join(", ")]}):null,i.description!==""?a("p",{class:"ac-pack-tile__desc",children:i.description}):null]},i.id))})]})}function Ic(){if(Me.value)return a("p",{children:"Loading discovery manifest…"});if(de.value!==null)return a("div",{class:"ac-wizard-step-stub",children:[a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",de.value]}),a("p",{children:"The manifest endpoint is gated on extended-mode. Re-run the server with extended steps enabled to populate this list."})]});const e=ae.value,n=new Set(xt.value),t=new Set(be.value),i=p=>t.has(p)?a("span",{class:"ac-badge ac-badge--installed",children:"installed"}):n.has(p)?a("span",{class:"ac-badge ac-badge--detected",children:"auto-detected"}):null,r=new Map(bn.value.map(p=>[p.id,p.label])),l=Z.value,o=p=>{const v=(p??[]).filter(_=>_!=="agent-config-maintainer");return v.length===0?null:a("span",{class:"ac-pack-tile__ws",children:v.map(_=>a("span",{class:`ac-badge ac-badge--ws${l[_]===!0?" ac-badge--ws-active":""}`,title:l[_]===!0?"Matches a role you picked":"Workspace / area",children:r.get(_)??_},_))})},s=At.value.filter(p=>p.id!=="engineering-base"),u=new Map;for(const p of s)if(p.cluster!==void 0){const v=u.get(p.cluster)??[];v.push(p),u.set(p.cluster,v)}const c=new Set(s.filter(p=>p.cluster!==void 0).map(p=>p.id)),d=s.filter(p=>!c.has(p.id)),g=(p,v)=>{ui.value=!0,ae.value={...ae.value,[p]:v}},f=(p,v)=>{ui.value=!0;const _={...ae.value,[p]:v};if(v)for(const k of u.get(p)??[])_[k.id]===void 0&&(_[k.id]=!0);ae.value=_};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the capability packs to install. Auto-detected packs are pre-selected; engineering hygiene is included automatically when a pack needs it. A language tile expands to its frameworks — turn the language off to skip them all."}),d.length===0?a("p",{children:a("em",{children:"No packs available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:d.map(p=>{const v=u.get(p.id)??[],_=v.length>0,k=e[p.id]??!1;return a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:k,onChange:w=>{const b=w.currentTarget.checked;_?f(p.id,b):g(p.id,b)}}),a("span",{class:"ac-pack-tile__title",children:p.label}),i(p.id)]}),o(p.workspaces),p.description!==""?a("p",{class:"ac-pack-tile__desc",children:p.description}):null,_?a("fieldset",{class:"ac-pack-tile__children",disabled:!k,children:v.map(w=>a("label",{class:"ac-pack-tile__child",children:[a("input",{type:"checkbox",checked:e[w.id]??!1,disabled:!k,onChange:b=>{g(w.id,b.currentTarget.checked)}}),a("span",{children:w.label}),i(w.id)]},w.id))}):null]},p.id)})})]})}function $c(){const e=Ur.value,n=Br.value,t=zr.value,i=Wr.value,r=Hr.value,l=e===null?a("span",{class:"ac-badge ac-badge--missing",children:"detecting…"}):e?a("span",{class:"ac-badge ac-badge--installed",children:["installed",i!==null?` (v${i})`:""]}):n===!0?a("span",{class:"ac-badge ac-badge--missing",children:t==="unknown-rtk"?"different tool":"unverified"}):a("span",{class:"ac-badge ac-badge--missing",children:"not installed"});return a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["rtk ",a("small",{children:"(Rust Token Killer — third-party, Apache-2.0)"})]}),l]}),n===!0&&t==="unknown-rtk"?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:["A binary named ",a("code",{children:"rtk"})," is on PATH, but it is not Rust Token Killer — two unrelated projects share the name (the other is Rust Type Kit). The token-saving integration stays off. See the upstream name-collision guidance:"]}),a("a",{class:"ac-button",href:`${oi.value}/blob/master/INSTALL.md`,target:"_blank",rel:"noreferrer noopener",children:"Open rtk install guide"})]}):null,n===!0&&t==="unverified"?a("p",{class:"ac-field__description",children:["rtk found but the identity check failed — verify manually with ",a("code",{children:"rtk gain"})," (Rust Token Killer renders a token-savings dashboard; the colliding Rust Type Kit does not)."]}):null,n===!1?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:"rtk wraps verbose CLI output — upstream reports 60–90% token savings (their estimate). Install it, then re-open the wizard to pick up detection:"}),r!==null?a(L,{children:[r.recommendedLabel!==void 0?a("p",{class:"ac-field__description",children:[r.recommendedLabel,":"]}):null,a("code",{class:"ac-rtk-row__cmd",children:r.recommended}),r.manual!==void 0?a(L,{children:[a("p",{class:"ac-field__description",children:[r.manualLabel??"Manual",":"]}),a("code",{class:"ac-rtk-row__cmd",children:r.manual})]}):null,r.note!==void 0?a("p",{class:"ac-field__description",children:r.note}):null]}):li.value!==null?a("code",{class:"ac-rtk-row__cmd",children:li.value}):null,a("a",{class:"ac-button",href:oi.value,target:"_blank",rel:"noreferrer noopener",children:"Open rtk repo"})]}):null]})}async function Oc(){try{await y("/api/v1/wizard/dismiss-recommendation",{method:"POST",body:{id:"agent-switch"}})}catch(e){x.value={message:e instanceof Error?e.message:String(e),tone:"error"};return}Ui.value=!0}function Pc(){return!si.value||Yr.value!==!1||Ui.value?null:a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["agent-switch ",a("small",{children:"(third-party, MIT)"})]}),a("span",{class:"ac-badge ac-badge--missing",children:"not installed"})]}),a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:["agent-switch isolates multiple agent accounts into per-account profiles (",a("code",{children:"CLAUDE_CONFIG_DIR"}),") so switching accounts never requires a re-login. Free and MIT-licensed."]}),ci.value!==null?a("code",{class:"ac-rtk-row__cmd",children:ci.value}):null,a("a",{class:"ac-button",href:`https://github.com/${qr.value}`,target:"_blank",rel:"noreferrer noopener",children:"Open agent-switch repo"}),a("button",{type:"button",class:"ac-button ac-button--small",onClick:()=>{Oc()},children:"Don't show again"})]})]})}function Lc(){const e=St(ye.value,{extended:D.value});if(D.value&&je.value==="install"&&e.id==="identity"&&!On.value)return a(ic,{});if(e.kind==="form"){const t=Vs(Fi.value,e.paths??[]);return a(L,{children:[e.id==="identity"?a($c,{}):null,e.id==="identity"?a(Pc,{}):null,a(Bl,{schema:t,values:W.value,errors:Fe.value,onChange:i=>{W.value=i}})]})}return e.kind==="userMd"?!ti.value||$.value===null?a("p",{children:"Loading .agent-user.yml…"}):a(Yl,{value:$.value,errors:Fe.value,hideRole:D.value&&je.value==="install",hideIdentityBasics:D.value&&je.value==="install",onChange:t=>{$.value=t,Ct.value=!1}}):e.kind==="welcome"?a(xc,{}):e.kind==="aiTools"?a(Nc,{}):e.kind==="roles"?a(Ec,{}):e.kind==="packs"?a(Ic,{}):a(nc,{steps:Vr(),currentIndex:ye.value,changes:Tt.value,errors:Fe.value,userMdChanged:lt(),userMdAction:Mi.value?"replace":"create",loading:Zn.value,onJump:t=>{Ie(t)},selectedToolsCount:Object.values(ee.value).filter(Boolean).length,selectedPacksCount:Object.values(ae.value).filter(Boolean).length,packRemovals:vi(),removalsConfirmed:ai.value,onConfirmRemovals:t=>{ai.value=t},selectedToolIds:Object.entries(ee.value).filter(([,t])=>t).map(([t])=>t),packAdditions:D.value?Et().filter(t=>t!=="engineering-base"&&!be.value.includes(t)):[]})}function vi(){return D.value?Ks(be.value,Et()):[]}function Oa({path:e}){if(ne(()=>{_c()},[]),!Lr.value||Fi.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Setup wizard"}),nn.value!==null?a("p",{class:"ac-banner ac-banner--error",children:nn.value}):a("p",{children:"Loading…"})]});const n=ye.value,t=ze(),i=St(n,{extended:D.value}),r=n===t-1,l=i.kind==="aiTools"&&Object.values(ee.value).filter(Boolean).length===0||i.kind==="roles"&&Object.values(Z.value).filter(Boolean).length===0||i.kind==="packs"&&Et().length===0,o=D.value&&je.value==="install"&&i.id==="identity"&&!On.value,s=rt.value,u=s!==null&&!Kr.value,c=di.value,d=c!==null&&c.present&&!fi.value,g=D.value&&je.value==="install"&&n===0&&!Bi.value&&!Ee.value;return d?a("div",{class:"ac-page",children:a(ac,{sourcePath:c.path,backupTarget:c.backupTarget,version:c.version,busy:hi.value,error:pi.value,onBackupAndProceed:()=>{gc()},onAbort:()=>{x.value={tone:"info",message:"Aborted. Uninstall v3 manually, then re-run `agent-config install`."},fi.value=!0}})}):g?a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:a("h1",{children:"Set up agent-config"})}),x.value!==null?a("p",{class:`ac-banner${x.value.tone==="error"?" ac-banner--error":""}`,children:x.value.message}):null,a(Cc,{})]}):a("div",{class:"ac-page",children:[a(Js,{step:i,index:n,total:t}),u?a(tc,{abortedAt:s.abortedAt,abortNote:s.abortNote,writesSinceRollback:s.writesSinceRollback,busy:Xn.value,onResume:()=>{zt("resume")},onRollback:()=>{zt("rollback")},onIgnore:()=>{zt("ignore")}}):null,x.value!==null&&!(Ee.value&&r&&x.value.tone==="success")?a("p",{class:`ac-banner${x.value.tone==="error"?" ac-banner--error":""}`,children:x.value.message}):null,a("div",{class:"ac-wizard__step",children:Ee.value&&r?a(oc,{message:x.value?.tone==="success"?x.value.message:null}):a(Lc,{})}),l?a("p",{class:"ac-wizard__hint",children:i.kind==="aiTools"?"Select at least one AI tool to continue.":i.kind==="roles"?"Select at least one role to continue.":"Select at least one capability pack to continue."}):null,a(Xs,{canGoPrev:n>0,canGoNext:!r&&!l,canSkip:o||i.kind==="userMd",skipLabel:o?"Finish install here":"Skip",isLast:r,busy:Xn.value||Zn.value,canFinish:(Tt.value.length>0||lt()||vi().length>0||D.value&&Object.values(ee.value).some(Boolean))&&(vi().length===0||ai.value),completed:Ee.value,onPrev:()=>{Ie(n-1)},onNext:()=>{if(o){On.value=!0;return}Ie(n+1)},onSkip:()=>{if(o){On.value=!0,Ie(ze()-1);return}Ct.value=!0,Ie(n+1)},onFinish:()=>{wc()}})]})}const Rc=new Set(["profile.id","rule_loading_tier","discipline_profile","personal.ide","personal.open_edited_files","personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon","personal.pr_progress_comments","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch","tokens.rich_skills","roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci","memory.review_threshold","memory.redact_patterns","memory.cadence","chat_history.enabled","update_check.enabled","subagents.enabled","subagents.auto","worktrees.mode","legal_review_prep.acknowledged"]);function Pa(e){return Rc.has(e)}function Fc(e,n){return JSON.stringify(e??null)===JSON.stringify(n??null)}function Zr(e,n){if(e.kind==="enum_removed"){const t=new Set(e.values??[]);return n!==void 0&&t.has(n)?"must_fix":"info"}return e.kind==="type_changed"?"must_fix":e.kind==="default_changed"?n===void 0||Fc(n,e.old?.default)?"adopt":"review":e.kind==="added"&&e.new?.default===void 0?"must_fix":"info"}const gi=h(!0),ot=h(null),_i=h(!1),$t=h(null),We=h({}),mi=h(0),ke=h({}),re=h(null),Q=h(!1),un=h(!1);function fe(e){return`${e.key}:${e.kind}`}async function Mc(){gi.value=!0,ot.value=null,_i.value=!1,un.value=!1;try{const e=await y("/api/v1/settings/changes"),n=await y("/api/v1/settings");$t.value=e.delta,We.value=n.values,mi.value=n.lastModified,jc(e.delta,n.values)}catch(e){e instanceof E&&e.status===404?_i.value=!0:ot.value=e instanceof Error?e.message:String(e)}finally{gi.value=!1}}function jc(e,n){const t={};for(const i of e.changes){const r=Zr(i,yn(n,i.key.split(".")));r==="adopt"?t[fe(i)]={mode:"adopt"}:r==="review"?t[fe(i)]={mode:"keep"}:r==="must_fix"&&(t[fe(i)]={mode:null})}ke.value=t}function Yi(e){return Zr(e,yn(We.value,e.key.split(".")))}function tn(e,n){ke.value={...ke.value,[e]:n}}function qi(){const e=$t.value;return e===null?[]:e.changes.filter(n=>{if(Yi(n)!=="must_fix")return!1;const t=ke.value[fe(n)];return t===void 0||t.mode===null||t.mode==="custom"&&(t.value===void 0||t.value==="")})}function Dc(){const e=$t.value;let n=We.value;if(e===null)return n;for(const t of e.changes){const i=ke.value[fe(t)];if(i===void 0||i.mode===null||i.mode==="keep")continue;const r=t.key.split(".");i.mode==="adopt"&&t.new?.default!==void 0?n=cn(n,r,t.new.default):i.mode==="custom"&&i.value!==void 0&&(n=cn(n,r,i.value))}return n}async function Uc(){if(Q.value)return;const e=qi();if(e.length>0){re.value=`Resolve the ${e.length} “Must fix” item${e.length===1?"":"s"} first.`;return}Q.value=!0,re.value=null;try{const n=Dc();if(JSON.stringify(n)!==JSON.stringify(We.value)){const t=await y("/api/v1/settings",{method:"PUT",headers:{"If-Unmodified-Since":String(mi.value)},body:{values:n}});We.value=n,mi.value=t.lastModified}await y("/api/v1/settings/changes/ack",{method:"POST"}),un.value=!0}catch(n){n instanceof E?re.value=z(n.body.error??{code:"UNKNOWN",message:n.message}):re.value=n instanceof Error?n.message:String(n)}finally{Q.value=!1}}async function Bc(){if(Q.value)return;if(qi().length>0){re.value="Cannot dismiss — “Must fix” items would leave invalid values in place.";return}Q.value=!0;try{await y("/api/v1/settings/changes/ack",{method:"POST"}),un.value=!0}catch(n){re.value=n instanceof Error?n.message:String(n)}finally{Q.value=!1}}function te(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Wt({change:e,id:n}){const t=e.new,r=ke.value[n]?.value;return t?.enum!==void 0?a("select",{class:"ac-input","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onChange:l=>{const o=l.currentTarget.value;tn(n,{mode:"custom",value:o})},children:[a("option",{value:"",disabled:!0,children:"Choose a value…"}),t.enum.map(l=>a("option",{value:String(l),children:String(l)},String(l)))]}):t?.type==="boolean"?a("select",{class:"ac-input","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onChange:l=>{tn(n,{mode:"custom",value:l.currentTarget.value==="true"})},children:[a("option",{value:"",disabled:!0,children:"Choose…"}),a("option",{value:"true",children:"true"}),a("option",{value:"false",children:"false"})]}):a("input",{class:"ac-input",type:t?.type==="number"||t?.type==="integer"?"number":"text","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onInput:l=>{const o=l.currentTarget.value,s=t?.type==="number"||t?.type==="integer"?Number(o):o;tn(n,{mode:"custom",value:s})}})}function zc({change:e}){const n=Yi(e),t=fe(e),i=ke.value[t],r=yn(We.value,e.key.split("."));return a("li",{class:`ac-change-card ac-change-card--${n}`,"data-key":e.key,"data-kind":e.kind,children:[a("div",{class:"ac-change-card__head",children:[a("code",{class:"ac-change-card__key",children:e.key}),a("span",{class:`ac-change-card__badge ac-change-card__badge--${n}`,children:n==="must_fix"?"Must fix":n==="adopt"?"New default":n==="review"?"Review":"Info"})]}),e.new?.description!==void 0?a("p",{class:"ac-change-card__desc",children:e.new.description}):null,e.kind==="default_changed"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Default changed: ",a("code",{children:te(e.old?.default)})," → ",a("code",{children:te(e.new?.default)}),n==="review"?a(L,{children:[" · your value: ",a("code",{children:te(r)})]}):null]}),a("div",{class:"ac-change-card__choices",role:"radiogroup","aria-label":`Resolution for ${e.key}`,children:[a("label",{class:"ac-change-card__choice",children:[a("input",{type:"radio",name:t,checked:i?.mode==="adopt",onChange:()=>{tn(t,{mode:"adopt"})}}),a("span",{children:["Adopt new default (",a("code",{children:te(e.new?.default)}),")"]})]}),a("label",{class:"ac-change-card__choice",children:[a("input",{type:"radio",name:t,checked:i?.mode==="keep",onChange:()=>{tn(t,{mode:"keep"})}}),a("span",{children:["Keep current (",a("code",{children:te(r??e.old?.default)}),")"]})]})]})]}):null,e.kind==="enum_removed"?n==="must_fix"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Your value ",a("code",{children:te(r)})," is no longer valid — removed option",(e.values?.length??0)===1?"":"s",": ",a("code",{children:(e.values??[]).join(", ")}),". Pick a replacement:"]}),a(Wt,{change:e,id:t})]}):a("p",{class:"ac-change-card__detail",children:["Removed option",(e.values?.length??0)===1?"":"s",": ",a("code",{children:(e.values??[]).join(", ")})," — your value ",a("code",{children:te(r??e.new?.default)})," is unaffected."]}):null,e.kind==="enum_added"?a("p",{class:"ac-change-card__detail",children:["New option",(e.values?.length??0)===1?"":"s"," available: ",a("code",{children:(e.values??[]).join(", ")})]}):null,e.kind==="added"?n==="must_fix"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:"New setting without a shipped default — define a value:"}),a(Wt,{change:e,id:t})]}):a("p",{class:"ac-change-card__detail",children:["New setting · default: ",a("code",{children:te(e.new?.default)}),e.new?.enum!==void 0?a(L,{children:[" · options: ",a("code",{children:e.new.enum.join(", ")})]}):null]}):null,e.kind==="removed"?a("p",{class:"ac-change-card__detail",children:"This setting no longer exists. Your stored value is kept in place and ignored (nothing is deleted)."}):null,e.kind==="type_changed"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Type changed: ",a("code",{children:e.old?.type})," → ",a("code",{children:e.new?.type}),". Define a new value:"]}),a(Wt,{change:e,id:t})]}):null]})}function Wc(e){const n=new Map;for(const c of e.changes){const d=Yi(c);n.set(d,[...n.get(d)??[],c])}const t=[],i=n.get("must_fix")??[];i.length>0&&t.push({title:"Must fix",hint:"These stored values are invalid after the upgrade — saving is blocked until each has a valid value.",changes:i});const r=[...n.get("adopt")??[],...n.get("review")??[]];r.length>0&&t.push({title:"Changed defaults",hint:"Values you never customized are preselected to adopt the new default; customized values are kept unless you choose otherwise.",changes:r});const l=n.get("info")??[],o=l.filter(c=>c.kind==="added"),s=l.filter(c=>c.kind==="enum_added"),u=l.filter(c=>c.kind!=="added"&&c.kind!=="enum_added");return o.length>0&&t.push({title:"New settings",changes:o}),s.length>0&&t.push({title:"New options",changes:s}),u.length>0&&t.push({title:"Removed / other",changes:u}),t}function Hc(){if(ne(()=>{Mc()},[]),gi.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings changes"}),a("p",{children:"Loading…"})]});if(ot.value!==null)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-banner ac-banner--error",children:ot.value})]});if(un.value||_i.value)return a("div",{class:"ac-page ac-settings-changes",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-banner",children:un.value?"Review complete — all changes resolved.":"Nothing to review — your settings are up to date."}),a("button",{type:"button",class:"ac-button",onClick:()=>_t("/settings"),children:"Back to Settings"})]});const e=$t.value;if(e===null)return a("div",{class:"ac-page",children:a("h1",{children:"Settings changes"})});const n=Wc(e),t=qi().length;return a("div",{class:"ac-page ac-settings-changes",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-page__lede",children:["The upgrade ",a("code",{children:e.oldVersion})," → ",a("code",{children:e.newVersion})," changed the available settings. Review below — nothing was changed automatically."]})]}),re.value!==null?a("p",{class:"ac-banner ac-banner--error",role:"alert",children:re.value}):null,n.map(i=>a("section",{class:"ac-settings-changes__group",children:[a("h2",{children:[i.title," ",a("span",{class:"ac-settings-changes__count",children:["(",i.changes.length,")"]})]}),i.hint!==void 0?a("p",{class:"ac-settings-changes__hint",children:i.hint}):null,a("ul",{class:"ac-settings-changes__list",children:i.changes.map(r=>a(zc,{change:r},fe(r)))})]},i.title)),a("div",{class:"ac-form__actions",children:[a("button",{type:"button",class:"ac-button",disabled:Q.value,onClick:()=>{Bc()},children:"Dismiss (keep everything)"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:Q.value||t>0,title:t>0?`${t} “Must fix” item${t===1?"":"s"} unresolved`:void 0,onClick:()=>{Uc()},children:Q.value?"Saving…":"Apply & finish review"})]})]})}const xe=h(null);function Yc(){return ne(()=>{(async()=>{try{const e=await y("/api/v1/settings/changes");xe.value=e.delta.changes.length}catch{xe.value=null}})()},[]),xe.value===null||xe.value===0?null:a("div",{class:"ac-banner ac-banner--pending",role:"status",children:[a("span",{children:["An upgrade changed ",xe.value," setting",xe.value===1?"":"s"," — review recommended."]}),a("button",{type:"button",class:"ac-button ac-button--small",onClick:()=>_t("/settings/changes"),children:"Review changes"})]})}const yi=h(!1),st=h(null),q=h({}),ct=h(null),dn=h(0),fn=h({}),J=h(null),we=h(!1),he=h(null),hn=h(null),Pn=h(""),Ne=h(!1),Ln=h({}),Rn=h({global:new Set,project:new Set});function La(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),t=e.definitions[n];if(t!==void 0)return t}return e}async function Ra(){st.value=null;try{const e=await y("/api/v1/settings");q.value=e.values,ct.value=La(e.schema),dn.value=e.lastModified,Rn.value={global:new Set(e.sources?.global??[]),project:new Set(e.sources?.project??[])},yi.value=!0}catch(e){if(e instanceof E&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0){q.value=n.defaults,ct.value=La(n.schema),dn.value=n.lastModified??0,yi.value=!0;return}}st.value=e instanceof Error?e.message:String(e)}}async function qc(){if(!we.value){J.value=null,fn.value={};try{const e=await y("/api/v1/settings/diff",{method:"POST",body:{values:q.value,ifUnmodifiedSince:dn.value}});if(e.changes.length===0){J.value="No changes to save.";return}he.value=e.changes}catch(e){e instanceof E?(fn.value=mt(e.body.error??{message:e.message}),J.value=z(e.body.error??{code:"UNKNOWN",message:e.message})):J.value=e instanceof Error?e.message:String(e)}}}async function Qr(e=!1){we.value=!0;try{const n=await y("/api/v1/settings",{method:"PUT",headers:{"If-Unmodified-Since":String(dn.value)},body:e?{values:q.value,confirmSharedWrite:!0}:{values:q.value}});dn.value=n.lastModified,he.value=null,hn.value=null,J.value=`Saved (${n.writtenPaths.join(", ")}).`}catch(n){if(n instanceof E){const t=n.body;if(n.status===409&&t.error==="shared-write"){he.value=null,hn.value={sharedPath:typeof t.sharedPath=="string"?t.sharedPath:"",message:typeof t.message=="string"?t.message:"This write affects a shared agent-switch profile."};return}const i=n.body.error??{code:"UNKNOWN",message:n.message};fn.value=mt(i),J.value=z(i),he.value=null;const r=Object.keys(fn.value)[0];r!==void 0&&queueMicrotask(()=>{const l=document.getElementById(r);l!==null&&l.focus()})}else J.value=n instanceof Error?n.message:String(n)}finally{we.value=!1}}function Ki(e){if(e.defaultValue===void 0)return!1;const n=yn(q.value,e.path);return n===void 0?!1:JSON.stringify(n)!==JSON.stringify(e.defaultValue)}function Kc(e,n){const t=Ki(n),i=Rn.value.project.has(e)?"project":Rn.value.global.has(e)&&Rn.value.project.size>0?"global":void 0;return{modified:t,onReset:t&&n.defaultValue!==void 0?()=>{q.value=cn(q.value,n.path,n.defaultValue)}:void 0,sourceLabel:i}}function Vc(e,n){const t=n.toLowerCase();return e.path.join(".").toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}function Gc(e){const n=Pn.value.trim(),t=Ne.value,i=e.path.join("."),r=Ln.value[i]===!0;let l=e.fields.filter(c=>c.kind!=="unsupported");if(n!==""&&(l=l.filter(c=>Vc(c,n))),t&&(l=l.filter(c=>Ki(c))),n!==""||t)return l.length===0?null:{section:e,visible:l,hiddenAdvancedCount:0,expanded:r};const o=l.filter(c=>Pa(c.path.join("."))),s=l.filter(c=>!Pa(c.path.join("."))),u=r?[...o,...s]:o;return u.length===0&&s.length===0?null:{section:e,visible:u,hiddenAdvancedCount:r?0:s.length,expanded:r}}function Jc(e){Ln.value={...Ln.value,[e]:Ln.value[e]!==!0}}function Xc(){const e=ge.value?.agentSwitchProfile;if(e===void 0||e.active!==!0)return null;const n=e.provider!==null&&e.profile!==null?`${e.provider}/${e.profile}`:"an unidentified profile";return a("div",{class:"ac-banner",role:"status",children:a("span",{children:["Running under agent-switch profile ",a("code",{children:n})," — settings shown and saved here are profile-scoped. Switching profiles shows that profile's own settings; nothing is lost."]})})}function Zc({block:e}){return a("div",{class:"ac-modal",role:"dialog","aria-modal":"true","aria-labelledby":"shared-write-title",children:a("div",{class:"ac-modal__panel",children:[a("h2",{id:"shared-write-title",children:"Shared write — affects all profiles"}),a("p",{children:e.message}),a("p",{children:a("code",{children:e.sharedPath})}),a("div",{class:"ac-modal__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{hn.value=null},children:"Cancel"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:we.value,onClick:()=>{Qr(!0)},children:we.value?"Writing…":"Write (affects all profiles)"})]})]})})}function Qc({changes:e}){return a("div",{class:"ac-modal",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:a("div",{class:"ac-modal__panel",children:[a("h2",{id:"diff-title",children:"Confirm changes"}),a("ul",{class:"ac-diff",children:e.map(n=>a("li",{children:[a("code",{children:n.path}),a("span",{class:"ac-diff__before",children:JSON.stringify(n.from)}),a("span",{class:"ac-diff__arrow",children:"→"}),a("span",{class:"ac-diff__after",children:JSON.stringify(n.to)})]},n.path))}),a("div",{class:"ac-modal__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{he.value=null},children:"Cancel"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:we.value,onClick:()=>{Qr()},children:we.value?"Saving…":"Save"})]})]})})}function eu(){if(ne(()=>{Ra()},[]),!yi.value||ct.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings"}),st.value!==null?a("p",{class:"ac-banner ac-banner--error",children:st.value}):a("p",{children:"Loading…"})]});const e=vr(ct.value),n=e.map(Gc).filter(r=>r!==null),t=e.flatMap(r=>r.fields).filter(r=>Ki(r)).length,i=Pn.value.trim()!==""||Ne.value;return a("div",{class:"ac-page ac-settings-hub",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Settings"}),a("nav",{class:"ac-page__nav",children:a("a",{href:"#/settings/user",children:"Edit .agent-user.yml →"})})]}),a(Yc,{}),a(Xc,{}),a("div",{class:"ac-settings-hub__toolbar",role:"search",children:[a("input",{class:"ac-input ac-settings-hub__search",type:"search",placeholder:"Search all settings (basic and advanced)…",value:Pn.value,onInput:r=>{Pn.value=r.currentTarget.value}}),a("button",{type:"button",class:`ac-chip-toggle${Ne.value?" ac-chip-toggle--active":""}`,"aria-pressed":Ne.value,onClick:()=>{Ne.value=!Ne.value},children:["@modified",t>0?` (${t})`:""]})]}),J.value!==null?a("p",{class:"ac-banner",children:J.value}):null,a("form",{class:"ac-form",onSubmit:r=>r.preventDefault(),children:[n.length===0?a("p",{class:"ac-settings-hub__empty",children:"No settings match."}):n.map(r=>{const l=r.section.path.join(".");return a(gr,{section:{...r.section,fields:r.visible},values:q.value,errors:fn.value,onChange:o=>{q.value=o},decorate:Kc,footer:!i&&(r.hiddenAdvancedCount>0||r.expanded)?a("button",{type:"button",class:"ac-settings-hub__disclosure","aria-expanded":r.expanded,onClick:()=>{Jc(l)},children:r.expanded?"Hide advanced settings":`Show ${r.hiddenAdvancedCount} advanced setting${r.hiddenAdvancedCount===1?"":"s"}`}):void 0},l)}),a("div",{class:"ac-form__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{Ra()},children:"Reload"}),a("button",{type:"button",class:"ac-button ac-button--primary",onClick:()=>{qc()},children:"Preview & Save"})]})]}),he.value!==null?a(Qc,{changes:he.value}):null,hn.value!==null?a(Zc,{block:hn.value}):null]})}const ut=h(!1),De=h(null);async function nu(){Qn.value=!0,et.value=null;try{const e=await y("/api/v1/modules/detect");ji.value=e.candidates,jr.value=e.project_root;const n={};for(const t of e.candidates)n[t.path]=!0;nt.value=n,tt.value=e.proposed_block.enabled,it.value=e.proposed_block.namespace_template??"",at.value=e.proposed_block.agent_folder??"agents"}catch(e){et.value=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{Qn.value=!1,sc.value=!0}}function tu(){const e=new Set(ji.value.map(i=>i.path)),n=nt.value,t=Object.keys(n).filter(i=>n[i]===!0&&e.has(i));return{enabled:tt.value,root_paths:t,namespace_template:it.value,agent_folder:at.value||"agents"}}async function iu(){ut.value=!0,De.value=null;try{const e=await y("/api/v1/modules/apply",{method:"POST",body:tu()});De.value={message:e.appliedTo!==null?`Saved project settings to ${e.appliedTo}.`:`Saved project settings to ${e.projectRoot}.`,tone:"success"}}catch(e){const n=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e);De.value={message:`Could not save project settings: ${n}`,tone:"error"}}finally{ut.value=!1}}function au(){if(Qn.value)return a("p",{children:"Detecting module roots…"});if(et.value!==null)return a("p",{class:"ac-banner ac-banner--error",children:["Module detection failed: ",et.value]});const e=ji.value,n=nt.value,t=jr.value;return a("div",{class:"ac-section",children:[t!==null?a("p",{class:"ac-section__description",children:["Scanning ",a("code",{children:t}),". Pick which detected roots the agent should treat as modules. These write to",a("code",{children:" .agent-project-settings.yml"})," in this repo only."]}):null,a("label",{children:[a("input",{type:"checkbox",checked:tt.value,onChange:i=>{tt.value=i.currentTarget.checked}})," ","Enable module discovery (writes ",a("code",{children:"modules.enabled"}),")"]}),e.length===0?a("p",{children:[a("em",{children:"No module roots detected."})," The scan found no common module layouts (Laravel ",a("code",{children:"app/Modules/"}),", Symfony",a("code",{children:" src/Module/"}),", Node ",a("code",{children:"packages/"}),", Python",a("code",{children:" src/"}),", Go ",a("code",{children:"internal/"}),")."]}):a("ul",{style:"list-style: none; padding-left: 0;",children:e.map(i=>a("li",{children:a("label",{children:[a("input",{type:"checkbox",checked:n[i.path]??!1,onChange:r=>{const l=r.currentTarget.checked;nt.value={...n,[i.path]:l}}})," ",a("code",{children:i.path})," — ",i.stack," ",a("small",{children:["(",i.confidence," confidence)"]})]})},i.path))}),a("div",{class:"ac-wizard__module-fields",children:[a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-namespace",children:"Namespace template"}),a("input",{id:"ac-modules-namespace",class:"ac-input",type:"text",value:it.value,placeholder:"e.g. App\\\\Modules\\\\{ModuleName}\\\\App",onInput:i=>{it.value=i.currentTarget.value}}),a("span",{class:"ac-field__description",children:"How a module path maps to its namespace. Leave blank to skip namespacing."})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-agent-folder",children:"Agent folder"}),a("input",{id:"ac-modules-agent-folder",class:"ac-input",type:"text",value:at.value,placeholder:"agents",onInput:i=>{at.value=i.currentTarget.value}}),a("span",{class:"ac-field__description",children:["Folder name that holds per-module agent docs (default ",a("code",{children:"agents"}),")."]})]})]})]})}function ru(){return ne(()=>{nu()},[]),a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Project settings"}),a("p",{class:"ac-section__description",children:["Configuration scoped to this repository — written to",a("code",{children:" .agent-project-settings.yml"}),", not the global tree."]})]}),De.value!==null?a("p",{class:`ac-banner ac-banner--${De.value.tone==="success"?"success":"error"}`,children:De.value.message}):null,a("section",{class:"ac-section",children:[a("h2",{class:"ac-section__title",children:"Modules"}),a(au,{})]}),a("div",{class:"ac-form__actions ac-wizard__nav",children:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:ut.value||Qn.value,onClick:()=>{iu()},children:ut.value?"Saving…":"Save project settings"})})]})}const Fn=h([]),pn=h([]),bi=h([]),ki=h([]),dt=h(null),el=h(!1),an=h(null),B=h(null),Ht=h("plain"),ft=h({}),nl=h([]),Fa={"claude-code":"Claude Code",codex:"Codex",gemini:"Gemini"};function lu(){try{return globalThis.sessionStorage?.getItem("ac-workspace-host")??"claude-code"}catch{return"claude-code"}}const Vi=h(lu());function ou(e){Vi.value=e;try{globalThis.sessionStorage?.setItem("ac-workspace-host",e)}catch{}}const vn=h([]),K=h(null),$e=h({}),pe=h(!1),gn=h(null),se=h(""),rn=h(!1),Ot=h(!1),wi=h(null),ve=h(null),_n=h([]),Mn=h(new Set),tl="claude-code",Ma=2e3;async function su(){an.value=null;try{const[e,n,t,i,r,l]=await Promise.all([y("/api/v1/workspace/roles"),y("/api/v1/workspace/sessions?limit=20"),y("/api/v1/workspace/knowledge?limit=20"),y("/api/v1/workspace/documents?limit=20"),y("/api/v1/workspace/drive-health").catch(()=>({health:{}})),y("/api/v1/workspace/hosts").catch(()=>({hosts:[]}))]);Fn.value=e.roles,pn.value=n.sessions,bi.value=t.chunks,ki.value=i.documents,ft.value=r.health??{},nl.value=l.hosts??[],el.value=!0}catch(e){e instanceof E?an.value=e.body?.error?.message??e.message:an.value=e instanceof Error?e.message:String(e)}}async function cu(e,n){try{const t=await y(`/api/v1/workspace/roles/${e}/tasks`);vn.value=t.tasks}catch{vn.value=n}}async function Gi(e){ve.value=e,Mn.value=new Set;try{const n=await y(`/api/v1/workspace/sessions/${e}`);_n.value=Array.isArray(n.log)?n.log:[]}catch{_n.value=[]}}async function uu(e){B.value=null,Ot.value=!1,se.value="",K.value=null,await Gi(e)}async function il(e,n,t){B.value=null,pe.value=!0,se.value="",Ot.value=!1,wi.value={role:e,task:n,inputs:t};try{const i=await y("/api/v1/workspace/launch",{method:"POST",body:{role:e,task:n,inputs:t,host:Vi.value}});gn.value=i,B.value=al(i),K.value=null,await Gi(i.id);const r=await y("/api/v1/workspace/sessions?limit=20");pn.value=r.sessions,await Ji()}catch(i){gn.value=null,i instanceof E?B.value=i.body?.error?.message??i.message:B.value=i instanceof Error?i.message:String(i)}finally{pe.value=!1}}async function du(e,n){if(!(n.trim()===""||rn.value)){rn.value=!0,B.value=null;try{const t=await y(`/api/v1/workspace/sessions/${e}/continue`,{method:"POST",body:{prompt:n}});gn.value=t,B.value=al(t),t.driven&&(se.value=""),await Gi(e);const i=await y("/api/v1/workspace/sessions?limit=20");pn.value=i.sessions,await Ji()}catch(t){t instanceof E&&t.status===410?(Ot.value=!0,B.value="Host session expired — start a new conversation."):t instanceof E?B.value=t.body?.error?.message??t.message:B.value=t instanceof Error?t.message:String(t)}finally{rn.value=!1}}}async function Ji(){try{const e=await y("/api/v1/workspace/drive-health");ft.value=e.health??{}}catch{}}async function fu(e){try{await y(`/api/v1/workspace/drive-health/${e}/reset`,{method:"POST"}),await Ji()}catch{}}function al(e){return e.driven?e.recovered===!0?`Host recovered — drove the turn for ${e.role} · ${e.task}.`:`Drove the turn for ${e.role} · ${e.task}.`:e.host_killed===!0?`Host ${tl} is paused after repeated failures — handed off to the inbox.`:e.error_kind==="render-error"?`Couldn't fill the prompt: ${e.error??"missing input"}.`:e.reason==="no-prompt-for-task"?"Recorded the session — this task has no runnable prompt yet.":typeof e.handoff=="string"?`Prepared a hand-off — open ${e.handoff} and paste it into your host.`:`Recorded the session ${e.id} (${e.role} · ${e.task}).`}function hu({role:e}){const n=dt.value===e.slug;return a("button",{type:"button",class:`ac-workspace__role${n?" ac-workspace__role--active":""}`,"aria-current":n?"true":void 0,"aria-label":`Pick role ${e.display_name}`,onClick:()=>{dt.value=e.slug,B.value=null,gn.value=null,K.value=null,$e.value={},vn.value=e.first_tasks,cu(e.slug,e.first_tasks)},children:[a("span",{class:"ac-workspace__role-name",children:e.display_name}),a("span",{class:"ac-workspace__role-status","data-status":e.status,children:e.status}),a("span",{class:"ac-workspace__role-tagline",children:e.tagline})]})}function pu({role:e,task:n}){const t=n.inputs??[],i=$e.value,r=t.some(l=>l.required&&(i[l.name]??"").trim()==="");return a("form",{class:"ac-workspace__task-form",onSubmit:l=>{l.preventDefault(),!r&&!pe.value&&il(e,n.name,$e.value)},children:[t.length===0?a("p",{class:"ac-workspace__form-note",children:"No inputs — runs the prompt as-is."}):t.map(l=>a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:[l.name,l.required?a("span",{class:"ac-workspace__req","aria-hidden":"true",children:" *"}):null]}),a("textarea",{class:"ac-workspace__field-input",placeholder:l.shape,required:l.required,"aria-label":`${l.name}${l.required?" (required)":""}`,value:i[l.name]??"",onInput:o=>{$e.value={...$e.value,[l.name]:o.target.value}}})]},l.name)),a("div",{class:"ac-workspace__form-actions",children:[a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:r||pe.value,children:pe.value?"Running…":"Run task"}),a("button",{type:"button",class:"ac-button",onClick:()=>{K.value=null},children:"Cancel"})]})]})}function vu(e){const n=[];for(const t of e){const i=t.data??{};if(t.kind==="launcher.input")i.followup===!0?n.push({kind:"user",text:typeof i.prompt=="string"?i.prompt:""}):n.push({kind:"task",text:typeof i.task=="string"?i.task:""});else if(t.kind==="host.turn"){const r=i.usage,l=r!=null?`${typeof i.model=="string"?i.model:tl} · in ${r.input_tokens??0} / out ${r.output_tokens??0} tokens`:void 0;n.push({kind:"assistant",text:typeof i.text=="string"?i.text:"",meta:l})}else if(t.kind==="host.error"){const r=typeof i.error_kind=="string"?i.error_kind:"error";n.push({kind:"error",text:`${r}: ${typeof i.error=="string"?i.error:""}`})}}return n}function gu(){if(ve.value===null)return null;const e=vu(_n.value),n=_n.value.some(t=>t.kind==="host.turn");return a("section",{class:"ac-workspace__thread","aria-label":"Conversation thread",children:[a("h2",{class:"ac-workspace__heading",children:"Conversation"}),e.length===0?a("p",{class:"ac-workspace__empty",children:"No turns yet."}):a("ol",{class:"ac-workspace__thread-list",children:e.map((t,i)=>{const r=t.kind==="assistant"&&t.text.length>Ma,l=Mn.value.has(i),o=r&&!l?`${t.text.slice(0,Ma)}…`:t.text;return a("li",{class:`ac-workspace__thread-block ac-workspace__thread-block--${t.kind}`,children:[a("span",{class:"ac-workspace__thread-role",children:t.kind==="task"?"Task":t.kind==="user"?"You":t.kind==="assistant"?"Host":"Error"}),a("pre",{class:"ac-workspace__thread-text",children:o}),r?a("button",{type:"button",class:"ac-button",onClick:()=>{const s=new Set(Mn.value);s.has(i)?s.delete(i):s.add(i),Mn.value=s},children:l?"Show less":"Show full"}):null,t.meta!=null?a("p",{class:"ac-workspace__turn-meta",children:t.meta}):null]},i)})}),Ot.value?a("div",{class:"ac-workspace__followup-gone",role:"status",children:[a("p",{children:"Host session expired."}),wi.value!==null?a("button",{type:"button",class:"ac-button ac-button--primary",disabled:pe.value,onClick:()=>{const t=wi.value;t!==null&&il(t.role,t.task,t.inputs)},children:pe.value?"Starting…":"Start a new conversation"}):a("p",{children:"Pick a task above to start a new conversation."})]}):n?a("form",{class:"ac-workspace__followup",onSubmit:t=>{t.preventDefault(),ve.value!==null&&du(ve.value,se.value)},children:[a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:"Follow up"}),a("textarea",{class:"ac-workspace__field-input",placeholder:"Continue this conversation — e.g. make it shorter","aria-label":"Follow-up prompt",value:se.value,onInput:t=>{se.value=t.target.value}})]}),a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:se.value.trim()===""||rn.value,children:rn.value?"Continuing…":"Send follow-up"})]}):null]})}function _u({role:e}){const n=vn.value.length>0?vn.value:e.first_tasks;return a("section",{class:"ac-workspace__tasks","aria-labelledby":"task-heading",children:[a("h2",{id:"task-heading",class:"ac-workspace__heading",children:["First tasks · ",e.display_name]}),n.length===0?a("p",{class:"ac-workspace__empty",children:"No tasks scaffolded yet for this role."}):a("ul",{class:"ac-workspace__task-list",children:n.map(t=>a("li",{class:"ac-workspace__task",children:[a("div",{class:"ac-workspace__task-head",children:[a("span",{class:"ac-workspace__task-name",children:t.name}),a("button",{type:"button",class:"ac-button ac-button--primary","aria-expanded":K.value===t.name,onClick:()=>{K.value=K.value===t.name?null:t.name,$e.value={},gn.value=null,ve.value=null,_n.value=[]},children:K.value===t.name?"Close":"Start session"})]}),a("p",{class:"ac-workspace__task-intent",children:t.intent}),t.prompt!==""?a("code",{class:"ac-workspace__task-prompt",children:["prompts/",t.prompt]}):null,K.value===t.name?a(pu,{role:e.slug,task:t}):null]},t.name))}),e.skills.length>0?a("details",{class:"ac-workspace__skills",children:[a("summary",{children:["Skill shortlist (",e.skills.length,")"]}),a("ul",{class:"ac-workspace__skill-list",children:[e.skills.slice(0,5).map(t=>a("li",{class:"ac-workspace__skill",children:[a("code",{children:t.id})," — ",t.why]},t.id)),e.skills.length>5?a("li",{class:"ac-workspace__skill-more",children:["+ ",e.skills.length-5," more"]}):null]})]}):null]})}function mu(){return a("section",{class:"ac-workspace__sessions","aria-labelledby":"sessions-heading",children:[a("h2",{id:"sessions-heading",class:"ac-workspace__heading",children:"Recent sessions"}),pn.value.length===0?a("p",{class:"ac-workspace__empty",children:"No sessions yet — pick a role and start one."}):a("ul",{class:"ac-workspace__session-list",children:pn.value.map(e=>a("li",{class:"ac-workspace__session",children:a("button",{type:"button",class:`ac-workspace__session-open${ve.value===e.id?" ac-workspace__session-open--active":""}`,"aria-label":`Open session ${e.task}`,"aria-current":ve.value===e.id?"true":void 0,onClick:()=>{uu(e.id)},children:[a("span",{class:"ac-workspace__session-id",children:e.id.slice(0,16)}),a("span",{class:"ac-workspace__session-role",children:e.role}),a("span",{class:"ac-workspace__session-task",children:e.task})]})},e.id))})]})}function yu(){return a("section",{class:"ac-workspace__knowledge","aria-labelledby":"knowledge-heading",children:[a("h2",{id:"knowledge-heading",class:"ac-workspace__heading",children:"Knowledge sources"}),bi.value.length===0?a("p",{class:"ac-workspace__empty",children:["No sources yet. Run ",a("code",{children:"/knowledge:ingest <path>"})," to add documents."]}):a("ol",{class:"ac-workspace__citation-list",children:bi.value.map((e,n)=>a("li",{class:"ac-workspace__citation",children:[a("span",{class:"ac-workspace__citation-marker","aria-label":`Citation ${n+1}`,children:["[",n+1,"]"]}),a("a",{href:`file://${e.source}`,class:"ac-workspace__citation-source",title:"Open source in OS default app",children:e.source.split("/").pop()??e.source}),e.pinned?a("span",{class:"ac-workspace__citation-pin","aria-label":"pinned",children:"★"}):null,a("p",{class:"ac-workspace__citation-excerpt",children:[e.excerpt.slice(0,200),e.excerpt.length>200?"…":""]})]},e.id))})]})}function bu(){return a("section",{class:"ac-workspace__recent","aria-labelledby":"recent-heading",children:[a("h2",{id:"recent-heading",class:"ac-workspace__heading",children:"Recent documents"}),ki.value.length===0?a("p",{class:"ac-workspace__empty",children:"No documents yet. Saved drafts land here."}):a("ul",{class:"ac-workspace__doc-list",children:ki.value.map(e=>a("li",{class:"ac-workspace__doc",children:[a("span",{class:"ac-workspace__doc-type","data-type":e.type,children:e.type}),a("span",{class:"ac-workspace__doc-title",children:e.title}),a("time",{class:"ac-workspace__doc-time",dateTime:e.updated_at,children:e.updated_at.slice(0,10)})]},`${e.type}/${e.slug}`))})]})}function ku(){const n=Object.values(ft.value).filter(t=>t.killed||t.consecutive_failures>0);return a("section",{class:"ac-workspace__drive-health","aria-labelledby":"drive-health-heading",children:[a("h2",{id:"drive-health-heading",class:"ac-workspace__heading",children:"Host health"}),n.length===0?a("p",{class:"ac-workspace__empty",children:"All hosts healthy."}):a("ul",{class:"ac-workspace__health-list",children:Object.entries(ft.value).filter(([,t])=>t.killed||t.consecutive_failures>0).map(([t,i])=>{const r=i.killed?i.kill_reason==="manual"?"paused (manual)":"paused — auto-recovering":"degraded";return a("li",{class:"ac-workspace__health","data-killed":i.killed?"true":"false",children:[a("span",{class:"ac-workspace__health-host",children:t}),a("span",{class:"ac-workspace__health-state",children:r}),a("span",{class:"ac-workspace__health-meta",children:[i.consecutive_failures," fail streak",i.last_error_kind!=null?` · ${i.last_error_kind}`:""]}),i.killed?a("button",{type:"button",class:"ac-button ac-workspace__health-reset","aria-label":`Reset ${t}`,onClick:()=>{fu(t)},children:"Reset"}):null]},t)})})]})}function wu(){const e=Ht.value;return a("fieldset",{class:"ac-workspace__explain",children:[a("legend",{class:"ac-workspace__heading",children:"Explanation style"}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"plain",checked:e==="plain",onChange:()=>{Ht.value="plain"},"aria-label":"Plain language"}),a("span",{children:"Plain language"})]}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"technical",checked:e==="technical",onChange:()=>{Ht.value="technical"},"aria-label":"Technical detail"}),a("span",{children:"Technical detail"})]}),a("p",{class:"ac-workspace__explain-hint",children:e==="plain"?"Replies use everyday words. Toggle to see the technical view.":"Replies keep the technical vocabulary. Toggle for the plain view."})]})}function Su(){const e=nl.value,n=e.length>0?e.map(i=>i.id):Object.keys(Fa),t=new Map(e.map(i=>[i.id,i.cli_present]));return a("label",{class:"ac-workspace__host-picker",children:[a("span",{class:"ac-workspace__host-label",children:"Host"}),a("select",{class:"ac-workspace__host-select","aria-label":"Host agent",value:Vi.value,onChange:i=>{ou(i.target.value)},children:n.map(i=>{const r=t.get(i)!==!1,l=Fa[i]??i;return a("option",{value:i,disabled:!r,children:[l," (",i,")",r?"":" — not installed"]},i)})})]})}function Cu(){if(ne(()=>{su()},[]),an.value!==null)return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-banner ac-banner--error",children:an.value})]});if(!el.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Workspace"}),a("p",{children:"Loading…"})]});const e=dt.value!==null?Fn.value.find(n=>n.slug===dt.value)??null:null;return a("div",{class:"ac-page ac-workspace",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-page__subtitle",children:"Pick a role, pick a first task, run it."}),a(Su,{})]}),B.value!==null?a("p",{class:"ac-banner",role:"status",children:B.value}):null,a("div",{class:"ac-workspace__grid",children:[a("section",{class:"ac-workspace__roles","aria-labelledby":"roles-heading",children:[a("h2",{id:"roles-heading",class:"ac-workspace__heading",children:"Roles"}),Fn.value.length===0?a("p",{class:"ac-workspace__empty",children:"No roles installed."}):a("div",{class:"ac-workspace__role-grid",children:Fn.value.map(n=>a(hu,{role:n},n.slug))})]}),a("main",{class:"ac-workspace__main","aria-label":"Tasks and sessions",children:[e!==null?a(_u,{role:e}):a("p",{class:"ac-workspace__empty",children:"Pick a role on the left to see its first tasks."}),a(gu,{}),a(mu,{})]}),a("aside",{class:"ac-workspace__rail","aria-label":"Knowledge and documents",children:[a(yu,{}),a(bu,{}),a(ku,{}),a(wu,{})]})]})]})}const rl="agent-config-theme";function Tu(){return(typeof document<"u"?document.documentElement.getAttribute("data-theme"):null)==="dark"?"dark":"light"}const ln=h(Tu());function Au(){try{const e=localStorage.getItem(rl);return e==="light"||e==="dark"?e:null}catch{return null}}function xu(){if(typeof window>"u")return null;try{const e=new URLSearchParams(window.location.search).get("theme");return e==="light"||e==="dark"?e:null}catch{return null}}function Nu(){return Au()===null&&xu()===null}function ll(e){ln.value=e,document.documentElement.setAttribute("data-theme",e)}function Eu(){const e=ln.value==="dark"?"light":"dark";try{localStorage.setItem(rl,e)}catch{}ll(e)}function Iu(){if(typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{Nu()&&ll(e.matches?"dark":"light")};typeof e.addEventListener=="function"&&e.addEventListener("change",n)}function $u(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("embed")==="1"}const Ou=$u(),ol=[{id:"setup",label:"Setup",hashPath:"/setup",matches:["/setup","/wizard"]},{id:"settings",label:"Settings",hashPath:"/settings",matches:["/settings"]},{id:"project",label:"Project",hashPath:"/project",matches:["/project"]},{id:"workspace",label:"Workspace",hashPath:"/workspace",matches:["/workspace"]}];function sl(e){for(const n of ol)for(const t of n.matches)if(e===t||e.startsWith(`${t}/`))return n.id;return null}function Pu(e){const n=ge.value,t=sl(e);return ol.filter(i=>i.id==="project"?n?.projectSurface===!0||t==="project":i.id==="workspace"?n?.devSurfaces===!0||t==="workspace":!0)}function Lu(){const e=Yn.value,n=sl(e);return a("header",{class:"ac-topnav",children:a("div",{class:"ac-topnav__inner",children:[a("div",{class:"ac-topnav__brand",children:[a("h1",{class:"ac-topnav__title",children:"@event4u/agent-config"}),a("p",{class:"ac-topnav__subtitle",children:"Browser Wizard"})]}),a("nav",{class:"ac-topnav__tabs","aria-label":"Surfaces",children:Pu(e).map(t=>a("button",{type:"button",class:`ac-topnav__tab${n===t.id?" ac-topnav__tab--active":""}`,"aria-current":n===t.id?"page":void 0,onClick:()=>_t(t.hashPath),children:t.label},t.id))}),a("button",{type:"button",class:"ac-topnav__theme","aria-label":ln.value==="dark"?"Switch to light theme":"Switch to dark theme",title:ln.value==="dark"?"Switch to light theme":"Switch to dark theme",onClick:()=>{Eu()},children:ln.value==="dark"?"☀":"☾"})]})})}function Ru({path:e}){return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Page not found"}),a("p",{children:["Nothing routed to ",a("code",{children:e}),". Try ",a("a",{href:"#/setup",children:"Setup"}),"."]})]})}function Fu(){const e=ge.value;return e===null||e.dryRun!==!0?null:a("div",{class:"ac-dryrun-banner",role:"status","aria-live":"polite",children:[a("strong",{children:"DRY RUN"}),a("span",{children:" · no files will be written. Validation + rendering run normally; commits return a preview."})]})}function Mu(e){return e==="/"||e==="/setup"||e.startsWith("/setup/")?a(Oa,{path:e}):e.startsWith("/wizard")?a(Oa,{path:e}):e==="/settings/changes"?a(Hc,{}):e==="/settings"||e.startsWith("/settings/")?a(eu,{}):e==="/project"||e.startsWith("/project/")?a(ru,{}):e==="/workspace"?a(Cu,{}):a(Ru,{path:e})}function ju(){return ne(()=>{Il(),Yn.value==="/"&&_t("/setup"),Pl()},[]),a(L,{children:[a(Fu,{}),Ou?null:a(Lu,{}),Mu(Yn.value)]})}const Du=3e4,Uu=30*6e4;let An=null,ja=!1;function Da(e){if(!ja&&(ja=!0,!(typeof navigator>"u"||typeof navigator.sendBeacon!="function")))try{navigator.sendBeacon(`/api/v1/shutdown?token=${encodeURIComponent(e)}`)}catch{}}function Bu(e){if(typeof window>"u")return()=>{};let n=Date.now();const t=()=>{n=Date.now()},i=["pointerdown","keydown","wheel","touchstart"];for(const s of i)window.addEventListener(s,t,{passive:!0});const r=()=>{document.hidden||t()};document.addEventListener("visibilitychange",r);const l=()=>{An!==null&&clearInterval(An),An=null;for(const s of i)window.removeEventListener(s,t);document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",o)};An=setInterval(()=>{if(!document.hidden){if(Date.now()-n>Uu){Da(e),l();return}y("/api/v1/ping").catch(()=>{})}},Du);function o(){Da(e)}return window.addEventListener("pagehide",o),l}function zu(){if(typeof window>"u"||typeof window.history?.replaceState!="function")return;const e=new URLSearchParams(window.location.search);if(!e.has("token"))return;e.delete("token");const n=e.toString(),t=window.location.pathname+(n?`?${n}`:"")+window.location.hash;window.history.replaceState(window.history.state,"",t)}function Wu(){return new URLSearchParams(window.location.search).get("token")}function Hu(){const e=document.getElementById("app");if(e===null)return;const n=Wu();if(n===null){e.textContent="agent-config UI · missing token — re-open via `agent-config ui:serve`.";return}$l(n),zu(),Bu(n),Iu(),e.textContent="",gl(a(ju,{}),e)}Hu();
|
|
26
|
-
//# sourceMappingURL=index-
|
|
25
|
+
`),c}function us(e,n){if(n.valueStart===is)return"";const{valueStart:t,valueEnd:i}=n;if(n.fast)return e.slice(t,i);switch(n.style){case 2:return ss(e,t,i);case 3:return cs(e,t,i);case 4:return ba(e,t,i,n.indent,n.chomping,!1);case 5:return ba(e,t,i,n.indent,n.chomping,!0);default:return os(e,t,i)}}var ds={"!":"!","!!":"tag:yaml.org,2002:"};function Sr(e,n){if(e.startsWith("!<")&&e.endsWith(">"))return decodeURIComponent(e.slice(2,-1));const t=e.indexOf("!",1),i=t===-1?"!":e.slice(0,t+1),r=n?.[i]??ds[i]??i;return decodeURIComponent(r)+decodeURIComponent(e.slice(i.length))}var Pe=-1,Li={filename:"",schema:Qo,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};function fs(e){return"tagStart"in e&&e.tagStart!==Pe?e.tagStart:"anchorStart"in e&&e.anchorStart!==Pe?e.anchorStart:"valueStart"in e&&e.valueStart!==Pe?e.valueStart:"start"in e?e.start:0}function U(e,n){wt(e.source,e.position,n,e.filename)}function Cr(e,n,t,i){try{return t.finalize(i)}catch(r){if(r instanceof Kn)throw r;wt(e.source,n,r instanceof Error?r.message:String(r),e.filename)}}function In(e,n,t){const i=e[t];if(i)return i;for(const r of n)if(t.startsWith(r.tagName))return r}function hs(e,n,t,i,r){const l=In(n,t,i);if(l)return l;U(e,`unknown ${r} tag !<${i}>`)}function ps(e,n){const t=us(e.source,n),i=n.tagStart===Pe?"":e.source.slice(n.tagStart,n.tagEnd),r=e.schema.defaultScalarTag;if(i!==""){if(i==="!")return{value:t,tag:r};const l=Sr(i,e.tagHandlers),o=In(e.schema.exact.scalar,e.schema.prefix.scalar,l);if(o){const u=o.resolve(t,!0,l);return u===S&&U(e,`cannot resolve a node with !<${l}> explicit tag`),{value:u,tag:o}}const s=In(e.schema.exact.mapping,e.schema.prefix.mapping,l)??In(e.schema.exact.sequence,e.schema.prefix.sequence,l);if(s){t!==""&&U(e,`cannot resolve a node with !<${l}> explicit tag`);const u=s.create(l);return{value:s.carrierIsResult?u:Cr(e,e.position,s,u),tag:s}}U(e,`unknown scalar tag !<${l}>`)}if(n.style===1){const l=e.schema.implicitScalarByFirstChar.get(t.charAt(0))??e.schema.implicitScalarAnyFirstChar;for(const o of l){const s=o.resolve(t,!1,o.tagName);if(s!==S)return{value:s,tag:o}}}return{value:r.resolve(t,!1,r.tagName),tag:r}}function ka(e,n,t,i,r,l){const o=n.tagStart===Pe?"":e.source.slice(n.tagStart,n.tagEnd),s=o===""||o==="!"?r:Sr(o,e.tagHandlers);return{tagName:s,tag:hs(e,t,i,s,l)}}function Tr(e){return e.nodeKind==="mapping"}function wa(e,n,t,i){for(const r of i.keys(t)){if(e.maxTotalMergeKeys!==-1&&++e.totalMergeKeys>e.maxTotalMergeKeys&&U(e,`merge keys exceeded maxTotalMergeKeys (${e.maxTotalMergeKeys})`),n.tag.has(n.value,r))continue;const l=n.tag.addPair(n.value,r,i.get(t,r));l&&U(e,l),(n.overridable??=new Set).add(r)}}function vs(e,n,t,i){if(e.position=n.keyPosition,Tr(i))wa(e,n,t,i);else if(i.nodeKind==="sequence"&&Array.isArray(t))for(const r of t)wa(e,n,r,n.tag);else U(e,"cannot merge mappings; the provided source object is unacceptable")}function gs(e,n,t,i,r){if(e.position=n.keyPosition,t===Ii){vs(e,n,i,r);return}!e.json&&n.tag.has(n.value,t)&&!n.overridable?.has(t)&&U(e,"duplicated mapping key");const l=n.tag.addPair(n.value,t,i);l&&U(e,l),n.overridable?.delete(t)}function Dt(e,n,t){const i=e.frames[e.frames.length-1];if(i.kind==="document")i.value=n,i.hasValue=!0;else if(i.kind==="sequence"){i.merge&&(Tr(t)||U(e,"cannot merge mappings; the provided source object is unacceptable"));const r=i.tag.addItem(i.value,n,i.index++);r&&U(e,r)}else if(i.hasKey){const r=i.key;i.key=void 0,i.hasKey=!1,gs(e,i,r,n,t)}else i.key=n,i.keyPosition=e.position,i.hasKey=!0}function Ut(e,n,t,i,r){if(n.anchorStart!==Pe){const l={value:t,tag:i,isValueFinal:r};return e.anchors.set(e.source.slice(n.anchorStart,n.anchorEnd),l),l}return null}function _s(e,n){const t={...Li,...n,events:e,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,tagHandlers:Object.create(null),totalMergeKeys:0,aliasCount:0};for(;t.eventIndex<t.events.length;){const i=t.events[t.eventIndex++];switch(t.position=fs(i),i.type){case 1:t.anchors=new Map,t.aliasCount=0,t.tagHandlers=Object.create(null);for(const r of i.directives)r.kind==="tag"&&(t.tagHandlers[r.handle]=r.prefix);t.frames.push({kind:"document",position:t.position,value:void 0,hasValue:!1});break;case 4:{const{value:r,tag:l}=ps(t,i);Ut(t,i,r,l,!0),Dt(t,r,l);break}case 2:{const r=ka(t,i,t.schema.exact.sequence,t.schema.prefix.sequence,"tag:yaml.org,2002:seq","sequence"),l=r.tag.create(r.tagName),o=Ut(t,i,l,r.tag,r.tag.carrierIsResult),s=t.frames[t.frames.length-1],u=s!==void 0&&s.kind==="mapping"&&s.hasKey&&s.key===Ii;t.frames.push({kind:"sequence",position:t.position,value:l,tag:r.tag,anchor:o,index:0,merge:u});break}case 3:{const r=ka(t,i,t.schema.exact.mapping,t.schema.prefix.mapping,"tag:yaml.org,2002:map","mapping"),l=r.tag.create(r.tagName),o=Ut(t,i,l,r.tag,r.tag.carrierIsResult);t.frames.push({kind:"mapping",position:t.position,value:l,tag:r.tag,anchor:o,key:void 0,keyPosition:t.position,hasKey:!1,overridable:null});break}case 5:{t.maxAliases!==-1&&++t.aliasCount>t.maxAliases&&U(t,`aliases exceeded maxAliases (${t.maxAliases})`);const r=t.source.slice(i.anchorStart,i.anchorEnd),l=t.anchors.get(r);l||U(t,`unidentified alias "${r}"`),l.isValueFinal||U(t,`recursive alias "${r}" is not supported for tag ${l.tag.tagName} because it uses finalize()`),Dt(t,l.value,l.tag);break}case 6:{const r=t.frames.pop();if(r.kind==="document")t.documents.push(r.value);else{const l=r.tag.carrierIsResult?r.value:Cr(t,r.position,r.tag,r.value);r.anchor&&(r.anchor.value=l,r.anchor.isValueFinal=!0),Dt(t,l,r.tag)}break}}}return t.documents}var C=-1,Ar=Object.prototype.hasOwnProperty,Be=1,Zt=2,xr=3,Gn=4,ms=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,ys=/[,\[\]{}]/,Nr=/^(?:!|!!|![0-9A-Za-z-]+!)$/,Qt=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,Er=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,bs=new RegExp(`^(?:${Qt})*$`),ks=new RegExp(`^(?:${Er})+$`),ws=new RegExp(`^(?:!(?:${Qt})*|${Er}(?:${Qt})*)$`),Ri={filename:"",maxDepth:100};function Ss(e,n,t){e.events.push({type:1,explicitStart:n,explicitEnd:t,directives:e.directives})}function Ir(e,n,t,i,r,l,o){e.events.push({type:2,start:n,anchorStart:t,anchorEnd:i,tagStart:r,tagEnd:l,style:o})}function ei(e,n,t,i,r,l,o){e.events.push({type:3,start:n,anchorStart:t,anchorEnd:i,tagStart:r,tagEnd:l,style:o})}function Sa(e,n){e.events.splice(n.eventsLength,0,{type:3,start:n.position,anchorStart:C,anchorEnd:C,tagStart:C,tagEnd:C,style:2})}function qe(e,n,t,i,r,l,o,s,u=1,c=-1,d=!1){e.events.push({type:4,valueStart:n,valueEnd:t,anchorStart:i,anchorEnd:r,tagStart:l,tagEnd:o,style:s,chomping:u,indent:c,fast:d})}function Cs(e,n,t){e.events.push({type:5,anchorStart:n,anchorEnd:t})}function Le(e){e.events.push({type:6})}function M(e){qe(e,C,C,C,C,C,C,1)}function Ca(){return{anchorStart:C,anchorEnd:C,tagStart:C,tagEnd:C}}function en(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,eventsLength:e.events.length}}function Re(e,n){e.position=n.position,e.line=n.line,e.lineStart=n.lineStart,e.lineIndent=n.lineIndent,e.firstTabInLine=n.firstTabInLine,e.events.length=n.eventsLength}function m(e,n){wt(e.input.slice(0,e.length),e.position,n,e.filename)}function O(e){return e===10||e===13}function _e(e){return e===9||e===32}function H(e){return _e(e)||O(e)}function G(e){return e===0||H(e)}function me(e){return e===44||e===91||e===93||e===123||e===125}function Ts(e){return e>=48&&e<=57?e-48:-1}function As(e){if(e>=48&&e<=57)return e-48;const n=e|32;return n>=97&&n<=102?n-97+10:-1}function xs(e){return e===120?2:e===117?4:e===85?8:0}function Ns(e){return e===48||e===97||e===98||e===116||e===9||e===110||e===118||e===102||e===114||e===101||e===32||e===34||e===47||e===92||e===78||e===95||e===76||e===80}function Jn(e){e.input.charCodeAt(e.position)===10?e.position++:(e.position++,e.input.charCodeAt(e.position)===10&&e.position++),e.line++,e.lineStart=e.position,e.lineIndent=0,e.firstTabInLine=-1}function j(e,n){let t=0,i=e.input.charCodeAt(e.position),r=e.position===e.lineStart||H(e.input.charCodeAt(e.position-1));for(;i!==0;){for(;_e(i);)r=!0,i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(n&&r&&i===35)do i=e.input.charCodeAt(++e.position);while(!O(i)&&i!==0);if(!O(i))break;for(Jn(e),t++,r=!0,i=e.input.charCodeAt(e.position);i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position)}return t}function le(e,n=e.position){const t=e.input.charCodeAt(n);if((t===45||t===46)&&t===e.input.charCodeAt(n+1)&&t===e.input.charCodeAt(n+2)){const i=e.input.charCodeAt(n+3);return i===0||H(i)}return!1}function Ta(e){let n=e.input.charCodeAt(e.position);for(;n!==0&&!O(n);)n=e.input.charCodeAt(++e.position)}function $r(e,n,t){ms.test(e.input.slice(n,t))&&m(e,"the stream contains non-printable characters")}function Es(e,n,t){if(e.input.charCodeAt(e.position)!==33)return!1;n.tagStart!==C&&m(e,"duplication of a tag property");const i=e.position;let r=!1,l=!1,o="!",s=e.input.charCodeAt(++e.position);s===60?(r=!0,s=e.input.charCodeAt(++e.position)):s===33&&(l=!0,o="!!",s=e.input.charCodeAt(++e.position));let u=e.position,c;if(r){for(;s!==0&&s!==62;)s=e.input.charCodeAt(++e.position);s!==62&&m(e,"unexpected end of the stream within a verbatim tag"),c=e.input.slice(u,e.position),e.position++}else{for(;s!==0&&!H(s)&&!(t&&me(s));)s===33&&(l?m(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(u-1,e.position+1),Nr.test(o)||m(e,"named tag handle cannot contain such characters"),l=!0,u=e.position+1)),s=e.input.charCodeAt(++e.position);c=e.input.slice(u,e.position),ys.test(c)&&m(e,"tag suffix cannot contain flow indicator characters")}return c&&!(r?bs.test(c):ks.test(c))&&m(e,`tag name cannot contain such characters: ${c}`),!r&&o!=="!"&&o!=="!!"&&!Ar.call(e.tagHandlers,o)&&m(e,`undeclared tag handle "${o}"`),n.tagStart=i,n.tagEnd=e.position,!0}function Is(e,n){if(e.input.charCodeAt(e.position)!==38)return!1;n.anchorStart!==C&&m(e,"duplication of an anchor property"),e.position++;const t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position))&&!me(e.input.charCodeAt(e.position));)e.position++;return e.position===t&&m(e,"name of an anchor node must contain at least one character"),n.anchorStart=t,n.anchorEnd=e.position,!0}function $s(e,n){if(e.input.charCodeAt(e.position)!==42)return!1;(n.anchorStart!==C||n.tagStart!==C)&&m(e,"alias node should not have any properties"),e.position++;const t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position))&&!me(e.input.charCodeAt(e.position));)e.position++;return e.position===t&&m(e,"name of an alias node must contain at least one character"),Cs(e,t,e.position),!0}function ni(e,n){j(e,!1),e.lineIndent<n&&m(e,"deficient indentation")}function Os(e,n,t){if(e.input.charCodeAt(e.position)!==39)return!1;e.position++;const i=e.position;let r=!0;for(;e.input.charCodeAt(e.position)!==0;){const l=e.input.charCodeAt(e.position);if(l===39){if(e.input.charCodeAt(e.position+1)===39){r=!1,e.position+=2;continue}const o=e.position;return e.position++,qe(e,i,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2,1,-1,r),!0}O(l)?(r=!1,ni(e,n)):e.position===e.lineStart&&le(e)?m(e,"unexpected end of the document within a single quoted scalar"):l!==9&&l<32?m(e,"expected valid JSON character"):e.position++}m(e,"unexpected end of the stream within a single quoted scalar")}function Ps(e,n,t){if(e.input.charCodeAt(e.position)!==34)return!1;e.position++;const i=e.position;let r=!0;for(;e.input.charCodeAt(e.position)!==0;){const l=e.input.charCodeAt(e.position);if(l===34){const o=e.position;return e.position++,qe(e,i,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,3,1,-1,r),!0}if(l===92){r=!1;const o=e.input.charCodeAt(++e.position);if(O(o))ni(e,n);else if(Ns(o))e.position++;else{let s=xs(o);for(s===0&&m(e,"unknown escape sequence");s-- >0;)e.position++,As(e.input.charCodeAt(e.position))<0&&m(e,"expected hexadecimal character");e.position++}}else O(l)?(r=!1,ni(e,n)):e.position===e.lineStart&&le(e)?m(e,"unexpected end of the document within a double quoted scalar"):l!==9&&l<32?m(e,"expected valid JSON character"):e.position++}m(e,"unexpected end of the stream within a double quoted scalar")}function Ls(e,n,t){const i=e.input.charCodeAt(e.position);let r=1,l=-1,o=!1;if(i!==124&&i!==62)return!1;const s=i===124?4:5;for(e.position++;e.input.charCodeAt(e.position)!==0;){const p=e.input.charCodeAt(e.position),v=Ts(p);if(p===43||p===45)r!==1&&m(e,"repeat of a chomping mode identifier"),r=p===43?3:2,e.position++;else if(v>=0)v===0&&m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"),o&&m(e,"repeat of an indentation width identifier"),l=n+v-1,o=!0,e.position++;else break}let u=!1;for(;_e(e.input.charCodeAt(e.position));)u=!0,e.position++;u&&e.input.charCodeAt(e.position)===35&&Ta(e),O(e.input.charCodeAt(e.position))?Jn(e):e.input.charCodeAt(e.position)!==0&&m(e,"a line break is expected");let c=o?l:-1,d=0;const g=e.position;let f=e.position;for(;e.input.charCodeAt(e.position)!==0;){const p=e.position;let v=0;for(;e.input.charCodeAt(p+v)===32;)v++;const _=e.input.charCodeAt(p+v);if(_===0){c>=0?v>c&&(f=p+v):v>0&&(f=p+v);break}if(p===e.lineStart&&le(e,p))break;if(!o&&c===-1&&O(_)&&(d=Math.max(d,v)),!o&&c===-1&&!O(_)&&(_===9&&v<n&&(e.position=p+v,m(e,"tab characters must not be used in indentation")),v<d&&(e.position=p+v,m(e,"bad indentation of a mapping entry"))),c===-1&&_!==0&&!O(_)&&v<n){e.lineIndent=v,e.position=p+v;break}!o&&_!==0&&!O(_)&&c===-1&&(c=v);const k=c===-1?n+1:c;if(_!==0&&!O(_)&&v<k){e.lineIndent=v,e.position=p+v;break}Ta(e),f=e.position,O(e.input.charCodeAt(e.position))&&(Jn(e),f=e.position)}return $r(e,g,f),qe(e,g,f,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,s,r,c),!0}function Rs(e,n){const t=e.input.charCodeAt(e.position),i=n===Be;if(t===0||H(t)||t===35||t===38||t===42||t===33||t===124||t===62||t===39||t===34||t===37||t===64||t===96||i&&me(t))return!1;if(t===63||t===45){const r=e.input.charCodeAt(e.position+1);if(G(r)||i&&me(r))return!1}return!0}function Fs(e,n,t,i){if(!Rs(e,t))return!1;const r=e.position;let l=e.position,o=e.input.charCodeAt(e.position);const s=t===Be;let u=!1;for(;o!==0&&!(e.position===e.lineStart&&le(e));){if(o===58){const c=e.input.charCodeAt(e.position+1);if(G(c)||s&&me(c))break}else if(o===35){if(H(e.input.charCodeAt(e.position-1)))break}else{if(s&&me(o))break;if(O(o)){const c=e.position,d=e.line,g=e.lineStart,f=e.lineIndent;if(j(e,!1),e.lineIndent>=n){u=!0,o=e.input.charCodeAt(e.position);continue}e.position=c,e.line=d,e.lineStart=g,e.lineIndent=f;break}}_e(o)||(l=e.position+1),o=e.input.charCodeAt(++e.position)}return l===r?!1:($r(e,r,l),qe(e,r,l,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1,1,-1,!u),!0)}function Ge(e,n){const t=e.line;j(e,!0),(e.line>t&&e.lineIndent<n||e.firstTabInLine!==-1&&e.lineIndent<n)&&m(e,"deficient indentation")}function Ms(e,n,t){const i=e.input.charCodeAt(e.position),r=i===123,l=e.position;let o=!0;if(i!==91&&i!==123)return!1;const s=r?125:93;for(r?ei(e,l,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2):Ir(e,l,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,2),e.position++;e.input.charCodeAt(e.position)!==0;){Ge(e,n);let u=e.input.charCodeAt(e.position);if(u===s)return e.position++,Le(e),!0;o?u===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries");let c=!1,d=!1;u===63&&H(e.input.charCodeAt(e.position+1))&&(c=d=!0,e.position+=1,Ge(e,n));const g=e.line,f=en(e),p=ce(e,n,Be,!1,!0);Ge(e,n),u=e.input.charCodeAt(e.position),(r||d||e.line===g)&&u===58?(c=!0,e.position++,Ge(e,n),r||Sa(e,f),p||M(e),ce(e,n,Be,!1,!0)||M(e),Ge(e,n),r||Le(e)):r&&c?(p||M(e),M(e)):r?M(e):c&&(Sa(e,f),p||M(e),M(e),Le(e)),u=e.input.charCodeAt(e.position),u===44?(o=!0,e.position++):o=!1}m(e,"unexpected end of the stream within a flow collection")}function Aa(e,n,t){if(e.firstTabInLine!==-1||e.input.charCodeAt(e.position)!==45||!G(e.input.charCodeAt(e.position+1)))return!1;for(Ir(e,e.position,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,1);e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1));){e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation"));const i=e.line;e.position++;const r=j(e,!0)>0;if(e.firstTabInLine!==-1&&e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1))&&m(e,"bad indentation of a sequence entry"),r&&e.lineIndent<=n?M(e):ce(e,n,xr,!1,!0),j(e,!0),e.lineIndent<n||e.position>=e.length)break;e.lineIndent>n&&m(e,"bad indentation of a sequence entry"),e.line===i&&e.input.charCodeAt(e.position)===45&&G(e.input.charCodeAt(e.position+1))&&m(e,"bad indentation of a sequence entry")}return Le(e),!0}function Bt(e,n,t,i){let r=!1,l=!1,o=!1,s=!1;if(e.firstTabInLine!==-1)return!1;let u=e.input.charCodeAt(e.position);for(;u!==0;){!r&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation"));const c=e.input.charCodeAt(e.position+1),d=e.line;if((u===63||u===58)&&G(c))o||(ei(e,e.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1),o=!0),u===63?(r&&M(e),l=!0,r=!0):(r||(M(e),l=!0),r=!1),e.position+=1,s=!0;else{r&&(M(e),r=!1);const g=en(e);if(!ce(e,t,Zt,!1,!0))break;if(e.line===d){for(u=e.input.charCodeAt(e.position);_e(u);)u=e.input.charCodeAt(++e.position);if(u===58){if(u=e.input.charCodeAt(++e.position),G(u)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),!o){for(Re(e,g),ei(e,g.position,i.anchorStart,i.anchorEnd,i.tagStart,i.tagEnd,1),o=!0,ce(e,t,Zt,!1,!0),u=e.input.charCodeAt(e.position);_e(u);)u=e.input.charCodeAt(++e.position);e.position++}l=!0,r=!1,s=!1}else if(l)m(e,"expected ':' after a mapping key");else return i.anchorStart!==C||i.tagStart!==C?(Re(e,g),!1):!0}else if(l)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return i.anchorStart!==C||i.tagStart!==C?(Re(e,g),!1):!0}if(ce(e,n,Gn,!0,s)&&(s=!1),r||s&&(M(e),s=!1),j(e,!0),u=e.input.charCodeAt(e.position),(e.line===d||e.lineIndent>n)&&u!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return l?(r&&M(e),o&&Le(e),!0):!1}function ce(e,n,t,i,r,l=!0){e.depth>=e.maxDepth&&m(e,`nesting exceeded maxDepth (${e.maxDepth})`),e.depth++;let o=1,s=!1,u=!1,c=null;const d=Ca();let g=t===Gn||t===xr,f=g;const p=g;if(i&&j(e,!0)&&(s=!0,e.lineIndent>n?o=1:e.lineIndent===n?o=0:o=-1),e.position===e.lineStart&&le(e))return e.depth--,!1;if(o===1)for(;;){const v=e.input.charCodeAt(e.position),_=en(e);if(s&&o!==1&&(v===33||v===38))break;if(s&&p&&(d.tagStart!==C||d.anchorStart!==C)&&(v===33||v===38)){const k=en(e),w=n+1;if(Bt(e,e.position-e.lineStart,w,d)&&e.events[k.eventsLength]?.type===3)return e.depth--,!0;Re(e,k)}if(s&&(v===33&&d.tagStart!==C||v===38&&d.anchorStart!==C)||!Es(e,d,t===Be)&&!Is(e,d))break;c===null&&(c=_),j(e,!0)?(s=!0,f=p,e.lineIndent>n?o=1:e.lineIndent===n?o=0:o=-1):f=!1}if(f&&(f=s||r),o===1||t===Gn){const v=t===Be||t===Zt?n:n+1,_=e.position-e.lineStart;if(o===1)if(f&&(Aa(e,_,d)||Bt(e,_,v,d))||Ms(e,v,d))u=!0;else{const k=e.input.charCodeAt(e.position);if(c!==null&&l&&p&&!f&&k!==124&&k!==62){const w=en(e),b=c.position-c.lineStart;Re(e,c),Bt(e,b,v,Ca())&&e.events[w.eventsLength]?.type===3?u=!0:Re(e,w)}!u&&(g&&Ls(e,v,d)||Os(e,v,d)||Ps(e,v,d)||$s(e,d)||Fs(e,v,t,d))&&(u=!0)}else o===0&&(u=f&&Aa(e,_,d))}return g=g&&!u,!u&&(d.anchorStart!==C||d.tagStart!==C||g)&&(qe(e,C,C,d.anchorStart,d.anchorEnd,d.tagStart,d.tagEnd,1),u=!0),e.depth--,u||d.anchorStart!==C||d.tagStart!==C}function js(e){if(e.lineIndent>0||e.input.charCodeAt(e.position)!==37)return!1;e.position++;const n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position));)e.position++;const t=e.input.slice(n,e.position),i=[];for(t.length===0&&m(e,"directive name must not be less than one character in length");e.input.charCodeAt(e.position)!==0&&!O(e.input.charCodeAt(e.position));){for(;_e(e.input.charCodeAt(e.position));)e.position++;if(e.input.charCodeAt(e.position)===35||O(e.input.charCodeAt(e.position))||e.input.charCodeAt(e.position)===0)break;const r=e.position;for(;e.input.charCodeAt(e.position)!==0&&!H(e.input.charCodeAt(e.position));)e.position++;i.push(e.input.slice(r,e.position))}if(O(e.input.charCodeAt(e.position))&&Jn(e),t==="YAML"){e.directives.some(l=>l.kind==="yaml")&&m(e,"duplication of %YAML directive"),i.length!==1&&m(e,"YAML directive accepts exactly one argument");const r=/^([0-9]+)\.([0-9]+)$/.exec(i[0]);r===null&&m(e,"ill-formed argument of the YAML directive"),parseInt(r[1],10)!==1&&m(e,"unacceptable YAML version of the document"),e.directives.push({kind:"yaml",version:i[0]})}else if(t==="TAG"){i.length!==2&&m(e,"TAG directive accepts exactly two arguments");const[r,l]=i;Nr.test(r)||m(e,"ill-formed tag handle (first argument) of the TAG directive"),Ar.call(e.tagHandlers,r)&&m(e,`there is a previously declared suffix for "${r}" tag handle`),ws.test(l)||m(e,"ill-formed tag prefix (second argument) of the TAG directive"),e.tagHandlers[r]=l,e.directives.push({kind:"tag",handle:r,prefix:l})}return!0}function Ds(e){e.directives=[],e.tagHandlers=Object.create(null);let n=!1;for(j(e,!0);js(e);)n=!0,j(e,!0);let t=!1,i=!1,r=!0;if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45&&G(e.input.charCodeAt(e.position+3))){t=!0;const s=e.line;e.position+=3,j(e,!0),r=e.line>s}else n&&m(e,"directives end mark is expected");const l=e.events.length;if(!t&&e.position===e.lineStart&&e.input.charCodeAt(e.position)===46&&le(e)){e.position+=3,j(e,!0);return}if(Ss(e,t,!1),ce(e,e.lineIndent-1,Gn,!1,r,r)||M(e),j(e,!0),e.position===e.lineStart&&le(e)&&(i=e.input.charCodeAt(e.position)===46,i)){const s=e.line;e.position+=3,j(e,!0),e.line===s&&e.position<e.length&&m(e,"end of the stream or a document separator is expected")}const o=e.events[l];o?.type===1&&(o.explicitEnd=i),Le(e),!i&&e.position<e.length&&!(e.position===e.lineStart&&le(e))&&m(e,"end of the stream or a document separator is expected")}function Us(e,n){const t=e.length,i={...Ri,...n,input:`${e}\0`,length:t,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]},r=e.indexOf("\0");for(r!==-1&&wt(e,r,"null byte is not allowed in input",i.filename),i.input.charCodeAt(i.position)===65279&&i.position++;i.position<i.length&&(j(i,!0),!(i.position>=i.length));){const l=i.position;Ds(i),i.position===l&&m(i,"can not read a document")}return i.events}var Bs={...Ri,...Li};function zs(e,n={}){const t={...Bs,...n},i=String(e),r=Object.keys(Ri),l=Object.keys(Li);return _s(Us(i,ga(t,r)),{...ga(t,l),source:i})}function Ws(e,n){const t=zs(e,n);if(t.length===0)throw new Kn("expected a document, but the input is empty");if(t.length===1)return t[0];throw new Kn("expected a single document in the stream, but found more")}es.withTags({...Jt,resolve:(e,n,t)=>{const i=Jt.resolve(e,n,t);return i===S?mr.resolve(e,n,t):i}},{...Xt,resolve:(e,n,t)=>{const i=Xt.resolve(e,n,t);return i===S?yr.resolve(e,n,t):i}});function Hs(e){if(e.trim()==="")return{};const t=Ws(e);if(t==null)return{};if(typeof t!="object"||Array.isArray(t))throw new Error(".agent-user.yml must parse to an object");return t}const xa={id:"welcome",title:"Welcome — who are you?",navLabel:"You",subtitle:"Your name and language. Stored in .agent-user.yml; we pre-fill what we can detect.",kind:"welcome"},Na={id:"profile",title:"Which experience?",navLabel:"Experience",subtitle:"Pick the experience that fits you — developer · content · founder · agency · finance · ops. It selects your default command/skill surface and persona pre-selection. Cost tier is a secondary knob on a later step. You can switch later with `agent-config use --profile=<id>`.",kind:"form",paths:["profile.id"]},Ys=[{id:"ai-tools",title:"Which AI tools do you use?",navLabel:"AI tools",subtitle:"Pick the editors and CLIs that should pick up this config. Auto-detect runs first; you can override.",kind:"aiTools"},{id:"roles",title:"What do you work on?",navLabel:"Roles",subtitle:"Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in .agent-user.yml.",kind:"roles"},{id:"packs",title:"Which capability packs do you want?",navLabel:"Packs",subtitle:"Founder-strategy, finance-basic, gtm-sales, ops-people, ai-video — pick zero or more. You can change this later.",kind:"packs"},{id:"legal-consent",title:"Legal review-prep — not legal advice",navLabel:"Legal consent",subtitle:"Only relevant if you picked the legal-review-prep pack. It provides templates and general information, never legal advice — check the box to acknowledge before it activates. Leave unchecked otherwise; the pack stays inactive.",kind:"form",paths:["legal_review_prep.acknowledged"]}],Ea=[{id:"identity",title:"Editor & behaviour",navLabel:"Preferences",subtitle:"Your IDE plus how the agent behaves: autonomy, output verbosity, PR-comment style. rtk presence is auto-detected (see the rtk row). Your name lives in .agent-user.yml (later step).",kind:"form",paths:["personal.ide","personal.open_edited_files","personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon"]},{id:"cost",title:"Budgets, rules & cadence",navLabel:"Budgets & cadence",subtitle:"Independent levers: rule_loading_tier (how many behavioural rules load — token footprint), cost.budgets (optional USD ceilings), model.auto_switch (per-skill model tier), plus quality/roadmap cadence and memory thresholds.",kind:"form",paths:["rule_loading_tier","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch","tokens.rich_skills","roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci","memory.review_threshold","memory.redact_patterns"]},{id:"user-md",title:"Your .agent-user.yml",navLabel:"User profile",subtitle:"Identity, voice, preferences. Stored at agents/settings/.agent-user.yml. Skip to leave empty.",kind:"userMd"},{id:"review",title:"Review & finish",navLabel:"Review",subtitle:"These keys will change. Confirm to write .agent-settings.yml and .agent-user.yml atomically.",kind:"review"}];function Or(e={}){return e.extended===!0?[xa,Na,...Ys,...Ea]:[xa,Na,...Ea]}function St(e,n={}){const t=Or(n),i=Math.max(0,Math.min(t.length-1,e));return t[i]}function qs(e){const n={},t=i=>{n[i]=!0;const r=e.clusterOf.get(i);r!==void 0&&(n[r]=!0)};for(const i of e.installed)t(i);for(const i of e.roleDefaults)t(i);for(const i of e.detected)t(i);return n}function Ks(e,n){const t=new Set(n);return e.filter(i=>i!=="engineering-base"&&!t.has(i)).sort()}function Vs(e,n){const t={type:"object",properties:{},...e.description!==void 0?{description:e.description}:{}},i=t.properties,r=e.properties??{};for(const l of n){const o=l.split(".").filter(F=>F.length>0);if(o.length===0)continue;const[s,u,c]=o;if(s===void 0)continue;const d=r[s];if(d===void 0)continue;if(u===void 0){i[s]=d;continue}const g=d.properties?.[u];if(g===void 0)continue;const p=i[s]??{type:"object",properties:{},...d.description!==void 0?{description:d.description}:{}},v=p.properties??={};if(c===void 0){v[u]=g,i[s]=p;continue}const _=g.properties?.[c];if(_===void 0)continue;const w=v[u]??{type:"object",properties:{},...g.description!==void 0?{description:g.description}:{}},b=w.properties??={};b[c]=_,v[u]=w,i[s]=p}return t}function Gs({current:e,total:n}){const t=Math.max(1,n),i=Math.max(0,Math.min(t-1,e)),r=Array.from({length:t},(o,s)=>s<=i),l=Math.round((i+1)/t*100);return a("div",{class:"ac-wizard__progress",role:"progressbar","aria-valuenow":i+1,"aria-valuemin":1,"aria-valuemax":t,"aria-valuetext":`Step ${i+1} of ${t} (${l}%)`,children:r.map((o,s)=>a("span",{class:`ac-wizard__progress-segment${o?" ac-wizard__progress-segment--filled":""}`,"aria-hidden":"true"},s))})}function Js({step:e,index:n,total:t}){return a("header",{class:"ac-page__header ac-wizard__header",children:[a("p",{class:"ac-wizard__step-count",children:["Step ",n+1," of ",t]}),a("div",{class:"ac-wizard__header-text",children:[a("h1",{children:e.title}),a("p",{class:"ac-wizard__subtitle",children:e.subtitle})]}),a(Gs,{current:n,total:t})]})}function Xs(e){const n=e.canFinish??!0,t=e.completed??!1;return a("div",{class:"ac-form__actions ac-wizard__nav",children:[a("button",{type:"button",class:"ac-button",disabled:!e.canGoPrev||e.busy,onClick:e.onPrev,children:"Back"}),e.canSkip&&e.onSkip!==void 0?a("button",{type:"button",class:"ac-button ac-wizard__skip",disabled:e.busy,onClick:e.onSkip,children:e.skipLabel??"Skip"}):null,e.isLast?t?null:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy||!n,onClick:e.onFinish,children:e.busy?"Saving…":"Finish & save"}):a("button",{type:"button",class:"ac-button ac-button--primary",disabled:!e.canGoNext||e.busy,onClick:e.onNext,children:e.nextLabel??"Next"})]})}function Pr(e,n){return e.kind!=="form"||e.paths===void 0?!1:!!(e.paths.includes(n)||e.id==="cost"&&(n.startsWith("telegraph.")||n.startsWith("verbosity.")))}function Zs(e,n){return e.kind==="userMd"?n==="body"||n.startsWith("body."):Pr(e,n)}function Qs(e,n){for(const t of Object.keys(n.errors))if(Zs(e,t))return!0;return!1}function ec(e,n){if(Qs(e,n))return{label:"needs attention",tone:"error"};if(e.kind==="userMd")return n.userMdChanged?{label:n.userMdAction==="create"?"will create":"will replace",tone:"changed"}:{label:"",tone:"idle"};if(e.kind==="form"){const t=n.changes.filter(i=>Pr(e,i.path)).length;return t===0?{label:"",tone:"idle"}:{label:`${t} change${t===1?"":"s"}`,tone:"changed"}}if(e.kind==="aiTools"){const t=n.selectedToolsCount??0;return t===0?{label:"",tone:"idle"}:{label:`${t} tool${t===1?"":"s"}`,tone:"changed"}}if(e.kind==="packs"){const t=n.selectedPacksCount??0;return t===0?{label:"",tone:"idle"}:{label:`${t} pack${t===1?"":"s"}`,tone:"changed"}}return{label:"",tone:"idle"}}function nc(e){const n=e.steps.filter((s,u)=>u!==e.currentIndex),t=e.packRemovals??[],i=e.selectedToolIds??[],r=e.packAdditions??[],l=e.changes.length,o=i.length>0||r.length>0||l>0||e.userMdChanged;return a(L,{children:[o?a("section",{class:"ac-review-summary","aria-label":"What happens on Finish",children:[a("h2",{class:"ac-review-summary__title",children:"What happens on Finish"}),a("ul",{class:"ac-review-summary__list",children:[l>0?a("li",{children:[a("strong",{children:l})," setting",l===1?"":"s"," will change"," ","in ",a("code",{children:".agent-settings.yml"}),"."]}):a("li",{children:"No settings change."}),e.userMdChanged?a("li",{children:[a("code",{children:".agent-user.yml"})," will be"," ",e.userMdAction==="create"?"created":"updated","."]}):null,i.length>0?a("li",{children:["Config is installed for ",i.length," tool",i.length===1?"":"s",":",a("span",{class:"ac-review-summary__chips",children:i.map(s=>a("code",{class:"ac-review-summary__chip",children:s},s))})]}):null,r.length>0?a("li",{children:["New pack",r.length===1?"":"s",":",a("span",{class:"ac-review-summary__chips",children:r.map(s=>a("code",{class:"ac-review-summary__chip",children:s},s))})]}):null]})]}):null,t.length>0?a("div",{class:"ac-review-removals",role:"alert",children:[a("p",{class:"ac-review-removals__title",children:["⚠️ ",t.length===1?"1 installed pack will be removed":`${t.length} installed packs will be removed`]}),a("ul",{class:"ac-review-removals__list",children:t.map(s=>a("li",{children:a("code",{children:s})},s))}),a("label",{class:"ac-review-removals__confirm",children:[a("input",{type:"checkbox",checked:e.removalsConfirmed??!1,onChange:s=>{e.onConfirmRemovals?.(s.currentTarget.checked)}}),a("span",{children:"I understand these packs will no longer be installed. Re-check them on the packs step to keep them."})]})]}):null,a("nav",{class:"ac-wizard__review-nav","aria-label":"Jump back to a step",children:[a("p",{class:"ac-wizard__review-nav-label",children:"Jump back to a step:"}),a("ul",{class:"ac-wizard__review-nav-list",children:n.map(s=>{const u=e.steps.indexOf(s),c=ec(s,e),d=c.tone==="error"?"ac-wizard__review-nav-button ac-wizard__review-nav-button--error":"ac-wizard__review-nav-button";return a("li",{children:a("button",{type:"button",class:d,onClick:()=>{e.onJump(u)},children:[a("span",{class:"ac-wizard__review-nav-index",children:u+1}),a("span",{class:"ac-wizard__review-nav-text",children:s.navLabel}),c.label!==""?a("span",{class:`ac-wizard__review-nav-status ac-wizard__review-nav-status--${c.tone}`,children:c.label}):null]})},s.id)})})]})]})}function tc(e){const n=e.abortedAt??"unknown time",t=e.abortNote??"no further detail recorded",i=e.writesSinceRollback;return a("aside",{class:"ac-banner ac-banner--recovery",role:"alert",children:[a("strong",{children:"Previous install was interrupted."}),a("p",{children:["Aborted at ",a("code",{children:n})," — ",t,". ",i," write",i===1?"":"s"," landed before the abort marker."]}),a("p",{children:"Pick how to recover before continuing. Resume reopens the wizard fresh, Rollback discards the abort state, Ignore hides this banner without touching the log."}),a("div",{class:"ac-banner__actions",children:[a("button",{type:"button",disabled:e.busy,onClick:()=>e.onResume(),children:"Resume install"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onRollback(),children:"Rollback"}),a("button",{type:"button",disabled:e.busy,onClick:()=>e.onIgnore(),children:"Ignore"})]})]})}function ic(){return a("section",{class:"ac-continue-screen","aria-labelledby":"ac-continue-title",children:[a("h2",{id:"ac-continue-title",children:"Install complete — continue with setup?"}),a("p",{children:"Your install selections (AI tools, roles, capability packs) are captured. Use the footer to continue:"}),a("ul",{children:[a("li",{children:[a("strong",{children:"Next"})," — go through the remaining personalisation steps: editor + tooling, personality, cost profile, roadmap & quality, memory, your",a("code",{children:" .agent-user.yml"}),", and finally the project module roots."]}),a("li",{children:[a("strong",{children:"Finish install here"})," — skip the rest and write ",a("code",{children:".agent-settings.yml"})," with the install-only selections. You can re-run ",a("code",{children:"agent-config setup"}),"later to pick up the personalisation steps."]})]})]})}function ac(e){const n=e.version??"unknown";return a("section",{class:"ac-backup-screen","aria-labelledby":"ac-backup-title",children:[a("h2",{id:"ac-backup-title",children:"Existing v3 install detected"}),a("p",{children:["Found a v3.x install at ",a("code",{children:e.sourcePath})," ","(VERSION: ",a("code",{children:n}),"). v4 is a hard-cut release with no auto-migration — settings, identity, and history layouts changed. The wizard can back up the v3 tree before writing the v4 layout so you can roll back manually if needed."]}),e.error!==null?a("p",{class:"ac-banner ac-banner--error",children:["Backup failed: ",e.error]}):null,a("ul",{children:[a("li",{children:[a("strong",{children:"Backup v3 and proceed"})," — copies the tree to ",a("code",{children:e.backupTarget}),", then runs the v4 install. Restore later with",a("code",{children:[" mv ",e.backupTarget," ",e.sourcePath]}),"."]}),a("li",{children:[a("strong",{children:"Abort, uninstall v3 first"})," — closes the wizard. You decide what to keep."]})]}),a("div",{class:"ac-backup-screen__actions",children:[a("button",{type:"button",class:"ac-button ac-button--primary",disabled:e.busy,onClick:()=>e.onBackupAndProceed(),children:e.busy?"Backing up…":"Backup v3 and proceed"}),a("button",{type:"button",class:"ac-button",disabled:e.busy,onClick:()=>e.onAbort(),children:"Abort, uninstall v3 first"})]})]})}const rc=[{title:"Restart your AI tools",detail:"Editors and CLIs pick up the new skills, rules, and commands on their next start."},{title:"Verify the installation",detail:"A read-only health report — scope, deployed files, drift.",command:"agent-config doctor"},{title:"Tune your settings any time",detail:"Opens the configuration GUI (global settings; --project for a project).",command:"agent-config config"},{title:"Initialize a project",detail:"Adds the minimal agents/ bridge + .gitignore block to a repository.",command:"agent-config init --project"},{title:"Stay up to date",detail:"Upgrades the global install and additively syncs your settings.",command:"agent-config upgrade"}];function lc({text:e}){const[n,t]=Ni(!1);return a("button",{type:"button",class:"ac-button ac-checklist__copy",onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{t(!0),setTimeout(()=>{t(!1)},1500)})},children:n?"Copied ✓":"Copy"})}function oc({message:e}){return a("div",{class:"ac-checklist",children:[a("div",{class:"ac-checklist__hero",children:[a("h2",{class:"ac-checklist__headline",children:"Setup complete"}),e!==null?a("p",{class:"ac-checklist__message",children:e}):null]}),a("ol",{class:"ac-checklist__items",children:rc.map(n=>a("li",{class:"ac-checklist__item",children:[a("div",{class:"ac-checklist__text",children:[a("span",{class:"ac-checklist__item-title",children:n.title}),a("span",{class:"ac-checklist__item-detail",children:n.detail})]}),n.command!==void 0?a("div",{class:"ac-checklist__cmd-row",children:[a("code",{class:"ac-checklist__cmd",children:n.command}),a(lc,{text:n.command})]}):null]},n.title))}),a("p",{class:"ac-checklist__close-hint",children:"You can close this browser window — the local server shuts down on its own."})]})}const Lr=h(!1),nn=h(null),x=h(null),Xn=h(!1),Zn=h(!1),ye=h(0),Fi=h(null),W=h({}),Rr=h({}),Fr=h(0),Fe=h({}),$=h(null),ue=h(null),Mi=h(!1),ti=h(!1),Ct=h(!1),Mr=h({}),Tt=h([]);h("global");const Ee=h(!1),D=h(!1),sc=h(!1),Qn=h(!1),et=h(null),ji=h([]),nt=h({}),tt=h(!0),it=h(""),at=h("agents");h(!1);const jr=h(null),cc=[{id:"claude-code",label:"Claude Code"},{id:"claude-desktop",label:"Claude Desktop"},{id:"cursor",label:"Cursor"},{id:"windsurf",label:"Windsurf"},{id:"cline",label:"Cline"},{id:"gemini-cli",label:"Gemini CLI"},{id:"copilot",label:"GitHub Copilot"},{id:"augment",label:"Augment"},{id:"aider",label:"Aider"},{id:"codex",label:"Codex"},{id:"roocode",label:"Roo Code"},{id:"continue",label:"Continue"},{id:"kilocode",label:"Kilo Code"},{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"},{id:"kiro",label:"Kiro"},{id:"qoder",label:"Qoder"},{id:"opencode",label:"OpenCode"},{id:"trae",label:"Trae"},{id:"antigravity",label:"Antigravity"},{id:"codebuddy",label:"CodeBuddy"},{id:"droid",label:"Droid"},{id:"warp",label:"Warp"}],ii=h(!1),Me=h(!1),de=h(null),At=h([]),xt=h([]),be=h([]),ai=h(!1),bn=h([]),Z=h({}),Dr=h(!1),ri=h(!1),$n=h(!1),Di=h({}),Ia=h(!1),Ur=h(null),Br=h(null),zr=h(null),Wr=h(null),li=h(null),Hr=h(null),oi=h("https://github.com/rtk-ai/rtk"),si=h(!1),Yr=h(null),uc=h(null),ci=h(null),qr=h("event4u-app/agent-switch"),Ui=h(!1);h(!1);h(null);h([]);h({});h({});const ee=h({}),ae=h({}),ui=h(!1),$a=h(!1);h({});h(null);h(null);h(!1);h(null);const rt=h(null),Kr=h(!1),di=h(null),fi=h(!1),hi=h(!1),pi=h(null),je=h(null),On=h(!1),Bi=h(!1);function Vr(){return Or({extended:D.value})}function ze(){return Vr().length}function dc(e){return e??new Date().toISOString()}function zi(e){return Math.max(0,Math.min(ze()-1,e))}function fc(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),t=e.definitions[n];if(t!==void 0)return t}return e}async function hc(){try{return await y("/api/v1/settings")}catch(e){if(e instanceof E&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0)return{values:n.defaults,lastModified:n.lastModified??0,path:n.path??".agent-settings.yml",schema:n.schema};const t=await y("/api/v1/schema");return{values:{},lastModified:0,path:".agent-settings.yml",schema:t.settings}}throw e}}async function pc(){try{const e=await y("/api/v1/install/recovery");rt.value=e.incomplete?e:null}catch{rt.value=null}}async function vc(){try{const e=await y("/api/v1/install/legacy-v3");di.value=e.present?e:null}catch{di.value=null}}async function gc(){hi.value=!0,pi.value=null;try{await y("/api/v1/install/backup-v3",{method:"POST"}),fi.value=!0}catch(e){pi.value=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{hi.value=!1}}async function zt(e){try{await y("/api/v1/install/recovery/dismiss",{method:"POST",body:{reason:e}})}catch(n){x.value={message:n instanceof Error?n.message:String(n),tone:"error"};return}rt.value=null,Kr.value=!0}async function _c(){nn.value=null;try{pc(),vc();const[e,n]=await Promise.all([y("/api/v1/wizard/state"),hc()]);Fi.value=fc(n.schema),Fr.value=n.lastModified,Rr.value=n.values,Mr.value=n.legacyHints??{},D.value=e.extendedSteps===!0,je.value=e.wizardMode??null;const t=Object.keys(e.partial??{});W.value=t.length>0?{...n.values,...e.partial}:n.values,ye.value=zi(e.step),Ee.value=!1,Lr.value=!0;const i=St(ye.value,{extended:D.value});(i.kind==="welcome"||i.kind==="userMd"||i.kind==="review")&&Wi(),(i.kind==="roles"||i.kind==="aiTools"||i.kind==="packs")&&kn(),i.kind==="roles"&&Hi(),i.kind==="aiTools"&&Nt(),i.id==="identity"&&(Gr(),Jr()),i.kind==="review"&&Xr()}catch(e){e instanceof E?nn.value=z(e.body.error??{code:"UNKNOWN",message:e.message}):nn.value=e instanceof Error?e.message:String(e)}}function mc(e,n){return e.identity.name.trim()!==""?e:{...e,identity:{...e.identity,name:n}}}async function Wi(){if(!ti.value)try{const e=await y("/api/v1/user-md");if(Mi.value=e.exists,e.exists&&e.identity!==null){const n=va(e.identity);ue.value=n,$.value=n}else{let n;try{const i=await y("/api/v1/user-md/template");n=va(Hs(i.body))}catch{n=_r()}const t=Mr.value.user_name;typeof t=="string"&&t.trim()!==""&&(n=mc(n,t)),ue.value=n,$.value=n}}catch(e){x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{ti.value=!0}}const yc=new Set(["python"]);async function kn(){if(!(ii.value||Me.value)){Me.value=!0,de.value=null;try{const[e,n]=await Promise.all([y("/api/v1/wizard/manifest"),y("/api/v1/wizard/auto-detect")]),t=(e.packs??[]).map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",requires_hint:l.requires_hint,cluster:l.cluster??void 0,workspaces:l.workspaces}));At.value=t,bn.value=(e.workspaces??[]).filter(l=>l.id!=="agent-config-maintainer").map(l=>({id:l.id,label:l.label??l.id,description:l.description??"",default_packs:l.default_packs??[],optional_packs:l.optional_packs??[],...l.example_roles!==void 0?{example_roles:l.example_roles}:{}}));const i=new Set(t.map(l=>l.id)),r=n.signals.map(l=>l.id.startsWith("pack-")?l.id.slice(5):l.id).filter(l=>i.has(l)).filter(l=>!yc.has(l));xt.value=r,be.value=(e.installedPacks??[]).filter(l=>i.has(l))}catch(e){e instanceof E?de.value=z(e.body.error??{code:"UNKNOWN",message:e.message}):de.value=e instanceof Error?e.message:String(e)}finally{Me.value=!1,ii.value=!0}}}async function Nt(){if(!(ri.value||$n.value)){$n.value=!0;try{const e=await y("/api/v1/wizard/detect-tools"),n=e.tools??{},t=e.configured??[];if(Di.value=n,Object.keys(ee.value).length===0){const i={};if(t.length>0)for(const r of t)i[r]=!0;else for(const[r,l]of Object.entries(n))l&&(i[r]=!0);ee.value=i}}catch{}finally{$n.value=!1,ri.value=!0}}}async function Gr(){if(!Ia.value){Ia.value=!0;try{const e=await y("/api/v1/wizard/detect-rtk"),n=e.installed===!0;Ur.value=n,Br.value=e.present===!0,zr.value=e.identity??null,Wr.value=e.version??null,li.value=e.installCommand??null,Hr.value=e.installCommands??null,typeof e.repo=="string"&&(oi.value=e.repo);const t=W.value.personal??{};W.value={...W.value,personal:{...t,rtk_installed:n}}}catch{}}}async function Jr(){if(!si.value){si.value=!0;try{const e=await y("/api/v1/wizard/detect-agent-switch");Yr.value=e.installed===!0,uc.value=e.version??null,ci.value=e.installCommand??null,typeof e.repo=="string"&&(qr.value=e.repo),Ui.value=e.dismissed===!0}catch{}}}async function bc(e,n){try{await y("/api/v1/wizard/state",{method:"POST",body:{step:e,totalSteps:ze(),partial:n,startedAt:dc(null)}})}catch(t){x.value={message:t instanceof Error?t.message:String(t),tone:"error"}}}async function Xr(){Zn.value=!0;try{const e=await y("/api/v1/settings/diff",{method:"POST",body:{values:W.value,ifUnmodifiedSince:Fr.value}});Tt.value=e.changes,Fe.value={}}catch(e){e instanceof E?(Fe.value=mt(e.body.error??{message:e.message}),x.value={message:z(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Zn.value=!1}}function lt(){return Ct.value?!1:$.value===null||ue.value===null?$.value!==ue.value:JSON.stringify($.value)!==JSON.stringify(ue.value)}async function Ie(e){const n=zi(e);await bc(n,W.value),ye.value=n,x.value=null;const t=St(n,{extended:D.value});(t.kind==="welcome"||t.kind==="userMd")&&Wi(),(t.kind==="roles"||t.kind==="aiTools"||t.kind==="packs")&&kn(),t.kind==="roles"&&Hi(),t.kind==="packs"&&It(),t.kind==="aiTools"&&Nt(),t.id==="identity"&&(Gr(),Jr()),t.kind==="review"&&Xr()}function Et(){const e=ae.value,n=new Map(At.value.map(l=>[l.id,l])),t=Object.entries(e).filter(([,l])=>l===!0).map(([l])=>l).filter(l=>{const o=n.get(l)?.cluster;return o===void 0||e[o]===!0}),i=new Set,r=l=>{if(!i.has(l)){i.add(l);for(const o of n.get(l)?.requires_hint??[])r(o)}};for(const l of t)r(l);return[...i].sort()}async function Hi(){if(await Promise.all([kn(),Wi()]),Dr.value||Object.values(Z.value).some(Boolean))return;const e=$.value?.role??[];if(e.length===0)return;const n=new Set(bn.value.map(i=>i.id)),t={};for(const i of e)n.has(i)&&(t[i]=!0);Object.keys(t).length!==0&&(Z.value=t,It())}function It(){if(ui.value)return;const e=Object.entries(Z.value).filter(([,r])=>r===!0).map(([r])=>r),n=new Map(bn.value.map(r=>[r.id,r])),t=[];for(const r of e)for(const l of n.get(r)?.default_packs??[])t.push(l);const i=new Map;for(const r of At.value)r.cluster!==void 0&&i.set(r.id,r.cluster);ae.value=qs({installed:be.value,roleDefaults:t,detected:xt.value,clusterOf:i})}function kc(){const e=Object.entries(ee.value).filter(([,i])=>i===!0).map(([i])=>i);if(e.length===0)return null;const n=Et(),t={schema_version:"wizard-v2",tools:e,packs:n,settings:W.value};return ge.value?.dryRun===!0&&(t.dry_run=!0),t}async function wc(){Xn.value=!0,x.value=null;try{const e={settings:W.value},n=Object.entries(Z.value).filter(([,u])=>u===!0).map(([u])=>u),t=$.value!==null&&typeof $.value.identity?.name=="string"&&$.value.identity.name.trim().length>0;$.value!==null&&t&&(lt()||n.length>0)&&(e.identity=n.length>0?{...$.value,role:n}:$.value);const i=await y("/api/v1/wizard/finish",{method:"POST",body:e}),r="You can close this browser window now.",l=i.dryRun===!0?"Dry-run complete — no files written. Settings would be saved.":Array.isArray(i.writtenPaths)?`Saved (${i.writtenPaths.join(", ")}). Wizard complete.`:"Wizard complete.",o=D.value?kc():null;let s="";if(o!==null&&o.dry_run===!0)try{await y("/api/v1/wizard/apply",{method:"POST",body:o}),s=" Installer preview OK (dry-run) — no files written."}catch(u){s=` Installer preview failed: ${u instanceof E?z(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}.`}else if(o!==null)try{let u=null;await Ol("/api/v1/wizard/apply",o,g=>{g.type==="error"&&(u=typeof g.message=="string"?g.message:"install failed")});const c=o.tools.length,d=o.packs.length;s=u!==null?` Installer failed: ${u}. Settings were saved; re-run the wizard to retry.`:` Installer applied ${c} tool${c===1?"":"s"}`+(d>0?` and ${d} pack${d===1?"":"s"}.`:".")}catch(u){s=` Installer bridge failed: ${u instanceof E?z(u.body.error??{code:"UNKNOWN",message:u.message}):u instanceof Error?u.message:String(u)}. Settings were saved; re-run the wizard to retry the install plan.`}x.value={message:`${l}${s} ${r}`,tone:"success"},ye.value=zi(ze()-1),Rr.value=W.value,ue.value=lt()?$.value:ue.value,Tt.value=[],Ee.value=!0}catch(e){e instanceof E?(Fe.value=mt(e.body.error??{message:e.message}),x.value={message:z(e.body.error??{code:"UNKNOWN",message:e.message}),tone:"error"}):x.value={message:e instanceof Error?e.message:String(e),tone:"error"}}finally{Xn.value=!1}}async function Sc(){Bi.value=!0,await Promise.all([kn(),Nt()]),await Hi(),It(),await Ie(ze()-1)}function Cc(){ne(()=>{kn(),Nt()},[]);const e=Me.value||$n.value||!ii.value||!ri.value,n=Object.values(Di.value).filter(Boolean).length,t=be.value.length,i=xt.value.filter(r=>!be.value.includes(r)).length;return a("div",{class:"ac-start",children:[a("section",{class:"ac-start__card ac-start__card--primary",children:[a("h2",{class:"ac-start__title",children:"Recommended setup"}),a("p",{class:"ac-start__desc",children:"The fastest path — we pre-select everything we can detect and you confirm one review screen before anything is written."}),a("ul",{class:"ac-start__facts",children:[a("li",{children:e?"Detecting your AI tools…":n===0?"No AI tools detected — pick them on the review screen.":`${n} AI tool${n===1?"":"s"} detected and pre-selected.`}),a("li",{children:e?"Detecting capability packs…":t>0?`${t} installed pack${t===1?"":"s"} kept${i>0?`, ${i} more auto-detected`:""}.`:i>0?`${i} capability pack${i===1?"":"s"} auto-detected.`:"No packs pre-selected — add them any time later."}),a("li",{children:"Settings keep their current values (or safe defaults on a first run)."}),a("li",{children:"Nothing is written until you confirm the review screen."})]}),a("button",{type:"button",class:"ac-button ac-button--primary ac-start__cta",disabled:e,onClick:()=>{Sc()},children:e?"Detecting…":"Use recommended setup"})]}),a("section",{class:"ac-start__card",children:[a("h2",{class:"ac-start__title",children:"Customize"}),a("p",{class:"ac-start__desc",children:"Walk through every step — tools, roles, packs, behaviour, budgets — and tune each choice yourself."}),a("button",{type:"button",class:"ac-button ac-start__cta",onClick:()=>{Bi.value=!0},children:"Customize step by step"})]})]})}const Tc=["de","en","en-US","en-GB","fr","es","it","nl","pt","pt-BR"];function Ac(){if($a.value)return;const e=$.value;if(e===null)return;$a.value=!0;let n=e;if(e.identity.name.trim()===""){const t=ge.value?.systemUser;t!==void 0&&t.trim()!==""&&(n={...n,identity:{...n.identity,name:t}})}if(!Mi.value&&typeof navigator<"u"){const t=(navigator.language||"").split("-")[0];t.length>=2&&(n={...n,language:t})}n!==e&&($.value=n)}function xc(){const e=$.value;if(ne(()=>{Ac()},[e]),e===null)return a("p",{children:"Loading…"});const n=t=>{$.value={...t,last_updated:new Date().toISOString().slice(0,10)},Ct.value=!1};return a("div",{class:"ac-wizard-step-stub ac-wizard__module-fields",children:[a("p",{children:["Tell the agent who you are. We pre-filled what we could detect — adjust freely. Stored in ",a("code",{children:".agent-user.yml"}),"."]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-name",children:"Name"}),a("input",{class:"ac-input",id:"welcome-name",type:"text",placeholder:"How should the agent address you?",value:e.identity.name,onInput:t=>n({...e,identity:{...e.identity,name:t.currentTarget.value}})})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"welcome-lang",children:"Language"}),a("input",{class:"ac-input",id:"welcome-lang",type:"text",list:"welcome-lang-list",placeholder:"BCP-47 code, e.g. de, en, en-US",value:e.language,onInput:t=>n({...e,language:t.currentTarget.value})}),a("datalist",{id:"welcome-lang-list",children:Tc.map(t=>a("option",{value:t},t))})]})]})}function Nc(){const e=ee.value,n=Di.value;return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the AI tools you use. Tools detected on this machine are pre-selected on first run. The installer wires each selected tool's surface (skills, rules, commands) on apply; you can change this list later by re-running the wizard."}),a("ul",{class:"ac-wizard__tool-list",children:cc.map(t=>{const i=n[t.id]===!0;return a("li",{class:"ac-wizard__tool-row",children:[a("label",{class:"ac-wizard__tool-label",children:[a("input",{type:"checkbox",checked:e[t.id]??!1,onChange:r=>{const l=r.currentTarget.checked;ee.value={...e,[t.id]:l}}})," ",t.label]}),a("span",{class:`ac-badge ${i?"ac-badge--installed":"ac-badge--missing"}`,title:i?"Detected on this machine":"Not detected on this machine",children:i?"installed":"not installed"})]},t.id)})})]})}function Ec(){if(Me.value)return a("p",{children:"Loading roles…"});if(de.value!==null)return a("div",{class:"ac-wizard-step-stub",children:a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",de.value]})});const e=Z.value,n=bn.value,t=(i,r)=>{Dr.value=!0,Z.value={...Z.value,[i]:r},It()};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:["Pick the areas you work in. We use them to recommend capability packs on the next step, and they become your roles in",a("code",{children:" .agent-user.yml"}),"."]}),n.length===0?a("p",{children:a("em",{children:"No roles available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:n.map(i=>a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:e[i.id]??!1,onChange:r=>{t(i.id,r.currentTarget.checked)}}),a("span",{class:"ac-pack-tile__title",children:i.label})]}),(i.example_roles??[]).length>0?a("p",{class:"ac-pack-tile__role",children:["e.g. ",(i.example_roles??[]).join(", ")]}):null,i.description!==""?a("p",{class:"ac-pack-tile__desc",children:i.description}):null]},i.id))})]})}function Ic(){if(Me.value)return a("p",{children:"Loading discovery manifest…"});if(de.value!==null)return a("div",{class:"ac-wizard-step-stub",children:[a("p",{class:"ac-banner ac-banner--error",children:["Discovery failed: ",de.value]}),a("p",{children:"The manifest endpoint is gated on extended-mode. Re-run the server with extended steps enabled to populate this list."})]});const e=ae.value,n=new Set(xt.value),t=new Set(be.value),i=p=>t.has(p)?a("span",{class:"ac-badge ac-badge--installed",children:"installed"}):n.has(p)?a("span",{class:"ac-badge ac-badge--detected",children:"auto-detected"}):null,r=new Map(bn.value.map(p=>[p.id,p.label])),l=Z.value,o=p=>{const v=(p??[]).filter(_=>_!=="agent-config-maintainer");return v.length===0?null:a("span",{class:"ac-pack-tile__ws",children:v.map(_=>a("span",{class:`ac-badge ac-badge--ws${l[_]===!0?" ac-badge--ws-active":""}`,title:l[_]===!0?"Matches a role you picked":"Workspace / area",children:r.get(_)??_},_))})},s=At.value.filter(p=>p.id!=="engineering-base"),u=new Map;for(const p of s)if(p.cluster!==void 0){const v=u.get(p.cluster)??[];v.push(p),u.set(p.cluster,v)}const c=new Set(s.filter(p=>p.cluster!==void 0).map(p=>p.id)),d=s.filter(p=>!c.has(p.id)),g=(p,v)=>{ui.value=!0,ae.value={...ae.value,[p]:v}},f=(p,v)=>{ui.value=!0;const _={...ae.value,[p]:v};if(v)for(const k of u.get(p)??[])_[k.id]===void 0&&(_[k.id]=!0);ae.value=_};return a("div",{class:"ac-wizard-step-stub",children:[a("p",{children:"Pick the capability packs to install. Auto-detected packs are pre-selected; engineering hygiene is included automatically when a pack needs it. A language tile expands to its frameworks — turn the language off to skip them all."}),d.length===0?a("p",{children:a("em",{children:"No packs available in the manifest."})}):a("div",{class:"ac-wizard__pack-grid",children:d.map(p=>{const v=u.get(p.id)??[],_=v.length>0,k=e[p.id]??!1;return a("section",{class:"ac-pack-tile",children:[a("label",{class:"ac-pack-tile__head",children:[a("input",{type:"checkbox",checked:k,onChange:w=>{const b=w.currentTarget.checked;_?f(p.id,b):g(p.id,b)}}),a("span",{class:"ac-pack-tile__title",children:p.label}),i(p.id)]}),o(p.workspaces),p.description!==""?a("p",{class:"ac-pack-tile__desc",children:p.description}):null,_?a("fieldset",{class:"ac-pack-tile__children",disabled:!k,children:v.map(w=>a("label",{class:"ac-pack-tile__child",children:[a("input",{type:"checkbox",checked:e[w.id]??!1,disabled:!k,onChange:b=>{g(w.id,b.currentTarget.checked)}}),a("span",{children:w.label}),i(w.id)]},w.id))}):null]},p.id)})})]})}function $c(){const e=Ur.value,n=Br.value,t=zr.value,i=Wr.value,r=Hr.value,l=e===null?a("span",{class:"ac-badge ac-badge--missing",children:"detecting…"}):e?a("span",{class:"ac-badge ac-badge--installed",children:["installed",i!==null?` (v${i})`:""]}):n===!0?a("span",{class:"ac-badge ac-badge--missing",children:t==="unknown-rtk"?"different tool":"unverified"}):a("span",{class:"ac-badge ac-badge--missing",children:"not installed"});return a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["rtk ",a("small",{children:"(Rust Token Killer — third-party, Apache-2.0)"})]}),l]}),n===!0&&t==="unknown-rtk"?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:["A binary named ",a("code",{children:"rtk"})," is on PATH, but it is not Rust Token Killer — two unrelated projects share the name (the other is Rust Type Kit). The token-saving integration stays off. See the upstream name-collision guidance:"]}),a("a",{class:"ac-button",href:`${oi.value}/blob/master/INSTALL.md`,target:"_blank",rel:"noreferrer noopener",children:"Open rtk install guide"})]}):null,n===!0&&t==="unverified"?a("p",{class:"ac-field__description",children:["rtk found but the identity check failed — verify manually with ",a("code",{children:"rtk gain"})," (Rust Token Killer renders a token-savings dashboard; the colliding Rust Type Kit does not)."]}):null,n===!1?a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:"rtk wraps verbose CLI output — upstream reports 60–90% token savings (their estimate). Install it, then re-open the wizard to pick up detection:"}),r!==null?a(L,{children:[r.recommendedLabel!==void 0?a("p",{class:"ac-field__description",children:[r.recommendedLabel,":"]}):null,a("code",{class:"ac-rtk-row__cmd",children:r.recommended}),r.manual!==void 0?a(L,{children:[a("p",{class:"ac-field__description",children:[r.manualLabel??"Manual",":"]}),a("code",{class:"ac-rtk-row__cmd",children:r.manual})]}):null,r.note!==void 0?a("p",{class:"ac-field__description",children:r.note}):null]}):li.value!==null?a("code",{class:"ac-rtk-row__cmd",children:li.value}):null,a("a",{class:"ac-button",href:oi.value,target:"_blank",rel:"noreferrer noopener",children:"Open rtk repo"})]}):null]})}async function Oc(){try{await y("/api/v1/wizard/dismiss-recommendation",{method:"POST",body:{id:"agent-switch"}})}catch(e){x.value={message:e instanceof Error?e.message:String(e),tone:"error"};return}Ui.value=!0}function Pc(){return!si.value||Yr.value!==!1||Ui.value?null:a("div",{class:"ac-rtk-row",children:[a("div",{class:"ac-rtk-row__head",children:[a("span",{class:"ac-rtk-row__label",children:["agent-switch ",a("small",{children:"(third-party, MIT)"})]}),a("span",{class:"ac-badge ac-badge--missing",children:"not installed"})]}),a("div",{class:"ac-rtk-row__install",children:[a("p",{class:"ac-field__description",children:["agent-switch isolates multiple agent accounts into per-account profiles (",a("code",{children:"CLAUDE_CONFIG_DIR"}),") so switching accounts never requires a re-login. Free and MIT-licensed."]}),ci.value!==null?a("code",{class:"ac-rtk-row__cmd",children:ci.value}):null,a("a",{class:"ac-button",href:`https://github.com/${qr.value}`,target:"_blank",rel:"noreferrer noopener",children:"Open agent-switch repo"}),a("button",{type:"button",class:"ac-button ac-button--small",onClick:()=>{Oc()},children:"Don't show again"})]})]})}function Lc(){const e=St(ye.value,{extended:D.value});if(D.value&&je.value==="install"&&e.id==="identity"&&!On.value)return a(ic,{});if(e.kind==="form"){const t=Vs(Fi.value,e.paths??[]);return a(L,{children:[e.id==="identity"?a($c,{}):null,e.id==="identity"?a(Pc,{}):null,a(Bl,{schema:t,values:W.value,errors:Fe.value,onChange:i=>{W.value=i}})]})}return e.kind==="userMd"?!ti.value||$.value===null?a("p",{children:"Loading .agent-user.yml…"}):a(Yl,{value:$.value,errors:Fe.value,hideRole:D.value&&je.value==="install",hideIdentityBasics:D.value&&je.value==="install",onChange:t=>{$.value=t,Ct.value=!1}}):e.kind==="welcome"?a(xc,{}):e.kind==="aiTools"?a(Nc,{}):e.kind==="roles"?a(Ec,{}):e.kind==="packs"?a(Ic,{}):a(nc,{steps:Vr(),currentIndex:ye.value,changes:Tt.value,errors:Fe.value,userMdChanged:lt(),userMdAction:Mi.value?"replace":"create",loading:Zn.value,onJump:t=>{Ie(t)},selectedToolsCount:Object.values(ee.value).filter(Boolean).length,selectedPacksCount:Object.values(ae.value).filter(Boolean).length,packRemovals:vi(),removalsConfirmed:ai.value,onConfirmRemovals:t=>{ai.value=t},selectedToolIds:Object.entries(ee.value).filter(([,t])=>t).map(([t])=>t),packAdditions:D.value?Et().filter(t=>t!=="engineering-base"&&!be.value.includes(t)):[]})}function vi(){return D.value?Ks(be.value,Et()):[]}function Oa({path:e}){if(ne(()=>{_c()},[]),!Lr.value||Fi.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Setup wizard"}),nn.value!==null?a("p",{class:"ac-banner ac-banner--error",children:nn.value}):a("p",{children:"Loading…"})]});const n=ye.value,t=ze(),i=St(n,{extended:D.value}),r=n===t-1,l=i.kind==="aiTools"&&Object.values(ee.value).filter(Boolean).length===0||i.kind==="roles"&&Object.values(Z.value).filter(Boolean).length===0||i.kind==="packs"&&Et().length===0,o=D.value&&je.value==="install"&&i.id==="identity"&&!On.value,s=rt.value,u=s!==null&&!Kr.value,c=di.value,d=c!==null&&c.present&&!fi.value,g=D.value&&je.value==="install"&&n===0&&!Bi.value&&!Ee.value;return d?a("div",{class:"ac-page",children:a(ac,{sourcePath:c.path,backupTarget:c.backupTarget,version:c.version,busy:hi.value,error:pi.value,onBackupAndProceed:()=>{gc()},onAbort:()=>{x.value={tone:"info",message:"Aborted. Uninstall v3 manually, then re-run `agent-config install`."},fi.value=!0}})}):g?a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:a("h1",{children:"Set up agent-config"})}),x.value!==null?a("p",{class:`ac-banner${x.value.tone==="error"?" ac-banner--error":""}`,children:x.value.message}):null,a(Cc,{})]}):a("div",{class:"ac-page",children:[a(Js,{step:i,index:n,total:t}),u?a(tc,{abortedAt:s.abortedAt,abortNote:s.abortNote,writesSinceRollback:s.writesSinceRollback,busy:Xn.value,onResume:()=>{zt("resume")},onRollback:()=>{zt("rollback")},onIgnore:()=>{zt("ignore")}}):null,x.value!==null&&!(Ee.value&&r&&x.value.tone==="success")?a("p",{class:`ac-banner${x.value.tone==="error"?" ac-banner--error":""}`,children:x.value.message}):null,a("div",{class:"ac-wizard__step",children:Ee.value&&r?a(oc,{message:x.value?.tone==="success"?x.value.message:null}):a(Lc,{})}),l?a("p",{class:"ac-wizard__hint",children:i.kind==="aiTools"?"Select at least one AI tool to continue.":i.kind==="roles"?"Select at least one role to continue.":"Select at least one capability pack to continue."}):null,a(Xs,{canGoPrev:n>0,canGoNext:!r&&!l,canSkip:o||i.kind==="userMd",skipLabel:o?"Finish install here":"Skip",isLast:r,busy:Xn.value||Zn.value,canFinish:(Tt.value.length>0||lt()||vi().length>0||D.value&&Object.values(ee.value).some(Boolean))&&(vi().length===0||ai.value),completed:Ee.value,onPrev:()=>{Ie(n-1)},onNext:()=>{if(o){On.value=!0;return}Ie(n+1)},onSkip:()=>{if(o){On.value=!0,Ie(ze()-1);return}Ct.value=!0,Ie(n+1)},onFinish:()=>{wc()}})]})}const Rc=new Set(["profile.id","rule_loading_tier","discipline_profile","personal.ide","personal.open_edited_files","personal.autonomy","personal.minimal_output","personal.play_by_play","personal.pr_comment_bot_icon","personal.pr_progress_comments","cost.budgets.daily","cost.budgets.weekly","cost.budgets.monthly","cost.enforcement","model.auto_switch","tokens.rich_skills","roadmap.quality_cadence","roadmap.dashboard_regen_cadence","quality.local_auto_run","quality.wait_for_remote_ci","memory.review_threshold","memory.redact_patterns","memory.cadence","chat_history.enabled","update_check.enabled","worktrees.mode","legal_review_prep.acknowledged"]);function Pa(e){return Rc.has(e)}function Fc(e,n){return JSON.stringify(e??null)===JSON.stringify(n??null)}function Zr(e,n){if(e.kind==="enum_removed"){const t=new Set(e.values??[]);return n!==void 0&&t.has(n)?"must_fix":"info"}return e.kind==="type_changed"?"must_fix":e.kind==="default_changed"?n===void 0||Fc(n,e.old?.default)?"adopt":"review":e.kind==="added"&&e.new?.default===void 0?"must_fix":"info"}const gi=h(!0),ot=h(null),_i=h(!1),$t=h(null),We=h({}),mi=h(0),ke=h({}),re=h(null),Q=h(!1),un=h(!1);function fe(e){return`${e.key}:${e.kind}`}async function Mc(){gi.value=!0,ot.value=null,_i.value=!1,un.value=!1;try{const e=await y("/api/v1/settings/changes"),n=await y("/api/v1/settings");$t.value=e.delta,We.value=n.values,mi.value=n.lastModified,jc(e.delta,n.values)}catch(e){e instanceof E&&e.status===404?_i.value=!0:ot.value=e instanceof Error?e.message:String(e)}finally{gi.value=!1}}function jc(e,n){const t={};for(const i of e.changes){const r=Zr(i,yn(n,i.key.split(".")));r==="adopt"?t[fe(i)]={mode:"adopt"}:r==="review"?t[fe(i)]={mode:"keep"}:r==="must_fix"&&(t[fe(i)]={mode:null})}ke.value=t}function Yi(e){return Zr(e,yn(We.value,e.key.split(".")))}function tn(e,n){ke.value={...ke.value,[e]:n}}function qi(){const e=$t.value;return e===null?[]:e.changes.filter(n=>{if(Yi(n)!=="must_fix")return!1;const t=ke.value[fe(n)];return t===void 0||t.mode===null||t.mode==="custom"&&(t.value===void 0||t.value==="")})}function Dc(){const e=$t.value;let n=We.value;if(e===null)return n;for(const t of e.changes){const i=ke.value[fe(t)];if(i===void 0||i.mode===null||i.mode==="keep")continue;const r=t.key.split(".");i.mode==="adopt"&&t.new?.default!==void 0?n=cn(n,r,t.new.default):i.mode==="custom"&&i.value!==void 0&&(n=cn(n,r,i.value))}return n}async function Uc(){if(Q.value)return;const e=qi();if(e.length>0){re.value=`Resolve the ${e.length} “Must fix” item${e.length===1?"":"s"} first.`;return}Q.value=!0,re.value=null;try{const n=Dc();if(JSON.stringify(n)!==JSON.stringify(We.value)){const t=await y("/api/v1/settings",{method:"PUT",headers:{"If-Unmodified-Since":String(mi.value)},body:{values:n}});We.value=n,mi.value=t.lastModified}await y("/api/v1/settings/changes/ack",{method:"POST"}),un.value=!0}catch(n){n instanceof E?re.value=z(n.body.error??{code:"UNKNOWN",message:n.message}):re.value=n instanceof Error?n.message:String(n)}finally{Q.value=!1}}async function Bc(){if(Q.value)return;if(qi().length>0){re.value="Cannot dismiss — “Must fix” items would leave invalid values in place.";return}Q.value=!0;try{await y("/api/v1/settings/changes/ack",{method:"POST"}),un.value=!0}catch(n){re.value=n instanceof Error?n.message:String(n)}finally{Q.value=!1}}function te(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Wt({change:e,id:n}){const t=e.new,r=ke.value[n]?.value;return t?.enum!==void 0?a("select",{class:"ac-input","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onChange:l=>{const o=l.currentTarget.value;tn(n,{mode:"custom",value:o})},children:[a("option",{value:"",disabled:!0,children:"Choose a value…"}),t.enum.map(l=>a("option",{value:String(l),children:String(l)},String(l)))]}):t?.type==="boolean"?a("select",{class:"ac-input","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onChange:l=>{tn(n,{mode:"custom",value:l.currentTarget.value==="true"})},children:[a("option",{value:"",disabled:!0,children:"Choose…"}),a("option",{value:"true",children:"true"}),a("option",{value:"false",children:"false"})]}):a("input",{class:"ac-input",type:t?.type==="number"||t?.type==="integer"?"number":"text","aria-label":`New value for ${e.key}`,value:r===void 0?"":String(r),onInput:l=>{const o=l.currentTarget.value,s=t?.type==="number"||t?.type==="integer"?Number(o):o;tn(n,{mode:"custom",value:s})}})}function zc({change:e}){const n=Yi(e),t=fe(e),i=ke.value[t],r=yn(We.value,e.key.split("."));return a("li",{class:`ac-change-card ac-change-card--${n}`,"data-key":e.key,"data-kind":e.kind,children:[a("div",{class:"ac-change-card__head",children:[a("code",{class:"ac-change-card__key",children:e.key}),a("span",{class:`ac-change-card__badge ac-change-card__badge--${n}`,children:n==="must_fix"?"Must fix":n==="adopt"?"New default":n==="review"?"Review":"Info"})]}),e.new?.description!==void 0?a("p",{class:"ac-change-card__desc",children:e.new.description}):null,e.kind==="default_changed"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Default changed: ",a("code",{children:te(e.old?.default)})," → ",a("code",{children:te(e.new?.default)}),n==="review"?a(L,{children:[" · your value: ",a("code",{children:te(r)})]}):null]}),a("div",{class:"ac-change-card__choices",role:"radiogroup","aria-label":`Resolution for ${e.key}`,children:[a("label",{class:"ac-change-card__choice",children:[a("input",{type:"radio",name:t,checked:i?.mode==="adopt",onChange:()=>{tn(t,{mode:"adopt"})}}),a("span",{children:["Adopt new default (",a("code",{children:te(e.new?.default)}),")"]})]}),a("label",{class:"ac-change-card__choice",children:[a("input",{type:"radio",name:t,checked:i?.mode==="keep",onChange:()=>{tn(t,{mode:"keep"})}}),a("span",{children:["Keep current (",a("code",{children:te(r??e.old?.default)}),")"]})]})]})]}):null,e.kind==="enum_removed"?n==="must_fix"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Your value ",a("code",{children:te(r)})," is no longer valid — removed option",(e.values?.length??0)===1?"":"s",": ",a("code",{children:(e.values??[]).join(", ")}),". Pick a replacement:"]}),a(Wt,{change:e,id:t})]}):a("p",{class:"ac-change-card__detail",children:["Removed option",(e.values?.length??0)===1?"":"s",": ",a("code",{children:(e.values??[]).join(", ")})," — your value ",a("code",{children:te(r??e.new?.default)})," is unaffected."]}):null,e.kind==="enum_added"?a("p",{class:"ac-change-card__detail",children:["New option",(e.values?.length??0)===1?"":"s"," available: ",a("code",{children:(e.values??[]).join(", ")})]}):null,e.kind==="added"?n==="must_fix"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:"New setting without a shipped default — define a value:"}),a(Wt,{change:e,id:t})]}):a("p",{class:"ac-change-card__detail",children:["New setting · default: ",a("code",{children:te(e.new?.default)}),e.new?.enum!==void 0?a(L,{children:[" · options: ",a("code",{children:e.new.enum.join(", ")})]}):null]}):null,e.kind==="removed"?a("p",{class:"ac-change-card__detail",children:"This setting no longer exists. Your stored value is kept in place and ignored (nothing is deleted)."}):null,e.kind==="type_changed"?a(L,{children:[a("p",{class:"ac-change-card__detail",children:["Type changed: ",a("code",{children:e.old?.type})," → ",a("code",{children:e.new?.type}),". Define a new value:"]}),a(Wt,{change:e,id:t})]}):null]})}function Wc(e){const n=new Map;for(const c of e.changes){const d=Yi(c);n.set(d,[...n.get(d)??[],c])}const t=[],i=n.get("must_fix")??[];i.length>0&&t.push({title:"Must fix",hint:"These stored values are invalid after the upgrade — saving is blocked until each has a valid value.",changes:i});const r=[...n.get("adopt")??[],...n.get("review")??[]];r.length>0&&t.push({title:"Changed defaults",hint:"Values you never customized are preselected to adopt the new default; customized values are kept unless you choose otherwise.",changes:r});const l=n.get("info")??[],o=l.filter(c=>c.kind==="added"),s=l.filter(c=>c.kind==="enum_added"),u=l.filter(c=>c.kind!=="added"&&c.kind!=="enum_added");return o.length>0&&t.push({title:"New settings",changes:o}),s.length>0&&t.push({title:"New options",changes:s}),u.length>0&&t.push({title:"Removed / other",changes:u}),t}function Hc(){if(ne(()=>{Mc()},[]),gi.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings changes"}),a("p",{children:"Loading…"})]});if(ot.value!==null)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-banner ac-banner--error",children:ot.value})]});if(un.value||_i.value)return a("div",{class:"ac-page ac-settings-changes",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-banner",children:un.value?"Review complete — all changes resolved.":"Nothing to review — your settings are up to date."}),a("button",{type:"button",class:"ac-button",onClick:()=>_t("/settings"),children:"Back to Settings"})]});const e=$t.value;if(e===null)return a("div",{class:"ac-page",children:a("h1",{children:"Settings changes"})});const n=Wc(e),t=qi().length;return a("div",{class:"ac-page ac-settings-changes",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Settings changes"}),a("p",{class:"ac-page__lede",children:["The upgrade ",a("code",{children:e.oldVersion})," → ",a("code",{children:e.newVersion})," changed the available settings. Review below — nothing was changed automatically."]})]}),re.value!==null?a("p",{class:"ac-banner ac-banner--error",role:"alert",children:re.value}):null,n.map(i=>a("section",{class:"ac-settings-changes__group",children:[a("h2",{children:[i.title," ",a("span",{class:"ac-settings-changes__count",children:["(",i.changes.length,")"]})]}),i.hint!==void 0?a("p",{class:"ac-settings-changes__hint",children:i.hint}):null,a("ul",{class:"ac-settings-changes__list",children:i.changes.map(r=>a(zc,{change:r},fe(r)))})]},i.title)),a("div",{class:"ac-form__actions",children:[a("button",{type:"button",class:"ac-button",disabled:Q.value,onClick:()=>{Bc()},children:"Dismiss (keep everything)"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:Q.value||t>0,title:t>0?`${t} “Must fix” item${t===1?"":"s"} unresolved`:void 0,onClick:()=>{Uc()},children:Q.value?"Saving…":"Apply & finish review"})]})]})}const xe=h(null);function Yc(){return ne(()=>{(async()=>{try{const e=await y("/api/v1/settings/changes");xe.value=e.delta.changes.length}catch{xe.value=null}})()},[]),xe.value===null||xe.value===0?null:a("div",{class:"ac-banner ac-banner--pending",role:"status",children:[a("span",{children:["An upgrade changed ",xe.value," setting",xe.value===1?"":"s"," — review recommended."]}),a("button",{type:"button",class:"ac-button ac-button--small",onClick:()=>_t("/settings/changes"),children:"Review changes"})]})}const yi=h(!1),st=h(null),q=h({}),ct=h(null),dn=h(0),fn=h({}),J=h(null),we=h(!1),he=h(null),hn=h(null),Pn=h(""),Ne=h(!1),Ln=h({}),Rn=h({global:new Set,project:new Set});function La(e){if("$ref"in e&&e.$ref!==void 0&&"definitions"in e&&e.definitions!==void 0){const n=e.$ref.replace("#/definitions/",""),t=e.definitions[n];if(t!==void 0)return t}return e}async function Ra(){st.value=null;try{const e=await y("/api/v1/settings");q.value=e.values,ct.value=La(e.schema),dn.value=e.lastModified,Rn.value={global:new Set(e.sources?.global??[]),project:new Set(e.sources?.project??[])},yi.value=!0}catch(e){if(e instanceof E&&e.status===404&&e.body.error?.code==="NOT_FOUND"){const n=e.body;if(n.defaults!==void 0&&n.schema!==void 0){q.value=n.defaults,ct.value=La(n.schema),dn.value=n.lastModified??0,yi.value=!0;return}}st.value=e instanceof Error?e.message:String(e)}}async function qc(){if(!we.value){J.value=null,fn.value={};try{const e=await y("/api/v1/settings/diff",{method:"POST",body:{values:q.value,ifUnmodifiedSince:dn.value}});if(e.changes.length===0){J.value="No changes to save.";return}he.value=e.changes}catch(e){e instanceof E?(fn.value=mt(e.body.error??{message:e.message}),J.value=z(e.body.error??{code:"UNKNOWN",message:e.message})):J.value=e instanceof Error?e.message:String(e)}}}async function Qr(e=!1){we.value=!0;try{const n=await y("/api/v1/settings",{method:"PUT",headers:{"If-Unmodified-Since":String(dn.value)},body:e?{values:q.value,confirmSharedWrite:!0}:{values:q.value}});dn.value=n.lastModified,he.value=null,hn.value=null,J.value=`Saved (${n.writtenPaths.join(", ")}).`}catch(n){if(n instanceof E){const t=n.body;if(n.status===409&&t.error==="shared-write"){he.value=null,hn.value={sharedPath:typeof t.sharedPath=="string"?t.sharedPath:"",message:typeof t.message=="string"?t.message:"This write affects a shared agent-switch profile."};return}const i=n.body.error??{code:"UNKNOWN",message:n.message};fn.value=mt(i),J.value=z(i),he.value=null;const r=Object.keys(fn.value)[0];r!==void 0&&queueMicrotask(()=>{const l=document.getElementById(r);l!==null&&l.focus()})}else J.value=n instanceof Error?n.message:String(n)}finally{we.value=!1}}function Ki(e){if(e.defaultValue===void 0)return!1;const n=yn(q.value,e.path);return n===void 0?!1:JSON.stringify(n)!==JSON.stringify(e.defaultValue)}function Kc(e,n){const t=Ki(n),i=Rn.value.project.has(e)?"project":Rn.value.global.has(e)&&Rn.value.project.size>0?"global":void 0;return{modified:t,onReset:t&&n.defaultValue!==void 0?()=>{q.value=cn(q.value,n.path,n.defaultValue)}:void 0,sourceLabel:i}}function Vc(e,n){const t=n.toLowerCase();return e.path.join(".").toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description??"").toLowerCase().includes(t)}function Gc(e){const n=Pn.value.trim(),t=Ne.value,i=e.path.join("."),r=Ln.value[i]===!0;let l=e.fields.filter(c=>c.kind!=="unsupported");if(n!==""&&(l=l.filter(c=>Vc(c,n))),t&&(l=l.filter(c=>Ki(c))),n!==""||t)return l.length===0?null:{section:e,visible:l,hiddenAdvancedCount:0,expanded:r};const o=l.filter(c=>Pa(c.path.join("."))),s=l.filter(c=>!Pa(c.path.join("."))),u=r?[...o,...s]:o;return u.length===0&&s.length===0?null:{section:e,visible:u,hiddenAdvancedCount:r?0:s.length,expanded:r}}function Jc(e){Ln.value={...Ln.value,[e]:Ln.value[e]!==!0}}function Xc(){const e=ge.value?.agentSwitchProfile;if(e===void 0||e.active!==!0)return null;const n=e.provider!==null&&e.profile!==null?`${e.provider}/${e.profile}`:"an unidentified profile";return a("div",{class:"ac-banner",role:"status",children:a("span",{children:["Running under agent-switch profile ",a("code",{children:n})," — settings shown and saved here are profile-scoped. Switching profiles shows that profile's own settings; nothing is lost."]})})}function Zc({block:e}){return a("div",{class:"ac-modal",role:"dialog","aria-modal":"true","aria-labelledby":"shared-write-title",children:a("div",{class:"ac-modal__panel",children:[a("h2",{id:"shared-write-title",children:"Shared write — affects all profiles"}),a("p",{children:e.message}),a("p",{children:a("code",{children:e.sharedPath})}),a("div",{class:"ac-modal__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{hn.value=null},children:"Cancel"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:we.value,onClick:()=>{Qr(!0)},children:we.value?"Writing…":"Write (affects all profiles)"})]})]})})}function Qc({changes:e}){return a("div",{class:"ac-modal",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:a("div",{class:"ac-modal__panel",children:[a("h2",{id:"diff-title",children:"Confirm changes"}),a("ul",{class:"ac-diff",children:e.map(n=>a("li",{children:[a("code",{children:n.path}),a("span",{class:"ac-diff__before",children:JSON.stringify(n.from)}),a("span",{class:"ac-diff__arrow",children:"→"}),a("span",{class:"ac-diff__after",children:JSON.stringify(n.to)})]},n.path))}),a("div",{class:"ac-modal__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{he.value=null},children:"Cancel"}),a("button",{type:"button",class:"ac-button ac-button--primary",disabled:we.value,onClick:()=>{Qr()},children:we.value?"Saving…":"Save"})]})]})})}function eu(){if(ne(()=>{Ra()},[]),!yi.value||ct.value===null)return a("div",{class:"ac-page",children:[a("h1",{children:"Settings"}),st.value!==null?a("p",{class:"ac-banner ac-banner--error",children:st.value}):a("p",{children:"Loading…"})]});const e=vr(ct.value),n=e.map(Gc).filter(r=>r!==null),t=e.flatMap(r=>r.fields).filter(r=>Ki(r)).length,i=Pn.value.trim()!==""||Ne.value;return a("div",{class:"ac-page ac-settings-hub",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Settings"}),a("nav",{class:"ac-page__nav",children:a("a",{href:"#/settings/user",children:"Edit .agent-user.yml →"})})]}),a(Yc,{}),a(Xc,{}),a("div",{class:"ac-settings-hub__toolbar",role:"search",children:[a("input",{class:"ac-input ac-settings-hub__search",type:"search",placeholder:"Search all settings (basic and advanced)…",value:Pn.value,onInput:r=>{Pn.value=r.currentTarget.value}}),a("button",{type:"button",class:`ac-chip-toggle${Ne.value?" ac-chip-toggle--active":""}`,"aria-pressed":Ne.value,onClick:()=>{Ne.value=!Ne.value},children:["@modified",t>0?` (${t})`:""]})]}),J.value!==null?a("p",{class:"ac-banner",children:J.value}):null,a("form",{class:"ac-form",onSubmit:r=>r.preventDefault(),children:[n.length===0?a("p",{class:"ac-settings-hub__empty",children:"No settings match."}):n.map(r=>{const l=r.section.path.join(".");return a(gr,{section:{...r.section,fields:r.visible},values:q.value,errors:fn.value,onChange:o=>{q.value=o},decorate:Kc,footer:!i&&(r.hiddenAdvancedCount>0||r.expanded)?a("button",{type:"button",class:"ac-settings-hub__disclosure","aria-expanded":r.expanded,onClick:()=>{Jc(l)},children:r.expanded?"Hide advanced settings":`Show ${r.hiddenAdvancedCount} advanced setting${r.hiddenAdvancedCount===1?"":"s"}`}):void 0},l)}),a("div",{class:"ac-form__actions",children:[a("button",{type:"button",class:"ac-button",onClick:()=>{Ra()},children:"Reload"}),a("button",{type:"button",class:"ac-button ac-button--primary",onClick:()=>{qc()},children:"Preview & Save"})]})]}),he.value!==null?a(Qc,{changes:he.value}):null,hn.value!==null?a(Zc,{block:hn.value}):null]})}const ut=h(!1),De=h(null);async function nu(){Qn.value=!0,et.value=null;try{const e=await y("/api/v1/modules/detect");ji.value=e.candidates,jr.value=e.project_root;const n={};for(const t of e.candidates)n[t.path]=!0;nt.value=n,tt.value=e.proposed_block.enabled,it.value=e.proposed_block.namespace_template??"",at.value=e.proposed_block.agent_folder??"agents"}catch(e){et.value=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e)}finally{Qn.value=!1,sc.value=!0}}function tu(){const e=new Set(ji.value.map(i=>i.path)),n=nt.value,t=Object.keys(n).filter(i=>n[i]===!0&&e.has(i));return{enabled:tt.value,root_paths:t,namespace_template:it.value,agent_folder:at.value||"agents"}}async function iu(){ut.value=!0,De.value=null;try{const e=await y("/api/v1/modules/apply",{method:"POST",body:tu()});De.value={message:e.appliedTo!==null?`Saved project settings to ${e.appliedTo}.`:`Saved project settings to ${e.projectRoot}.`,tone:"success"}}catch(e){const n=e instanceof E?z(e.body.error??{code:"UNKNOWN",message:e.message}):e instanceof Error?e.message:String(e);De.value={message:`Could not save project settings: ${n}`,tone:"error"}}finally{ut.value=!1}}function au(){if(Qn.value)return a("p",{children:"Detecting module roots…"});if(et.value!==null)return a("p",{class:"ac-banner ac-banner--error",children:["Module detection failed: ",et.value]});const e=ji.value,n=nt.value,t=jr.value;return a("div",{class:"ac-section",children:[t!==null?a("p",{class:"ac-section__description",children:["Scanning ",a("code",{children:t}),". Pick which detected roots the agent should treat as modules. These write to",a("code",{children:" .agent-project-settings.yml"})," in this repo only."]}):null,a("label",{children:[a("input",{type:"checkbox",checked:tt.value,onChange:i=>{tt.value=i.currentTarget.checked}})," ","Enable module discovery (writes ",a("code",{children:"modules.enabled"}),")"]}),e.length===0?a("p",{children:[a("em",{children:"No module roots detected."})," The scan found no common module layouts (Laravel ",a("code",{children:"app/Modules/"}),", Symfony",a("code",{children:" src/Module/"}),", Node ",a("code",{children:"packages/"}),", Python",a("code",{children:" src/"}),", Go ",a("code",{children:"internal/"}),")."]}):a("ul",{style:"list-style: none; padding-left: 0;",children:e.map(i=>a("li",{children:a("label",{children:[a("input",{type:"checkbox",checked:n[i.path]??!1,onChange:r=>{const l=r.currentTarget.checked;nt.value={...n,[i.path]:l}}})," ",a("code",{children:i.path})," — ",i.stack," ",a("small",{children:["(",i.confidence," confidence)"]})]})},i.path))}),a("div",{class:"ac-wizard__module-fields",children:[a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-namespace",children:"Namespace template"}),a("input",{id:"ac-modules-namespace",class:"ac-input",type:"text",value:it.value,placeholder:"e.g. App\\\\Modules\\\\{ModuleName}\\\\App",onInput:i=>{it.value=i.currentTarget.value}}),a("span",{class:"ac-field__description",children:"How a module path maps to its namespace. Leave blank to skip namespacing."})]}),a("div",{class:"ac-field",children:[a("label",{class:"ac-field__label",for:"ac-modules-agent-folder",children:"Agent folder"}),a("input",{id:"ac-modules-agent-folder",class:"ac-input",type:"text",value:at.value,placeholder:"agents",onInput:i=>{at.value=i.currentTarget.value}}),a("span",{class:"ac-field__description",children:["Folder name that holds per-module agent docs (default ",a("code",{children:"agents"}),")."]})]})]})]})}function ru(){return ne(()=>{nu()},[]),a("div",{class:"ac-page",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Project settings"}),a("p",{class:"ac-section__description",children:["Configuration scoped to this repository — written to",a("code",{children:" .agent-project-settings.yml"}),", not the global tree."]})]}),De.value!==null?a("p",{class:`ac-banner ac-banner--${De.value.tone==="success"?"success":"error"}`,children:De.value.message}):null,a("section",{class:"ac-section",children:[a("h2",{class:"ac-section__title",children:"Modules"}),a(au,{})]}),a("div",{class:"ac-form__actions ac-wizard__nav",children:a("button",{type:"button",class:"ac-button ac-button--primary",disabled:ut.value||Qn.value,onClick:()=>{iu()},children:ut.value?"Saving…":"Save project settings"})})]})}const Fn=h([]),pn=h([]),bi=h([]),ki=h([]),dt=h(null),el=h(!1),an=h(null),B=h(null),Ht=h("plain"),ft=h({}),nl=h([]),Fa={"claude-code":"Claude Code",codex:"Codex",gemini:"Gemini"};function lu(){try{return globalThis.sessionStorage?.getItem("ac-workspace-host")??"claude-code"}catch{return"claude-code"}}const Vi=h(lu());function ou(e){Vi.value=e;try{globalThis.sessionStorage?.setItem("ac-workspace-host",e)}catch{}}const vn=h([]),K=h(null),$e=h({}),pe=h(!1),gn=h(null),se=h(""),rn=h(!1),Ot=h(!1),wi=h(null),ve=h(null),_n=h([]),Mn=h(new Set),tl="claude-code",Ma=2e3;async function su(){an.value=null;try{const[e,n,t,i,r,l]=await Promise.all([y("/api/v1/workspace/roles"),y("/api/v1/workspace/sessions?limit=20"),y("/api/v1/workspace/knowledge?limit=20"),y("/api/v1/workspace/documents?limit=20"),y("/api/v1/workspace/drive-health").catch(()=>({health:{}})),y("/api/v1/workspace/hosts").catch(()=>({hosts:[]}))]);Fn.value=e.roles,pn.value=n.sessions,bi.value=t.chunks,ki.value=i.documents,ft.value=r.health??{},nl.value=l.hosts??[],el.value=!0}catch(e){e instanceof E?an.value=e.body?.error?.message??e.message:an.value=e instanceof Error?e.message:String(e)}}async function cu(e,n){try{const t=await y(`/api/v1/workspace/roles/${e}/tasks`);vn.value=t.tasks}catch{vn.value=n}}async function Gi(e){ve.value=e,Mn.value=new Set;try{const n=await y(`/api/v1/workspace/sessions/${e}`);_n.value=Array.isArray(n.log)?n.log:[]}catch{_n.value=[]}}async function uu(e){B.value=null,Ot.value=!1,se.value="",K.value=null,await Gi(e)}async function il(e,n,t){B.value=null,pe.value=!0,se.value="",Ot.value=!1,wi.value={role:e,task:n,inputs:t};try{const i=await y("/api/v1/workspace/launch",{method:"POST",body:{role:e,task:n,inputs:t,host:Vi.value}});gn.value=i,B.value=al(i),K.value=null,await Gi(i.id);const r=await y("/api/v1/workspace/sessions?limit=20");pn.value=r.sessions,await Ji()}catch(i){gn.value=null,i instanceof E?B.value=i.body?.error?.message??i.message:B.value=i instanceof Error?i.message:String(i)}finally{pe.value=!1}}async function du(e,n){if(!(n.trim()===""||rn.value)){rn.value=!0,B.value=null;try{const t=await y(`/api/v1/workspace/sessions/${e}/continue`,{method:"POST",body:{prompt:n}});gn.value=t,B.value=al(t),t.driven&&(se.value=""),await Gi(e);const i=await y("/api/v1/workspace/sessions?limit=20");pn.value=i.sessions,await Ji()}catch(t){t instanceof E&&t.status===410?(Ot.value=!0,B.value="Host session expired — start a new conversation."):t instanceof E?B.value=t.body?.error?.message??t.message:B.value=t instanceof Error?t.message:String(t)}finally{rn.value=!1}}}async function Ji(){try{const e=await y("/api/v1/workspace/drive-health");ft.value=e.health??{}}catch{}}async function fu(e){try{await y(`/api/v1/workspace/drive-health/${e}/reset`,{method:"POST"}),await Ji()}catch{}}function al(e){return e.driven?e.recovered===!0?`Host recovered — drove the turn for ${e.role} · ${e.task}.`:`Drove the turn for ${e.role} · ${e.task}.`:e.host_killed===!0?`Host ${tl} is paused after repeated failures — handed off to the inbox.`:e.error_kind==="render-error"?`Couldn't fill the prompt: ${e.error??"missing input"}.`:e.reason==="no-prompt-for-task"?"Recorded the session — this task has no runnable prompt yet.":typeof e.handoff=="string"?`Prepared a hand-off — open ${e.handoff} and paste it into your host.`:`Recorded the session ${e.id} (${e.role} · ${e.task}).`}function hu({role:e}){const n=dt.value===e.slug;return a("button",{type:"button",class:`ac-workspace__role${n?" ac-workspace__role--active":""}`,"aria-current":n?"true":void 0,"aria-label":`Pick role ${e.display_name}`,onClick:()=>{dt.value=e.slug,B.value=null,gn.value=null,K.value=null,$e.value={},vn.value=e.first_tasks,cu(e.slug,e.first_tasks)},children:[a("span",{class:"ac-workspace__role-name",children:e.display_name}),a("span",{class:"ac-workspace__role-status","data-status":e.status,children:e.status}),a("span",{class:"ac-workspace__role-tagline",children:e.tagline})]})}function pu({role:e,task:n}){const t=n.inputs??[],i=$e.value,r=t.some(l=>l.required&&(i[l.name]??"").trim()==="");return a("form",{class:"ac-workspace__task-form",onSubmit:l=>{l.preventDefault(),!r&&!pe.value&&il(e,n.name,$e.value)},children:[t.length===0?a("p",{class:"ac-workspace__form-note",children:"No inputs — runs the prompt as-is."}):t.map(l=>a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:[l.name,l.required?a("span",{class:"ac-workspace__req","aria-hidden":"true",children:" *"}):null]}),a("textarea",{class:"ac-workspace__field-input",placeholder:l.shape,required:l.required,"aria-label":`${l.name}${l.required?" (required)":""}`,value:i[l.name]??"",onInput:o=>{$e.value={...$e.value,[l.name]:o.target.value}}})]},l.name)),a("div",{class:"ac-workspace__form-actions",children:[a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:r||pe.value,children:pe.value?"Running…":"Run task"}),a("button",{type:"button",class:"ac-button",onClick:()=>{K.value=null},children:"Cancel"})]})]})}function vu(e){const n=[];for(const t of e){const i=t.data??{};if(t.kind==="launcher.input")i.followup===!0?n.push({kind:"user",text:typeof i.prompt=="string"?i.prompt:""}):n.push({kind:"task",text:typeof i.task=="string"?i.task:""});else if(t.kind==="host.turn"){const r=i.usage,l=r!=null?`${typeof i.model=="string"?i.model:tl} · in ${r.input_tokens??0} / out ${r.output_tokens??0} tokens`:void 0;n.push({kind:"assistant",text:typeof i.text=="string"?i.text:"",meta:l})}else if(t.kind==="host.error"){const r=typeof i.error_kind=="string"?i.error_kind:"error";n.push({kind:"error",text:`${r}: ${typeof i.error=="string"?i.error:""}`})}}return n}function gu(){if(ve.value===null)return null;const e=vu(_n.value),n=_n.value.some(t=>t.kind==="host.turn");return a("section",{class:"ac-workspace__thread","aria-label":"Conversation thread",children:[a("h2",{class:"ac-workspace__heading",children:"Conversation"}),e.length===0?a("p",{class:"ac-workspace__empty",children:"No turns yet."}):a("ol",{class:"ac-workspace__thread-list",children:e.map((t,i)=>{const r=t.kind==="assistant"&&t.text.length>Ma,l=Mn.value.has(i),o=r&&!l?`${t.text.slice(0,Ma)}…`:t.text;return a("li",{class:`ac-workspace__thread-block ac-workspace__thread-block--${t.kind}`,children:[a("span",{class:"ac-workspace__thread-role",children:t.kind==="task"?"Task":t.kind==="user"?"You":t.kind==="assistant"?"Host":"Error"}),a("pre",{class:"ac-workspace__thread-text",children:o}),r?a("button",{type:"button",class:"ac-button",onClick:()=>{const s=new Set(Mn.value);s.has(i)?s.delete(i):s.add(i),Mn.value=s},children:l?"Show less":"Show full"}):null,t.meta!=null?a("p",{class:"ac-workspace__turn-meta",children:t.meta}):null]},i)})}),Ot.value?a("div",{class:"ac-workspace__followup-gone",role:"status",children:[a("p",{children:"Host session expired."}),wi.value!==null?a("button",{type:"button",class:"ac-button ac-button--primary",disabled:pe.value,onClick:()=>{const t=wi.value;t!==null&&il(t.role,t.task,t.inputs)},children:pe.value?"Starting…":"Start a new conversation"}):a("p",{children:"Pick a task above to start a new conversation."})]}):n?a("form",{class:"ac-workspace__followup",onSubmit:t=>{t.preventDefault(),ve.value!==null&&du(ve.value,se.value)},children:[a("label",{class:"ac-workspace__field",children:[a("span",{class:"ac-workspace__field-label",children:"Follow up"}),a("textarea",{class:"ac-workspace__field-input",placeholder:"Continue this conversation — e.g. make it shorter","aria-label":"Follow-up prompt",value:se.value,onInput:t=>{se.value=t.target.value}})]}),a("button",{type:"submit",class:"ac-button ac-button--primary",disabled:se.value.trim()===""||rn.value,children:rn.value?"Continuing…":"Send follow-up"})]}):null]})}function _u({role:e}){const n=vn.value.length>0?vn.value:e.first_tasks;return a("section",{class:"ac-workspace__tasks","aria-labelledby":"task-heading",children:[a("h2",{id:"task-heading",class:"ac-workspace__heading",children:["First tasks · ",e.display_name]}),n.length===0?a("p",{class:"ac-workspace__empty",children:"No tasks scaffolded yet for this role."}):a("ul",{class:"ac-workspace__task-list",children:n.map(t=>a("li",{class:"ac-workspace__task",children:[a("div",{class:"ac-workspace__task-head",children:[a("span",{class:"ac-workspace__task-name",children:t.name}),a("button",{type:"button",class:"ac-button ac-button--primary","aria-expanded":K.value===t.name,onClick:()=>{K.value=K.value===t.name?null:t.name,$e.value={},gn.value=null,ve.value=null,_n.value=[]},children:K.value===t.name?"Close":"Start session"})]}),a("p",{class:"ac-workspace__task-intent",children:t.intent}),t.prompt!==""?a("code",{class:"ac-workspace__task-prompt",children:["prompts/",t.prompt]}):null,K.value===t.name?a(pu,{role:e.slug,task:t}):null]},t.name))}),e.skills.length>0?a("details",{class:"ac-workspace__skills",children:[a("summary",{children:["Skill shortlist (",e.skills.length,")"]}),a("ul",{class:"ac-workspace__skill-list",children:[e.skills.slice(0,5).map(t=>a("li",{class:"ac-workspace__skill",children:[a("code",{children:t.id})," — ",t.why]},t.id)),e.skills.length>5?a("li",{class:"ac-workspace__skill-more",children:["+ ",e.skills.length-5," more"]}):null]})]}):null]})}function mu(){return a("section",{class:"ac-workspace__sessions","aria-labelledby":"sessions-heading",children:[a("h2",{id:"sessions-heading",class:"ac-workspace__heading",children:"Recent sessions"}),pn.value.length===0?a("p",{class:"ac-workspace__empty",children:"No sessions yet — pick a role and start one."}):a("ul",{class:"ac-workspace__session-list",children:pn.value.map(e=>a("li",{class:"ac-workspace__session",children:a("button",{type:"button",class:`ac-workspace__session-open${ve.value===e.id?" ac-workspace__session-open--active":""}`,"aria-label":`Open session ${e.task}`,"aria-current":ve.value===e.id?"true":void 0,onClick:()=>{uu(e.id)},children:[a("span",{class:"ac-workspace__session-id",children:e.id.slice(0,16)}),a("span",{class:"ac-workspace__session-role",children:e.role}),a("span",{class:"ac-workspace__session-task",children:e.task})]})},e.id))})]})}function yu(){return a("section",{class:"ac-workspace__knowledge","aria-labelledby":"knowledge-heading",children:[a("h2",{id:"knowledge-heading",class:"ac-workspace__heading",children:"Knowledge sources"}),bi.value.length===0?a("p",{class:"ac-workspace__empty",children:["No sources yet. Run ",a("code",{children:"/knowledge:ingest <path>"})," to add documents."]}):a("ol",{class:"ac-workspace__citation-list",children:bi.value.map((e,n)=>a("li",{class:"ac-workspace__citation",children:[a("span",{class:"ac-workspace__citation-marker","aria-label":`Citation ${n+1}`,children:["[",n+1,"]"]}),a("a",{href:`file://${e.source}`,class:"ac-workspace__citation-source",title:"Open source in OS default app",children:e.source.split("/").pop()??e.source}),e.pinned?a("span",{class:"ac-workspace__citation-pin","aria-label":"pinned",children:"★"}):null,a("p",{class:"ac-workspace__citation-excerpt",children:[e.excerpt.slice(0,200),e.excerpt.length>200?"…":""]})]},e.id))})]})}function bu(){return a("section",{class:"ac-workspace__recent","aria-labelledby":"recent-heading",children:[a("h2",{id:"recent-heading",class:"ac-workspace__heading",children:"Recent documents"}),ki.value.length===0?a("p",{class:"ac-workspace__empty",children:"No documents yet. Saved drafts land here."}):a("ul",{class:"ac-workspace__doc-list",children:ki.value.map(e=>a("li",{class:"ac-workspace__doc",children:[a("span",{class:"ac-workspace__doc-type","data-type":e.type,children:e.type}),a("span",{class:"ac-workspace__doc-title",children:e.title}),a("time",{class:"ac-workspace__doc-time",dateTime:e.updated_at,children:e.updated_at.slice(0,10)})]},`${e.type}/${e.slug}`))})]})}function ku(){const n=Object.values(ft.value).filter(t=>t.killed||t.consecutive_failures>0);return a("section",{class:"ac-workspace__drive-health","aria-labelledby":"drive-health-heading",children:[a("h2",{id:"drive-health-heading",class:"ac-workspace__heading",children:"Host health"}),n.length===0?a("p",{class:"ac-workspace__empty",children:"All hosts healthy."}):a("ul",{class:"ac-workspace__health-list",children:Object.entries(ft.value).filter(([,t])=>t.killed||t.consecutive_failures>0).map(([t,i])=>{const r=i.killed?i.kill_reason==="manual"?"paused (manual)":"paused — auto-recovering":"degraded";return a("li",{class:"ac-workspace__health","data-killed":i.killed?"true":"false",children:[a("span",{class:"ac-workspace__health-host",children:t}),a("span",{class:"ac-workspace__health-state",children:r}),a("span",{class:"ac-workspace__health-meta",children:[i.consecutive_failures," fail streak",i.last_error_kind!=null?` · ${i.last_error_kind}`:""]}),i.killed?a("button",{type:"button",class:"ac-button ac-workspace__health-reset","aria-label":`Reset ${t}`,onClick:()=>{fu(t)},children:"Reset"}):null]},t)})})]})}function wu(){const e=Ht.value;return a("fieldset",{class:"ac-workspace__explain",children:[a("legend",{class:"ac-workspace__heading",children:"Explanation style"}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"plain",checked:e==="plain",onChange:()=>{Ht.value="plain"},"aria-label":"Plain language"}),a("span",{children:"Plain language"})]}),a("label",{class:"ac-workspace__explain-option",children:[a("input",{type:"radio",name:"explain-mode",value:"technical",checked:e==="technical",onChange:()=>{Ht.value="technical"},"aria-label":"Technical detail"}),a("span",{children:"Technical detail"})]}),a("p",{class:"ac-workspace__explain-hint",children:e==="plain"?"Replies use everyday words. Toggle to see the technical view.":"Replies keep the technical vocabulary. Toggle for the plain view."})]})}function Su(){const e=nl.value,n=e.length>0?e.map(i=>i.id):Object.keys(Fa),t=new Map(e.map(i=>[i.id,i.cli_present]));return a("label",{class:"ac-workspace__host-picker",children:[a("span",{class:"ac-workspace__host-label",children:"Host"}),a("select",{class:"ac-workspace__host-select","aria-label":"Host agent",value:Vi.value,onChange:i=>{ou(i.target.value)},children:n.map(i=>{const r=t.get(i)!==!1,l=Fa[i]??i;return a("option",{value:i,disabled:!r,children:[l," (",i,")",r?"":" — not installed"]},i)})})]})}function Cu(){if(ne(()=>{su()},[]),an.value!==null)return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-banner ac-banner--error",children:an.value})]});if(!el.value)return a("div",{class:"ac-page",children:[a("h1",{children:"Workspace"}),a("p",{children:"Loading…"})]});const e=dt.value!==null?Fn.value.find(n=>n.slug===dt.value)??null:null;return a("div",{class:"ac-page ac-workspace",children:[a("header",{class:"ac-page__header",children:[a("h1",{children:"Workspace"}),a("p",{class:"ac-page__subtitle",children:"Pick a role, pick a first task, run it."}),a(Su,{})]}),B.value!==null?a("p",{class:"ac-banner",role:"status",children:B.value}):null,a("div",{class:"ac-workspace__grid",children:[a("section",{class:"ac-workspace__roles","aria-labelledby":"roles-heading",children:[a("h2",{id:"roles-heading",class:"ac-workspace__heading",children:"Roles"}),Fn.value.length===0?a("p",{class:"ac-workspace__empty",children:"No roles installed."}):a("div",{class:"ac-workspace__role-grid",children:Fn.value.map(n=>a(hu,{role:n},n.slug))})]}),a("main",{class:"ac-workspace__main","aria-label":"Tasks and sessions",children:[e!==null?a(_u,{role:e}):a("p",{class:"ac-workspace__empty",children:"Pick a role on the left to see its first tasks."}),a(gu,{}),a(mu,{})]}),a("aside",{class:"ac-workspace__rail","aria-label":"Knowledge and documents",children:[a(yu,{}),a(bu,{}),a(ku,{}),a(wu,{})]})]})]})}const rl="agent-config-theme";function Tu(){return(typeof document<"u"?document.documentElement.getAttribute("data-theme"):null)==="dark"?"dark":"light"}const ln=h(Tu());function Au(){try{const e=localStorage.getItem(rl);return e==="light"||e==="dark"?e:null}catch{return null}}function xu(){if(typeof window>"u")return null;try{const e=new URLSearchParams(window.location.search).get("theme");return e==="light"||e==="dark"?e:null}catch{return null}}function Nu(){return Au()===null&&xu()===null}function ll(e){ln.value=e,document.documentElement.setAttribute("data-theme",e)}function Eu(){const e=ln.value==="dark"?"light":"dark";try{localStorage.setItem(rl,e)}catch{}ll(e)}function Iu(){if(typeof window>"u"||typeof window.matchMedia!="function")return;const e=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{Nu()&&ll(e.matches?"dark":"light")};typeof e.addEventListener=="function"&&e.addEventListener("change",n)}function $u(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("embed")==="1"}const Ou=$u(),ol=[{id:"setup",label:"Setup",hashPath:"/setup",matches:["/setup","/wizard"]},{id:"settings",label:"Settings",hashPath:"/settings",matches:["/settings"]},{id:"project",label:"Project",hashPath:"/project",matches:["/project"]},{id:"workspace",label:"Workspace",hashPath:"/workspace",matches:["/workspace"]}];function sl(e){for(const n of ol)for(const t of n.matches)if(e===t||e.startsWith(`${t}/`))return n.id;return null}function Pu(e){const n=ge.value,t=sl(e);return ol.filter(i=>i.id==="project"?n?.projectSurface===!0||t==="project":i.id==="workspace"?n?.devSurfaces===!0||t==="workspace":!0)}function Lu(){const e=Yn.value,n=sl(e);return a("header",{class:"ac-topnav",children:a("div",{class:"ac-topnav__inner",children:[a("div",{class:"ac-topnav__brand",children:[a("h1",{class:"ac-topnav__title",children:"@event4u/agent-config"}),a("p",{class:"ac-topnav__subtitle",children:"Browser Wizard"})]}),a("nav",{class:"ac-topnav__tabs","aria-label":"Surfaces",children:Pu(e).map(t=>a("button",{type:"button",class:`ac-topnav__tab${n===t.id?" ac-topnav__tab--active":""}`,"aria-current":n===t.id?"page":void 0,onClick:()=>_t(t.hashPath),children:t.label},t.id))}),a("button",{type:"button",class:"ac-topnav__theme","aria-label":ln.value==="dark"?"Switch to light theme":"Switch to dark theme",title:ln.value==="dark"?"Switch to light theme":"Switch to dark theme",onClick:()=>{Eu()},children:ln.value==="dark"?"☀":"☾"})]})})}function Ru({path:e}){return a("div",{class:"ac-page ac-page--error",children:[a("h1",{children:"Page not found"}),a("p",{children:["Nothing routed to ",a("code",{children:e}),". Try ",a("a",{href:"#/setup",children:"Setup"}),"."]})]})}function Fu(){const e=ge.value;return e===null||e.dryRun!==!0?null:a("div",{class:"ac-dryrun-banner",role:"status","aria-live":"polite",children:[a("strong",{children:"DRY RUN"}),a("span",{children:" · no files will be written. Validation + rendering run normally; commits return a preview."})]})}function Mu(e){return e==="/"||e==="/setup"||e.startsWith("/setup/")?a(Oa,{path:e}):e.startsWith("/wizard")?a(Oa,{path:e}):e==="/settings/changes"?a(Hc,{}):e==="/settings"||e.startsWith("/settings/")?a(eu,{}):e==="/project"||e.startsWith("/project/")?a(ru,{}):e==="/workspace"?a(Cu,{}):a(Ru,{path:e})}function ju(){return ne(()=>{Il(),Yn.value==="/"&&_t("/setup"),Pl()},[]),a(L,{children:[a(Fu,{}),Ou?null:a(Lu,{}),Mu(Yn.value)]})}const Du=3e4,Uu=30*6e4;let An=null,ja=!1;function Da(e){if(!ja&&(ja=!0,!(typeof navigator>"u"||typeof navigator.sendBeacon!="function")))try{navigator.sendBeacon(`/api/v1/shutdown?token=${encodeURIComponent(e)}`)}catch{}}function Bu(e){if(typeof window>"u")return()=>{};let n=Date.now();const t=()=>{n=Date.now()},i=["pointerdown","keydown","wheel","touchstart"];for(const s of i)window.addEventListener(s,t,{passive:!0});const r=()=>{document.hidden||t()};document.addEventListener("visibilitychange",r);const l=()=>{An!==null&&clearInterval(An),An=null;for(const s of i)window.removeEventListener(s,t);document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",o)};An=setInterval(()=>{if(!document.hidden){if(Date.now()-n>Uu){Da(e),l();return}y("/api/v1/ping").catch(()=>{})}},Du);function o(){Da(e)}return window.addEventListener("pagehide",o),l}function zu(){if(typeof window>"u"||typeof window.history?.replaceState!="function")return;const e=new URLSearchParams(window.location.search);if(!e.has("token"))return;e.delete("token");const n=e.toString(),t=window.location.pathname+(n?`?${n}`:"")+window.location.hash;window.history.replaceState(window.history.state,"",t)}function Wu(){return new URLSearchParams(window.location.search).get("token")}function Hu(){const e=document.getElementById("app");if(e===null)return;const n=Wu();if(n===null){e.textContent="agent-config UI · missing token — re-open via `agent-config ui:serve`.";return}$l(n),zu(),Bu(n),Iu(),e.textContent="",gl(a(ju,{}),e)}Hu();
|
|
26
|
+
//# sourceMappingURL=index-JDAF00bC.js.map
|