@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
@@ -184,9 +184,9 @@ ${e.sessionId}`)}:{}},p=e.binding?{schema:"comet.native.workspace.v3",...f,...e.
184
184
  `}function By(e){return Ry("sha256").update(e).digest("hex")}function My(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Native root-move cleanup manifest entry ${t} must be an object`);let r=e,i=Object.keys(r).sort(),n=r.type==="file"?["hash","ref","size","type"]:["ref","type"];if(JSON.stringify(i)!==JSON.stringify(n))throw new Error(`Native root-move cleanup manifest entry ${t} has invalid fields`);if(typeof r.ref!="string"||r.ref.length===0||r.ref.includes("\\")||$.posix.normalize(r.ref)!==r.ref||r.ref.startsWith("/")||r.ref.split("/").includes("..")||Buffer.byteLength(r.ref,"utf8")>4096)throw new Error(`Native root-move cleanup manifest entry ${t} has an invalid ref`);if(r.type==="directory")return{ref:r.ref,type:"directory"};if(r.type!=="file"||typeof r.size!="number"||!Number.isSafeInteger(r.size)||r.size<0||typeof r.hash!="string"||!/^[a-f0-9]{64}$/u.test(r.hash))throw new Error(`Native root-move cleanup manifest entry ${t} is invalid`);return{ref:r.ref,type:"file",size:r.size,hash:r.hash}}function Fy(e,t,r){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native root-move cleanup manifest must be an object");let i=e;if(JSON.stringify(Object.keys(i).sort())!==JSON.stringify(["entries","kind","schema","transactionId"])||i.schema!=="comet.native.root-move-cleanup.v1"||i.transactionId!==t||i.kind!==r||!Array.isArray(i.entries))throw new Error("Native root-move cleanup manifest binding is invalid");let n=i.entries.map(My);for(let a=0;a<n.length;a+=1){if(a>0&&n[a-1].ref.localeCompare(n[a].ref)>=0)throw new Error("Native root-move cleanup manifest refs must be unique and sorted");let o=$.posix.dirname(n[a].ref);if(o!=="."&&!n.some(s=>s.ref===o&&s.type==="directory"))throw new Error(`Native root-move cleanup manifest parent is missing: ${o}`)}return{schema:"comet.native.root-move-cleanup.v1",transactionId:t,kind:r,entries:n}}async function Vy(e){let t={schema:"comet.native.root-move-cleanup.v1",transactionId:e.id,kind:e.kind,entries:e.entries},r=Ly(t);if(Buffer.byteLength(r,"utf8")>of)throw new Error("Native root-move cleanup manifest exceeds its byte budget");return await Y(sf(e.paths,e.id,e.kind),r,{containedRoot:e.paths.runtimeDir}),By(r)}async function qy(e){let t=await Q({root:e.paths.runtimeDir,file:sf(e.paths,e.id,e.cleanup.kind),maxBytes:of,label:`Native root-move cleanup manifest ${e.cleanup.kind}`});if(t.hash!==e.cleanup.manifestHash)throw new Error("Native root-move cleanup manifest hash changed");return Fy(JSON.parse(t.bytes.toString("utf8")),e.id,e.cleanup.kind)}async function bs(e){let t=await ai(e.quarantine,{rejectSymlinks:!0}),r=new Map(e.manifest.entries.map(i=>[i.ref,i]));for(let i of t){let n=r.get(i.ref);if(!n||JSON.stringify(n)!==JSON.stringify(i))throw new Error(`Native root-move cleanup quarantine differs from its bound manifest: ${i.ref}`)}if(e.exact&&t.length!==e.manifest.entries.length)throw new Error("Native root-move cleanup quarantine is incomplete before deletion");return t}function rf(e){return e.ref.split("/").length}async function Wy(e){let r=[...await bs({quarantine:e.quarantine,manifest:e.manifest,exact:!1})].sort((n,a)=>rf(a)-rf(n)||(n.type===a.type?a.ref.localeCompare(n.ref):n.type==="file"?-1:1)),i=0;for(let n of r){let a=$.join(e.quarantine,...n.ref.split("/"));n.type==="file"?await ts({root:e.projectRoot,file:a,maxBytes:ks,expectedHash:n.hash,expectedSize:n.size,label:`Native root-move cleanup file ${n.ref}`}):await rs({root:e.projectRoot,directory:a,label:`Native root-move cleanup directory ${n.ref}`}),i+=1,await e.hooks?.afterRootMoveCleanupEntryRemoved?.(e.manifest.kind,n.ref,i)}await bs({quarantine:e.quarantine,manifest:e.manifest,exact:!1}),await rs({root:e.projectRoot,directory:e.quarantine,label:`Native root-move cleanup quarantine ${e.manifest.kind}`})}function Un(e,t,r=e.native.artifact_root){return{...e,native:{...e.native,artifact_root:r,pending_root_move:t}}}function zy(e){return{schema:"comet.native.transaction.v1",id:e.id,kind:"root-move",status:"prepared",projectRoot:e.paths.projectRoot,nativeRoot:e.paths.nativeRoot,createdAt:e.now.toISOString(),operations:[]}}async function nf(e){let t=Un(e.config,{...e.pending,stage:e.stage},e.activeArtifactRoot);return await et(e.projectRoot,t),t}async function ni(e){let t=e.config.native.pending_root_move;if(!t||t.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let r=Un(e.config,{id:t.id,fromArtifactRoot:t.fromArtifactRoot,toArtifactRoot:t.toArtifactRoot,stage:t.stage,...e.cleanup?{cleanup:e.cleanup}:{}},e.config.native.artifact_root);return await et(e.projectRoot,r),r}async function af(e){let t=e.config,r=t.native.pending_root_move;if(!r||r.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let i=r.cleanup;if(i&&i.kind!==e.kind)throw new Error(`Native root move has unfinished ${i.kind} cleanup; cannot start ${e.kind}`);let n=await ne(e.target),a=await ne(e.quarantine);if(n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(!i){if(!n&&!a)return t;if(!n&&a)throw new Error(`Native root-move cleanup quarantine is not transaction-bound: ${e.kind}`);let s=await Vy({paths:e.stablePaths,id:e.id,kind:e.kind,entries:await ai(e.target,{rejectSymlinks:!0})});i={kind:e.kind,state:"prepared",manifestHash:s},t=await ni({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:i})}let o=await qy({paths:e.stablePaths,id:e.id,cleanup:i});if(n=await ne(e.target),a=await ne(e.quarantine),n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(n){if(i.state!=="prepared")throw new Error(`Native root-move cleanup target reappeared after quarantine: ${e.kind}`);await cd({root:e.projectRoot,directory:e.target,quarantine:e.quarantine,label:e.label,beforeQuarantine:e.beforeQuarantine,afterQuarantine:e.afterQuarantine}),a=!0}if(!a){if(i.state!=="deleting")throw new Error(`Native root-move cleanup quarantine disappeared: ${e.kind}`);return ni({projectRoot:e.projectRoot,config:t,id:e.id})}return await bs({quarantine:e.quarantine,manifest:o,exact:i.state!=="deleting"}),i.state==="prepared"&&(i={...i,state:"quarantined"},t=await ni({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:i})),i.state==="quarantined"&&(i={...i,state:"deleting"},t=await ni({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:i})),await Wy({projectRoot:e.projectRoot,quarantine:e.quarantine,manifest:o,hooks:e.hooks}),ni({projectRoot:e.projectRoot,config:t,id:e.id})}async function Jy(e){let t=e.config,r=t.native.pending_root_move.stage;if(r==="copying"){if(!await ne(e.sourcePaths.nativeRoot))throw new Error(`Native source root is missing: ${e.sourcePaths.nativeRoot}`);let s=Dy(e.staging);t=await af({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"restart-staging",stablePaths:e.sourcePaths,target:e.staging,quarantine:s,label:"Native root move stale staging removal",hooks:e.hooks}),await ai(e.sourcePaths.nativeRoot,{rejectSymlinks:!0,excludedFiles:new Set([$.resolve(e.lockFile)])}),await $y(e.sourcePaths.nativeRoot,e.staging,e.lockFile,e.destinationPaths.projectRoot),await Gn(e.sourcePaths.nativeRoot,e.staging,e.lockFile),t=await nf({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"ready"}),r="ready",await e.hooks?.afterRootMoveStage?.("ready",e.journal)}if(r==="ready"){if(await ne(e.destinationPaths.nativeRoot)){if(await ne(e.staging))throw new Error(`Native destination is occupied: ${e.destinationPaths.nativeRoot}`);await Gn(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile)}else{if(!await ne(e.staging))throw new Error("Native move staging tree is missing");await Gn(e.sourcePaths.nativeRoot,e.staging,e.lockFile),await it.rename(e.staging,e.destinationPaths.nativeRoot)}t=await nf({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"switched",activeArtifactRoot:e.pending.toArtifactRoot}),r="switched",await e.hooks?.afterRootMoveStage?.("switched",e.journal)}if(r!=="switched")throw new Error(`Unsupported Native root-move stage: ${r}`);if(!await ne(e.destinationPaths.nativeRoot))throw new Error(`Native destination root is missing: ${e.destinationPaths.nativeRoot}`);let i=Hy(e.sourcePaths,e.pending.id);!t.native.pending_root_move?.cleanup&&await ne(e.sourcePaths.nativeRoot)&&await Gn(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile),t=await af({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"forward-source",stablePaths:e.destinationPaths,target:e.sourcePaths.nativeRoot,quarantine:i,label:"Native root move source removal",beforeQuarantine:()=>e.hooks?.beforeRootMoveSourceRemove?.(e.sourcePaths.nativeRoot),afterQuarantine:s=>e.hooks?.afterRootMoveSourceQuarantined?.(s),hooks:e.hooks}),await Iy(e.destinationPaths);let n=await Jr(e.destinationPaths,e.pending.id);await os(e.destinationPaths,n,"commit");let a={artifact_root:t.native.artifact_root,language:t.native.language,clarification_mode:t.native.clarification_mode,archive_confirmation:t.native.archive_confirmation,max_verify_failures:t.native.max_verify_failures,snapshot:t.native.snapshot},o={...t,native:{...a,artifact_root:e.pending.toArtifactRoot}};return await et(e.projectRoot,o),o}async function cf(e){let t=await oe(e.projectRoot)??Ku("docs");if(t.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is already incomplete`);let r=Dr(e.toArtifactRoot);if(r===t.native.artifact_root)throw new Error(`Native artifact root is already ${r}`);let i=await Se(e.projectRoot,t.native.artifact_root),n=await Se(e.projectRoot,r);if(z(i.nativeRoot,n.nativeRoot)||z(n.nativeRoot,i.nativeRoot))throw new Error("Native source and destination roots must not overlap");if(!await ne(i.nativeRoot))throw new Error(`Native source root does not exist: ${i.nativeRoot}`);if(await Ay(i),await ne(n.nativeRoot))throw new Error(`Native destination is occupied: ${n.nativeRoot}`);let a=await Br(i,"root-move",`move root to ${r}`),o=_y(),s={id:o,fromArtifactRoot:t.native.artifact_root,toArtifactRoot:r,stage:"copying"},c=zy({id:o,paths:i,now:e.now??new Date}),l=Oy(n,o);try{if(await Ty(i,a.file),await jy(i),await ne(l))throw new Error(`Native move staging path is occupied: ${l}`);return await et(e.projectRoot,Un(t,s)),await yd(i,c),await e.hooks?.afterRootMoveStage?.("copying",c),await Jy({projectRoot:e.projectRoot,config:Un(t,s),pending:s,sourcePaths:i,destinationPaths:n,staging:l,journal:c,lockFile:a.file,hooks:e.hooks}),{fromNativeRoot:i.nativeRoot,toNativeRoot:n.nativeRoot,transactionId:o}}finally{await Mr(a)}}jr();import di from"path";import{realpathSync as ib}from"fs";tt();var De={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function lf(e){return e?e.command?`${De.next} ${e.command}`:e.ask_user?`${De.next} ${e.ask_user}`:null:null}function uf(e,t){let r=[e.summary],i=lf(e.next);return i&&r.push(i),e.user_message&&r.push("",De.relay,e.user_message),t!==void 0&&r.push("",De.details,JSON.stringify(t,null,2)),`${r.join(`
185
185
  `)}
186
186
  `}function df(e,t,r){let i=[e.summary],n=lf(e.next);return n&&i.push(n),e.user_message&&i.push("",De.relay,e.user_message),i.push("",`${De.detail} ${t}`),r!==void 0&&i.push("",De.details,JSON.stringify(r,null,2)),i.join(`
187
- `)}gt();G();Re();_e();O();var Uy=["outcome","scope","nonGoals","acceptanceExamples"],QP=[...Uy,"constraints","decisions","openQuestions","verificationExpectations"];Zr();ee();Re();G();ee();var Ky=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});Gt();me();ti();G();ie();O();Qr();H();G();_e();Ft();ge();O();me();wt();ee();ee();Kn();Jt();_e();var mf={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:[]},nN=le("comet-native-runtime:v3:scope-reopen"),o_=[{skillVersion:"3",skillHash:le("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:le("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:le("comet-native-runtime:v1")}];Zr();_e();Zr();_e();us();Ln();var gf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],M_=new Set(gf),dN=new Set([...gf,"minimum_runtime_version","revision"]),F_=new Set([...dN,"operation"]),V_=512*1024,fN=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),q_=new Set([...fN,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Vn();Re();G();Re();Vn();ee();var U_={maxAcceptanceCriteria:Bd.maxCriteria};var Z_={maxSpecs:64,maxFileBytes:On,maxTotalBytes:4*1024*1024};Gt();Xr();Jt();Kn();import{execFile as SN}from"node:child_process";Xn();Es();G();import{promisify as EN}from"node:util";G();H();G();_e();O();me();Yr();wt();var fA={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};ge();H();Ss();O();ke();var jA=512*1024;Gt();ge();wt();var ci=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Xr();Yn();Jt();var rT=64*1024;var iT=3600*1e3;var nT=EN(SN);Yn();var Qn=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};ti();_e();me();var VT={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};H();ke();O();me();Gr();var XT=16*1024*1024,QT=256*1024,ZT=16*1024;G();H();gt();G();Gt();var aI=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});_e();Ft();ge();O();me();jr();var cI=16*1024;G();ie();ge();tt();H();Re();ee();Sf();_s();G();Ps();ri();Wn();ui();Zn();H();qn();ge();vs();ri();gs();Wn();ui();Zn();H();gt();ui();O();gt();Gt();ie();var K$=Hn("en");var uO=16*1024;Gr();var ZO=16*1024*1024,ta=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"},ra=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"};G();O();ie();function x(e,t,r){return e==="zh-CN"?r:t}var As={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Ef(e,t){return typeof e=="string"&&As[e]?x(t,As[e].en,As[e].zh):typeof e=="string"?e:""}function Ts(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function qN(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function Cf(e,t){let r=[];e.failed>0&&r.push(x(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(x(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(x(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=x(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function xf(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function Is(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function WN(e,t,r){return e==="done"?x(r,"complete","已完成"):e==="await-user"?x(r,"waiting for a user decision","等待用户决定"):e==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):t?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function zN(e,t,r){let i=Is(e),n=[];r&&n.push(r);let a=x(i,`Change ${e.change}`,`需求 ${e.change}`),o=Ef(e.phase,i),s=WN(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(Cf(t,i));let c=e.userCommunication,l=Pf(e,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Pf(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:x(t,"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(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:x(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:x(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function JN(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function GN(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=Ef(e.phase,t),n=e.status==="await-user"?x(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?x(t,"paused","已暂停"):e.status==="done"?x(t,"complete","已完成"):x(t,"in progress","进行中"),a=Ts(e.acceptance)?`${x(t,", ",",")}${Cf(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function UN(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function KN(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function YN(e){if(e.healthy){let i=e.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=XN(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.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 XN(e){return xf(e)?Pf(e,Is(e)):void 0}function Rf(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(KN(t))return YN(t);if(JN(t)){let i=UN(t.items);return{summary:[t.total===t.items.length?x(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):x(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>GN(a,i))].join(`
188
- `)}}let r=t.continuation;if(xf(r))return zN(r,QN(t),ZN(t,Is(r)));if(typeof t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:x(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function QN(e){if(Ts(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(Ts(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return qN(r.acceptance)}return null}function ZN(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return x(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?x(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function _f(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.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}}Rs();var Af=["--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."],$s=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:Af,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>
189
- 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>]
187
+ `)}gt();G();Re();_e();O();var Uy=["outcome","scope","nonGoals","acceptanceExamples"],QP=[...Uy,"constraints","decisions","openQuestions","verificationExpectations"];Zr();ee();Re();G();ee();var Ky=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});Gt();me();ti();G();ie();O();Qr();H();G();_e();Ft();ge();O();me();wt();ee();ee();Kn();Jt();_e();var mf={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:[]},nN=le("comet-native-runtime:v3:scope-reopen"),o_=[{skillVersion:"3",skillHash:le("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:le("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:le("comet-native-runtime:v1")}];Zr();_e();Zr();_e();us();Ln();var gf=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],M_=new Set(gf),dN=new Set([...gf,"minimum_runtime_version","revision"]),F_=new Set([...dN,"operation"]),V_=512*1024,fN=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),q_=new Set([...fN,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Vn();Re();G();Re();Vn();ee();var U_={maxAcceptanceCriteria:Bd.maxCriteria};var Z_={maxSpecs:64,maxFileBytes:On,maxTotalBytes:4*1024*1024};Gt();Xr();Jt();Kn();import{execFile as SN}from"node:child_process";Xn();Es();G();import{promisify as EN}from"node:util";G();H();G();_e();O();me();Yr();wt();var fA={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};ge();H();Ss();O();ke();var jA=512*1024;Gt();ge();wt();var ci=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Xr();Yn();Jt();var rT=64*1024;var iT=3600*1e3;var nT=EN(SN);Yn();var Qn=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};ti();_e();me();var VT={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};H();ke();O();me();Gr();var XT=16*1024*1024,QT=256*1024,ZT=16*1024;G();H();gt();G();Gt();var aI=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});_e();Ft();ge();O();me();jr();var cI=16*1024;G();ie();ge();tt();H();Re();ee();Sf();_s();G();Ps();ri();Wn();ui();Zn();H();qn();ge();vs();ri();gs();Wn();ui();Zn();H();gt();ui();O();gt();Gt();ie();var K$=Hn("en");var uO=16*1024;Gr();var ZO=16*1024*1024,ta=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"},ra=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"};G();O();ie();function x(e,t,r){return e==="zh-CN"?r:t}var As={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Ef(e,t){return typeof e=="string"&&As[e]?x(t,As[e].en,As[e].zh):typeof e=="string"?e:""}function Ts(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function qN(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function Cf(e,t){let r=[];e.failed>0&&r.push(x(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(x(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(x(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=x(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function xf(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function Is(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function WN(e,t,r){return e==="done"?x(r,"complete","已完成"):e==="await-user"?x(r,"waiting for a user decision","等待用户决定"):e==="blocked"?x(r,"paused: needs attention","已暂停,需要处理"):t?x(r,"waiting for a user decision","等待用户决定"):x(r,"ready to continue","可继续推进")}function zN(e,t,r){let i=Is(e),n=[];r&&n.push(r);let a=x(i,`Change ${e.change}`,`需求 ${e.change}`),o=Ef(e.phase,i),s=WN(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(Cf(t,i));let c=e.userCommunication,l=Pf(e,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Pf(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:x(t,"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(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:x(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:x(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function JN(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function GN(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=Ef(e.phase,t),n=e.status==="await-user"?x(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?x(t,"paused","已暂停"):e.status==="done"?x(t,"complete","已完成"):x(t,"in progress","进行中"),a=Ts(e.acceptance)?`${x(t,", ",",")}${Cf(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function UN(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function KN(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function YN(e){if(e.healthy){let i=e.repaired?x("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):x("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=XN(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.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 XN(e){return xf(e)?Pf(e,Is(e)):void 0}function Rf(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(KN(t))return YN(t);if(JN(t)){let i=UN(t.items);return{summary:[t.total===t.items.length?x(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):x(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>GN(a,i))].join(`
188
+ `)}}let r=t.continuation;if(xf(r))return zN(r,QN(t),ZN(t,Is(r)));if(typeof t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:x(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function QN(e){if(Ts(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(Ts(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return qN(r.acceptance)}return null}function ZN(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return x(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?x(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function _f(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.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}}Rs();var Af=["--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."],$s=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:Af,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>
189
+ 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>]
190
190
  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>]
191
191
  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]
192
192
  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 js(e,t){return`${e}: