@tocca-systems/twp-cli 0.102.0 → 0.102.1

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.
@@ -11,6 +11,12 @@
11
11
  `CHANGELOG.md` に残してあります。顧客向けの履歴は public 公開以降を対象とします。
12
12
  -->
13
13
 
14
+ ## 0.102.1
15
+
16
+ `/context` の「コンテキスト残量」に表示される窓サイズが、使用中のモデルの実際の窓サイズを示すようになりました。
17
+
18
+ ループのキューへ積むアイテムで、引数の先頭に `[検証用]` のような注記を置いた場合に、タスクキーでない値がタスクキーとして記録される不具合を修正しました。
19
+
14
20
  ## 0.102.0
15
21
 
16
22
  `--quiet`(`-q`)または環境変数 `TWP_QUIET=1` で、既定値の使用などを知らせる情報用の注記を省けるようになりました。エラー・警告・続きのページの案内は従来どおり表示されます。
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{stepToItem}from"./chunk-DTDIQOVQ.js";import"./chunk-VEEZJNOB.js";import{loadLocalConfig}from"./chunk-INS77QHY.js";import{parseOperations}from"./chunk-CVX2YWHC.js";import"./chunk-VYDPW2YO.js";import"./chunk-TTST7UDR.js";import{loadAiConfig}from"./chunk-FABDZBDZ.js";import{SKILL_PREFIX_RE,setSkillPrefix}from"./chunk-6CS5L24D.js";import"./chunk-N2UVRM3Z.js";import"./chunk-UZUV5FYG.js";import{PRIVATE_PROJECT_PREFIX,PRIVATE_PROJECT_REF,
3
+ import{stepToItem}from"./chunk-2UTJI3BT.js";import"./chunk-VEEZJNOB.js";import{loadLocalConfig}from"./chunk-INS77QHY.js";import{parseOperations}from"./chunk-CVX2YWHC.js";import"./chunk-VYDPW2YO.js";import"./chunk-TTST7UDR.js";import{loadAiConfig}from"./chunk-FABDZBDZ.js";import{SKILL_PREFIX_RE,setSkillPrefix}from"./chunk-6CS5L24D.js";import"./chunk-N2UVRM3Z.js";import"./chunk-UZUV5FYG.js";import{PRIVATE_PROJECT_PREFIX,PRIVATE_PROJECT_REF,
4
4
  isPrivateProjectRef,privateProjectId}from"./chunk-RMFLTSOV.js";import"./chunk-BD7O73GK.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-MI6HVYR2.js";import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";import{acknowledgement,isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiResponseError,UsageError}from"./chunk-VFPY2A23.js";import"./chunk-PMOUHEJQ.js";import"./chunk-J7QYPKVK.js";
5
5
  import"./chunk-5WGOHFAS.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";var LABEL="\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u30EB\u30FC\u30D7\u306E\u30A2\u30A4\u30C6\u30E0";var STATUSES=["pending","processing","completed","failed"];var AI_TYPES=["claude","gemini","codex","copilot"];var EFFORTS=["low","medium","high","xhigh","max"];var PRIORITIES=["P0","P1","P2","P3"];var LIST_COLUMNS=["item_id","status","task_key","label","ai_type","ai_effort","runner_id","created_at"];var GET_COLUMNS=["item_id","status","task_key","label","prompt","ai_type","ai_model","ai_effort","runn\
6
6
  er_id","attempt_count","reclaim_count","error_message","created_by_name","created_at","started_at","completed_at"];var HISTORY_COLUMNS=["item_id","status","task_key","skill","ai_type","runner_id","duration_ms","cost_usd","created_at"];var PLAN_RESULTS=["enqueued","empty","json_not_found","ai_failed","error","skipped","gated","locked","abandoned"];var PLAN_HISTORY_COLUMNS=["plan_run_id","result","runner_id","ai_type","duration_ms","cost_usd","step_count","started_at"];var PROJECT_FLAG={name:"--pr\
@@ -22,7 +22,7 @@ input);const category=requireResolved(input,"category");const primary=input.reso
22
22
  ai_type;const effort=oneOf(input.flags,"--ai-effort",EFFORTS);if(effort!==void 0)body["ai_effort"]=effort;return body}var createOperation={name:"create",summary:"\u30AD\u30E5\u30FC\u306B\u30A2\u30A4\u30C6\u30E0\u3092\u6295\u5165\u3059\u308B",usage:'twp task-loop item create --prompt "/<\u63A5\u982D\u8F9E><\u30B9\u30AD\u30EB\u540D> <\u5F15\u6570>" [--priority P2] [--label <\u30E9\u30D9\u30EB>] [--ai-effort <effort>] [--project <\u30B3\u30FC\u30C9|ID|__private__>]',description:`\u30EB\u30FC\u30D7\u306E\u8A08\u753B\u6295\u5165\u3068\u540C\u3058\u898F\u5247\u3067\u30A2\u30A4\u30C6\u30E0\u3092\
23
23
  \u4F5C\u308A\u307E\u3059\uFF08\u30E9\u30D9\u30EB\u66F8\u5F0F\u30FBtask_key \u306E\u62BD\u51FA\u306F\u8A08\u753B\u6295\u5165\u3068\u5171\u901A\uFF09:
24
24
  \u30E9\u30D9\u30EB [<\u512A\u5148\u5EA6>] <\u30BF\u30B9\u30AF\u30AD\u30FC> <\u30E9\u30D9\u30EB> #ai:<\u30AB\u30C6\u30B4\u30EA>\uFF08200\u5B57\u3067\u5207\u308B\u3002--label \u7701\u7565\u6642\u306F\u30D7\u30ED\u30F3\u30D7\u30C8\uFF09
25
- task_key \u30D7\u30ED\u30F3\u30D7\u30C8\u306E\u5F15\u6570\u306E\u5148\u982D\u306B\u3042\u308B\u30BF\u30B9\u30AF\u30AD\u30FC\uFF08\u4F8B ABC-123\uFF09
25
+ task_key \u30D7\u30ED\u30F3\u30D7\u30C8\u306E\u5F15\u6570\u306E\u5148\u982D\u306B\u3042\u308B\u30BF\u30B9\u30AF\u30AD\u30FC\uFF08\u4F8B ABC-123\uFF09\u3002\u5148\u982D\u304C\u30AD\u30FC\u3067\u306A\u3044\u30FB[\u691C\u8A3C\u7528] \u306E\u3088\u3046\u306A\u62EC\u5F27\u4ED8\u304D\u306E\u6CE8\u8A18\u3067\u59CB\u307E\u308B\u3068\u304D\u306F\u9001\u308A\u307E\u305B\u3093
26
26
  1\u756A\u624B \u3053\u306E\u6A5F\u4F53\u306E\u30EB\u30FC\u30D7\u8A2D\u5B9A\uFF08~/.twp/loops/<\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8ID>.json\uFF09\u306E\u30AB\u30C6\u30B4\u30EA\u8868\u3068 primary_rotation \u3067\u6C7A\u3081\u308B
27
27
  \uFF08\u30B3\u30DE\u30F3\u30C91\u56DE\u3054\u3068\u306B\u8A2D\u5B9A\u3092\u8AAD\u307F\u76F4\u3059\u306E\u3067\u3001\u91CD\u307F\u4ED8\u304D\u30ED\u30FC\u30C6\u30FC\u30B7\u30E7\u30F3\u306F\u56DE\u3089\u305A\u6BCE\u56DE\u305D\u306E\u5148\u982D\u306E\u4F7F\u3048\u308B AI \u306B\u306A\u308A\u307E\u3059\uFF09
28
28
  ai_model \u9001\u308A\u307E\u305B\u3093\uFF08claim \u3057\u305F\u5B9F\u884C\u6A5F\u304C\u81EA\u5206\u306E\u8A2D\u5B9A\u3067\u89E3\u6C7A\u3057\u307E\u3059\uFF09
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-CDAU3M7F.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-HKLXKBNL.js";import"./chunk-3SRTD2GD.js";import"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderOutput}from"./chunk-P4QSPSOQ.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";
3
+ import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelRoutes,validateBody,validateQuery}from"./chunk-CDAU3M7F.js";import{exitCodeFor,fetchAllPages,reportError}from"./chunk-U3GNDK63.js";import"./chunk-MKF6BHGU.js";import"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderOutput}from"./chunk-P4QSPSOQ.js";import{describeWaitResult,parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";
4
4
  import{readBody}from"./chunk-HEH3PUW2.js";import{ALLOW_REDACTED_FLAG,NO_REDACT_FLAG,NO_REDACT_NOTICE}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs,repeatedValues}from"./chunk-VGT2EGH6.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";
5
5
  import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,envelopePaging,isPageNumberEnvelope,pageRangeNotes,positiveInteger,readEnvelopeCursor,readPageNumberCursor,shellQuote}from"./chunk-MI6HVYR2.js";import"./chunk-3ZRMMBP5.js";import{ApiResponseError,EXIT_OK,EXIT_WAIT_TIMEOUT,NetworkError,UsageError}from"./chunk-VFPY2A23.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{
6
6
  httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{HELP_TOKEN}from"./chunk-6FI4ZMZ7.js";import"./chunk-OKATZ4SN.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";var MIN_SEGMENT_CHARS=3;var parsedCache=new WeakMap;function splitSegments(path){return path.split("/").filter(segment=>segment!=="")}function parseRoutes(routes){const cached=parsedCache.get(routes);if(cached!==void 0)return cached;const parsed=[];for(const[key,domain]of Object.entries(routes.routes)){const space=key.indexOf(" ");if(space<=0)continue;const template=key.slice(space+1);parsed.push({method:key.slice(0,space),template,domain,segments:splitSegments(template).map(segment=>/^\{[^/{}]+\}$/.
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{RESIDENT_TOKEN_CAP,activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,describeAuditLog,describeToolCatalog,displayCwd,executeTool,findProjectTwpSubdir,localTools,lstatOrNull,parseFrontMatter,parseRule,persistProjectAllow,projectPermissionsPath,projectRootFor,readFileTool,residentInputs,resolveGitExecutable,runTurn,secretReason}from"./chunk-FZ55A6NN.js";import"./chunk-CDAU3M7F.js";import{buildDiffLines,
4
- diffStat}from"./chunk-VRBI2NPI.js";import{require_fuzzysort}from"./chunk-DIMZRTLE.js";import"./chunk-N2UVRM3Z.js";import"./chunk-BD7O73GK.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-VFPY2A23.js";import{RelayError,builtinCatalog,classifyModelSwitch,createRuntime,loadCachedCatalog,modelLabel,pickModel,specFor,toModelInfos}from"./chunk-PJ7IKTZI.js";
5
- import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import{proxyDiagnostics}from"./chunk-J7QYPKVK.js";import{checkMinSupportedVersion,isBelowMinSupported,minSupportedBlockMessage}from"./chunk-DXXFUNYN.js";import"./chunk-EDF4U5BT.js";import{configReadDirs,twpHomeDir}from"./chunk-RZVI6PMW.js";import{parseArgv}from"./chunk-T4TVFQ5R.js";import{applyPermissionMode,checkPermission,describePermissionMode,getMode,isModeId,modeSource,
6
- nextMode}from"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import{isFullWidth,isWide,stringWidth,stripAnsi}from"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{__commonJS,__export,__require,__toESM}from"./chunk-VSJBJXZO.js";var require_react_production=__commonJS({"node_modules/react/cjs/react.production.js"(exports){"use strict";var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element");var REACT_PORTAL_TYPE=Symbol.for("react.portal");var REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");var REACT_STRICT_MODE_TYPE=Symbol.for("react.strict_mode");var REACT_PROFILER_TYPE=Symbol.for("react.profiler");var REACT_CONSUMER_TYPE=Symbol.for("react.consumer");var REACT_CONTEXT_TYPE=Symbol.for("react.context");var REACT_FORWARD_REF_TYPE=Symbol.
3
+ import{RESIDENT_TOKEN_CAP,activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,describeAuditLog,describeToolCatalog,displayCwd,executeTool,findProjectTwpSubdir,localTools,lstatOrNull,parseFrontMatter,parseRule,persistProjectAllow,projectPermissionsPath,projectRootFor,readFileTool,residentInputs,resolveGitExecutable,runTurn,secretReason}from"./chunk-6R6CY6KM.js";import"./chunk-CDAU3M7F.js";import{buildDiffLines,
4
+ diffStat}from"./chunk-VRBI2NPI.js";import{require_fuzzysort}from"./chunk-DIMZRTLE.js";import"./chunk-N2UVRM3Z.js";import"./chunk-BD7O73GK.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-VFPY2A23.js";import{RelayError,builtinCatalog,classifyModelSwitch,createRuntime,formatContextRemaining,loadCachedCatalog,modelLabel,pickModel,specFor,
5
+ toModelInfos}from"./chunk-65SBCDVQ.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import{proxyDiagnostics}from"./chunk-J7QYPKVK.js";import{checkMinSupportedVersion,isBelowMinSupported,minSupportedBlockMessage}from"./chunk-DXXFUNYN.js";import"./chunk-EDF4U5BT.js";import{configReadDirs,twpHomeDir}from"./chunk-RZVI6PMW.js";import{parseArgv}from"./chunk-T4TVFQ5R.js";import{applyPermissionMode,checkPermission,
6
+ describePermissionMode,getMode,isModeId,modeSource,nextMode}from"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import{isFullWidth,isWide,stringWidth,stripAnsi}from"./chunk-UREA4ZIG.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{__commonJS,__export,__require,__toESM}from"./chunk-VSJBJXZO.js";var require_react_production=__commonJS({"node_modules/react/cjs/react.production.js"(exports){"use strict";var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element");var REACT_PORTAL_TYPE=Symbol.for("react.portal");var REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");var REACT_STRICT_MODE_TYPE=Symbol.for("react.strict_mode");var REACT_PROFILER_TYPE=Symbol.for("react.profiler");var REACT_CONSUMER_TYPE=Symbol.for("react.consumer");var REACT_CONTEXT_TYPE=Symbol.for("react.context");var REACT_FORWARD_REF_TYPE=Symbol.
7
7
  for("react.forward_ref");var REACT_SUSPENSE_TYPE=Symbol.for("react.suspense");var REACT_MEMO_TYPE=Symbol.for("react.memo");var REACT_LAZY_TYPE=Symbol.for("react.lazy");var REACT_ACTIVITY_TYPE=Symbol.for("react.activity");var REACT_VIEW_TRANSITION_TYPE=Symbol.for("react.view_transition");var MAYBE_ITERATOR_SYMBOL=Symbol.iterator;function getIteratorFn(maybeIterable){if(null===maybeIterable||"object"!==typeof maybeIterable)return null;maybeIterable=MAYBE_ITERATOR_SYMBOL&&maybeIterable[MAYBE_ITERATOR_SYMBOL]||
8
8
  maybeIterable["@@iterator"];return"function"===typeof maybeIterable?maybeIterable:null}var ReactNoopUpdateQueue={isMounted:function(){return false},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}};var assign=Object.assign;var emptyObject={};function Component(props,context,updater){this.props=props;this.context=context;this.refs=emptyObject;this.updater=updater||ReactNoopUpdateQueue}Component.prototype.isReactComponent={};Component.prototype.setState=
9
9
  function(partialState,callback){if("object"!==typeof partialState&&"function"!==typeof partialState&&null!=partialState)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,partialState,callback,"setState")};Component.prototype.forceUpdate=function(callback){this.updater.enqueueForceUpdate(this,callback,"forceUpdate")};function ComponentDummy(){}ComponentDummy.prototype=Component.prototype;function PureComponent2(props,context,updater){
@@ -1212,7 +1212,7 @@ cwd()){const listed=await gitListFiles(cwd2);const raw=listed??await walkFiles(c
1212
1212
  1;const after=/^[^\s]*/.exec(text.slice(cursor))?.[0]??"";return{query,start,end:cursor+after.length}}var TWP_SLASH_ROUTES={"/tasks":{domain:"task",operation:"list"},"/task":{domain:"task",operation:"get"},"/projects":{domain:"project",operation:"list"}};function isTwpSlashCommand(name){return Object.hasOwn(TWP_SLASH_ROUTES,name)}async function runTwpSlashCommand(name,args,deps){const route=TWP_SLASH_ROUTES[name];if(!Object.hasOwn(TWP_SLASH_ROUTES,name)||route===void 0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u30B3\u30DE\u30F3\u30C9: ${name}
1213
1213
  `}}const parsed=parseArgv([route.domain,route.operation,...args]);if(parsed.command!=="domain"||parsed.domain!==route.domain){return{code:2,out:"",err:`${name}: \u3053\u306E\u5F15\u6570\u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08${args.join(" ")}\uFF09
1214
1214
  `}}if(parsed.unknown.length>0){return{code:2,out:"",err:`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(parsed.unknown)}
1215
- `}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-CWQ7KDOB.js");try{const code=await runDomain({domain:route.domain,...parsed.operation!==void 0?{operation:parsed.operation}:
1215
+ `}}let out="";let err="";const io={out:text=>void(out+=text),err:text=>void(err+=text),isTty:true};const globals={profile:parsed.profile??deps.profile,...parsed.output!==void 0?{output:parsed.output}:{},...parsed.query!==void 0?{query:parsed.query}:{},dryRun:parsed.dryRun,debug:parsed.debug,yes:parsed.yes,refresh:parsed.refresh};const{runDomain}=await import("./run-264WTPVI.js");try{const code=await runDomain({domain:route.domain,...parsed.operation!==void 0?{operation:parsed.operation}:
1216
1216
  {},argv:parsed.domainArgv,help:parsed.domainHelp,globals,version:deps.version,io,...deps.fetchImpl!==void 0?{fetchImpl:deps.fetchImpl}:{}});return{code,out,err}}catch(e){return{code:1,out,err:`${err}${e.message}
1217
1217
  `}}}var GIT_LOG_OUTPUT=["9f3c1a2 feat(ui): \u4E00\u89A7\u306E\u30D5\u30A3\u30EB\u30BF\u3092 URL \u30AF\u30A8\u30EA\u3068\u540C\u671F\u3059\u308B","4b8e0d7 fix(ui): \u4EEE\u60F3\u30B9\u30AF\u30ED\u30FC\u30EB\u306E\u884C\u9AD8\u3055\u3092\u5B9F\u6E2C\u5024\u306B\u5408\u308F\u305B\u308B","c15a99e refactor(api): \u4E00\u89A7\u53D6\u5F97\u306E\u30DA\u30FC\u30B8\u30F3\u30B0\u51E6\u7406\u3092\u5171\u901A\u5316\u3059\u308B","2d70f4b test: \u4E00\u89A7\u30D5\u30A3\u30EB\u30BF\u306E\u56DE\u5E30\u30C6\u30B9\u30C8\u3092\u8FFD\u52A0\u3059\u308B",
1218
1218
  "a6e2b38 fix(api): \u7A7A\u306E\u691C\u7D22\u6761\u4EF6\u3067\u5168\u4EF6\u8FD4\u3089\u306A\u3044\u3088\u3046\u306B\u3059\u308B","7c40d51 chore(deps): \u958B\u767A\u4F9D\u5B58\u3092\u6700\u65B0\u3078\u66F4\u65B0\u3059\u308B","e83b1c6 docs: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u624B\u9806\u306B Node 22 \u306E\u524D\u63D0\u3092\u8FFD\u8A18\u3059\u308B","b91f7a4 fix(ui): \u30E2\u30FC\u30C0\u30EB\u306E\u91CD\u306A\u308A\u9806\u3092\u6307\u5B9A\u3059\u308B","5a2c8e0 perf(api): \u4E00\u89A7\u306E N+1 \u3092\u89E3\u6D88\u3059\u308B",
@@ -1326,10 +1326,10 @@ to).label}\uFF08${to}\uFF09\u306B\u5207\u308A\u66FF\u3048\u307E\u3057\u305F \u20
1326
1326
  modeRef.current).filter(c=>c.source!==void 0).map(c=>` ${c.name} \u2014 ${c.origin==="project"?"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u5B9A\u7FA9":"\u30E6\u30FC\u30B6\u30FC\u5B9A\u7FA9"}: ${c.source??""}`),"\u30B3\u30DE\u30F3\u30C9\u306F .twp/commands/*.md\uFF08\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\uFF09\u3068 ~/.twp/commands/*.md\uFF08\u30E6\u30FC\u30B6\u30FC\uFF09\u306B\u7F6E\u3051\u307E\u3059 \xB7 @\u30D1\u30B9 \u3067\u30D5\u30A1\u30A4\u30EB\u6DFB\u4ED8 \xB7 #ABC-123 \u306E\u3088\u3046\u306A\u30BF\u30B9\u30AF\u30AD\u30FC\u3067\u30BF\u30B9\u30AF\u6DFB\u4ED8",
1327
1327
  ...(()=>{const pending=PENDING_COMMANDS.filter(c=>findCommand(c.name)===void 0);return pending.length>0?[`\u672A\u5B9F\u88C5\u306E\u305F\u3081\u767B\u9332\u3057\u3066\u3044\u306A\u3044\u30B3\u30DE\u30F3\u30C9: ${pending.map(c=>c.name).join(" ")}`]:[]})(),"\u30AD\u30FC: Shift+Tab \u307E\u305F\u306F Alt+M \u3067\u30E2\u30FC\u30C9\u5DE1\u56DE \xB7 Ctrl+R \u3067\u76F4\u524D\u306E\u30C4\u30FC\u30EB\u51FA\u529B\u3092\u5C55\u958B","\u6539\u884C: Shift+Enter\uFF08kitty \u5BFE\u5FDC\u7AEF\u672B\uFF09\xB7 Ctrl+J\uFF08\u5168\u7AEF\u672B\uFF09\xB7 \\ \u3092\u6253\u3063\u3066\u304B\u3089 Enter \u3067\u3082\u53EF"].
1328
1328
  join("\n")});return;case"/context":{const snapshot=runtime.context.snapshot();const t=snapshot.totals;const resident=buildResidentSet(getMode(modeRef.current),{...residentInputs(toolkit),...permissionMode!==void 0?{permissionMode}:{},permissionLayers});commit({kind:"notice",tone:"info",text:[`\u30E2\u30C7\u30EB: ${modelLabel(model)}\uFF08\u30E2\u30FC\u30C9\u3068\u306F\u72EC\u7ACB\uFF09`,`\u30E2\u30FC\u30C9: ${getMode(modeRef.current).label} \u2014 \u6709\u52B9\u30C4\u30FC\u30EB glob: ${getMode(modeRef.
1329
- current).tools.join(" ")}`,`\u30E2\u30FC\u30C9\u5B9A\u7FA9: ${modeSource(modeRef.current)??"\u7D44\u307F\u8FBC\u307F\uFF08\u5B9A\u7FA9\u30D5\u30A1\u30A4\u30EB\u306A\u3057\uFF09"}`,`\u63A5\u7D9A\u5148: ${runtime.relayUrl}\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB: ${runtime.profileName}\uFF09`,`\u30BF\u30FC\u30F3\u6570: ${snapshot.turns} \xB7 \u76F4\u8FD1\u306E\u30D7\u30ED\u30F3\u30D7\u30C8\u9577: ${snapshot.lastPromptTokens} tok`,`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u6B8B\u91CF: ${snapshot.remainingPercent}\
1330
- %\uFF08\u7A93 200,000 tok \u306E\u6982\u7B97\uFF09`,`\u5B9F\u6E2C\u30C8\u30FC\u30AF\u30F3\u5408\u8A08: input ${t.inputTokens} / cache_read ${t.cacheReadTokens} / cache_write ${t.cacheWriteTokens} / output ${t.outputTokens}`,...snapshot.droppedMessages>0?[`\u4E0A\u9650\u306E\u305F\u3081\u843D\u3068\u3057\u305F\u3084\u308A\u53D6\u308A: ${snapshot.droppedMessages} \u4EF6`]:[],`permission-mode: ${describePermissionMode(permissionMode)}`,`\u76E3\u67FB\u30ED\u30B0: ${describeAuditLog(audit)}`,`\u5E38\u99D0\u30C4\u30FC\u30EB: ${resident.
1331
- tools.length} \u672C / \u30B9\u30AD\u30FC\u30DE\u6982\u7B97 ${resident.tokens} tok\uFF08\u4E0A\u9650 ${RESIDENT_TOKEN_CAP} tok\uFF09`,` ${resident.tools.map(t2=>t2.name).join(" ")||"\uFF08\u306A\u3057\uFF09"}`,...resident.dropped.length>0?[` \u4E0A\u9650\u8D85\u904E\u3067\u5916\u3057\u305F\u30C4\u30FC\u30EB: ${resident.dropped.join(" ")}`]:[],...(()=>{const status=toolkit.catalogStatus();return status!==null?[describeToolCatalog(status)]:[]})()].join("\n")});return}case"/demo":void runDemo("\uFF08\u30C7\
1332
- \u30E2\u518D\u751F\uFF09\u30C4\u30FC\u30EB\u30AB\u30FC\u30C9\u3068\u6A29\u9650\u30C0\u30A4\u30A2\u30ED\u30B0");return;default:commit({kind:"notice",tone:"warn",text:`\u4E0D\u660E\u306A\u30B3\u30DE\u30F3\u30C9: ${name}`})}},[audit,catalog,commit,exit,model,permissionMode,runDemo,runPromptCommand,runTwp,runtime]);const submit=(0,import_react39.useCallback)(()=>{if(busyRef.current){commit({kind:"notice",tone:"warn",text:"\u5B9F\u884C\u4E2D\u3067\u3059\u3002Ctrl+C \u3067\u4E2D\u65AD\u3057\u3066\u304B\u3089\u9001\u4FE1\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5165\u529B\u306F\u4FDD\u6301\u3057\u3066\u3044\u307E\u3059\uFF09"});
1329
+ current).tools.join(" ")}`,`\u30E2\u30FC\u30C9\u5B9A\u7FA9: ${modeSource(modeRef.current)??"\u7D44\u307F\u8FBC\u307F\uFF08\u5B9A\u7FA9\u30D5\u30A1\u30A4\u30EB\u306A\u3057\uFF09"}`,`\u63A5\u7D9A\u5148: ${runtime.relayUrl}\uFF08\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB: ${runtime.profileName}\uFF09`,`\u30BF\u30FC\u30F3\u6570: ${snapshot.turns} \xB7 \u76F4\u8FD1\u306E\u30D7\u30ED\u30F3\u30D7\u30C8\u9577: ${snapshot.lastPromptTokens} tok`,formatContextRemaining(snapshot),`\u5B9F\u6E2C\u30C8\u30FC\u30AF\u30F3\u5408\u8A08: input ${t.
1330
+ inputTokens} / cache_read ${t.cacheReadTokens} / cache_write ${t.cacheWriteTokens} / output ${t.outputTokens}`,...snapshot.droppedMessages>0?[`\u4E0A\u9650\u306E\u305F\u3081\u843D\u3068\u3057\u305F\u3084\u308A\u53D6\u308A: ${snapshot.droppedMessages} \u4EF6`]:[],`permission-mode: ${describePermissionMode(permissionMode)}`,`\u76E3\u67FB\u30ED\u30B0: ${describeAuditLog(audit)}`,`\u5E38\u99D0\u30C4\u30FC\u30EB: ${resident.tools.length} \u672C / \u30B9\u30AD\u30FC\u30DE\u6982\u7B97 ${resident.tokens}\
1331
+ tok\uFF08\u4E0A\u9650 ${RESIDENT_TOKEN_CAP} tok\uFF09`,` ${resident.tools.map(t2=>t2.name).join(" ")||"\uFF08\u306A\u3057\uFF09"}`,...resident.dropped.length>0?[` \u4E0A\u9650\u8D85\u904E\u3067\u5916\u3057\u305F\u30C4\u30FC\u30EB: ${resident.dropped.join(" ")}`]:[],...(()=>{const status=toolkit.catalogStatus();return status!==null?[describeToolCatalog(status)]:[]})()].join("\n")});return}case"/demo":void runDemo("\uFF08\u30C7\u30E2\u518D\u751F\uFF09\u30C4\u30FC\u30EB\u30AB\u30FC\u30C9\u3068\u6A29\u9650\u30C0\u30A4\u30A2\u30ED\u30B0");
1332
+ return;default:commit({kind:"notice",tone:"warn",text:`\u4E0D\u660E\u306A\u30B3\u30DE\u30F3\u30C9: ${name}`})}},[audit,catalog,commit,exit,model,permissionMode,runDemo,runPromptCommand,runTwp,runtime]);const submit=(0,import_react39.useCallback)(()=>{if(busyRef.current){commit({kind:"notice",tone:"warn",text:"\u5B9F\u884C\u4E2D\u3067\u3059\u3002Ctrl+C \u3067\u4E2D\u65AD\u3057\u3066\u304B\u3089\u9001\u4FE1\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5165\u529B\u306F\u4FDD\u6301\u3057\u3066\u3044\u307E\u3059\uFF09"});
1333
1333
  return}const text=bufferRef.current.text.trim();clearBuffer();setOverlay("none");if(text==="")return;if(text.startsWith("/")){runCommand(text);return}void runTurn2(text)},[clearBuffer,commit,runCommand,runTurn2]);const paletteItems=(0,import_react39.useMemo)(()=>paletteFor(buffer.text,mode),[buffer.text,mode]);const dismissedMentionRef=(0,import_react39.useRef)(null);const fileCompletion=(0,import_react39.useMemo)(()=>{const c=fileCompletionFor(buffer,fileIndex);return c!==null&&c.start!==dismissedMentionRef.
1334
1334
  current?c:null},[buffer,fileIndex]);(0,import_react39.useEffect)(()=>{if(fileIndexRef.current!==null||fileIndexLoading.current)return;if(mentionAtCursor(buffer.text,buffer.cursor)===null)return;fileIndexLoading.current=true;void buildFileIndex(process.cwd()).then(index=>{setFileIndex(index);if(index.note!==null)commit({kind:"notice",tone:"info",text:`@ \u88DC\u5B8C: ${index.note}`})},err=>{fileIndexLoading.current=false;commit({kind:"notice",tone:"warn",text:`@ \u88DC\u5B8C\u306E\u5019\u88DC\u3092\u4F5C\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ${stripTerminalControls(
1335
1335
  err.message)}`})})},[buffer,commit]);const onKey=(0,import_react39.useCallback)(ev=>{setKeyLog(prev=>[...prev.slice(-49),ev]);if(ev.name==="ctrl-d"){exit();return}if(ev.name==="ctrl-c"){if(busyRef.current){if(abortRef.current){permissionResolver.current?.("no");return}abortRef.current=true;streamAbortRef.current?.abort();permissionResolver.current?.("no");stream.cancel();abortSleep();setRunningTool(null);if(!streamAbortRef.current){commit({kind:"notice",tone:"warn",text:"\u4E2D\u65AD\u3057\u307E\u3057\u305F\uFF08Ctrl+C\uFF09"})}
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{fetchLatestVersion,isBehindLatest,resolveNpmCommand}from"./chunk-F36CIBG3.js";import"./chunk-PJ7IKTZI.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import{PARENT_PID_ENV,WORKER_ENV,autoUpdateDisabledReason,classifyInstall,isCheckDue,listRegisteredPids,lockFilePath,readUpdateState,resolveCliPath,runDirPath,writeUpdateState}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,parseVersionCore}from"./chunk-DXXFUNYN.js";
3
+ import{fetchLatestVersion,isBehindLatest,resolveNpmCommand}from"./chunk-JS55SZ6W.js";import"./chunk-65SBCDVQ.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import{PARENT_PID_ENV,WORKER_ENV,autoUpdateDisabledReason,classifyInstall,isCheckDue,listRegisteredPids,lockFilePath,readUpdateState,resolveCliPath,runDirPath,writeUpdateState}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,parseVersionCore}from"./chunk-DXXFUNYN.js";
4
4
  import"./chunk-5WGOHFAS.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import{execFile}from"child_process";import fs from"fs";import path from"path";var PARENT_WAIT_MAX_MS=12*60*60*1e3;var PARENT_POLL_MS=1e3;var LOCK_STALE_MS=PARENT_WAIT_MAX_MS+60*60*1e3;var INSTALL_TIMEOUT_MS=0;function childEnv(env){const next={...env};delete next[WORKER_ENV];delete next[PARENT_PID_ENV];return next}function createNpmRunner(env=process.env){const cmd=resolveNpmCommand({env});if(cmd===null)return null;return(args,timeoutMs)=>new Promise(resolve=>{execFile(cmd.file,[...cmd.prefix,...args],{timeout:timeoutMs,windowsHide:true,maxBuffer:8*1024*1024,cwd:path.dirname(lockFilePath(env)),env:childEnv(env)},(error,stdout,stderr)=>{if(error===null){resolve({ok:true,stdout:String(stdout),stderr:String(
5
5
  stderr)});return}const e=error;resolve({ok:false,stdout:String(stdout??""),stderr:String(stderr??""),...e.killed?{error:"\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F"}:typeof e.code==="string"?{error:e.code}:{}})})})}function summarizeNpmFailure(result){const text=`${result.stderr}
6
6
  ${result.stdout}`;const code=/npm (?:ERR!|error) code (\S+)/.exec(text)?.[1]??result.error;let reason;if(code==="EACCES"||code==="EPERM"){reason=`\u30B0\u30ED\u30FC\u30D0\u30EB\u306E\u5C0E\u5165\u5148\u306B\u66F8\u304D\u8FBC\u3080\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\uFF08${code}\uFF09`}else if(code!==void 0&&/^(ENOTFOUND|ETIMEDOUT|ECONNREFUSED|ECONNRESET|EAI_AGAIN|ENETUNREACH)$/.test(code)){reason=`npm registry \u306B\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08${code}\
@@ -0,0 +1,16 @@
1
+ import { createRequire as __twpCreateRequire } from 'node:module';
2
+ const require = __twpCreateRequire(import.meta.url);
3
+ import{FINAL_REPORT_BEGIN,FINAL_REPORT_END,redactLoopOutput}from"./chunk-VEEZJNOB.js";import{skillCommand,skillPrefix}from"./chunk-6CS5L24D.js";import{normalizeRequiredPlatforms}from"./chunk-UZUV5FYG.js";import{extractLeadingTaskKey}from"./chunk-SBRTBKEZ.js";var LEDGER_TASK_KEY_MAX=50;var CONTROL_CHAR_RE=/[\u0000-\u001f\u007f]/;var FLAG_TOKEN_RE=/(?:^|\s)-/;var BRACKET_RE=/[[\]()【】〔〕()「」『』<><>]/;function loosen(source){let t=source.replace(/^[ \t]*\/\/[^\n]*$/gm,"");t=t.replace(/\/\*[\s\S]*?\*\//g,"");t=t.replace(/,(\s*[}\]])/g,"$1");return t===source?null:t}function tryParsePlan(source){for(const candidate of[source,loosen(source)]){if(candidate===null)continue;try{const obj=JSON.parse(candidate);if(obj!==null&&typeof obj===
4
+ "object"&&Array.isArray(obj.steps)){return obj}}catch{}}return null}function fencedBlocks(text,tag){const re=new RegExp("```"+tag+"\\s*\\n([\\s\\S]*?)\\n```","g");const out=[];for(const m of text.matchAll(re)){if(m[1]!==void 0)out.push(m[1])}return out}function extractGeminiEnvelope(text){const anchor=/\{[^{}]*"session_id"[^{}]*"response"\s*:\s*"/g;for(const m of text.matchAll(anchor)){const start=m.index;if(start===void 0)continue;let depth=0;let inStr=false;let escape=false;for(let i=start;i<text.
5
+ length;i++){const c=text[i];if(escape){escape=false;continue}if(c==="\\"){escape=true;continue}if(c==='"'){inStr=!inStr;continue}if(inStr)continue;if(c==="{")depth++;else if(c==="}"){depth--;if(depth===0){try{const obj=JSON.parse(text.slice(start,i+1));if(obj!==null&&typeof obj==="object"&&typeof obj.response==="string"){return obj.response}}catch{}break}}}}return null}function matchingBrace(text,start){let depth=0;let inStr=false;let escape=false;for(let i=start;i<text.length;i++){const c=text[i];
6
+ if(escape){escape=false;continue}if(inStr){if(c==="\\")escape=true;else if(c==='"')inStr=false;continue}if(c==='"')inStr=true;else if(c==="{")depth++;else if(c==="}"){depth--;if(depth===0)return i}}return-1}var MAX_STEPS_ANCHORS=20;var MAX_OPEN_CANDIDATES=8;function lastStepsObject(text){const anchors=[...text.matchAll(/"steps"\s*:/g)].map(m=>m.index).filter(i=>i!==void 0);for(const at of anchors.reverse().slice(0,MAX_STEPS_ANCHORS)){let tried=0;for(let open=text.lastIndexOf("{",at);open>=0&&tried<
7
+ MAX_OPEN_CANDIDATES;open=text.lastIndexOf("{",open-1)){tried++;const close=matchingBrace(text,open);if(close>at){const plan=tryParsePlan(text.slice(open,close+1));if(plan)return plan}if(open===0)break}}return null}function finalReports(text){const re=new RegExp(`${FINAL_REPORT_BEGIN}\\n?([\\s\\S]*?)${FINAL_REPORT_END}`,"g");const out=[];for(const m of text.matchAll(re)){if(m[1]!==void 0)out.push(m[1])}return out.reverse()}function extractFrom(text){for(const tag of["json:execution-plan","json"]){
8
+ for(const block of fencedBlocks(text,tag).reverse()){const plan=tryParsePlan(block);if(plan)return plan}}const resp=extractGeminiEnvelope(text);if(resp!==null){for(const block of[...fencedBlocks(resp,"json:execution-plan"),...fencedBlocks(resp,"json")].reverse()){const plan2=tryParsePlan(block);if(plan2)return plan2}const plan=tryParsePlan(resp);if(plan)return plan}const whole=tryParsePlan(text.trim());if(whole)return whole;return lastStepsObject(text)}function extractPlanJson(rawText){const text=rawText.
9
+ replace(/^\s*\[\d{2}:\d{2}:\d{2}\][ \t]*(?:💬 ?)?/gmu,"");for(const report of finalReports(text)){const plan=extractFrom(report);if(plan)return plan}return extractFrom(text)}function ledgerTaskKey(args){const key=extractLeadingTaskKey(args);if(key.length>LEDGER_TASK_KEY_MAX)return"";if(CONTROL_CHAR_RE.test(key))return"";if(FLAG_TOKEN_RE.test(key))return"";if(BRACKET_RE.test(key))return"";return key}function placeholderTaskKey(args){for(const token of args.split(/\s+/)){if(token==="")continue;if(token.
10
+ startsWith("-"))continue;const m=/^[A-Z]{2,}[A-Z0-9]*-([A-Za-z0-9_<>{}]*)$/.exec(token);if(!m)return null;if(/^\d+$/.test(m[1]??""))return null;return token}return null}function stepToItem(step,assign,prefix=skillPrefix()){const skill=typeof step.skill==="string"?step.skill.trim():"";if(!skill)return null;const args=redactLoopOutput((step.args??"").trim());const priority=step.priority??"P2";const prompt=skillCommand(skill,args,prefix);let label=redactLoopOutput((step.label??"").trim());const own=skillCommand(
11
+ skill,"",prefix);const promptLike=prefix===""?label===own||label.startsWith(`${own} `):label.startsWith(`/${prefix}`);if(!label||promptLike||label.startsWith("[P"))label=prompt;const taskKey=ledgerTaskKey(args);const category=assign?.categoryForSkill(skill)??step.ai_category??"complex";const display=taskKey&&!label.includes(taskKey)?`[${priority}] ${taskKey} ${label} #ai:${category}`:`[${priority}] ${label} #ai:${category}`;const item={label:display.slice(0,200),prompt,task_key:taskKey};const platforms=normalizeRequiredPlatforms(
12
+ step.required_platforms);if(platforms.length>0)item.required_platforms=platforms;if(assign!==void 0){const ai=assign.selectPrimary(category,skill,priority,display);if(ai!=="")item.ai_type=ai}return item}function parsePlanExcludeKeys(prefetchSection){const m=/OPS_PLAN_EXCLUDE_KEYS\s+([^\s]*)\s+-->/.exec(prefetchSection);const keys=new Set;if(!m||!m[1])return keys;for(const raw of m[1].split(",")){const key=raw.trim();if(key!=="")keys.add(key)}return keys}function excludedKeyInArgs(args,excluded){
13
+ if(excluded.size===0)return null;for(const key of[...excluded].sort()){const re=new RegExp(`(?<![A-Za-z0-9-])${key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![0-9])`);if(re.test(args))return key}return null}function parseOpsCount(prefetchSection,field){const marker=/OPS_COUNTS\s+([^>]*?)-->/.exec(prefetchSection);if(!marker||!marker[1])return null;const escaped=field.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const hit=new RegExp(`(?:^|\\s)${escaped}=(-?\\d+)(?:\\s|$)`).exec(marker[1]);if(!hit||hit[1]===
14
+ void 0)return null;const n=Number.parseInt(hit[1],10);if(!Number.isFinite(n)||n<0)return null;return n}function releaseDeployDropReason(verifyBacklog,devVerifyPlanned,guard){if(verifyBacklog===null){return`${guard.countField} \u306E\u4EF6\u6570\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\uFF08\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u30EA\u30EA\u30FC\u30B9\u306F\u898B\u9001\u308B\uFF09`}if(verifyBacklog>devVerifyPlanned){return`${guard.countField} ${verifyBacklog}\u4EF6 > \u8A08\u753B\u5185${guard.
15
+ drainedBy}${devVerifyPlanned}\u4EF6\uFF08Phase 1\u306E0\u4EF6\u898B\u8FBC\u307F\u304C\u7ACB\u305F\u306A\u3044\uFF09`}return null}function duplicateTaskKeyDropReason(enqueuedKeys,taskKey){if(!taskKey)return null;if(!enqueuedKeys.has(taskKey))return null;return`${taskKey} \u306F\u672C\u8A08\u753B\u3067\u65E2\u306B\u6295\u5165\u6E08\u307F\uFF08\u540C\u4E00\u30AD\u30FC\u306F1\u8A08\u753B1\u4EF6\uFF09`}var NO_ZERO_TARGET_GATES={};function zeroTargetDropReasons(prefetchSection,gates=NO_ZERO_TARGET_GATES){
16
+ const reasons=new Map;for(const[skill,gate]of Object.entries(gates)){const n=parseOpsCount(prefetchSection,gate.field);if(n===null)reasons.set(skill,`${gate.label}\u4EF6\u6570\u304C\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u898B\u9001\u308A`);else if(n===0)reasons.set(skill,`${gate.label}0\u4EF6\u306E\u305F\u3081\u5BFE\u8C61\u306A\u3057`)}return reasons}export{extractPlanJson,placeholderTaskKey,stepToItem,parsePlanExcludeKeys,excludedKeyInArgs,parseOpsCount,releaseDeployDropReason,duplicateTaskKeyDropReason,zeroTargetDropReasons};
@@ -69,6 +69,6 @@ this.lastPromptTokens=prompt;this.pendingChars=0}}history(){return this.messages
69
69
  messages.reduce((sum,m)=>sum+bytesOf(m),0);while((this.estimatedPromptTokens()>limit||bytes>maxHistoryBytes)&&this.messages.length>1){const removed=this.messages.shift();if(!removed)break;const removedTokens=Math.ceil(lengthOf(removed)/4);this.lastPromptTokens=Math.max(0,this.lastPromptTokens-removedTokens);bytes-=bytesOf(removed);dropped+=1}while(this.messages.length>0){const head2=this.messages[0];if(!head2)break;const orphanResult=hasToolResult(head2)&&this.messages.length>1;if(head2.role!=="\
70
70
  assistant"&&!orphanResult)break;this.messages.shift();this.lastPromptTokens=Math.max(0,this.lastPromptTokens-Math.ceil(lengthOf(head2)/4));dropped+=1}const head=this.messages[0];if(head&&hasToolResult(head)){const before=lengthOf(head);const kept=head.content.filter(block=>block.type!=="tool_result");head.content=kept.length>0?kept:[{type:"text",text:"\uFF08\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u4E0A\u9650\u306E\u305F\u3081\u3001\u76F4\u524D\u306E\u30C4\u30FC\u30EB\u5B9F\u884C\u7D50\u679C\u306F\u5C65\u6B74\u304B\u3089\u5916\u308C\u307E\u3057\u305F\uFF09"}];
71
71
  const freed=before-lengthOf(head);this.lastPromptTokens=Math.max(0,this.lastPromptTokens-Math.ceil(freed/4));this.pendingChars=Math.max(0,this.pendingChars-freed);dropped+=1}this.droppedMessages+=dropped;return dropped}estimatedPromptTokens(){if(this.lastPromptTokens===0){return Math.ceil(this.totalChars()/4)}return this.lastPromptTokens+Math.ceil(this.pendingChars/4)}snapshot(){const used=this.estimatedPromptTokens();const remaining=Math.round((this.contextWindowTokens-used)/this.contextWindowTokens*
72
- 100);return{totals:{...this.totals},turns:this.turns,lastPromptTokens:this.lastPromptTokens,remainingPercent:Math.max(0,Math.min(100,remaining)),droppedMessages:this.droppedMessages}}totalChars(){return this.messages.reduce((sum,m)=>sum+lengthOf(m),0)}};function bytesOf(message){return Buffer.byteLength(JSON.stringify(message),"utf8")+1}function lengthOf(message){return message.content.reduce((sum,block)=>sum+blockLength(block),0)}function copyBlock(block){return block.type==="tool_use"?{...block,
73
- input:{...block.input}}:{...block}}function hasToolResult(message){return message.content.some(block=>block.type==="tool_result")}function createRuntime(opts){const env=opts.env??process.env;const cwd=opts.cwd??process.cwd();const profile=resolveProfile(opts.profile,env,cwd);const creds=loadCredentials(profile.name,env);const apiUrl=effectiveApiUrl(profile,creds?.api_url,env);const relayUrl=effectiveRelayUrl(profile,creds?.relay_url,env);const session=new AuthSession(profile.name,apiUrl,env);const client=new RelayClient(relayUrl,session,httpFetch,opts.cliVersion);const configured=resolveConfiguredModel(opts.model,profile.name,
74
- env,cwd);return{profileName:profile.name,apiUrl,relayUrl,client,session,context:new ContextManager,loggedIn:creds!==null,configuredModel:configured?.model??null,loadCatalog:()=>loadCatalog(client,profile.name,relayUrl,env),loadCachedFloor:()=>loadCachedVersionFloor(profile.name,relayUrl,env),loadCachedCatalog:()=>loadCachedCatalog(profile.name,relayUrl,env)}}export{emptyUsage,DEFAULT_MAX_TOKENS,DEFAULT_MAX_HISTORY_BYTES,modelLabel,toModelInfos,effectiveModelSpec,builtinCatalog,loadCachedCatalog,pickModel,specFor,classifyModelSwitch,RelayError,createRuntime};
72
+ 100);return{totals:{...this.totals},turns:this.turns,lastPromptTokens:this.lastPromptTokens,remainingPercent:Math.max(0,Math.min(100,remaining)),contextWindowTokens:this.contextWindowTokens,droppedMessages:this.droppedMessages}}totalChars(){return this.messages.reduce((sum,m)=>sum+lengthOf(m),0)}};function bytesOf(message){return Buffer.byteLength(JSON.stringify(message),"utf8")+1}function lengthOf(message){return message.content.reduce((sum,block)=>sum+blockLength(block),0)}function copyBlock(block){
73
+ return block.type==="tool_use"?{...block,input:{...block.input}}:{...block}}function hasToolResult(message){return message.content.some(block=>block.type==="tool_result")}function formatContextRemaining(snapshot){return`\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u6B8B\u91CF: ${snapshot.remainingPercent}%\uFF08\u7A93 ${snapshot.contextWindowTokens.toLocaleString("en-US")} tok \u306E\u6982\u7B97\uFF09`}function createRuntime(opts){const env=opts.env??process.env;const cwd=opts.cwd??process.cwd();const profile=resolveProfile(opts.profile,env,cwd);const creds=loadCredentials(profile.name,env);const apiUrl=effectiveApiUrl(profile,creds?.api_url,env);const relayUrl=effectiveRelayUrl(profile,creds?.relay_url,env);const session=new AuthSession(profile.name,apiUrl,env);const client=new RelayClient(relayUrl,session,httpFetch,opts.cliVersion);const configured=resolveConfiguredModel(opts.model,profile.name,
74
+ env,cwd);return{profileName:profile.name,apiUrl,relayUrl,client,session,context:new ContextManager,loggedIn:creds!==null,configuredModel:configured?.model??null,loadCatalog:()=>loadCatalog(client,profile.name,relayUrl,env),loadCachedFloor:()=>loadCachedVersionFloor(profile.name,relayUrl,env),loadCachedCatalog:()=>loadCachedCatalog(profile.name,relayUrl,env)}}export{emptyUsage,DEFAULT_MAX_TOKENS,DEFAULT_MAX_HISTORY_BYTES,formatContextRemaining,modelLabel,toModelInfos,effectiveModelSpec,builtinCatalog,loadCachedCatalog,pickModel,specFor,classifyModelSwitch,RelayError,createRuntime};
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
3
  import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelIndex,validateBody,validateQuery,withCommonQueryParams}from"./chunk-CDAU3M7F.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{redactSecretValues}from"./chunk-BD7O73GK.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_HISTORY_BYTES,DEFAULT_MAX_TOKENS,effectiveModelSpec,
4
- emptyUsage}from"./chunk-PJ7IKTZI.js";import{isPrivateTwpHome,isTrustworthyCacheFile,writePrivateFileAtomic}from"./chunk-D233KKXW.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{AuthSession,NotLoggedInError,SessionExpiredError,withFileLock}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{configReadDirs,ensureTwpHome,twpHomeDir}from"./chunk-RZVI6PMW.js";import{MODES,applyPermissionMode,checkPermission,
4
+ emptyUsage}from"./chunk-65SBCDVQ.js";import{isPrivateTwpHome,isTrustworthyCacheFile,writePrivateFileAtomic}from"./chunk-D233KKXW.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{AuthSession,NotLoggedInError,SessionExpiredError,withFileLock}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{configReadDirs,ensureTwpHome,twpHomeDir}from"./chunk-RZVI6PMW.js";import{MODES,applyPermissionMode,checkPermission,
5
5
  isModeId,setActiveModes}from"./chunk-2LOT54OO.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs2 from"fs";import path3 from"path";import os2 from"os";import{realpathSync}from"fs";import{homedir}from"os";import{dirname,isAbsolute,relative,resolve,sep}from"path";var PathDeniedError=class extends Error{constructor(message){super(message);this.name="PathDeniedError"}};function resolveToolPath(input,cwd,home=homedir()){if(typeof input!=="string"||input.trim()===""){throw new PathDeniedError("path must be a non-empty string")}const expanded=expandHome(input,home);const abs=isAbsolute(expanded)?resolve(expanded):resolve(cwd,expanded);const root=realOrSelf(resolve(cwd));assertInside(abs,resolve(cwd),abs);assertNotSecret(abs,home);const real=realOrSelf(abs);if(real!==
6
6
  abs){assertInside(real,root,abs);assertNotSecret(real,home)}return abs}function realToolPath(input,cwd,home=homedir()){return realOrSelf(resolveToolPath(input,cwd,home))}function assertInside(target,root,reported){const rel=relative(root,target);const outside=rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel);if(outside){throw new PathDeniedError(`path escapes the working directory (${reported}). Only paths under ${root} can be accessed.`)}}function realOrSelf(target){let current=target;const rest=[];
7
7
  for(;;){try{const real=realpathSync(current);return rest.length===0?real:resolve(real,...rest.reverse())}catch{const parent=dirname(current);if(parent===current)return target;rest.push(current.slice(parent.length+1));current=parent}}}function assertNotSecret(absPath,home=homedir(),env=process.env){const reason=secretReason(absPath,home,env);if(reason!==null)throw new PathDeniedError(`refusing to access ${absPath}: ${reason}`)}function secretReason(absPath,_home=homedir(),env=process.env){const lower=absPath.
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{createRuntime}from"./chunk-PJ7IKTZI.js";import{findExecutable}from"./chunk-PMOUHEJQ.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{describeAutoUpdate}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,UPDATE_COMMAND,compareVersionCores,isBelowMinSupported,parseVersionCore}from"./chunk-DXXFUNYN.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{execFile}from"child_process";import fs from"fs";import path from"path";function resolveNpmCommand(deps={}){const platform=deps.platform??process.platform;const env=deps.env??process.env;const npmPath=(deps.find??(name=>findExecutable(name,{env,platform})))("npm");if(npmPath===null)return null;if(platform!=="win32")return{file:npmPath,prefix:[]};if(/\.exe$/i.test(npmPath))return{file:npmPath,prefix:[]};const cliJs=path.win32.join(path.win32.dirname(npmPath),"node_modules","npm","bin","npm-cli.js");return(deps.exists??fs.existsSync)(cliJs)?{file:deps.nodePath??process.
3
+ import{createRuntime}from"./chunk-65SBCDVQ.js";import{findExecutable}from"./chunk-PMOUHEJQ.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{describeAutoUpdate}from"./chunk-CH6QU76P.js";import{PACKAGE_NAME,UPDATE_COMMAND,compareVersionCores,isBelowMinSupported,parseVersionCore}from"./chunk-DXXFUNYN.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{execFile}from"child_process";import fs from"fs";import path from"path";function resolveNpmCommand(deps={}){const platform=deps.platform??process.platform;const env=deps.env??process.env;const npmPath=(deps.find??(name=>findExecutable(name,{env,platform})))("npm");if(npmPath===null)return null;if(platform!=="win32")return{file:npmPath,prefix:[]};if(/\.exe$/i.test(npmPath))return{file:npmPath,prefix:[]};const cliJs=path.win32.join(path.win32.dirname(npmPath),"node_modules","npm","bin","npm-cli.js");return(deps.exists??fs.existsSync)(cliJs)?{file:deps.nodePath??process.
4
4
  execPath,prefix:[cliJs]}:null}var DEFAULT_REGISTRY="https://registry.npmjs.org";function registryBase(env=process.env){const configured=env["npm_config_registry"]?.trim();if(configured===void 0||configured==="")return DEFAULT_REGISTRY;try{const url=new URL(configured);if(url.protocol!=="https:"&&url.protocol!=="http:")return DEFAULT_REGISTRY}catch{return DEFAULT_REGISTRY}return configured.replace(/\/+$/,"")}async function fetchFromRegistry(fetchImpl=httpFetch,env=process.env){const url=`${registryBase(env)}/${PACKAGE_NAME.replace(
5
5
  "/","%2f")}`;const res=await fetchImpl(url,{headers:{Accept:"application/vnd.npm.install-v1+json"},signal:AbortSignal.timeout(5e3)});if(!res.ok){throw new Error(`registry \u304C ${res.status} \u3092\u8FD4\u3057\u307E\u3057\u305F`)}const body=await res.json();const latest=body["dist-tags"]?.latest;if(typeof latest!=="string"||parseVersionCore(latest)===null){throw new Error("registry \u306E\u5FDC\u7B54\u306B dist-tags.latest \u304C\u3042\u308A\u307E\u305B\u3093")}return{version:latest.trim(),source:"\
6
6
  registry"}}async function fetchFromNpmCli(){const npm=resolveNpmCommand();if(npm===null){throw new Error("npm \u304C PATH \u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093")}const stdout=await new Promise((resolve,reject)=>{execFile(npm.file,[...npm.prefix,"view",PACKAGE_NAME,"version","--json"],{timeout:15e3,windowsHide:true},(error,out)=>error?reject(error):resolve(out))});const parsed=JSON.parse(stdout.trim());const latest=typeof parsed==="string"?parsed:null;if(latest===null||parseVersionCore(
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- var LOADERS={agent:async()=>(await import("./agent-HIZOEXPJ.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-3LE5FD4U.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-NVOUC3FC.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-J6DYNA53.js")).analysisDomain,announcement:async()=>(await import("./announcement-2GTF3KDU.js")).announcementDomain,"api-key":async()=>(await import("./api-key-MMQ3AN7V.js")).apiKeyDomain,attendance:async()=>(await import("./attendance-correct-SIS5UGMY.js")).
3
+ var LOADERS={agent:async()=>(await import("./agent-HIZOEXPJ.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-X2FH7LCO.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-NVOUC3FC.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-J6DYNA53.js")).analysisDomain,announcement:async()=>(await import("./announcement-2GTF3KDU.js")).announcementDomain,"api-key":async()=>(await import("./api-key-MMQ3AN7V.js")).apiKeyDomain,attendance:async()=>(await import("./attendance-correct-SIS5UGMY.js")).
4
4
  attendanceDomainWithRecords,"audit-log":async()=>(await import("./audit-log-ZGK7IVLD.js")).auditLogDomain,backlog:async()=>(await import("./backlog-UC5BLMGR.js")).backlogDomain,budget:async()=>(await import("./budget-KBD7M3BQ.js")).budgetDomain,"business-hours":async()=>(await import("./business-hours-37MRL53C.js")).businessHoursDomain,"business-place":async()=>(await import("./sales-master-BOR7D5QK.js")).businessPlaceDomain,company:async()=>(await import("./company-FKHXNP5D.js")).companyDomain,
5
5
  contract:async()=>(await import("./contract-YYGKQ3AJ.js")).contractDomain,customer:async()=>(await import("./company-FKHXNP5D.js")).customerDomain,department:async()=>(await import("./department-C35IWGFL.js")).departmentDomain,deposit:async()=>(await import("./deposit-DJ4JDEFB.js")).depositDomain,estimate:async()=>(await import("./estimate-5JIENI2G.js")).estimateDomain,evaluation:async()=>(await import("./evaluation-QOEV2VNV.js")).evaluationDomain,expense:async()=>(await import("./expense-J3CMLOAV.js")).
6
6
  expenseDomain,faq:async()=>(await import("./faq-HPBYZLNO.js")).faqDomain,"fiscal-year":async()=>(await import("./fiscal-year-ZCRHTUSK.js")).fiscalYearDomain,holiday:async()=>(await import("./holiday-R6WLLRIS.js")).holidayDomain,"goal-sheet":async()=>(await import("./evaluation-QOEV2VNV.js")).goalSheetDomain,inquiry:async()=>(await import("./inquiry-LYBQYPXK.js")).inquiryDomain,invoice:async()=>(await import("./invoice-BMBKXDES.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-EQBDT5QY.js")).
7
- jobTitleDomain,knowledge:async()=>(await import("./domain-knowledge-SX2U3G2T.js")).knowledgeDomain,leave:async()=>(await import("./leave-HVOP77HO.js")).leaveDomain,license:async()=>(await import("./license-4GY3UVML.js")).licenseDomain,"login-history":async()=>(await import("./login-history-WZ3RYFAB.js")).loginHistoryDomain,media:async()=>(await import("./media-WHEEH7F5.js")).mediaDomain,meeting:async()=>(await import("./knowledge-YNWUVXDF.js")).meetingDomain,note:async()=>(await import("./knowledge-YNWUVXDF.js")).
7
+ jobTitleDomain,knowledge:async()=>(await import("./domain-knowledge-SX2U3G2T.js")).knowledgeDomain,leave:async()=>(await import("./leave-HVOP77HO.js")).leaveDomain,license:async()=>(await import("./license-4GY3UVML.js")).licenseDomain,"login-history":async()=>(await import("./login-history-WZ3RYFAB.js")).loginHistoryDomain,media:async()=>(await import("./media-JYPX3PEY.js")).mediaDomain,meeting:async()=>(await import("./knowledge-YNWUVXDF.js")).meetingDomain,note:async()=>(await import("./knowledge-YNWUVXDF.js")).
8
8
  noteDomain,notification:async()=>(await import("./notification-VMTIJ5N3.js")).notificationDomain,onedrive:async()=>(await import("./onedrive-Z43D26SJ.js")).onedriveDomain,outlook:async()=>(await import("./outlook-DLEA27PZ.js")).outlookDomain,payee:async()=>(await import("./sales-master-BOR7D5QK.js")).payeeDomain,position:async()=>(await import("./position-J6TOE5KO.js")).positionDomain,project:async()=>(await import("./project-IV5M2SLT.js")).projectDomain,prospect:async()=>(await import("./prospect-LSNBOVFF.js")).
9
9
  prospectDomain,purchase:async()=>(await import("./purchase-K75TDCCD.js")).purchaseDomain,qualification:async()=>(await import("./skill-KNJGR57V.js")).qualificationDomain,receivable:async()=>(await import("./receivable-X7BEQOJF.js")).receivableDomain,redmine:async()=>(await import("./redmine-A5LDGTPW.js")).redmineDomain,report:async()=>(await import("./report-KDOXKFPP.js")).reportDomain,"role-template":async()=>(await import("./evaluation-QOEV2VNV.js")).roleTemplateDomain,"rou\
10
10
  nding-setting":async()=>(await import("./sales-numbering-O5RAC5TI.js")).roundingSettingDomain,"seal-impression":async()=>(await import("./sales-master-BOR7D5QK.js")).sealImpressionDomain,search:async()=>(await import("./search-AHFUN2XY.js")).searchDomain,secret:async()=>(await import("./secret-P42JCOI4.js")).secretDomain,segment:async()=>(await import("./segment-G3G6B26B.js")).segmentDomain,shift:async()=>(await import("./attendance-lists-O6T2Q42G.js")).shiftDomain,skill:async()=>(await import("./skill-KNJGR57V.js")).
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{placeholderTaskKey,stepToItem}from"./chunk-DTDIQOVQ.js";import{redactLoopOutput}from"./chunk-VEEZJNOB.js";import{localDate}from"./chunk-INS77QHY.js";import{normalizeSkillName,skillOfItem}from"./chunk-FABDZBDZ.js";import{DEFAULT_SKILL_PREFIX,SKILL_PREFIX_RE,setSkillPrefix,skillCommand,skillPrefix}from"./chunk-6CS5L24D.js";import{describeError,pick,pickString}from"./chunk-UZUV5FYG.js";import{isTaskKey}from"./chunk-SBRTBKEZ.js";import{createHash,randomBytes}from"crypto";import fs from"fs";import path from"path";var INFLIGHT_STALE_HOURS=3;function staleFloorHours(aiTimeoutSec){return Math.ceil(aiTimeoutSec*2/3600)}function inflightStaleHours(aiTimeoutSec,baseHours=INFLIGHT_STALE_HOURS){const base=Number.isFinite(baseHours)&&baseHours>0?baseHours:INFLIGHT_STALE_HOURS;return Math.max(base,staleFloorHours(aiTimeoutSec))}function ageMinutesOf(item,now){for(const raw of[item.started_at,item.updated_at,item.dequeued_at,item.created_at]){if(!raw)continue;const ts=Date.parse(raw);if(Number.isNaN(ts))continue;return Math.
3
+ import{placeholderTaskKey,stepToItem}from"./chunk-2UTJI3BT.js";import{redactLoopOutput}from"./chunk-VEEZJNOB.js";import{localDate}from"./chunk-INS77QHY.js";import{normalizeSkillName,skillOfItem}from"./chunk-FABDZBDZ.js";import{DEFAULT_SKILL_PREFIX,SKILL_PREFIX_RE,setSkillPrefix,skillCommand,skillPrefix}from"./chunk-6CS5L24D.js";import{describeError,pick,pickString}from"./chunk-UZUV5FYG.js";import{isTaskKey}from"./chunk-SBRTBKEZ.js";import{createHash,randomBytes}from"crypto";import fs from"fs";import path from"path";var INFLIGHT_STALE_HOURS=3;function staleFloorHours(aiTimeoutSec){return Math.ceil(aiTimeoutSec*2/3600)}function inflightStaleHours(aiTimeoutSec,baseHours=INFLIGHT_STALE_HOURS){const base=Number.isFinite(baseHours)&&baseHours>0?baseHours:INFLIGHT_STALE_HOURS;return Math.max(base,staleFloorHours(aiTimeoutSec))}function ageMinutesOf(item,now){for(const raw of[item.started_at,item.updated_at,item.dequeued_at,item.created_at]){if(!raw)continue;const ts=Date.parse(raw);if(Number.isNaN(ts))continue;return Math.
4
4
  floor((now.getTime()-ts)/6e4)}return null}function inflightEntries(items,now=new Date,staleHours=INFLIGHT_STALE_HOURS){const staleMinutes=staleHours*60;const byKey=new Map;for(const item of items){const key=(item.task_key??"").trim();if(!key)continue;const ageMinutes=ageMinutesOf(item,now);if(ageMinutes!==null&&ageMinutes>staleMinutes)continue;const entry={key,runner:item.runner_id??"-",ageMinutes,label:(item.label??"").slice(0,60)};const prev=byKey.get(key);if(!prev||(entry.ageMinutes??-1)>(prev.
5
5
  ageMinutes??-1))byKey.set(key,entry)}return[...byKey.values()].sort((a,b)=>a.key.localeCompare(b.key))}function formatInflightEntry(entry){const age=entry.ageMinutes===null?"\u4E0D\u660E":`${entry.ageMinutes}\u5206`;return`${entry.key} runner=${entry.runner} \u7D4C\u904E=${age}`}async function createItem(api,body){const res=await api.create(redactItemBody(body));if(isTriggerBlocked(res))return{itemId:null,detail:triggerBlockedDetail(res),blocked:true};if(!res.ok)return{itemId:null,detail:describeError(res)};for(const p of["item_id","id","item.item_id","item.id","data.item_id","data.id"]){const v=pickString(res.json,p);if(v)return{itemId:v,detail:""}}return{itemId:null,detail:`item_id \u3092\u8AAD\u3081\u307E\u305B\u3093: ${res.raw.slice(0,200)}`}}function isTriggerBlocked(res){
6
6
  if(res.status!==409)return false;const json=res.json&&typeof res.json==="object"?res.json:{};const data=json["data"]&&typeof json["data"]==="object"?json["data"]:{};return[json["reason"],json["error"],data["reason"]].includes("loop_trigger_blocked")}function triggerBlockedDetail(res){const message=pickString(res.json,"error_description")||pickString(res.json,"message");const parts=[pickString(res.json,"block.task_key")&&pickString(res.json,"block.skill")?`${pickString(res.json,"block.task_key")}\
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{loadDomain}from"./chunk-3SRTD2GD.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderDocument,renderOutput}from"./chunk-P4QSPSOQ.js";import{NO_REDACT_NOTICE,withCommonFlags}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs}from"./chunk-VGT2EGH6.js";import{Resolver,requireDefaultProject}from"./chunk-FW2AZBFR.js";
3
+ import{loadDomain}from"./chunk-MKF6BHGU.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{evaluateQuery}from"./chunk-GFLGXGWE.js";import{renderDocument,renderOutput}from"./chunk-P4QSPSOQ.js";import{NO_REDACT_NOTICE,withCommonFlags}from"./chunk-W4NLJ2YK.js";import{redactSecretValues,redactSecrets,withDebug}from"./chunk-BD7O73GK.js";import{parseOperationArgs}from"./chunk-VGT2EGH6.js";import{Resolver,requireDefaultProject}from"./chunk-FW2AZBFR.js";
4
4
  import{ResolveError}from"./chunk-HVZUXLQ4.js";import{ApiError,MultipartBody,TwpApiClient,appendQuery}from"./chunk-JA5A6UJ2.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-MI6HVYR2.js";import{isRecord}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,EXIT_WAIT_TIMEOUT,NetworkError,UsageError,WaitTimeoutError}from"./chunk-VFPY2A23.js";
5
5
  import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredBacklogSpace,resolveConfiguredOutput,resolveProfile}from"./chunk-EDF4U5BT.js";import{HELP_TOKEN}from"./chunk-6FI4ZMZ7.js";import{OUTPUT_FORMATS,resolveOutputFormat}from"./chunk-RKBUJKI5.js";import{stringWidth}from"./chunk-UREA4ZIG.js";
6
6
  import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs from"fs";import path from"path";function alignedList(entries,indent=" "){const width=entries.reduce((max,[left])=>Math.max(max,stringWidth(left)),0);return entries.map(([left,right])=>`${indent}${left}${" ".repeat(Math.max(0,width-stringWidth(left)))} ${right}`).join("\n")}function subresourcesOf(resource){return resource.subresources??[]}function renderResourceHelp(resource,path2){const subresources=subresourcesOf(resource);const operationSection=resource.operations.length===0?"":`
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __twpCreateRequire } from 'node:module';
3
3
  const require = __twpCreateRequire(import.meta.url);
4
- import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{parseArgv,quietFromEnv}from"./chunk-T4TVFQ5R.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.102.0":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
4
+ import{GLOBAL_OPTIONS_HELP}from"./chunk-KIZIRVW6.js";import{parseArgv,quietFromEnv}from"./chunk-T4TVFQ5R.js";import"./chunk-2LOT54OO.js";import"./chunk-NJL3H2BB.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-AH4KHEAC.js";import{formatUnknownArgs}from"./chunk-OKATZ4SN.js";import"./chunk-VSJBJXZO.js";var VERSION=true?"0.102.1":"0.0.0-dev";var HELP=`twp ${VERSION} \u2014 TWP CLI
5
5
 
6
6
  \u4F7F\u3044\u65B9:
7
7
  twp \u5BFE\u8A71 TUI \u3092\u8D77\u52D5
@@ -1570,17 +1570,17 @@ TUI \u5185:
1570
1570
  TWP API \u3092\u547C\u3079\u307E\u3059\u3002TWP API \u306E\u30C4\u30FC\u30EB\u306F\u65E2\u5B9A\u3067\u78BA\u8A8D\u304C\u51FA\u307E\u3059\uFF08-p \u3067\u306F\u62D2\u5426\u3002--allowed-tools \u3067\u540D\u524D\u3092\u8A31\u53EF\uFF09\u3002
1571
1571
  \u4F1A\u8A71\u30FB\u30ED\u30FC\u30AB\u30EB\u30C4\u30FC\u30EB\uFF08\u30D5\u30A1\u30A4\u30EB\u30FB\u30B3\u30DE\u30F3\u30C9\u30FBgit\uFF09\u306F\u30C6\u30CA\u30F3\u30C8\u306E\u30AF\u30EC\u30B8\u30C3\u30C8\u3067\u5B9F\u969B\u306B\u52D5\u304D\u307E\u3059\u3002
1572
1572
  `;function ignoreEpipe(stream){stream.on("error",err=>{if(err.code==="EPIPE")process.exit(0);throw err})}async function main(){const nodeMajor=Number(process.versions.node.split(".")[0]);if(nodeMajor<22){process.stderr.write(`twp-cli \u306B\u306F Node.js 22 \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728: ${process.versions.node}\uFF09
1573
- `);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);if(process.env["TWP_AUTO_UPDATE_WORKER"]==="1"){const{runAutoUpdateWorker}=await import("./auto-update-worker-3GV3BK5P.js");await runAutoUpdateWorker().catch(()=>void 0);return}const[first,...rest]=process.argv.slice(2);if(first==="__complete"||first==="completion"){const completion=await import("./completion-DN2XKSJ2.js");if(first==="completion"){process.exitCode=completion.runCompletion(rest,process.stdout,process.stderr);return}
1574
- const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-3JCGMFDA.js"),import("./config-XYWRBIC6.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);const{runConfigure}=await import("./configure-BJGPASNG.js");process.exitCode=
1573
+ `);process.exit(1)}ignoreEpipe(process.stdout);ignoreEpipe(process.stderr);if(process.env["TWP_AUTO_UPDATE_WORKER"]==="1"){const{runAutoUpdateWorker}=await import("./auto-update-worker-26OZDLQ7.js");await runAutoUpdateWorker().catch(()=>void 0);return}const[first,...rest]=process.argv.slice(2);if(first==="__complete"||first==="completion"){const completion=await import("./completion-DN2XKSJ2.js");if(first==="completion"){process.exitCode=completion.runCompletion(rest,process.stdout,process.stderr);return}
1574
+ const[{loadDomain},{loadUserConfig}]=await Promise.all([import("./registry-XG4NJNOU.js"),import("./config-XYWRBIC6.js")]);process.exitCode=await completion.runComplete(rest,process.stdout,{loadDomain,profileNames:()=>Object.keys(loadUserConfig().profiles??{})});return}if(first==="configure"){const autoUpdate2=await import("./auto-update-FXXQHBV5.js");autoUpdate2.registerRunning();autoUpdate2.onStartup(VERSION);const{runConfigure}=await import("./configure-BJGPASNG.js");process.exitCode=
1575
1575
  await runConfigure(rest);return}const args=parseArgv(process.argv.slice(2));if(args.command==="version"){process.stdout.write(`${VERSION}
1576
1576
  `);return}if(args.command==="help"){process.stdout.write(HELP);return}if(args.movedCommand!==void 0){const{MOVED_QUEUE_COMMAND_MESSAGE}=await import("./dispatch-ZWCEVLKZ.js");process.stderr.write(MOVED_QUEUE_COMMAND_MESSAGE);process.exitCode=2;return}if(args.unknown.length>0){process.stderr.write(`\u4E0D\u660E\u306A\u5F15\u6570: ${formatUnknownArgs(args.unknown)}
1577
1577
 
1578
- ${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-CWQ7KDOB.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
1579
- {},argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,refresh:args.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-45OPLR4Q.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1580
- globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-2N3V64AA.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.
1578
+ ${HELP}`);process.exitCode=2;return}const autoUpdate=await import("./auto-update-FXXQHBV5.js");autoUpdate.registerRunning();if(args.command==="task-loop"&&args.taskLoopAction!=="capacity"){process.env[autoUpdate.DISABLE_ENV]="1"}else if(args.command!=="update"){autoUpdate.onStartup(VERSION)}if(args.command==="domain"&&args.domain!==void 0){const{runDomain}=await import("./run-264WTPVI.js");process.exitCode=await runDomain({domain:args.domain,...args.operation!==void 0?{operation:args.operation}:
1579
+ {},argv:args.domainArgv,help:args.domainHelp,globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,refresh:args.refresh,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="api"){const{runApiCommand}=await import("./api-command-F7RDDVV5.js");process.exitCode=await runApiCommand({argv:args.domainArgv,help:args.domainHelp,
1580
+ globals:{...args.profile!==void 0?{profile:args.profile}:{},...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{},dryRun:args.dryRun,debug:args.debug,yes:args.yes,quiet:args.quiet||quietFromEnv(process.env)},version:VERSION});return}if(args.command==="update"){const{runUpdate}=await import("./update-QGM225Q7.js");process.exitCode=await runUpdate({...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}if(args.command==="login"||args.
1581
1581
  command==="logout"||args.command==="whoami"){const{runLogin,runLogout,runWhoami}=await import("./commands-GY6C6QY7.js");const options={profile:args.profile,method:args.loginMethod,tenant:args.tenant,noBrowser:args.loginNoBrowser,cliVersion:VERSION,force:args.logoutForce,...args.output!==void 0?{output:args.output}:{},...args.query!==void 0?{query:args.query}:{}};const runner=args.command==="login"?runLogin:args.command==="logout"?runLogout:runWhoami;process.exitCode=await runner(options);return}
1582
- if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-MO5YCZ56.js");process.exitCode=await runTaskLoop({action:args.taskLoopAction??"run",project:args.project,profile:args.profile,safe:args.safe,daemon:args.daemon,interval:args.interval,maxCycles:args.maxCycles,forceRunner:args.forceRunner,force:args.stopForce,drain:args.stopDrain,engine:args.engine,version:VERSION,verbose:args.verbose,scheduleNow:args.scheduleNow,scheduleCounts:args.scheduleCounts,scheduleGate:args.scheduleGate,
1582
+ if(args.command==="task-loop"){const{runTaskLoop}=await import("./commands-WXWGQF3Q.js");process.exitCode=await runTaskLoop({action:args.taskLoopAction??"run",project:args.project,profile:args.profile,safe:args.safe,daemon:args.daemon,interval:args.interval,maxCycles:args.maxCycles,forceRunner:args.forceRunner,force:args.stopForce,drain:args.stopDrain,engine:args.engine,version:VERSION,verbose:args.verbose,scheduleNow:args.scheduleNow,scheduleCounts:args.scheduleCounts,scheduleGate:args.scheduleGate,
1583
1583
  scheduleOp:args.scheduleOp,scheduleConfigOp:args.scheduleConfigOp,scheduleId:args.scheduleId,charterOp:args.charterOp,charterInput:args.charterFile,charterOutput:args.charterOut,charterRevision:args.charterRevision,settingsOp:args.settingsOp,orientationOp:args.orientationOp,orientationArgs:args.orientationArgs,skillOp:args.skillOp,skillName:args.skillName,skillAll:args.skillAll,skillDir:args.skillDir,skillConfig:args.skillConfig,output:args.output,query:args.query,revisionFrom:args.revisionFrom,
1584
- revisionTo:args.revisionTo,planOp:args.planOp,capacityOp:args.capacityOp,includeStopped:args.includeStopped,runnerOp:args.runnerOp,runnerId:args.runnerTargetId,triggerOp:args.triggerOp,triggerId:args.triggerId,triggerKey:args.triggerKey,triggerLimit:args.triggerLimit,planEmpty:args.planEmpty,planCheck:args.planCheck,yes:args.yes,ais:args.ais,workspace:args.workspace,aiConfigFile:args.aiConfigFile,noAiConfigFile:args.noAiConfigFile});return}if(args.command==="print"){const{runOneShot}=await import("./oneshot-DCL6NYBZ.js");
1585
- process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-5P53TGTK.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1584
+ revisionTo:args.revisionTo,planOp:args.planOp,capacityOp:args.capacityOp,includeStopped:args.includeStopped,runnerOp:args.runnerOp,runnerId:args.runnerTargetId,triggerOp:args.triggerOp,triggerId:args.triggerId,triggerKey:args.triggerKey,triggerLimit:args.triggerLimit,planEmpty:args.planEmpty,planCheck:args.planCheck,yes:args.yes,ais:args.ais,workspace:args.workspace,aiConfigFile:args.aiConfigFile,noAiConfigFile:args.noAiConfigFile});return}if(args.command==="print"){const{runOneShot}=await import("./oneshot-PQFHGBNR.js");
1585
+ process.exitCode=await runOneShot({prompt:args.prompt??"",fromStdin:args.promptFromStdin,mode:args.mode??"dev",...args.permissionMode!==void 0?{permissionMode:args.permissionMode}:{},allowedTools:args.allowedTools,disallowedTools:args.disallowedTools,...args.model!==void 0?{model:args.model}:{},...args.profile!==void 0?{profile:args.profile}:{},version:VERSION});return}const{startTui}=await import("./app-Q2IHSSVM.js");await startTui({mode:args.mode,permissionMode:args.permissionMode,allowedTools:args.
1586
1586
  allowedTools,disallowedTools:args.disallowedTools,model:args.model,profile:args.profile,noTui:args.noTui||!process.stdout.isTTY,doctor:args.doctor,version:VERSION})}await main();
@@ -2,7 +2,7 @@ import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
3
  import{ScheduleApi,collectDue,gateStatus,nowInZone,parseCounts,promptSection}from"./chunk-6M5NUVJJ.js";import{EngineNotConfiguredError,NoopEngine,UnknownEngineError,aiUnavailableLabel,assertKnownEngine,failureHint,isAiUnavailable,needsHumanToRestoreAi}from"./chunk-REWDCJNB.js";import{claudeConfigDir,resolveDetectDeps}from"./chunk-5SONMN6K.js";import{InstanceLock,buildLockOwner,defaultIsLoopProcess,writeLockOwner}from"./chunk-3WHC4FSG.js";import{LoopSettingsApplier,renderStepBudget}from"./chunk-5YJSWKQG.js";
4
4
  import{ServerSkillCatalog,formatSkillOrigins}from"./chunk-3OCV6SOR.js";import"./chunk-MYBIPHZ7.js";import"./chunk-A4LFG7MW.js";import{NO_PLAN_SESSION,RECENT_ADVANCE_WINDOW_HOURS,buildDynamicBlocks,buildRecentCandidateIndex,createItem,enqueueBlockerRecovery,enqueueDevVerifyForMerged,enqueueReleasePartialMergeRerun,enqueueReleasePhase5Recovery,fileSkillNames,findRecentCandidate,formatInflightEntry,formatPlanResultLine,formatRecentAdvance,formatResumeHold,inflightEntries,inflightStaleHours,
5
- openPlanSession,parseOutcomeCode,parseReleaseResult,parseTaskStatusSnapshot,pendingTaskKeys,resolveRecentAdvance,resolveResumeHold,shouldSuppressForResume,shouldSuppressForStatus,staleFloorHours,unavailableChecks,windowStartMicros}from"./chunk-FDXBQ7JB.js";import"./chunk-VRBI2NPI.js";import{duplicateTaskKeyDropReason,excludedKeyInArgs,extractPlanJson,parseOpsCount,parsePlanExcludeKeys,placeholderTaskKey,releaseDeployDropReason,stepToItem,zeroTargetDropReasons}from"./chunk-DTDIQOVQ.js";
5
+ openPlanSession,parseOutcomeCode,parseReleaseResult,parseTaskStatusSnapshot,pendingTaskKeys,resolveRecentAdvance,resolveResumeHold,shouldSuppressForResume,shouldSuppressForStatus,staleFloorHours,unavailableChecks,windowStartMicros}from"./chunk-NY5NFOJB.js";import"./chunk-VRBI2NPI.js";import{duplicateTaskKeyDropReason,excludedKeyInArgs,extractPlanJson,parseOpsCount,parsePlanExcludeKeys,placeholderTaskKey,releaseDeployDropReason,stepToItem,zeroTargetDropReasons}from"./chunk-2UTJI3BT.js";
6
6
  import{redactLoopOutput}from"./chunk-VEEZJNOB.js";import{buildLoopConfig,evaluateOwnership,exportStateDirEnv,localConfigPath,loopStateDir}from"./chunk-INS77QHY.js";import{describeOperations,evaluatePlanGate,planGateStatePath,recordPlanned}from"./chunk-CVX2YWHC.js";import{CapacityReporter}from"./chunk-VYDPW2YO.js";import{formatHookIds,formatHookWiring,runHook,runPrefetch,runPreflight}from"./chunk-TTST7UDR.js";import{exclusiveInflightEntries,formatExclusiveEntry,normalizeSkillName,
7
7
  spawnSyncResolved}from"./chunk-FABDZBDZ.js";import{setSkillPrefix,skillCommand,skillFromPrompt,stripSkillCommand}from"./chunk-6CS5L24D.js";import{killProcessTree}from"./chunk-N2UVRM3Z.js";import{AgentLoopApi,describeError,filterByStatus,isPermanent,pick,pickString}from"./chunk-UZUV5FYG.js";import{PRIVATE_PROJECT_REF,isPrivateProjectId,isPrivateProjectRef,privateProjectId,projectFileKey}from"./chunk-RMFLTSOV.js";import"./chunk-BD7O73GK.js";import{ULID_RE,loopProjectIdPolicy,
8
8
  resolveProjectRef}from"./chunk-HVZUXLQ4.js";import"./chunk-SBRTBKEZ.js";import"./chunk-VFPY2A23.js";import{joinFor}from"./chunk-PMOUHEJQ.js";import{AuthSession}from"./chunk-XNLIEUAW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{compareVersionCores,parseVersionCore}from"./chunk-DXXFUNYN.js";import"./chunk-5WGOHFAS.js";import{effectiveApiUrl,resolveProfile}from"./chunk-EDF4U5BT.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";import{
@@ -302,7 +302,7 @@ handlers.onRestart({from:decision.from,to:decision.to})};const timer=setInterval
302
302
  pid<=0)return null;return{pid,at:sanitizeAt(at)}}catch{return null}}function sanitizeAt(at){if(typeof at!=="string")return"";return at.replace(/[\u0000-\u001f\u007f]/g," ").slice(0,MAX_AT_LENGTH)}function clearMarker(lockDir2,kind,deps={}){const rm=deps.rmSync??(p=>fs8.rmSync(p,{recursive:true,force:true}));try{rm(markerPath(lockDir2,kind))}catch{}}function watchMarker(lockDir2,kind,selfPid,onStop,deps={}){let fired=false;const timer=setInterval(()=>{if(fired)return;const req=readMarker(lockDir2,kind,deps);if(req===null||req.pid!==selfPid)return;fired=true;onStop(req)},deps.intervalMs??POLL_MS);timer.unref?.();return()=>{fired=true;clearInterval(timer)}}function safe(s){return stripTerminalControls(s)}function compactTimestamp(at=new Date){const p2=n=>String(n).padStart(2,"0");return`${at.getFullYear()}${p2(at.getMonth()+1)}${p2(at.getDate())}-${p2(at.getHours())}${p2(at.getMinutes())}${p2(at.getSeconds())}`}async function buildEngine(config,log){if(config.engine==="noop")return new NoopEngine;const{DispatchEngine}=await import("./ai-dispatch-QXSO4EQF.js");const{DEFAULT_PREFLIGHT_HOSTS}=await import("./ai-dispatch-QXSO4EQF.js");const extraHosts=config.
303
303
  operations.preflightHosts;return new DispatchEngine(config.ai,log,{workspace:config.workspace,charterFile:config.charterFile??void 0,charterEnabled:config.charterEnabled,...config.charterPrefix===null?{}:{charterPrefix:config.charterPrefix},...config.charterSuffix===null?{}:{charterSuffix:config.charterSuffix},serverPrompts:()=>config.serverPrompts??{},compileCommand:config.compileCommand??void 0,skillOverlayDir:path7.join(config.stateDir,"skill-overlay",projectFileKey(config.projectId)),launcherBin:config.
304
304
  claudeLauncher.bin,...extraHosts.length>0?{preflightHosts:[...DEFAULT_PREFLIGHT_HOSTS,...extraHosts]}:{}})}function lockDir(config){return path7.join(config.stateDir,`task-loop-${projectFileKey(config.projectId)}.lock.d`)}function runnerIdPersisted(stateDir,env=process.env){if((env.RUNNER_ID?.trim()??"")!=="")return true;const file=env.RUNNER_ID_FILE&&env.RUNNER_ID_FILE.trim()!==""?env.RUNNER_ID_FILE:path7.join(stateDir,"runner-id");return fs9.existsSync(file)}async function runTaskLoop(opts){if(opts.
305
- action==="stop")return await stopLoop(opts);if(opts.action==="plan"){if(opts.planOp!=="submit"){process.stderr.write("plan \u306B\u306F submit \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runPlanSubmit}=await import("./plan-submit-WI3GFVWV.js");return runPlanSubmit({file:opts.charterInput,empty:opts.planEmpty===true,check:opts.planCheck===true},{env:process.env,readStdin:()=>fs9.readFileSync(0,"utf8"),stdout:s=>process.stdout.write(s),stderr:s=>process.stderr.write(s)})}
305
+ action==="stop")return await stopLoop(opts);if(opts.action==="plan"){if(opts.planOp!=="submit"){process.stderr.write("plan \u306B\u306F submit \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\n");return 2}const{runPlanSubmit}=await import("./plan-submit-EFMGUECM.js");return runPlanSubmit({file:opts.charterInput,empty:opts.planEmpty===true,check:opts.planCheck===true},{env:process.env,readStdin:()=>fs9.readFileSync(0,"utf8"),stdout:s=>process.stdout.write(s),stderr:s=>process.stderr.write(s)})}
306
306
  const profile=resolveProfile(opts.profile);let creds;try{creds=new AuthSession(profile.name,profile.apiUrl).loadOrThrow()}catch(err){process.stderr.write(`${err.message}
307
307
  `);return 1}const apiUrl=effectiveApiUrl(profile,creds.api_url);const session=new AuthSession(profile.name,apiUrl);if(opts.action==="capacity"&&opts.capacityOp==="list"){let filterId;if(opts.project!==void 0&&opts.project!==""){try{filterId=(await new ProjectApi(apiUrl,session).resolve(opts.project)).id}catch(err){process.stderr.write(`${err.message}
308
308
  `);return 1}}const api2=new AgentLoopApi({apiUrl,projectId:filterId??"",session});const{runCapacityList}=await import("./capacity-list-command-7SR23CXI.js");return runCapacityList({get:()=>api2.runnersOverview()},{output:opts.output,query:opts.query,includeStopped:opts.includeStopped===true,projectId:filterId})}const projectRef=opts.project??process.env.TWP_PROJECT??"";if(projectRef===""){process.stderr.write("--project <\u30AD\u30FC|UUID> \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08TWP_PROJECT \u3067\u3082\u53EF\uFF09\n");
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{checkOutTarget}from"./chunk-HKLXKBNL.js";import"./chunk-3SRTD2GD.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import{contentTypeFor,inspectLocalFile}from"./chunk-RR6VGVZS.js";import{checkUploadQuota}from"./chunk-V64CGX7V.js";import{parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";import"./chunk-RMFLTSOV.js";import{readBody}from"./chunk-HEH3PUW2.js";import"./chunk-W4NLJ2YK.js";
3
+ import{checkOutTarget}from"./chunk-U3GNDK63.js";import"./chunk-MKF6BHGU.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import{contentTypeFor,inspectLocalFile}from"./chunk-RR6VGVZS.js";import{checkUploadQuota}from"./chunk-V64CGX7V.js";import{parseWaitOptions,waitUntilTerminal}from"./chunk-WVCEKC7V.js";import"./chunk-RMFLTSOV.js";import{readBody}from"./chunk-HEH3PUW2.js";import"./chunk-W4NLJ2YK.js";
4
4
  import"./chunk-BD7O73GK.js";import{repeatedValues}from"./chunk-VGT2EGH6.js";import"./chunk-FW2AZBFR.js";import{collapsesInUrlPath,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{ApiError}from"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger,readEnvelopeCursor,shellQuote}from"./chunk-MI6HVYR2.js";import{requireResolved,singleRef,withResolved}from"./chunk-PS5QFKHB.js";
5
5
  import{acknowledgement,isRecord,pick}from"./chunk-3ZRMMBP5.js";import{ApiRejectedError,ApiResponseError,NetworkError,UsageError,WaitTimeoutError}from"./chunk-VFPY2A23.js";import"./chunk-KIZIRVW6.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-OKATZ4SN.js";import"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";
6
6
  import"./chunk-VSJBJXZO.js";import crypto2 from"crypto";import fs2 from"fs";import path from"path";var SCOPE_PERSONAL="personal";var SCOPE_PROJECT="project";var UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var FORBIDDEN_NAME=/[/\\:*?"<>|]/;var NAME_MAX=255;var ROW_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","updated_at"];var TRASH_COLUMNS=["id","path","name","file_count","subfolder_count","parent_id","deleted_at"];function folderRows(raw){return raw.map(row=>{const id=row["id"];const name=row["name"];const parentId=row["parent_id"];if(typeof id!==
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,displayCwd,residentInputs,runTurn}from"./chunk-FZ55A6NN.js";import"./chunk-CDAU3M7F.js";import"./chunk-N2UVRM3Z.js";import"./chunk-BD7O73GK.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-VFPY2A23.js";
4
- import{RelayError,createRuntime,pickModel,specFor}from"./chunk-PJ7IKTZI.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import{checkMinSupportedVersion,enforceMinSupportedVersion,floorNeedsRefresh}from"./chunk-DXXFUNYN.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{getMode}from"./chunk-2LOT54OO.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";
3
+ import{activateModeFiles,activatePermissionSettings,buildResidentSet,buildSystemPrompt,createAuditLogger,createTwpToolkit,currentBranch,displayCwd,residentInputs,runTurn}from"./chunk-6R6CY6KM.js";import"./chunk-CDAU3M7F.js";import"./chunk-N2UVRM3Z.js";import"./chunk-BD7O73GK.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-VFPY2A23.js";
4
+ import{RelayError,createRuntime,pickModel,specFor}from"./chunk-65SBCDVQ.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import{checkMinSupportedVersion,enforceMinSupportedVersion,floorNeedsRefresh}from"./chunk-DXXFUNYN.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import{getMode}from"./chunk-2LOT54OO.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";
5
5
  import"./chunk-VSJBJXZO.js";async function runOneShot(opts,deps={}){const out=deps.out??(text=>void process.stdout.write(stripTerminalControls(text)));const err=deps.err??(text=>void process.stderr.write(stripTerminalControls(text)));activateModeFiles(err);const permissionLayers=activatePermissionSettings(err,{...opts.allowedTools?{allowedTools:opts.allowedTools}:{},...opts.disallowedTools?{disallowedTools:opts.disallowedTools}:{}});const prompt=opts.fromStdin?await(deps.readStdin??readStdin)():opts.prompt;if(prompt.trim()===
6
6
  ""){err('\u30D7\u30ED\u30F3\u30D7\u30C8\u304C\u7A7A\u3067\u3059\u3002`twp -p "\u8CEA\u554F"`\uFF08`-p -` \u3067\u6A19\u6E96\u5165\u529B\uFF09\n');return 2}const runtime=deps.runtime??createRuntime({...opts.profile!==void 0?{profile:opts.profile}:{},...opts.model!==void 0?{model:opts.model}:{},cliVersion:opts.version});const cachedFloor=runtime.loadCachedFloor();if(await checkMinSupportedVersion({current:opts.version,cachedFloor:cachedFloor.minSupportedVersion,refresh:async()=>(await runtime.loadCatalog()).
7
7
  minSupportedVersion,write:err})){return 1}if(!runtime.loggedIn){err("\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u307E\u305B\u3093\u3002`twp login` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n");return 1}let model=runtime.configuredModel??"";let catalog=null;if(model===""){catalog=await runtime.loadCatalog();const picked=pickModel(catalog,void 0);model=picked.model;if(catalog.source!=="server"){err(`\u26A0 \u30E2\u30C7\u30EB\u4E00\u89A7\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\u305F\u3081 ${model}\
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{NO_PLAN_SESSION,PLAN_DIR_ENV,PLAN_TOKEN_ENV,checkPlan,fileSkillNames,formatCheck,openPlanSession,runPlanSubmit}from"./chunk-FDXBQ7JB.js";import"./chunk-DTDIQOVQ.js";import"./chunk-VEEZJNOB.js";import"./chunk-INS77QHY.js";import"./chunk-CVX2YWHC.js";import"./chunk-VYDPW2YO.js";import"./chunk-TTST7UDR.js";import"./chunk-FABDZBDZ.js";import"./chunk-6CS5L24D.js";import"./chunk-N2UVRM3Z.js";import"./chunk-UZUV5FYG.js";import"./chunk-RMFLTSOV.js";
3
+ import{NO_PLAN_SESSION,PLAN_DIR_ENV,PLAN_TOKEN_ENV,checkPlan,fileSkillNames,formatCheck,openPlanSession,runPlanSubmit}from"./chunk-NY5NFOJB.js";import"./chunk-2UTJI3BT.js";import"./chunk-VEEZJNOB.js";import"./chunk-INS77QHY.js";import"./chunk-CVX2YWHC.js";import"./chunk-VYDPW2YO.js";import"./chunk-TTST7UDR.js";import"./chunk-FABDZBDZ.js";import"./chunk-6CS5L24D.js";import"./chunk-N2UVRM3Z.js";import"./chunk-UZUV5FYG.js";import"./chunk-RMFLTSOV.js";
4
4
  import"./chunk-BD7O73GK.js";import"./chunk-SBRTBKEZ.js";import"./chunk-PMOUHEJQ.js";import"./chunk-J7QYPKVK.js";import"./chunk-5WGOHFAS.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{NO_PLAN_SESSION,PLAN_DIR_ENV,PLAN_TOKEN_ENV,checkPlan,fileSkillNames,formatCheck,openPlanSession,runPlanSubmit};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{loadDomain}from"./chunk-3SRTD2GD.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
3
+ import{loadDomain}from"./chunk-MKF6BHGU.js";import"./chunk-VSJBJXZO.js";export{loadDomain};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-HKLXKBNL.js";import"./chunk-3SRTD2GD.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-VGT2EGH6.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";
3
+ import{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-U3GNDK63.js";import"./chunk-MKF6BHGU.js";import"./chunk-Q3B65OFC.js";import"./chunk-GFLGXGWE.js";import"./chunk-P4QSPSOQ.js";import"./chunk-W4NLJ2YK.js";import"./chunk-BD7O73GK.js";import"./chunk-VGT2EGH6.js";import"./chunk-FW2AZBFR.js";import"./chunk-HVZUXLQ4.js";import"./chunk-JA5A6UJ2.js";
4
4
  import"./chunk-MMVXE2CJ.js";import"./chunk-SBRTBKEZ.js";import"./chunk-MI6HVYR2.js";import"./chunk-3ZRMMBP5.js";import"./chunk-VFPY2A23.js";import"./chunk-KIZIRVW6.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-6FI4ZMZ7.js";import"./chunk-OKATZ4SN.js";import"./chunk-RKBUJKI5.js";import"./chunk-UREA4ZIG.js";import"./chunk-NHYMHCAT.js";
5
5
  import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,checkOutTarget,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __twpCreateRequire } from 'node:module';
2
2
  const require = __twpCreateRequire(import.meta.url);
3
- import{fetchLatestVersion,isBehindLatest,runUpdate}from"./chunk-F36CIBG3.js";import"./chunk-PJ7IKTZI.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-CH6QU76P.js";import"./chunk-DXXFUNYN.js";import"./chunk-5WGOHFAS.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{fetchLatestVersion,isBehindLatest,runUpdate};
3
+ import{fetchLatestVersion,isBehindLatest,runUpdate}from"./chunk-JS55SZ6W.js";import"./chunk-65SBCDVQ.js";import"./chunk-D233KKXW.js";import"./chunk-PMOUHEJQ.js";import"./chunk-XNLIEUAW.js";import"./chunk-J7QYPKVK.js";import"./chunk-CH6QU76P.js";import"./chunk-DXXFUNYN.js";import"./chunk-5WGOHFAS.js";import"./chunk-EDF4U5BT.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";export{fetchLatestVersion,isBehindLatest,runUpdate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tocca-systems/twp-cli",
3
- "version": "0.102.0",
3
+ "version": "0.102.1",
4
4
  "description": "TWP CLI — Tocca Working Platform の CLI 型統合インターフェース(AIエージェントハーネス)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,16 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{FINAL_REPORT_BEGIN,FINAL_REPORT_END,redactLoopOutput}from"./chunk-VEEZJNOB.js";import{skillCommand,skillPrefix}from"./chunk-6CS5L24D.js";import{normalizeRequiredPlatforms}from"./chunk-UZUV5FYG.js";import{extractLeadingTaskKey}from"./chunk-SBRTBKEZ.js";var LEDGER_TASK_KEY_MAX=50;var CONTROL_CHAR_RE=/[\u0000-\u001f\u007f]/;var FLAG_TOKEN_RE=/(?:^|\s)-/;function loosen(source){let t=source.replace(/^[ \t]*\/\/[^\n]*$/gm,"");t=t.replace(/\/\*[\s\S]*?\*\//g,"");t=t.replace(/,(\s*[}\]])/g,"$1");return t===source?null:t}function tryParsePlan(source){for(const candidate of[source,loosen(source)]){if(candidate===null)continue;try{const obj=JSON.parse(candidate);if(obj!==null&&typeof obj==="object"&&Array.isArray(obj.steps)){return obj}}catch{}}return null}
4
- function fencedBlocks(text,tag){const re=new RegExp("```"+tag+"\\s*\\n([\\s\\S]*?)\\n```","g");const out=[];for(const m of text.matchAll(re)){if(m[1]!==void 0)out.push(m[1])}return out}function extractGeminiEnvelope(text){const anchor=/\{[^{}]*"session_id"[^{}]*"response"\s*:\s*"/g;for(const m of text.matchAll(anchor)){const start=m.index;if(start===void 0)continue;let depth=0;let inStr=false;let escape=false;for(let i=start;i<text.length;i++){const c=text[i];if(escape){escape=false;continue}if(c===
5
- "\\"){escape=true;continue}if(c==='"'){inStr=!inStr;continue}if(inStr)continue;if(c==="{")depth++;else if(c==="}"){depth--;if(depth===0){try{const obj=JSON.parse(text.slice(start,i+1));if(obj!==null&&typeof obj==="object"&&typeof obj.response==="string"){return obj.response}}catch{}break}}}}return null}function matchingBrace(text,start){let depth=0;let inStr=false;let escape=false;for(let i=start;i<text.length;i++){const c=text[i];if(escape){escape=false;continue}if(inStr){if(c==="\\")escape=true;else if(c===
6
- '"')inStr=false;continue}if(c==='"')inStr=true;else if(c==="{")depth++;else if(c==="}"){depth--;if(depth===0)return i}}return-1}var MAX_STEPS_ANCHORS=20;var MAX_OPEN_CANDIDATES=8;function lastStepsObject(text){const anchors=[...text.matchAll(/"steps"\s*:/g)].map(m=>m.index).filter(i=>i!==void 0);for(const at of anchors.reverse().slice(0,MAX_STEPS_ANCHORS)){let tried=0;for(let open=text.lastIndexOf("{",at);open>=0&&tried<MAX_OPEN_CANDIDATES;open=text.lastIndexOf("{",open-1)){tried++;const close=matchingBrace(
7
- text,open);if(close>at){const plan=tryParsePlan(text.slice(open,close+1));if(plan)return plan}if(open===0)break}}return null}function finalReports(text){const re=new RegExp(`${FINAL_REPORT_BEGIN}\\n?([\\s\\S]*?)${FINAL_REPORT_END}`,"g");const out=[];for(const m of text.matchAll(re)){if(m[1]!==void 0)out.push(m[1])}return out.reverse()}function extractFrom(text){for(const tag of["json:execution-plan","json"]){for(const block of fencedBlocks(text,tag).reverse()){const plan=tryParsePlan(block);if(plan)
8
- return plan}}const resp=extractGeminiEnvelope(text);if(resp!==null){for(const block of[...fencedBlocks(resp,"json:execution-plan"),...fencedBlocks(resp,"json")].reverse()){const plan2=tryParsePlan(block);if(plan2)return plan2}const plan=tryParsePlan(resp);if(plan)return plan}const whole=tryParsePlan(text.trim());if(whole)return whole;return lastStepsObject(text)}function extractPlanJson(rawText){const text=rawText.replace(/^\s*\[\d{2}:\d{2}:\d{2}\][ \t]*(?:💬 ?)?/gmu,"");for(const report of finalReports(
9
- text)){const plan=extractFrom(report);if(plan)return plan}return extractFrom(text)}function ledgerTaskKey(args){const key=extractLeadingTaskKey(args);if(key.length>LEDGER_TASK_KEY_MAX)return"";if(CONTROL_CHAR_RE.test(key))return"";if(FLAG_TOKEN_RE.test(key))return"";return key}function placeholderTaskKey(args){for(const token of args.split(/\s+/)){if(token==="")continue;if(token.startsWith("-"))continue;const m=/^[A-Z]{2,}[A-Z0-9]*-([A-Za-z0-9_<>{}]*)$/.exec(token);if(!m)return null;if(/^\d+$/.test(
10
- m[1]??""))return null;return token}return null}function stepToItem(step,assign,prefix=skillPrefix()){const skill=typeof step.skill==="string"?step.skill.trim():"";if(!skill)return null;const args=redactLoopOutput((step.args??"").trim());const priority=step.priority??"P2";const prompt=skillCommand(skill,args,prefix);let label=redactLoopOutput((step.label??"").trim());const own=skillCommand(skill,"",prefix);const promptLike=prefix===""?label===own||label.startsWith(`${own} `):label.startsWith(`/${prefix}`);
11
- if(!label||promptLike||label.startsWith("[P"))label=prompt;const taskKey=ledgerTaskKey(args);const category=assign?.categoryForSkill(skill)??step.ai_category??"complex";const display=taskKey&&!label.includes(taskKey)?`[${priority}] ${taskKey} ${label} #ai:${category}`:`[${priority}] ${label} #ai:${category}`;const item={label:display.slice(0,200),prompt,task_key:taskKey};const platforms=normalizeRequiredPlatforms(step.required_platforms);if(platforms.length>0)item.required_platforms=platforms;if(assign!==
12
- void 0){const ai=assign.selectPrimary(category,skill,priority,display);if(ai!=="")item.ai_type=ai}return item}function parsePlanExcludeKeys(prefetchSection){const m=/OPS_PLAN_EXCLUDE_KEYS\s+([^\s]*)\s+-->/.exec(prefetchSection);const keys=new Set;if(!m||!m[1])return keys;for(const raw of m[1].split(",")){const key=raw.trim();if(key!=="")keys.add(key)}return keys}function excludedKeyInArgs(args,excluded){if(excluded.size===0)return null;for(const key of[...excluded].sort()){const re=new RegExp(`(\
13
- ?<![A-Za-z0-9-])${key.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![0-9])`);if(re.test(args))return key}return null}function parseOpsCount(prefetchSection,field){const marker=/OPS_COUNTS\s+([^>]*?)-->/.exec(prefetchSection);if(!marker||!marker[1])return null;const escaped=field.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const hit=new RegExp(`(?:^|\\s)${escaped}=(-?\\d+)(?:\\s|$)`).exec(marker[1]);if(!hit||hit[1]===void 0)return null;const n=Number.parseInt(hit[1],10);if(!Number.isFinite(n)||n<0)return null;
14
- return n}function releaseDeployDropReason(verifyBacklog,devVerifyPlanned,guard){if(verifyBacklog===null){return`${guard.countField} \u306E\u4EF6\u6570\u3092\u53D6\u5F97\u3067\u304D\u306A\u304B\u3063\u305F\uFF08\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u30EA\u30EA\u30FC\u30B9\u306F\u898B\u9001\u308B\uFF09`}if(verifyBacklog>devVerifyPlanned){return`${guard.countField} ${verifyBacklog}\u4EF6 > \u8A08\u753B\u5185${guard.drainedBy}${devVerifyPlanned}\u4EF6\uFF08Phase 1\u306E0\u4EF6\u898B\u8FBC\u307F\u304C\u7ACB\u305F\u306A\u3044\uFF09`}
15
- return null}function duplicateTaskKeyDropReason(enqueuedKeys,taskKey){if(!taskKey)return null;if(!enqueuedKeys.has(taskKey))return null;return`${taskKey} \u306F\u672C\u8A08\u753B\u3067\u65E2\u306B\u6295\u5165\u6E08\u307F\uFF08\u540C\u4E00\u30AD\u30FC\u306F1\u8A08\u753B1\u4EF6\uFF09`}var NO_ZERO_TARGET_GATES={};function zeroTargetDropReasons(prefetchSection,gates=NO_ZERO_TARGET_GATES){const reasons=new Map;for(const[skill,gate]of Object.entries(gates)){const n=parseOpsCount(prefetchSection,gate.field);
16
- if(n===null)reasons.set(skill,`${gate.label}\u4EF6\u6570\u304C\u5224\u5B9A\u4E0D\u80FD\u306E\u305F\u3081\u898B\u9001\u308A`);else if(n===0)reasons.set(skill,`${gate.label}0\u4EF6\u306E\u305F\u3081\u5BFE\u8C61\u306A\u3057`)}return reasons}export{extractPlanJson,placeholderTaskKey,stepToItem,parsePlanExcludeKeys,excludedKeyInArgs,parseOpsCount,releaseDeployDropReason,duplicateTaskKeyDropReason,zeroTargetDropReasons};