@rpamis/comet 0.4.0-rc.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +332 -333
  3. package/assets/manifest.json +1 -1
  4. package/assets/skills/comet/scripts/comet-archive.mjs +56 -51
  5. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +22 -20
  6. package/assets/skills/comet/scripts/comet-guard.mjs +93 -88
  7. package/assets/skills/comet/scripts/comet-handoff.mjs +111 -106
  8. package/assets/skills/comet/scripts/comet-hook-guard.mjs +54 -49
  9. package/assets/skills/comet/scripts/comet-hook-router.mjs +106 -106
  10. package/assets/skills/comet/scripts/comet-intent.mjs +12 -7
  11. package/assets/skills/comet/scripts/comet-resume-probe.mjs +50 -45
  12. package/assets/skills/comet/scripts/comet-runtime.mjs +180 -175
  13. package/assets/skills/comet/scripts/comet-state.mjs +80 -75
  14. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +57 -52
  15. package/assets/skills/comet-classic/reference/scripts.md +1 -1
  16. package/assets/skills/comet-native/SKILL.md +3 -3
  17. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +31 -31
  18. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +51 -51
  19. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +3 -3
  20. package/assets/skills/comet-native/scripts/comet-native-init.mjs +37 -37
  21. package/assets/skills/comet-native/scripts/comet-native-new.mjs +33 -33
  22. package/assets/skills/comet-native/scripts/comet-native-next.mjs +43 -43
  23. package/assets/skills/comet-native/scripts/comet-native-root.mjs +3 -3
  24. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +71 -71
  25. package/assets/skills/comet-native/scripts/comet-native-select.mjs +36 -36
  26. package/assets/skills/comet-native/scripts/comet-native-show.mjs +27 -27
  27. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +23 -23
  28. package/assets/skills/comet-native/scripts/comet-native-status.mjs +39 -39
  29. package/assets/skills-zh/comet-classic/reference/scripts.md +1 -1
  30. package/assets/skills-zh/comet-native/SKILL.md +3 -3
  31. package/bin/fast-runtime-router.js +1 -1
  32. package/dist/app/cli/index.js +7 -1
  33. package/dist/app/cli/index.js.map +1 -1
  34. package/dist/app/commands/classic.js +4 -0
  35. package/dist/app/commands/classic.js.map +1 -1
  36. package/dist/app/commands/doctor.d.ts +1 -1
  37. package/dist/app/commands/doctor.d.ts.map +1 -1
  38. package/dist/app/commands/doctor.js +2 -1
  39. package/dist/app/commands/doctor.js.map +1 -1
  40. package/dist/app/commands/eval.js +2 -2
  41. package/dist/app/commands/eval.js.map +1 -1
  42. package/dist/app/commands/init.d.ts.map +1 -1
  43. package/dist/app/commands/init.js +16 -5
  44. package/dist/app/commands/init.js.map +1 -1
  45. package/dist/app/commands/personal-memory.d.ts.map +1 -1
  46. package/dist/app/commands/personal-memory.js +5 -0
  47. package/dist/app/commands/personal-memory.js.map +1 -1
  48. package/dist/app/commands/project-knowledge.d.ts.map +1 -1
  49. package/dist/app/commands/project-knowledge.js +26 -2
  50. package/dist/app/commands/project-knowledge.js.map +1 -1
  51. package/dist/app/commands/status.d.ts.map +1 -1
  52. package/dist/app/commands/status.js +17 -10
  53. package/dist/app/commands/status.js.map +1 -1
  54. package/dist/app/commands/uninstall.d.ts.map +1 -1
  55. package/dist/app/commands/uninstall.js +5 -1
  56. package/dist/app/commands/uninstall.js.map +1 -1
  57. package/dist/app/commands/update.d.ts.map +1 -1
  58. package/dist/app/commands/update.js +10 -4
  59. package/dist/app/commands/update.js.map +1 -1
  60. package/dist/domains/agent-learning/context-director.d.ts.map +1 -1
  61. package/dist/domains/agent-learning/context-director.js +14 -10
  62. package/dist/domains/agent-learning/context-director.js.map +1 -1
  63. package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
  64. package/dist/domains/comet-classic/classic-archive.js +3 -0
  65. package/dist/domains/comet-classic/classic-archive.js.map +1 -1
  66. package/dist/domains/comet-classic/classic-cli-help.d.ts +3 -0
  67. package/dist/domains/comet-classic/classic-cli-help.d.ts.map +1 -0
  68. package/dist/domains/comet-classic/classic-cli-help.js +40 -0
  69. package/dist/domains/comet-classic/classic-cli-help.js.map +1 -0
  70. package/dist/domains/comet-classic/classic-cli.d.ts +1 -0
  71. package/dist/domains/comet-classic/classic-cli.d.ts.map +1 -1
  72. package/dist/domains/comet-classic/classic-cli.js +5 -0
  73. package/dist/domains/comet-classic/classic-cli.js.map +1 -1
  74. package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
  75. package/dist/domains/comet-classic/classic-guard.js +12 -2
  76. package/dist/domains/comet-classic/classic-guard.js.map +1 -1
  77. package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
  78. package/dist/domains/comet-classic/classic-handoff.js +11 -10
  79. package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
  80. package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
  81. package/dist/domains/comet-classic/classic-script-entry.js +4 -1
  82. package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
  83. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  84. package/dist/domains/comet-classic/classic-state-command.js +37 -18
  85. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  86. package/dist/domains/comet-classic/classic-validate-command.d.ts.map +1 -1
  87. package/dist/domains/comet-classic/classic-validate-command.js +2 -0
  88. package/dist/domains/comet-classic/classic-validate-command.js.map +1 -1
  89. package/dist/domains/comet-classic/classic-workspace.d.ts +1 -0
  90. package/dist/domains/comet-classic/classic-workspace.d.ts.map +1 -1
  91. package/dist/domains/comet-classic/classic-workspace.js +2 -1
  92. package/dist/domains/comet-classic/classic-workspace.js.map +1 -1
  93. package/dist/domains/comet-entry/entry-runtime.d.ts.map +1 -1
  94. package/dist/domains/comet-entry/entry-runtime.js +13 -3
  95. package/dist/domains/comet-entry/entry-runtime.js.map +1 -1
  96. package/dist/domains/comet-memory/plugin.js +4 -9
  97. package/dist/domains/comet-memory/plugin.js.map +1 -1
  98. package/dist/domains/comet-memory/repository.d.ts +3 -0
  99. package/dist/domains/comet-memory/repository.d.ts.map +1 -1
  100. package/dist/domains/comet-memory/repository.js +117 -25
  101. package/dist/domains/comet-memory/repository.js.map +1 -1
  102. package/dist/domains/comet-memory/review-contract.d.ts.map +1 -1
  103. package/dist/domains/comet-memory/review-contract.js +4 -2
  104. package/dist/domains/comet-memory/review-contract.js.map +1 -1
  105. package/dist/domains/comet-native/native-check-command.d.ts.map +1 -1
  106. package/dist/domains/comet-native/native-check-command.js +5 -1
  107. package/dist/domains/comet-native/native-check-command.js.map +1 -1
  108. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  109. package/dist/domains/comet-native/native-cli-help.js +7 -2
  110. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  111. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  112. package/dist/domains/comet-native/native-next-command.js +22 -1
  113. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  114. package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
  115. package/dist/domains/comet-native/native-output-language.js +3 -1
  116. package/dist/domains/comet-native/native-output-language.js.map +1 -1
  117. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  118. package/dist/domains/comet-native/native-portable-continuation.js +11 -0
  119. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  120. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  121. package/dist/domains/comet-plugin/integration.js +14 -8
  122. package/dist/domains/comet-plugin/integration.js.map +1 -1
  123. package/dist/domains/comet-plugin/plugin-runtime.d.ts +2 -2
  124. package/dist/domains/comet-plugin/plugin-runtime.d.ts.map +1 -1
  125. package/dist/domains/comet-plugin/plugin-runtime.js +89 -77
  126. package/dist/domains/comet-plugin/plugin-runtime.js.map +1 -1
  127. package/dist/domains/comet-plugin/types.d.ts +2 -0
  128. package/dist/domains/comet-plugin/types.d.ts.map +1 -1
  129. package/dist/domains/dashboard/server.d.ts.map +1 -1
  130. package/dist/domains/dashboard/server.js +20 -0
  131. package/dist/domains/dashboard/server.js.map +1 -1
  132. package/dist/domains/dashboard/web/index.html +14 -14
  133. package/dist/domains/integrations/openspec.d.ts.map +1 -1
  134. package/dist/domains/integrations/openspec.js +4 -3
  135. package/dist/domains/integrations/openspec.js.map +1 -1
  136. package/dist/domains/integrations/superpowers.js +2 -2
  137. package/dist/domains/integrations/superpowers.js.map +1 -1
  138. package/dist/domains/project-knowledge/corpus.d.ts.map +1 -1
  139. package/dist/domains/project-knowledge/corpus.js +5 -2
  140. package/dist/domains/project-knowledge/corpus.js.map +1 -1
  141. package/dist/domains/skill/languages.d.ts +3 -1
  142. package/dist/domains/skill/languages.d.ts.map +1 -1
  143. package/dist/domains/skill/languages.js +26 -1
  144. package/dist/domains/skill/languages.js.map +1 -1
  145. package/dist/domains/skill/uninstall.d.ts.map +1 -1
  146. package/dist/domains/skill/uninstall.js +16 -0
  147. package/dist/domains/skill/uninstall.js.map +1 -1
  148. package/dist/platform/process/git-environment.d.ts +3 -0
  149. package/dist/platform/process/git-environment.d.ts.map +1 -0
  150. package/dist/platform/process/git-environment.js +26 -0
  151. package/dist/platform/process/git-environment.js.map +1 -0
  152. package/eval/langsmith/tests/tasks/test_tasks.py +6 -0
  153. package/eval/local/tests/scaffold/test_langsmith_conftest.py +10 -0
  154. package/package.json +2 -2
@@ -155,9 +155,9 @@ ${c}
155
155
  ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return ua(p),p}async function da(t,e){let r=await hk(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(ua(r),r)}async function Qf(t){ua(t.identity);let e=await pk({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),nc==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function Zf(t){if(ua(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Qf(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=ve(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function eh(t,e){let r=await da(t,e);if(r===null)return null;let i=await Zf({paths:t,identity:r});if(i.state==="drifted")throw new Error(`${i.code}: ${i.message}`);return r}var si,Wf,ck,nc,fa=N(()=>{"use strict";ot();D();_e();Ce();O();si=/^[a-f0-9]{64}$/u,Wf=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,ck=16*1024,nc=process.platform});import{promises as vk}from"fs";import It from"path";function ui(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function ah(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function va(t){if(!nh.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ek(t){if(!nh.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function oh(t,e){if(t.length===0||It.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Ck(t,e){let r=ui(t,`spec_changes[${e}]`);if(ah(r,yk,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(Ek(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&oh(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!sc.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!sc.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function xk(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function uc(t,e){if(ah(t,e,jt),typeof t.name!="string")throw new Error("Native change name is required");if(va(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!Nk.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!bk.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let r=t.spec_changes.map(Ck),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof t.verification_result!="string"||!kk.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&oh(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!xk(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Kn(t){let e=ui(t,jt);if(e.schema!==Je)throw new Error(`Expected ${Je}`);return{schema:Je,...uc(e,gk)}}function li(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function oc(t,e,r){if(t===null)return null;let i=typeof t=="string"?Sk.exec(t):null;if(!i||i[1]!==r)throw new Error(`${e} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return t}function Pk(t){if(t==null)return null;if(typeof t!="string"||!sc.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function Rk(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function Yn(t){let e=ui(t,jt);if(e.schema!==ze)throw new Error(`Expected ${ze}`);if(li(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${ze} minimum_runtime_version must be 2`);return{schema:ze,minimum_runtime_version:2,revision:li(e.revision,"Native v2 revision"),...uc(e,ih)}}function Xn(t){let e=ui(t,jt);if(e.schema!==We){if(e.schema===Je||e.schema===ze){let o=e.schema===Je?Kn(e):Yn(e);throw new ha(o.name,o.schema)}throw new Tt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=li(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Tt(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=li(e.revision,"Native revision"),n=uc(e,wk),a=Pk(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:We,minimum_runtime_version:3,revision:i,verification_protocol:Rk(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:oc(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:oc(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:oc(e.partial_allowance,"Native partial_allowance","allowances")}}function Ak(t){let e=ui(t,jt);if(e.schema===Je){let n=Kn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${We}`}}if(e.schema===ze){let n=Yn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${We}`}}if(e.schema!==We){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Tt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=li(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Tt(e.schema,r).message};let i=Xn(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}function $t(t,e){va(e);let r=It.join(t.changesDir,e);if(!W(t.changesDir,r))throw new Error("Native change path escaped");return r}async function dc(t,e){let r=se(t,e),i=It.join(r,"schema-migration.json");await j(W(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await vk.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function _k(t,e=It.dirname(t)){let r=It.relative(e,t).split(It.sep).join("/"),i=await ae({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,lc.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function Ik(t,e){let r=It.join($t(t,e),jt);await j(t.nativeRoot,r);let i=Ak(await _k(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await dc(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await Tk(t,i.state),i)}async function Tk(t,e){if(await Tf(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function Be(t,e){let r=await Ik(t,e);if(r.status==="migration-required")throw new ha(e,r.schema);if(r.status==="runtime-incompatible"||!r.state)throw new Tt(r.schema,r.minimumRuntimeVersion);return await eh(t,e),r.state}var lc,rh,gk,ih,wk,yk,Nk,bk,kk,jt,sc,nh,Sk,ha,Tt,pa,ci,ma,R_,z=N(()=>{"use strict";lc=ur(Ut(),1);ot();_e();D();kt();ce();Ce();O();He();xf();ni();rc();fa();Un();rh=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],gk=new Set(rh),ih=new Set([...rh,"minimum_runtime_version","revision"]),wk=new Set([...ih,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),yk=new Set(["capability","operation","source","base_hash"]),Nk=new Set(["shape","build","verify","archive"]),bk=new Set(["implicit","confirmed"]),kk=new Set(["pending","pass","fail"]),jt="comet-state.yaml",sc=/^[a-f0-9]{64}$/u,nh=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Sk=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,ha=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},Tt=class extends Error{constructor(r,i){super(r!==We||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"},pa=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},ci=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},ma=class extends Error{constructor(r,i,n,a,o,s=null,c=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},R_=En("en")});var F_,di=N(()=>{"use strict";F_=8*1024*1024});var pc=N(()=>{"use strict";di();D()});var G_,ga=N(()=>{"use strict";G_=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ")});var mc=N(()=>{"use strict"});var Ot=N(()=>{"use strict"});var vc=N(()=>{"use strict";ga();mc();Ot()});var hi=N(()=>{"use strict"});var wa=N(()=>{"use strict";hi()});var uh=N(()=>{"use strict"});var cI,dh=N(()=>{"use strict";ga();cI=8*1024*1024});var fh=N(()=>{"use strict";dh()});var ya,gc=N(()=>{"use strict";di();ot();ce();pc();Qr();O();ya=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation}});var wc=N(()=>{"use strict";pc();D();Z();vc();wa();Ce();O();ce();ot();uh();di();fh();gc()});var Gk,hh=N(()=>{"use strict";Gk=ur(Ut(),1);ot();di();_e();Z();ce();O();ri();wc()});var gh,sr=N(()=>{"use strict";Z();ni();gh=1024*1024});var Ea=N(()=>{"use strict";Z();Ot();Wr();sr()});var yh,nS,aS,oS,PT,sS,RT,Sc=N(()=>{"use strict";Z();yh="scoped-text-safety",nS=1,aS=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),oS="comet.native.checker-policy.v1",PT=Q(oS,{policy:yh,version:nS,limits:aS,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),sS=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],RT=new Set(sS)});var Ca=N(()=>{"use strict";Z();Sc();Ot()});var uS,zT,cr=N(()=>{"use strict";D();O();Ae();sr();Ea();Ca();uS=gh,zT=3*uS});ja();import{promises as gS}from"fs";import re from"path";import{readFileSync as sp}from"fs";import $c from"path";function $a(t){return t.charCodeAt(0)===65279?t.slice(1):t}var cp=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","searchreplace","strreplaceeditor","write","writefile","writefiletool"]),lp=new Set(["glob","grep","listfiles","read","readfile","search","view"]),Oc=["file_path","filePath","path","target_file","targetFile"],Hc=["file_paths","filePaths","paths","files","targets"],Dc=["operations","edits"],up=["patch","diff","patchText","patch_text","changes"];function Da(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Oa(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function dp(t){for(let e of["tool_name","toolName","tool","name"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}return null}function fp(t){for(let e of["cwd","working_directory","workspaceRoot"]){let r=t[e];if(!(typeof r!="string"||!r.trim()||!$c.isAbsolute(r.trim())))return $c.resolve(r.trim())}}function hp(t){for(let e of["session_id","sessionId","conversation_id","conversationId"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim().slice(0,256)}}function pp(t){for(let e of["hook_event_name","hookEventName","event_name","eventName"]){let r=t[e];if(typeof r=="string"&&r.trim())return Oa(r)}}function mp(t){for(let e of["task","prompt","user_prompt","userPrompt"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}}function vp(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function gp(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return vp(t[e]);return t}function Ha(t){let e=[],r=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let i of r)for(let n of t.matchAll(i)){let a=n[1]?.trim();a&&a!=="/dev/null"&&e.push(a)}return e}function mt(t,e){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(Array.isArray(e)){for(let r of e)mt(t,r);return}if(Da(e)){for(let r of Oc)mt(t,e[r]);for(let r of Hc)mt(t,e[r]);for(let r of Dc)mt(t,e[r])}}function wp(t,e){let r=[],i=[e,t].filter(Da);for(let n of i){for(let a of Oc)mt(r,n[a]);for(let a of Hc)mt(r,n[a]);for(let a of Dc)mt(r,n[a]);for(let a of up){let o=n[a];typeof o=="string"&&r.push(...Ha(o))}}return typeof e=="string"&&r.push(...Ha(e)),[...new Set(r)]}function dr(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let r;try{r=JSON.parse($a(t))}catch{let s=Ha(t);return s.length>0?{intent:"write",targets:[...new Set(s)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!Da(r))return{intent:"unknown",targets:[],toolName:null};let i=dp(r),n=wp(r,gp(r)),a=fp(r),o=hp(r);if(pp(r)==="beforeagentstart"){let s=mp(r);return{intent:"context",targets:[],toolName:null,...s?{task:s}:{},...a?{cwd:a}:{},...o?{sessionId:o}:{}}}return i&&cp.has(Oa(i))?{intent:n.length>0?"write":"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i&&lp.has(Oa(i))?{intent:"non-write",targets:[],toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i?{intent:"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...a?{cwd:a}:{},...o?{sessionId:o}:{}}}function Lc(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return dr("",t);try{return dr(sp(0,"utf8"),t)}catch{return dr("",t)}}z();ce();O();tc();Kr();import jk from"path";var fc="comet.selection.v2",$k=16*1024;function ch(t){return jk.join(t,".comet","current-change.json")}function Ok(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function sh(t){return t===null||typeof t=="string"}function Hk(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`current change selection contains invalid JSON: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!Ok(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!sh(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:fc,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==fc)throw new Error(`current change selection schema must be ${fc}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!sh(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function lh(t){let e;try{let i=ch(t),{bytes:n}=await Et(i,$k,{label:"current change selection"});e=n.toString("utf8")}catch(i){if(i.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${i instanceof Error?i.message:String(i)}`,{cause:i})}return{status:"selected",...Hk(e)}}z();ce();Ce();ot();D();import{promises as Nh}from"node:fs";import xa from"node:path";kt();z();_e();De();O();var Lk=["outcome","scope","nonGoals","acceptanceExamples"],B_=[...Lk,"constraints","decisions","openQuestions","verificationExpectations"];_e();Z();hh();wc();z();vc();ri();Gn();hi();wa();function Kk(t){return t.state_version+1}function Yk(t){return t.map(e=>({...e,result:"pending",reason:null}))}function Xk(t){return{goal_cycle:t.state.loop.goal_cycle,iteration:t.state.loop.iteration,attempt:t.state.loop.attempt,outcome:t.outcome,unresolved_ids:t.unresolvedIds??[],summary:ii(t.summary),completed_at:t.completedAt}}function ph(t){let e=Oe(t.state);if(e.phase!=="verify"&&e.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=(t.now??new Date).toISOString(),i=Jn(e,Xk({state:e,outcome:"recovery",summary:t.reason,completedAt:r})),n=new Set(e.loop.previous_unresolved_ids),a=n.size===0?Yk(e.acceptance):e.acceptance.map(o=>n.has(o.id)?{...o,result:"pending",reason:null}:o);return Oe({...i,phase:"build",status:"active",state_version:Kk(e),verification_result:"pending",verification_report:null,verification:null,builder_handoff:e.builder_handoff,blockers:[],acceptance:a,loop:{...e.loop,stage:"repairing",iteration:e.loop.iteration+1,attempt:0,execution_failure_count:0,stop_reason:void 0,next_action:"submit-builder-candidate"}})}D();Fn();import{promises as Qk}from"node:fs";import pi from"node:path";function Na(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ba(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Me(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function mh(t,e){return t===null?null:Me(t,e)}function Sa(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Zk(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function eS(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function ka(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function yc(t,e){if(t===null)return null;let r=Me(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Nc(t,e){let r=Me(t,e);if(!pi.isAbsolute(r))throw new Error(`${e} must be absolute`);return pi.resolve(r)}function tS(t,e){let r=`Native local checks[${e}]`,i=Na(t,r);if(ba(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((l,u)=>Me(l,`${r}.argv[${u}]`,!0)),a=ka(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=yc(i.startedAt,`${r}.startedAt`),s=yc(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=Sa(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);return{id:Me(i.id,`${r}.id`),name:Me(i.name,`${r}.name`),operationId:Me(i.operationId,`${r}.operationId`),status:a,repeatable:eS(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Sa(i.executionCount,`${r}.executionCount`),argv:n,cwd:Nc(i.cwd,`${r}.cwd`),exitCode:Zk(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:Me(i.log,`${r}.log`)}}function vh(t){let e="Native local execution state",r=Na(t,e);if(ba(r,new Set(["schema","change","basedOnStateVersion","workspace","execution","checks"]),e),r.schema!==ei)throw new Error(`Native local execution schema must be ${ei}`);let i=Na(r.workspace,"Native local workspace");ba(i,new Set(["projectRoot","worktreeRoot","branch"]),"Native local workspace");let n=null;if(r.execution!==null){let o=Na(r.execution,"Native local execution");ba(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds"]),"Native local execution");let s=yc(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:Me(o.operationId,"Native local execution.operationId"),stage:ka(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:ka(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:mh(o.executionId,"Native local execution.executionId"),status:ka(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Sa(o.requestCheckRounds,"Native local execution.requestCheckRounds")}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(tS);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:ei,change:Me(r.change,"Native local change"),basedOnStateVersion:Sa(r.basedOnStateVersion,"Native local basedOnStateVersion",1),workspace:{projectRoot:Nc(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Nc(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:mh(i.branch,"Native local workspace.branch")},execution:n,checks:a}}function bc(t){return vh({schema:ei,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,workspace:{projectRoot:pi.resolve(t.projectRoot),worktreeRoot:pi.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null},execution:null,checks:[]})}async function kc(t,e,r={}){let i=vh(e);await Qk.mkdir(pi.dirname(t),{recursive:!0}),await oe(t,i,r)}Ce();Fs();ri();Js();Gn();hi();wa();D();kt();hi();O();kt();cr();ce();var fS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hS="comet-state.yaml",pS="state.json",i$=En("en");function bh(t){let e=t.expected;if(e){if(t.state.state_version!==e.stateVersion)throw new Error(`Native continuation is stale for state version ${e.stateVersion}; current state version is ${t.state.state_version}`);if(e.action!==t.action)throw new Error(`Native continuation expected ${e.action} cannot be used for ${t.action}`)}}function Pa(t,e){if(!fS.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=xa.join(t.changesDir,e);if(!W(t.changesDir,r))throw new Error("Native change path escaped");return r}function Ec(t,e){return xa.join(Pa(t,e),hS)}function kh(t,e){return xa.join(rr(t,e),pS)}async function Ra(t,e){try{let r=await Nh.readFile(Ec(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function Sh(t){return ve(t).currentBranch}async function lr(t,e){return ti(Ec(t,e))}async function Eh(t){let e=await cf({file:Ec(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=xa.join(Pa(t.paths,e.name),"verification.md");await j(t.paths.nativeRoot,r),await Nh.rm(r,{force:!0})}return e}async function Ch(t){return de(t.paths,`return portable change ${t.name} to Build`,async()=>{let e=await lr(t.paths,t.name);if(bh({state:e,expected:t.expectedContinuation,action:"revise-implementation"}),e.phase==="build")return e;let r=ph({state:e,reason:t.reason}),i=await Eh({paths:t.paths,previous:e,next:r});return await kc(kh(t.paths,e.name),bc({portableState:i,projectRoot:t.paths.projectRoot,branch:Sh(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),i})}async function xh(t){return de(t.paths,`return portable change ${t.name} to Shape`,async()=>{let e=await lr(t.paths,t.name);if(bh({state:e,expected:t.expectedContinuation,action:"revise-requirements"}),t.allowedPhases&&!t.allowedPhases.includes(e.phase))throw new Error("--revise-requirements is only valid from Verify or Archive");return e.phase==="shape"?e:mS({paths:t.paths,state:e,reason:t.reason})})}async function mS(t){let{state:e}=t;if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i={...Jn(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:ii(t.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:e.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await Eh({paths:t.paths,previous:e,next:i});return await kc(kh(t.paths,e.name),bc({portableState:n,projectRoot:t.paths.projectRoot,branch:Sh(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n}var h$=16*1024;async function vS(t){let e=await lh(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(va(e.selection.change),e.selection)}async function Ph(t){let e=await vS(t);return e?(await Ra(t,e.change)?await lr(t,e.change):await Be(t,e.change),e.change):null}function Rh(t){let e=`Native change ${t.name} is in ${t.phase}; implementation writes are only allowed in Build.`;return t.phase==="shape"?`${e} Reread the latest continuation, complete requirement clarification, and execute the Shape confirmation command after user confirmation.`:t.phase==="verify"?`${e} Select and execute the matching commandAlternative from the latest continuation, preserving --expected-state-version and --expected-action.`:t.phase==="archive"?`${e} Continue finalizing the accepted result; do not run Verify-only revision commands from Archive.`:`${e} Create or select a separate Native change if this write belongs to different work.`}async function wS(t){let{projectRoot:e,paths:r,state:i,request:n}=t,a=Pa(r,i.name),o=[],s=[],c=!1,l=!1,u=!1;for(let d of n.targets){let f=re.resolve(e,d);if(!pt(e,f)){u=!0;continue}let p=re.relative(e,f).replaceAll("\\","/");if(p===".comet/config.yaml"){l=!0;continue}if(!pt(r.nativeRoot,f)){if(await ca(e,f,[re.join(e,".comet"),r.nativeRoot])){c=!0;continue}s.push(p);continue}if(!pt(a,f))return{allowed:!1,reason:pt(r.specsDir,f)?`Published Native specs are updated through Archive. Stage the complete target spec in ${re.join(a,"specs",re.relative(r.specsDir,f))}; use comet native spec sync for reference-only corrections, or revise-requirements for requirement changes.`:"Portable Native control state is Runtime-owned",workflow:"native",phase:i.phase,change:i.name};let g=re.relative(a,f).replaceAll("\\","/");if(g==="brief.md"||g==="children.yaml"||g.startsWith("specs/")){o.push(g);continue}return{allowed:!1,reason:`${g||"change directory"} is Runtime-owned and cannot be edited by the Agent`,workflow:"native",phase:i.phase,change:i.name}}return o.length>0&&s.length>0?{allowed:!1,reason:"Formal Native requirements and implementation files must be edited in separate actions",workflow:"native",phase:i.phase,change:i.name}:o.length>0?i.phase!=="shape"?{allowed:!0,reason:`Native requirements changed; returned to Shape goal cycle ${(await xh({paths:r,name:i.name,reason:`Formal requirement write requested for ${o.join(", ")}`})).loop.goal_cycle}`,workflow:"native",phase:"shape",change:i.name}:{allowed:!0,reason:"Native control artifact write",workflow:"native",phase:i.phase,change:i.name}:s.length>0?i.children_contract_hash?{allowed:!1,reason:"Native parent Build advances child changes instead of editing implementation",workflow:"native",phase:i.phase,change:i.name}:i.phase==="build"?{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:i.phase,change:i.name}:i.phase==="verify"||i.phase==="archive"?{allowed:!0,reason:`Native candidate was invalidated and returned to Build iteration ${(await Ch({paths:r,name:i.name,reason:`Observed implementation write before ${s.join(", ")}`})).loop.iteration}`,workflow:"native",phase:"build",change:i.name}:{allowed:!1,reason:Rh(i),workflow:"native",phase:i.phase,change:i.name}:c?{allowed:!0,reason:"Native configured Hook allow path",workflow:"native",phase:i.phase,change:i.name}:{allowed:!0,reason:l?"Native control artifact write":u?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:i.phase,change:i.name}}function pt(t,e){let r=re.relative(t,e);return r===""||!r.startsWith("..")&&!re.isAbsolute(r)}function yS(t,e,r){return r.targets.length>0&&r.targets.every(i=>{let n=re.resolve(t,i);return pt(t,n)?re.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||pt(e,n):!0})}async function NS(t){let e=await be(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let r=await Pt(t,e.native.artifact_root),i;try{i=await gS.readdir(r.changesDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return{paths:r,changes:[]};throw a}let n=[];for(let a of i.sort((o,s)=>o.name.localeCompare(s.name)))if(!(!a.isDirectory()||a.isSymbolicLink()))if(await Ra(r,a.name)){let o=await lr(r,a.name);o.archived||n.push({kind:"portable",state:o})}else{let o=await Be(r,a.name);o.archived||n.push({kind:"legacy",state:o})}return{paths:r,changes:n}}var bS=wi("nativeActiveContext",t=>NS(t));async function Ah(){let{intent:t,targets:e}=await Lc();return{intent:t,targets:e}}async function _h(t,e,r){let i=await bS(t);if(!i)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.changes.length===0)return{allowed:!0,reason:yS(t,i.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let n;if(r){if(n=i.changes.find(l=>l.state.name===r),!n)return{allowed:!1,reason:`Selected Native change ${r} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:r}}else if(i.changes.length===1)n=i.changes[0];else{let l=await Ph(i.paths);if(n=i.changes.find(u=>u.state.name===l),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}let a=n.state;if(n.kind==="legacy"&&a.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:a.phase,change:a.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:a.phase,change:a.name};if(n.kind==="portable")return wS({projectRoot:t,paths:i.paths,state:n.state,request:e});let o=!1,s=!1,c=!1;for(let l of e.targets){let u=re.resolve(t,l);if(!pt(t,u)){s=!0;continue}if(re.relative(t,u).replaceAll("\\","/")===".comet/config.yaml"){o=!0;continue}if(pt(i.paths.nativeRoot,u)){o=!0;continue}if(await ca(t,u,[re.join(t,".comet"),i.paths.nativeRoot])){c=!0;continue}return{allowed:!1,reason:Rh(a),workflow:"native",phase:a.phase,change:a.name}}return{allowed:!0,reason:o?"Native control artifact write":s?"Write target is outside the guarded project":c?"Native configured Hook allow path":"No guarded write target was provided",workflow:"native",phase:a.phase,change:a.name}}Kr();import vi from"path";import{realpathSync as sE}from"fs";ot();var Ue={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Ih(t){return t?t.command?`${Ue.next} ${t.command}`:t.ask_user?`${Ue.next} ${t.ask_user}`:null:null}function Th(t,e){let r=[t.summary],i=Ih(t.next);return i&&r.push(i),t.user_message&&r.push("",Ue.relay,t.user_message),e!==void 0&&r.push("",Ue.details,JSON.stringify(e,null,2)),`${r.join(`
156
156
  `)}
157
157
  `}function jh(t,e,r){let i=[t.summary],n=Ih(t.next);return n&&i.push(n),t.user_message&&i.push("",Ue.relay,t.user_message),i.push("",`${Ue.detail} ${e}`),r!==void 0&&i.push("",Ue.details,JSON.stringify(r,null,2)),i.join(`
158
- `)}oi();Z();_e();z();Z();var kS=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});cr();He();fa();z();ce();O();ai();D();z();De();Qr();Ce();O();He();Ot();Z();Z();Ea();sr();De();var $h={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},ES=te("comet-native-runtime:v3:scope-reopen"),dO=[{skillVersion:"3",skillHash:te("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:te("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:te("comet-native-runtime:v1")}];oi();De();oi();De();rc();Un();var Hh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],zO=new Set(Hh),_S=new Set([...Hh,"minimum_runtime_version","revision"]),JO=new Set([..._S,"operation"]),GO=512*1024,IS=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),UO=new Set([...IS,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Mn();_e();z();_e();Mn();Z();var ZO={maxAcceptanceCriteria:nf.maxCriteria};var n0={maxSpecs:64,maxFileBytes:bn,maxTotalBytes:4*1024*1024};cr();ni();sr();Ea();import{execFile as MS}from"node:child_process";ga();mc();z();import{promisify as FS}from"node:util";z();D();z();De();O();He();Wr();Ot();var p0={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};Ce();D();Sc();O();Ae();var O0=512*1024;cr();Ce();Ot();var mi=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};ni();Ca();sr();var nH=64*1024;var aH=3600*1e3;var oH=FS(MS);Ca();var Aa=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};fa();De();He();var WH={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};D();Ae();O();He();na();var eD=16*1024*1024,tD=256*1024,rD=16*1024;z();D();kt();z();cr();var cD=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});De();Qr();Ce();O();He();na();var QD=16*1024*1024,_a=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Ia=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};z();O();ce();function x(t,e,r){return t==="zh-CN"?r:e}var Cc={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Bh(t,e){return typeof t=="string"&&Cc[t]?x(e,Cc[t].en,Cc[t].zh):typeof t=="string"?t:""}function xc(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function GS(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function Mh(t,e){let r=[];t.failed>0&&r.push(x(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(x(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(x(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=x(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Fh(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function Pc(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function US(t,e,r){return t==="done"?x(r,"complete","已完成"):t==="await-user"?x(r,"waiting for a user decision","等待用户决定"):t==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):e?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function KS(t,e,r){let i=Pc(t),n=[];r&&n.push(r);let a=x(i,`Change ${t.change}`,`需求 ${t.change}`),o=Bh(t.phase,i),s=US(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Mh(e,i));let c=t.userCommunication,l=Vh(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Vh(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:x(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:x(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:x(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function YS(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function XS(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Bh(t.phase,e),n=t.status==="await-user"?x(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?x(e,"paused","已暂停"):t.status==="done"?x(e,"complete","已完成"):x(e,"in progress","进行中"),a=xc(t.acceptance)?`${x(e,", ",",")}${Mh(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function QS(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function ZS(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function eE(t){if(t.healthy){let i=t.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=tE(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:x("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:x("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function tE(t){return Fh(t)?Vh(t,Pc(t)):void 0}function qh(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(ZS(e))return eE(e);if(YS(e)){let i=QS(e.items);return{summary:[e.total===e.items.length?x(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):x(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>XS(a,i))].join(`
159
- `)}}let r=e.continuation;if(Fh(r))return KS(r,rE(e),iE(e,Pc(r)));if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:x(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function rE(t){if(xc(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(xc(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return GS(r.acceptance)}return null}function iE(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return x(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?x(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Wh(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:x("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:x("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:x("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:x("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:x("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:x("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:x("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:x("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:x("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}gc();var zh=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],Ac=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","check <change-name> Run the read-only Native verification check.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:zh,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec remove <change-name> <capability>
160
- comet native spec sync <change-name> <capability> --input <json-file>`,purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal.","sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections without changing prose or acceptance."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},"spec sync":{usage:"comet native spec sync <change-name> <capability> --input <json-file>",purpose:"Sync local Markdown link destinations in an already confirmed target spec; semantic edits require Shape.",options:["--input <json-file> Fields: expectedStateVersion, actor, reason, affectedAcceptanceIds, replacements [{from,to}]. Include all acceptance IDs from the affected spec."],output:"The audited portable state, preserved unaffected acceptance results and Build continuation for re-verification."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--coordination-mode multi-session|single-session] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
158
+ `)}oi();Z();_e();z();Z();var kS=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});cr();He();fa();z();ce();O();ai();D();z();De();Qr();Ce();O();He();Ot();Z();Z();Ea();sr();De();var $h={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},ES=te("comet-native-runtime:v3:scope-reopen"),dO=[{skillVersion:"3",skillHash:te("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:te("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:te("comet-native-runtime:v1")}];oi();De();oi();De();rc();Un();var Hh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],zO=new Set(Hh),_S=new Set([...Hh,"minimum_runtime_version","revision"]),JO=new Set([..._S,"operation"]),GO=512*1024,IS=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),UO=new Set([...IS,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Mn();_e();z();_e();Mn();Z();var ZO={maxAcceptanceCriteria:nf.maxCriteria};var n0={maxSpecs:64,maxFileBytes:bn,maxTotalBytes:4*1024*1024};cr();ni();sr();Ea();import{execFile as MS}from"node:child_process";ga();mc();z();import{promisify as FS}from"node:util";z();D();z();De();O();He();Wr();Ot();var p0={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};Ce();D();Sc();O();Ae();var O0=512*1024;cr();Ce();Ot();var mi=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};ni();Ca();sr();var nH=64*1024;var aH=3600*1e3;var oH=FS(MS);Ca();var Aa=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};fa();De();He();var WH={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};D();Ae();O();He();na();var eD=16*1024*1024,tD=256*1024,rD=16*1024;z();D();kt();z();cr();var cD=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});De();Qr();Ce();O();He();na();var QD=16*1024*1024,_a=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Ia=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};z();O();ce();function x(t,e,r){return t==="zh-CN"?r:e}var Cc={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Bh(t,e){return typeof t=="string"&&Cc[t]?x(e,Cc[t].en,Cc[t].zh):typeof t=="string"?t:""}function xc(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function GS(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function Mh(t,e){let r=[];t.failed>0&&r.push(x(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(x(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(x(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=x(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Fh(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function Pc(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function US(t,e,r){return t==="done"?x(r,"complete","已完成"):t==="await-user"?x(r,"waiting for a user decision","等待用户决定"):t==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):e?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function KS(t,e,r){let i=Pc(t),n=[];r&&n.push(r);let a=x(i,`Change ${t.change}`,`需求 ${t.change}`),o=Bh(t.phase,i),s=US(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Mh(e,i));let c=t.userCommunication,l=Vh(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Vh(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:x(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:x(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:x(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function YS(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function XS(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Bh(t.phase,e),n=t.status==="await-user"?x(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?x(e,"paused","已暂停"):t.status==="done"?x(e,"complete","已完成"):x(e,"in progress","进行中"),a=xc(t.acceptance)?`${x(e,", ",",")}${Mh(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function QS(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function ZS(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function eE(t){if(t.healthy){let i=t.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=tE(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:x("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:x("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function tE(t){return Fh(t)?Vh(t,Pc(t)):void 0}function qh(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(ZS(e))return eE(e);if(YS(e)){let i=QS(e.items);return{summary:[e.total===e.items.length?x(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):x(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>XS(a,i))].join(`
159
+ `)}}let r=e.continuation;if(Fh(r))return KS(r,rE(e),iE(e,Pc(r)));if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:x(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function rE(t){if(xc(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(xc(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return GS(r.acceptance)}return null}function iE(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return x(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?x(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Wh(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:x("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:x("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:x("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:x("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:x("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:x("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:x("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:x("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:x("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}gc();var zh=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],Ac=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:zh,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec remove <change-name> <capability>
160
+ comet native spec sync <change-name> <capability> --input <json-file>`,purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal.","sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections without changing prose or acceptance."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},"spec sync":{usage:"comet native spec sync <change-name> <capability> --input <json-file>",purpose:"Sync local Markdown link destinations in an already confirmed target spec; semantic edits require Shape.",options:["--input <json-file> Fields: expectedStateVersion, actor, reason, affectedAcceptanceIds, replacements [{from,to}]. Include all acceptance IDs from the affected spec."],output:"The audited portable state, preserved unaffected acceptance results and Build continuation for re-verification."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"A compact summary and NEXT action by default. Use --json to read the portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required. Fill command-template placeholders before executing NEXT commands."},check:{usage:"comet native check <change-name>",purpose:"Legacy-only verification command; not supported for current portable changes.",output:"For current changes, run comet native status <change-name> --json and follow the continuation to dispatch verification through comet native next."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--coordination-mode multi-session|single-session] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
161
161
  comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--expected-state-version <n>] [--expected-action <action>]
162
162
  comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Select how a multi-child Supervisor proceeds while preparing its Shape confirmation; final Shape confirmation is a later, separate step.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits, review. review fields: status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}]. Returns checkExecution with operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
163
163
  comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, and the exact next continuation, or the completed Archive transaction and workspace finish result. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function Rc(t,e){return`${t}: