@tocca-systems/twp-cli 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.public.md +12 -0
  2. package/README.md +55 -4
  3. package/command-model/user-management.json +1137 -2
  4. package/dist/{ai-dispatch-PNA4UF4I.js → ai-dispatch-VSCKUY6J.js} +33 -33
  5. package/dist/{api-command-2OPQMSTE.js → api-command-Q2CSB4PV.js} +3 -3
  6. package/dist/{app-FZT4U3VG.js → app-THTQX3A5.js} +70 -71
  7. package/dist/{auto-update-CV2MM32C.js → auto-update-FBZGOQFI.js} +1 -1
  8. package/dist/{auto-update-worker-ML7EBNQW.js → auto-update-worker-Z3XKBFMQ.js} +2 -2
  9. package/dist/{backlog-NV7Z76R3.js → backlog-X2MQTA6F.js} +2 -2
  10. package/dist/charter-command-UPKTVL7H.js +36 -0
  11. package/dist/{chunk-DEVIQH5U.js → chunk-24ZZFFA3.js} +1 -1
  12. package/dist/chunk-3XG457E3.js +12 -0
  13. package/dist/{chunk-3SNMDSCW.js → chunk-5ISIXBKD.js} +91 -70
  14. package/dist/{chunk-ILKQDXI5.js → chunk-DSDVIU6A.js} +1 -1
  15. package/dist/chunk-E4H22AO5.js +3 -0
  16. package/dist/chunk-I2QFW7EK.js +30 -0
  17. package/dist/chunk-JB27KNCX.js +52 -0
  18. package/dist/{chunk-GTABFTZP.js → chunk-JDMNIUVX.js} +1 -1
  19. package/dist/chunk-K2ONOH3L.js +9 -0
  20. package/dist/chunk-ODLJ2LNQ.js +13 -0
  21. package/dist/chunk-PEGUHUTD.js +3 -0
  22. package/dist/{chunk-FOFV2MNL.js → chunk-PI5DUWNZ.js} +1 -1
  23. package/dist/chunk-RKJ6B2KL.js +56 -0
  24. package/dist/chunk-TYNCXQSN.js +38 -0
  25. package/dist/{chunk-N56AWWTM.js → chunk-UG2I6VRD.js} +2 -12
  26. package/dist/chunk-VRBI2NPI.js +15 -0
  27. package/dist/{chunk-5QCAIKFE.js → chunk-X4RS5VBH.js} +1 -1
  28. package/dist/{chunk-BYRM4NSC.js → chunk-XLE4HW6B.js} +1 -1
  29. package/dist/chunk-Y2QAP6SU.js +15 -0
  30. package/dist/cli.js +22 -10
  31. package/dist/{commands-EWRHQZYM.js → commands-ET4F34OD.js} +26 -25
  32. package/dist/{commands-7D5EEQBY.js → commands-NXBQ5OWL.js} +12 -7
  33. package/dist/format-NMW6Y2E5.js +3 -0
  34. package/dist/{logout-guard-Q4MQFEGR.js → logout-guard-CMZZBRUL.js} +1 -1
  35. package/dist/{oneshot-AXS5LWUY.js → oneshot-QVFA2SUM.js} +2 -2
  36. package/dist/{project-BATJQR3F.js → project-2LJZW747.js} +1 -1
  37. package/dist/query-NJMVSQR6.js +3 -0
  38. package/dist/render-XMVI3AKB.js +3 -0
  39. package/dist/run-IS46BQBB.js +4 -0
  40. package/dist/{schedule-command-YPKIO3FK.js → schedule-command-GKXKNMLG.js} +1 -1
  41. package/dist/server-settings-CG3EM7R7.js +3 -0
  42. package/dist/{setup-ROGEF3UO.js → setup-UI6V2Q3V.js} +1 -1
  43. package/dist/{task-6QUH5OXF.js → task-GKNM3G4K.js} +2 -2
  44. package/dist/{update-EXFIHTMW.js → update-3QHRK5BP.js} +1 -1
  45. package/dist/user-EU7Z3DAO.js +24 -0
  46. package/package.json +1 -1
  47. package/dist/chunk-MIMDLO52.js +0 -43
  48. package/dist/chunk-NWABK3RZ.js +0 -36
  49. package/dist/chunk-OVYHOZ3C.js +0 -27
  50. package/dist/chunk-SPZO6C5N.js +0 -69
  51. package/dist/chunk-ZGG7TRAM.js +0 -3
  52. package/dist/run-2OQQAOHL.js +0 -4
@@ -1,43 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{isTaskKey}from"./chunk-II5RVJQN.js";import{ApiError}from"./chunk-JKSXUBND.js";import{loadProjectConfig,loadUserConfig}from"./chunk-NERYSBA4.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";import{UsageError}from"./chunk-M3GWY6NT.js";import{ResolveError,isSafePathSegment,resolveProjectRef,safeProjectIdPolicy}from"./chunk-5QCAIKFE.js";var BACKLOG_BASE_PATH="/api/v2/integrations/backlog";function assertBacklogPathSegment(value,label){if(!isSafePathSegment(value)){throw new ResolveError(`${label}\u3068\u3057\u3066 URL \u306B\u5165\u308C\u3089\u308C\u306A\u3044\u5024\u304C\u30B5\u30FC\u30D0\u304B\u3089\u8FD4\u308A\u307E\u3057\u305F: ${JSON.stringify(value)}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return value}function backlogSpacePath(spaceId,suffix=""){assertBacklogPathSegment(spaceId,
4
- "Backlog \u30B9\u30DA\u30FC\u30B9 ID");return`${BACKLOG_BASE_PATH}/${encodeURIComponent(spaceId)}${suffix}`}function idString(value){if(typeof value==="number"&&Number.isFinite(value))return String(value);if(typeof value==="string"&&value.trim()!=="")return value.trim();return null}function text(value){return typeof value==="string"&&value.trim()!==""?value.trim():null}function backlogSpaceAliases(spaceUrl){const aliases=[];const trimmed=spaceUrl.trim().replace(/\/+$/,"");if(trimmed==="")return aliases;
5
- let host;try{host=new URL(trimmed).host}catch{host=trimmed.replace(/^\/+/,"").split("/")[0]??""}if(host==="")return aliases;aliases.push(host);const label=host.split(".")[0];if(label!==void 0&&label!==""&&label!==host)aliases.push(label);return aliases}function backlogSpaceRow(row){const url=text(row["space_url"]);return{id:idString(row["id"]),name:url,code:null,aliases:url!==null?backlogSpaceAliases(url):[]}}function backlogProjectRow(row){return{id:idString(row["id"]),name:text(row["name"]),code:text(
6
- row["projectKey"])}}function backlogStatusRow(row){return{id:idString(row["id"]),name:text(row["name"]),code:null}}function backlogUserRow(row){return{id:idString(row["id"]),name:text(row["name"]),code:null,aliases:[text(row["userId"]),text(row["mailAddress"])].filter(v=>v!==null)}}var DEFAULT_LOOKUP_SCOPE="\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8";function fold(value){return value.trim().toLowerCase()}function keysOf(ref){return[ref.id,ref.code,ref.name,...ref.aliases??[]].filter(v=>typeof v==="string"&&v.trim()!=="").map(fold)}function describe(ref){return ref.code!==void 0&&ref.code!==null&&ref.code!==""&&ref.code!==ref.name?`${ref.name}\uFF08${ref.code}\uFF09`:ref.name}async function suggest(input,candidates){try{const{default:fuzzysort}=await import("./fuzzysort-DFVKV4B4.js");
7
- const indexed=candidates.map(ref=>({hay:keysOf(ref).join(" "),ref}));const hits=fuzzysort.go(input.trim(),indexed,{key:"hay",limit:5,threshold:-1e4});return hits.map(hit=>hit.obj.ref)}catch{return[]}}function listCandidates(candidates,limit=10){const shown=candidates.slice(0,limit).map(describe).join(" / ");return candidates.length>limit?`${shown} \u2026\uFF08\u5168 ${candidates.length} \u4EF6\uFF09`:shown}async function resolveNamed(input,candidates,ctx){const needle=fold(input);if(needle===""){
8
- throw new UsageError(`${ctx.flag} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`)}if(candidates.length===0){throw new UsageError(`${ctx.scope??DEFAULT_LOOKUP_SCOPE}\u306B\u306F${ctx.label}\u304C1\u4EF6\u3082\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08${ctx.flag} ${input}\uFF09`)}const hits=candidates.filter(ref=>keysOf(ref).includes(needle));const distinct=[...new Map(hits.map(ref=>[ref.id,ref])).values()];if(distinct.length===1)return distinct[0];if(distinct.
9
- length>1){throw new UsageError(`${ctx.flag} \u306E\u300C${input}\u300D\u304C${ctx.label}${distinct.length}\u4EF6\u306B\u4E00\u81F4\u3057\u307E\u3059: ${listCandidates(distinct)}`,`\u3069\u308C\u304B1\u3064\u306B\u6C7A\u307E\u308B\u5024\uFF08ID \u304B\u30B3\u30FC\u30C9\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}const near=await suggest(input,candidates);throw new UsageError(`${ctx.flag} \u306E\u300C${input}\u300D\u306B\u4E00\u81F4\u3059\u308B${ctx.label}\u304C\u3042\u308A\u307E\u305B\u3093`,
10
- near.length>0?`\u3082\u3057\u304B\u3057\u3066: ${listCandidates(near,5)}\uFF08\u5168 ${candidates.length} \u4EF6\uFF09`:`\u6307\u5B9A\u3067\u304D\u308B${ctx.label}: ${listCandidates(candidates)}`)}function usable(value){return typeof value==="string"&&value.trim()!==""?value.trim():null}function resolveDefaultProject(explicit,profileName,env=process.env,cwd=process.cwd()){const fromFlag=usable(explicit);if(fromFlag!==null)return{ref:fromFlag,source:"flag"};const fromEnv=usable(env.TWP_PROJECT);if(fromEnv!==null)return{ref:fromEnv,source:"env"};const fromProjectConfig=usable(loadProjectConfig(cwd).project);if(fromProjectConfig!==null)return{ref:fromProjectConfig,source:"project-config"};const user=loadUserConfig(
11
- env);const fromProfile=usable(user.profiles?.[profileName]?.project);if(fromProfile!==null)return{ref:fromProfile,source:"user-config"};const fromUser=usable(user.project);if(fromUser!==null)return{ref:fromUser,source:"user-config"};return null}function requireDefaultProject(explicit,profileName,env=process.env,cwd=process.cwd()){const resolved=resolveDefaultProject(explicit,profileName,env,cwd);if(resolved!==null)return resolved;throw new UsageError("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
12
- '--project <\u30B3\u30FC\u30C9|ID> \u3092\u4ED8\u3051\u308B\u304B\u3001TWP_PROJECT / .twp/config.json / ~/.twp/config.json \u306E "project" \u306B\u65E2\u5B9A\u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002')}import crypto from"crypto";import fs from"fs";import path from"path";var DEFAULT_TTL_MS=10*60*1e3;var CACHE_VERSION=3;function cacheDir(env=process.env){return path.join(twpHomeDir(env),"cache")}function cacheFilePath(key,env=process.env){const digest=crypto.createHash("sha256").update(JSON.stringify([key.profile,key.scope,key.project??""])).digest("hex").slice(0,12);const label=key.scope.replace(/[^A-Za-z0-9._-]/g,"_").slice(0,40);return path.join(cacheDir(env),`${label}-${digest}.json`)}function sameKey(a,b){return a.profile===b.profile&&a.scope===b.scope&&(a.project??
13
- "")===(b.project??"")}function isOursAndPrivate(target,check){if(process.platform==="win32")return true;try{const st=fs.lstatSync(target);if(st.isSymbolicLink())return false;const uid=process.getuid?.();if(uid!==void 0&&st.uid!==uid)return false;const forbidden=check==="file"?54:18;return(st.mode&forbidden)===0}catch{return false}}function isCacheLocationTrusted(env){const home=twpHomeDir(env);const dir=cacheDir(env);for(const target of[home,dir]){if(fs.existsSync(target)&&!isOursAndPrivate(target,
14
- "dir"))return false}return true}function readCache(key,options={}){if(options.refresh===true)return null;const env=options.env??process.env;const file=cacheFilePath(key,env);if(!isCacheLocationTrusted(env)||!isOursAndPrivate(file,"file"))return null;let parsed;try{parsed=JSON.parse(fs.readFileSync(file,"utf8"))}catch{return null}if(parsed?.version!==CACHE_VERSION||!parsed.key||!sameKey(parsed.key,key))return null;const fetchedAt=Date.parse(parsed.fetched_at);if(!Number.isFinite(fetchedAt))return null;
15
- const ttl=options.ttlMs??DEFAULT_TTL_MS;const now=(options.now??Date.now)();if(Math.abs(now-fetchedAt)>ttl)return null;return parsed.value}function writeCache(key,value,options={}){const env=options.env??process.env;const dir=cacheDir(env);const file=cacheFilePath(key,env);const body={version:CACHE_VERSION,key:{profile:key.profile,scope:key.scope,...key.project!==void 0?{project:key.project}:{}},fetched_at:new Date((options.now??Date.now)()).toISOString(),value};if(!isCacheLocationTrusted(env))return;
16
- const tmp=`${file}.${process.pid}.tmp`;try{fs.mkdirSync(dir,{recursive:true,mode:448});fs.writeFileSync(tmp,`${JSON.stringify(body)}
17
- `,{mode:384});fs.renameSync(tmp,file)}catch{try{fs.rmSync(tmp,{force:true})}catch{}}}var SELF_REF="me";var PRIVATE_TASKS_PATH="/api/v2/tasks/private";var PRIVATE_MASTERS_CACHE_KEY="__private__";var BACKLOG_SPACES_CACHE_KEY="__backlog__";var BACKLOG_SCOPE_LABEL="\u3053\u306E\u63A5\u7D9A\u5148";var BACKLOG_PROJECT_SCOPE_LABEL="\u3053\u306E Backlog \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8";var PRIVATE_SCOPE_LABEL="\u500B\u4EBA\u30BF\u30B9\u30AF";function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function str(value){return typeof value==="string"&&
18
- value.trim()!==""?value:null}function truthyFlag(value){return value===true||value===1}function rawGetVia(client){return async path2=>{try{return{ok:true,status:200,json:await client.request("GET",path2),error:null}}catch(err){if(err instanceof ApiError){return{ok:false,status:err.status,json:err.body,error:err.message}}throw err}}}var TASK_MASTERS={status:{path:"task-statuses",envelope:"data",scope:"task-statuses",label:"\u30B9\u30C6\u30FC\u30BF\u30B9"},type:{path:"task-types",envelope:"data",scope:"\
19
- task-types",label:"\u7A2E\u5225"},category:{path:"task-categories",envelope:"data",scope:"task-categories",label:"\u30AB\u30C6\u30B4\u30EA"},milestone:{path:"task-milestones",envelope:"data",scope:"task-milestones",label:"\u30DE\u30A4\u30EB\u30B9\u30C8\u30FC\u30F3"},label:{path:"task-labels",envelope:"items",scope:"task-labels",label:"\u30E9\u30D9\u30EB"}};var Resolver=class{constructor(client,options){this.client=client;this.options=options;this.get=rawGetVia(client)}client;options;get;privateMastersInFlight=null;async project(ref){
20
- const trimmed=ref.trim();if(trimmed==="")throw new UsageError("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30FC\u30C9\u304B ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");return resolveProjectRef(trimmed,this.get,safeProjectIdPolicy)}async taskByKey(key){const trimmed=key.trim();if(!isTaskKey(trimmed)){throw new UsageError(`\u30BF\u30B9\u30AF\u30AD\u30FC\u306E\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093: ${key}`,"\u30AD\u30FC\u306F\u300C\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30B3\u30FC\u30C9-\u756A\u53F7\u300D\u306E\u5F62\u3067\u3059\uFF08\u4F8B: ABC-123\uFF09\u3002")}
21
- const res=await this.get(`/api/v2/tasks/resolve-by-key/${encodeURIComponent(trimmed)}`);if(res.status===404){throw new ResolveError(`\u30BF\u30B9\u30AF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${trimmed}\uFF08\u5B58\u5728\u3057\u306A\u3044\u304B\u3001\u95B2\u89A7\u3067\u304D\u308B\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u3042\u308A\u307E\u305B\u3093\uFF09`,404)}if(!res.ok){throw new ResolveError(`\u30BF\u30B9\u30AF\u30AD\u30FC\u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${trimmed}\
22
- \uFF08HTTP ${res.status}\uFF09\u3002\u63A5\u7D9A\u5148\u3068\u30ED\u30B0\u30A4\u30F3\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}const body=isRecord(res.json)?res.json:{};const projectId=str(body["project_id"]);const task=body["task"];if(projectId===null||!isRecord(task)){throw new ResolveError("\u30BF\u30B9\u30AF\u30AD\u30FC\u89E3\u6C7A\u306E\u5FDC\u7B54\u306B project_id / task \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
23
- res.status)}safeProjectIdPolicy.assertId(projectId);return{projectId,task}}async currentUser(){const res=await this.get("/api/v2/user");if(!res.ok){throw new ResolveError(`\u30ED\u30B0\u30A4\u30F3\u4E2D\u306E\u30E6\u30FC\u30B6\u30FC\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08HTTP ${res.status}\uFF09\u3002twp login \u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}const user=isRecord(res.json)?res.json["user"]:void 0;if(!isRecord(user)||str(user["\
24
- id"])===null){throw new ResolveError("\u30E6\u30FC\u30B6\u30FC\u53D6\u5F97\u306E\u5FDC\u7B54\u306B user.id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002",res.status)}return{id:user["id"],name:str(user["name"])??user["id"],email:str(user["email"])}}async status(projectId,input){return resolveNamed(this.applyAlias("status",input),await this.statuses(projectId),{flag:"--status",label:"\u30B9\u30C6\u30FC\u30BF\u30B9"})}async taskType(projectId,input){
25
- return resolveNamed(this.applyAlias("type",input),await this.taskTypes(projectId),{flag:"--type",label:"\u7A2E\u5225"})}async assignee(projectId,input,flag="--assignee"){if(input.trim().toLowerCase()===SELF_REF)return this.self();const value=this.applyAlias("assignee",input);if(value.trim().toLowerCase()===SELF_REF)return this.self();return resolveNamed(value,await this.members(projectId),{flag,label:"\u30E1\u30F3\u30D0\u30FC"})}async self(){const me=await this.currentUser();return{id:me.id,name:me.
26
- name,...me.email!==null?{aliases:[me.email]}:{}}}async defaultStatus(projectId){return requireDefault(await this.statuses(projectId),{flag:"--status",label:"\u30B9\u30C6\u30FC\u30BF\u30B9"})}async defaultTaskType(projectId){return requireDefault(await this.taskTypes(projectId),{flag:"--type",label:"\u7A2E\u5225"})}async statuses(projectId){return namedFromRows(await this.taskMasterRows("status",projectId),"\u30B9\u30C6\u30FC\u30BF\u30B9",codedMasterRow)}async taskTypes(projectId){return namedFromRows(
27
- await this.taskMasterRows("type",projectId),"\u7A2E\u5225",codedMasterRow)}async taskMaster(kind,projectId,input,flag){const spec=TASK_MASTERS[kind];return resolveNamed(input,await this.taskMasterRefs(kind,projectId),{flag,label:spec.label})}async taskMasterRefs(kind,projectId){const spec=TASK_MASTERS[kind];return namedFromRows(await this.taskMasterRows(kind,projectId),spec.label,codedMasterRow)}async privateTaskMaster(envelope,input,flag,label){return resolveNamed(input,await this.privateMasters(
28
- envelope,label),{flag,label,scope:PRIVATE_SCOPE_LABEL})}async taskMasterRows(kind,projectId){const spec=TASK_MASTERS[kind];return this.cached(spec.scope,projectId,async()=>rawListFrom(await this.get(`/api/v2/projects/${encodeURIComponent(projectId)}/${spec.path}`),spec.envelope,spec.label))}async privateStatuses(){return this.privateMasters("statuses","\u30B9\u30C6\u30FC\u30BF\u30B9")}async privateTaskTypes(){return this.privateMasters("types","\u7A2E\u5225")}async privateStatus(input){return resolveNamed(
29
- this.applyAlias("status",input),await this.privateStatuses(),{flag:"--status",label:"\u30B9\u30C6\u30FC\u30BF\u30B9",scope:PRIVATE_SCOPE_LABEL})}async privateTaskType(input){return resolveNamed(this.applyAlias("type",input),await this.privateTaskTypes(),{flag:"--type",label:"\u7A2E\u5225",scope:PRIVATE_SCOPE_LABEL})}async privateDefaultStatus(){return requireDefault(await this.privateStatuses(),{flag:"--status",label:"\u30B9\u30C6\u30FC\u30BF\u30B9",scope:PRIVATE_SCOPE_LABEL})}async privateDefaultTaskType(){
30
- return requireDefault(await this.privateTaskTypes(),{flag:"--type",label:"\u7A2E\u5225",scope:PRIVATE_SCOPE_LABEL})}async privateTask(ref){const trimmed=ref.trim();const res=await this.get(`${PRIVATE_TASKS_PATH}/${encodeURIComponent(trimmed)}`);if(res.status===404){throw new ResolveError(`\u500B\u4EBA\u30BF\u30B9\u30AF\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${trimmed}`,404)}if(!res.ok){throw new ResolveError(`\u500B\u4EBA\u30BF\u30B9\u30AF\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${trimmed}\
31
- \uFF08HTTP ${res.status}\uFF09\u3002\u63A5\u7D9A\u5148\u3068\u30ED\u30B0\u30A4\u30F3\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}const task=isRecord(res.json)?res.json["task"]:void 0;if(!isRecord(task)){throw new ResolveError("\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u5FDC\u7B54\u306B task \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002",res.status)}return task}async privateMasters(envelope,label){
32
- return namedFromRows(await this.privateMasterRows(envelope,label),label,codedMasterRow)}async privateMasterRows(envelope,label){return this.cached(`private-${envelope}`,PRIVATE_MASTERS_CACHE_KEY,async()=>rawListFrom(await this.privateMastersResponse(),envelope,label))}privateMastersResponse(){this.privateMastersInFlight??=this.get(`${PRIVATE_TASKS_PATH}/masters`);return this.privateMastersInFlight}async members(projectId){return this.cached("members",projectId,()=>this.namedList(`/api/v2/project\
33
- s/${encodeURIComponent(projectId)}/members`,"list","\u30E1\u30F3\u30D0\u30FC",row=>({id:str(row["user_id"]),name:str(row["user_name"]),code:null,aliases:[str(row["alias"]),str(row["user_email"])].filter(v=>v!==null)})))}async namedList(path2,envelope,label,map){return namedListFrom(await this.get(path2),envelope,label,map)}async cached(scope,projectId,load){const key={profile:this.options.profile,scope,project:projectId};const options={...this.options.env!==void 0?{env:this.options.env}:{},refresh:this.
34
- options.refresh,...this.options.ttlMs!==void 0?{ttlMs:this.options.ttlMs}:{},...this.options.now!==void 0?{now:this.options.now}:{}};const hit=readCache(key,options);if(hit!==null&&Array.isArray(hit))return hit;const fresh=await load();writeCache(key,fresh,options);return fresh}applyAlias(kind,input){const table=this.options.aliases?.[kind];if(table===void 0)return input;const needle=input.trim().toLowerCase();for(const[from,to]of Object.entries(table)){if(from.trim().toLowerCase()===needle&&typeof to===
35
- "string"&&to.trim()!=="")return to}return input}async backlogSpaces(){return this.cached("backlog-spaces",BACKLOG_SPACES_CACHE_KEY,()=>this.namedList(`${BACKLOG_BASE_PATH}/spaces`,"spaces","Backlog \u30B9\u30DA\u30FC\u30B9",backlogSpaceRow))}async backlogSpace(ref){return resolveNamed(ref,await this.backlogSpaces(),{flag:"--space",label:"Backlog \u30B9\u30DA\u30FC\u30B9",scope:BACKLOG_SCOPE_LABEL})}async backlogDefaultSpace(){const spaces=await this.backlogSpaces();if(spaces.length===1)return spaces[0];
36
- if(spaces.length===0){throw new UsageError("Backlog \u30B9\u30DA\u30FC\u30B9\u304C1\u4EF6\u3082\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u305B\u3093","TWP \u306E\u5916\u90E8\u9023\u643A\u8A2D\u5B9A\u3067 Backlog \u30B9\u30DA\u30FC\u30B9\u3092\u767B\u9332\u3057\u3066\u304F\u3060\u3055\u3044\uFF08twp backlog space list \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\uFF09\u3002")}throw new UsageError(`Backlog \u30B9\u30DA\u30FC\u30B9\u304C ${spaces.length} \u4EF6\u767B\u9332\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001--space \u30671\u3064\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,
37
- `twp backlog space list \u3067 ID \u3068\u30B9\u30DA\u30FC\u30B9URL\u3092\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002`)}async backlogProjects(spaceId){return this.cached("backlog-projects",spaceId,()=>this.namedList(backlogSpacePath(spaceId,"/projects"),"projects","Backlog \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8",backlogProjectRow))}async backlogStatuses(spaceId,projectId){return this.cached("backlog-statuses",`${spaceId}/${projectId}`,()=>this.namedList(backlogSpacePath(spaceId,`/projects/${encodeURIComponent(
38
- assertBacklogPathSegment(projectId,"Backlog \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8 ID"))}/statuses`),"statuses","Backlog \u30B9\u30C6\u30FC\u30BF\u30B9",backlogStatusRow))}async backlogUsers(spaceId,projectId){return this.cached("backlog-users",`${spaceId}/${projectId}`,()=>this.namedList(backlogSpacePath(spaceId,`/projects/${encodeURIComponent(assertBacklogPathSegment(projectId,"Backlog \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8 ID"))}/users`),"users","Backlog \u30E6\u30FC\u30B6\u30FC",backlogUserRow))}get apiClient(){
39
- return this.client}};function rawListFrom(res,envelope,label){if(!res.ok){throw new ResolveError(`${label}\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08HTTP ${res.status}\uFF09\u3002\u63A5\u7D9A\u5148\u3068\u30ED\u30B0\u30A4\u30F3\u72B6\u614B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}const list=isRecord(res.json)?res.json[envelope]:void 0;if(!Array.isArray(list)){throw new ResolveError(`${label}\u4E00\u89A7\u306E\u5FDC\u7B54\u306B ${envelope}\
40
- \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}return list.map((row,index)=>{if(!isRecord(row)){throw new ResolveError(`${label}\u4E00\u89A7\u306E ${index+1} \u4EF6\u76EE\u304C\u60F3\u5B9A\u306E\u5F62\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,res.status)}return row})}function codedMasterRow(row){return{id:str(row["\
41
- id"]),name:str(row["name"]),code:str(row["code"]),isDefault:truthyFlag(row["is_default"])}}function namedListFrom(res,envelope,label,map){return namedFromRows(rawListFrom(res,envelope,label),label,map,res.status??void 0)}function namedFromRows(rows,label,map,status=200){return rows.map((row,index)=>{const mapped=map(row);if(mapped.id===null||mapped.name===null){throw new ResolveError(`${label}\u4E00\u89A7\u306E ${index+1} \u4EF6\u76EE\u306B id / \u540D\u524D\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,
42
- status)}return{id:mapped.id,name:mapped.name,...mapped.code!==void 0?{code:mapped.code}:{},...mapped.aliases!==void 0&&mapped.aliases.length>0?{aliases:mapped.aliases}:{},...mapped.isDefault!==void 0?{isDefault:mapped.isDefault}:{}}})}function requireDefault(candidates,ctx){const hit=candidates.find(ref=>ref.isDefault===true);if(hit!==void 0)return hit;throw new UsageError(`${ctx.flag} \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${ctx.scope??DEFAULT_LOOKUP_SCOPE}\u306B\u306F\u65E2\u5B9A\u306E${ctx.
43
- label}\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF09`,`\u6307\u5B9A\u3067\u304D\u308B${ctx.label}: ${candidates.map(ref=>ref.name).join(" / ")}\uFF08\u53E4\u3044\u30AD\u30E3\u30C3\u30B7\u30E5\u304C\u6B8B\u3063\u3066\u3044\u308B\u5834\u5408\u306F --refresh \u3067\u53D6\u308A\u76F4\u305B\u307E\u3059\uFF09`)}export{BACKLOG_BASE_PATH,backlogSpacePath,resolveNamed,requireDefaultProject,PRIVATE_TASKS_PATH,BACKLOG_SCOPE_LABEL,BACKLOG_PROJECT_SCOPE_LABEL,TASK_MASTERS,Resolver};
@@ -1,36 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{spawnSync as spawnSync2}from"child_process";import{spawnSync}from"child_process";import fs from"fs";import path from"path";function resolveDeps(d){return{platform:d.platform??process.platform,env:d.env??process.env,findExecutable:d.findExecutable??((name,env,platform)=>findExecutable(name,{env,platform})),readFileSync:d.readFileSync??(p=>fs.readFileSync(p,"utf8")),existsSync:d.existsSync??fs.existsSync,sizeOf:d.sizeOf??(p=>fs.statSync(p).size),nodePath:d.nodePath??process.execPath}}var MAX_SHIM_BYTES=64*1024;var DENIED_NODE_FLAGS=["--require","-r","--import","--loader","--experimental-loader","--env-file","--eval","\
4
- -e","--print","-p","--inspect"];function deniedNodeFlag(arg){const name=arg.split("=")[0]??arg;if(name.startsWith("--inspect"))return true;return DENIED_NODE_FLAGS.includes(name)}function escapeRegExp(v){return v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function parseCmdShim(text){const paths=[];const re=/"%~?dp0%?[\\/]*([^"]+)"/gi;for(let m=re.exec(text);m!==null;m=re.exec(text))paths.push(m[1]??"");for(const script of paths.filter(v=>/\.[cm]?js$/i.test(v))){const esc=escapeRegExp(script);const adjacent=new RegExp(
5
- `"%_prog%"([^"]*)"%~?dp0%?[\\\\/]*${esc}"`,"i").exec(text)??new RegExp(`"%~?dp0%?[\\\\/]*node\\.exe"([^"]*)"%~?dp0%?[\\\\/]*${esc}"`,"i").exec(text);if(adjacent===null)continue;const middle=adjacent[1]??"";return{target:script,viaNode:true,nodeArgs:middle.trim().split(/\s+/).filter(a=>a!=="")}}const exe=paths.find(v=>/\.(exe|com)$/i.test(v)&&!/(^|[\\/])node\.exe$/i.test(v));if(exe!==void 0)return{target:exe,viaNode:false,nodeArgs:[]};return null}function resolveSpawnTarget(file,args,deps={}){const d=resolveDeps(
6
- deps);if(d.platform!=="win32")return{ok:true,file,args:[...args],note:null};const hasSeparator=/[\\/]/.test(file);const isAbsolute=isWindowsDriveAbsolute(file);if(hasSeparator&&!isAbsolute){return{ok:false,reason:`${file} \u306F\u76F8\u5BFE\u30D1\u30B9\u3067\u3059\u3002bare name \u304B\u7D76\u5BFE\u30D1\u30B9\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`}}const resolved=isAbsolute?file:d.findExecutable(file,d.env,d.platform);if(resolved===null||resolved===""){return{ok:false,reason:`${file}\
7
- \u304C PATH \u4E0A\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08PATHEXT \u306E\u62E1\u5F35\u5B50\u3082\u542B\u3081\u3066\u63A2\u3057\u307E\u3057\u305F\uFF09`}}const describe=to=>file===to?null:`${file} \u2192 ${to}`;const ext=path.win32.extname(resolved).toLowerCase();if(ext===".exe"||ext===".com"){return{ok:true,file:resolved,args:[...args],note:describe(resolved)}}if(ext!==".cmd"&&ext!==".bat"){return{ok:false,reason:`${resolved} \u306F Windows \u306E spawn \u3067\u8D77\u52D5\u3067\u304D\u306A\u3044\u5F62\u3067\u3059\uFF08\u62E1\u5F35\u5B50 ${ext===
8
- ""?"\u306A\u3057":ext}\uFF09\u3002native \u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\uFF08.exe\uFF09\u304B npm \u30B0\u30ED\u30FC\u30D0\u30EB\uFF08.cmd\uFF09\u3067\u5165\u308C\u76F4\u3057\u3066\u304F\u3060\u3055\u3044`}}let text;try{const size=d.sizeOf(resolved);if(size>MAX_SHIM_BYTES){return{ok:false,reason:`${resolved} \u304C\u5927\u304D\u3059\u304E\u307E\u3059\uFF08${size} \u30D0\u30A4\u30C8\uFF09\u3002npm \u306E cmd \u30B7\u30E0\u3067\u306F\u3042\u308A\u307E\u305B\u3093`}}text=d.readFileSync(resolved)}catch(e){
9
- return{ok:false,reason:`${resolved} \u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F: ${e.message}`}}const shim=parseCmdShim(text);if(shim===null){return{ok:false,reason:`${resolved} \u306F npm \u306E cmd \u30B7\u30E0\u306E\u5F62\u3067\u306F\u306A\u3044\u305F\u3081\u3001\u5B9F\u4F53\u3092\u7279\u5B9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002cmd.exe \u7D4C\u7531\u306E\u8D77\u52D5\u306F\u5F15\u6570\u3092\u6700\u521D\u306E\u6539\u884C\u3067\u5207\u308A\u6368\u3066\u308B\u305F\u3081\u4F7F\u3044\u307E\u305B\u3093\u3002native \u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\uFF08.exe\uFF09\u3067\u5165\u308C\u76F4\u3059\u304B\u3001npm \u3067\u30B0\u30ED\u30FC\u30D0\u30EB\u306B\u5165\u308C\u76F4\u3057\u3066\u304F\u3060\u3055\u3044`}}
10
- const dir=path.win32.dirname(resolved);if(path.win32.isAbsolute(shim.target)||/^[\\/]{2}/.test(shim.target)){return{ok:false,reason:`${resolved} \u304C\u7D76\u5BFE\u30D1\u30B9\uFF08${shim.target}\uFF09\u3092\u6307\u3057\u3066\u3044\u307E\u3059\u3002npm \u306E cmd \u30B7\u30E0\u3067\u306F\u3042\u308A\u307E\u305B\u3093`}}const target=path.win32.resolve(dir,shim.target);if(!d.existsSync(target)){return{ok:false,reason:`${resolved} \u304C\u6307\u3059 ${target} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08\u5C0E\u5165\u304C\u58CA\u308C\u3066\u3044\u307E\u3059\uFF09`}}
11
- if(!shim.viaNode){return{ok:true,file:target,args:[...args],note:`${file} \u2192 ${resolved} \u2192 ${target}`}}const bad=shim.nodeArgs.filter(a=>!a.startsWith("-")||deniedNodeFlag(a));if(bad.length>0){return{ok:false,reason:`${resolved} \u304C node \u3078\u6E21\u305D\u3046\u3068\u3057\u3066\u3044\u308B\u5F15\u6570\u3092\u8A31\u53EF\u3067\u304D\u307E\u305B\u3093\uFF08${bad.join(" ")}\uFF09`}}const colocated=path.win32.join(dir,"node.exe");const prog=d.existsSync(colocated)?colocated:d.nodePath;return{
12
- ok:true,file:prog,args:[...shim.nodeArgs,target,...args],note:`${file} \u2192 ${resolved}\uFF08cmd \u30B7\u30E0\u3092\u89E3\u6C7A: ${prog} ${target}\uFF09`}}function spawnSyncResolved(file,args,options,deps={},run=spawnSync){const target=resolveSpawnTarget(file,args,deps);if(!target.ok){return{pid:0,output:[],stdout:"",stderr:"",status:null,signal:null,error:new Error(target.reason)}}return run(target.file,target.args,options)}var DEFAULT_CLAUDE_LAUNCHER={bin:"claude-auto-switch",probe:["--help"],probeMatch:"^\\s*exec\\s",execArgs:["exec","--"],activeArgs:["active","--path"]};function detectClaudeAutoSwitch(bin=DEFAULT_CLAUDE_LAUNCHER.bin,run=spawnSync2,lookup={}){const r=spawnSyncResolved(bin,[...DEFAULT_CLAUDE_LAUNCHER.probe],{encoding:"utf8",timeout:1e4},lookup,run);if(r.error!==void 0||r.status!==0)return null;const help=`${r.stdout??""}${r.stderr??""}`;return{bin,hasExec:new RegExp(DEFAULT_CLAUDE_LAUNCHER.probeMatch,
13
- "m").test(help)}}function wrapWithAutoSwitch(cas,file,args){if(cas===null||!cas.hasExec)return{file,args:[...args]};return{file:cas.bin,args:[...DEFAULT_CLAUDE_LAUNCHER.execArgs,file,...args]}}function activeSlotPath(cas,run=spawnSync2,lookup={}){if(cas===null)return null;const r=spawnSyncResolved(cas.bin,[...DEFAULT_CLAUDE_LAUNCHER.activeArgs],{encoding:"utf8",timeout:1e4},lookup,run);if(r.error!==void 0||r.status!==0)return null;const out=(r.stdout??"").trim();return out===""?null:out}function isClaudeAi(ai){
14
- return ai==="claude"||!["gemini","codex","copilot"].includes(ai)}import{createHash}from"crypto";import fs2 from"fs";var EXCLUSIVE_SKILL_FLOOR=["support-triage"];function normalizeSkillName(skill){return skill.trim().replace(/^twp-/,"")}var stripPrefix=normalizeSkillName;function skillOfItem(item){const explicit=(item.ai_skill??"").trim();if(explicit)return stripPrefix(explicit);const m=/\/twp-([a-z0-9-]+)/.exec(item.prompt??"");return m?.[1]??""}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.
15
- isNaN(ts))continue;return Math.floor((now.getTime()-ts)/6e4)}return null}function exclusiveInflightEntries(groups,opts){const now=opts.now??new Date;const staleMinutes=opts.staleHours*60;const bySkill=new Map;for(const group of groups){for(const item of group.items){const skill=skillOfItem(item);if(!skill)continue;const status=group.status==="mixed"?item.status??"unknown":group.status;const ageMinutes=ageMinutesOf(item,now);if(status==="processing"&&ageMinutes!==null&&ageMinutes>staleMinutes)continue;
16
- const entry={skill,status,runner:item.runner_id??"-",ageMinutes};const prev=bySkill.get(skill);if(!prev||(entry.ageMinutes??-1)>(prev.ageMinutes??-1))bySkill.set(skill,entry)}}return[...bySkill.values()].sort((a,b)=>a.skill.localeCompare(b.skill))}function formatExclusiveEntry(entry){const age=entry.ageMinutes===null?"\u4E0D\u660E":`${entry.ageMinutes}\u5206`;return`${entry.skill} status=${entry.status} runner=${entry.runner} \u7D4C\u904E=${age}`}import path2 from"path";var BUILTIN={primary_rotation:{complex:["claude"],search:["claude"],simple:["claude"]},fallback_chains:{complex:["claude","codex"],search:["codex","gemini","copilot","claude"],simple:["codex","gemini","copilot","claude"]}};function usesBedrock(env){return isBoolishTrue(env.CLAUDE_CODE_USE_BEDROCK)}var DEFAULT_CATEGORY="complex";var EFFORTS=new Set(["low","medium","high","xhigh","max"]);var MAX_COOLDOWN_SEC=3600;var DEFAULT_COOLDOWN_SEC=300;var AI_UNUSABLE_COOLDOWN_SEC=1800;
17
- function loadAiConfig(inline,file,workspace){const read=readAiConfigFile(file,workspace);const warnings=read.problem===null?[]:[read.problem.startsWith("ai_config_file \u3092\u8AAD\u3081\u307E\u305B\u3093")?`${read.problem}
18
- \u3053\u306E\u72B6\u614B\u3067\u306F\u5168\u30B9\u30AD\u30EB\u304C\u65E2\u5B9A\u30AB\u30C6\u30B4\u30EA\u3067\u8D70\u308A\u307E\u3059\u3002\u78BA\u8A8D: python3 -m json.tool <file>`:read.problem];return{config:new AiConfig(mergeAiConfig(read.file,inline)),warnings}}function readAiConfigFile(file,workspace){if(file===void 0||file.trim()==="")return{file:null,problem:null};const resolved=path2.isAbsolute(file)?file:path2.resolve(workspace,file);try{const parsed=JSON.parse(fs2.readFileSync(resolved,
19
- "utf8"));if(parsed===null||typeof parsed!=="object"||Array.isArray(parsed)){return{file:null,problem:`ai_config_file \u304C\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093: ${resolved}`}}return{file:parsed,problem:null}}catch(err){return{file:null,problem:`ai_config_file \u3092\u8AAD\u3081\u307E\u305B\u3093: ${resolved}\uFF08${err.message}\uFF09`}}}function mergeAiConfig(fromFile,inline){return{...fromFile??{},...inline??{}}}function reloadAiConfig(target,inline,file,workspace){
20
- const hashBefore=target.hash();const read=readAiConfigFile(file,workspace);if(read.file===null){if(read.problem===null)return{status:"skipped",hashBefore,hashAfter:hashBefore,warnings:[]};return{status:"kept",hashBefore,hashAfter:hashBefore,warnings:[`${read.problem}
21
- \u73FE\u5728\u306E\u8A2D\u5B9A\uFF08config_hash ${hashBefore}\uFF09\u306E\u307E\u307E\u8D70\u308A\u307E\u3059\u3002\u78BA\u8A8D: python3 -m json.tool <file>`]}}const changed=target.replace(mergeAiConfig(read.file,inline));return{status:changed?"updated":"unchanged",hashBefore,hashAfter:target.hash(),warnings:[]}}function stableJson(value){return JSON.stringify(value,(_key,v)=>v!==null&&typeof v==="object"&&!Array.isArray(v)?Object.fromEntries(Object.entries(v).sort(([a],[b])=>a.localeCompare(
22
- b))):v)}var CHAIN_KEYS=["primary_rotation","fallback_chains"];var AiConfig=class _AiConfig{rotation=new Map;limitedUntil=new Map;unusableUntil=new Map;highRiskSkills;raw;constructor(raw){this.raw=raw;this.highRiskSkills=_AiConfig.highRiskSet(raw)}static highRiskSet(raw){return new Set((raw.high_risk_skills??[]).filter(v=>typeof v==="string"&&v!==""))}replace(next){if(stableJson(next)===stableJson(this.raw))return false;this.raw=next;this.highRiskSkills=_AiConfig.highRiskSet(next);return true}hash(){
23
- const significant=Object.fromEntries(Object.entries(this.raw).filter(([k])=>!k.startsWith("_")&&!CHAIN_KEYS.includes(k)).sort(([a],[b])=>a.localeCompare(b)));return createHash("sha256").update(JSON.stringify(significant)).digest("hex").slice(0,16)}categoryForSkill(skill){const name=stripPrefix2(skill);return this.raw.skill_category?.[name]??DEFAULT_CATEGORY}usesAi(ai){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;
24
- const categories=new Set([DEFAULT_CATEGORY,...Object.keys(rotations),...Object.keys(chains),...Object.values(this.raw.skill_category??{})]);const matches=name=>isClaudeAi(ai)?isClaudeAi(name):name===ai;for(const category of categories){const rotation=rotations[category]??rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];const chain=chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"];for(const name of[...rotation,...chain]){if(matches(
25
- name))return true}}return false}chainFor(category){const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;return chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"]}primaryFor(category,skill){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const entries=rotations[category]??rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];if(entries.length===0)return"";const start=this.rotation.get(category)??0;for(let i=0;i<
26
- entries.length;i+=1){const ai=entries[(start+i)%entries.length];if(ai!==void 0&&this.isAllowed(ai,category,skill)){this.rotation.set(category,(start+i+1)%entries.length);return ai}}return""}isHighRisk(category,skill,priority,label){if(["verify","security","support"].includes(category))return true;if(priority==="P0"||priority==="P0.5")return true;const name=stripPrefix2(skill);if(this.highRiskSkills.has(name))return true;return HIGH_RISK_LABEL.test(label)}selectPrimary(category,skill,priority,label){
27
- if(this.isHighRisk(category,skill,priority,label)&&this.chainFor(category).includes("claude")){return"claude"}return this.primaryFor(category,skill)}isAllowed(ai,category,skill){if(ai!=="gemini")return true;if(["complex","verify","security","support"].includes(category))return false;return!this.requiresGitRemote(skill)}requiresGitRemote(skill){return(this.raw.git_remote_skills??[]).includes(stripPrefix2(skill))}exclusiveSkills(){const configured=(this.raw.exclusive_skills??[]).map(s=>stripPrefix2(
28
- (s??"").trim())).filter(s=>s!=="");return new Set([...configured,...EXCLUSIVE_SKILL_FLOOR])}isExclusiveSkill(skill){const name=stripPrefix2(skill.trim());return name!==""&&this.exclusiveSkills().has(name)}modelFor(ai,category,env=process.env){switch(ai){case"gemini":return this.raw.gemini_models?.[category]??"";case"codex":return this.raw.codex_models?.[category]??this.raw.codex_models?.[DEFAULT_CATEGORY]??"";case"claude":return this.claudeModelFor(category,env);default:return isClaudeAi(ai)?this.
29
- claudeModelFor(category,env):""}}claudeModelFor(category,env){const table=usesBedrock(env)?this.raw.claude_models_bedrock:this.raw.claude_models;return table?.[category]??env.CLAUDE_MODEL??""}maxTurnsFor(category,env=process.env){const fallback=Number.parseInt(env.CLAUDE_MAX_TURNS??"",10);const base=Number.isInteger(fallback)&&fallback>0?fallback:200;const configured=this.raw.claude_max_turns?.[category];return Number.isInteger(configured)&&(configured??0)>0?configured:base}effortFor(category,skill,env=process.
30
- env,explicit){const name=stripPrefix2(skill);const item=(explicit??"").trim();if(item!==""&&EFFORTS.has(item))return{value:item,warning:null};const itemWarning=item!==""?`\u4E0D\u6B63\u306A ai_effort '${item}'\uFF08\u30A2\u30A4\u30C6\u30E0\u6307\u5B9A\uFF09\u2192 \u30B9\u30AD\u30EB\uFF0F\u30AB\u30C6\u30B4\u30EA\u65E2\u5B9A\u3092\u4F7F\u3044\u307E\u3059`:null;const raw=(name!==""?this.raw.claude_effort_by_skill?.[name]:void 0)??this.raw.claude_effort?.[category]??env.CLAUDE_EFFORT??"";if(raw==="")
31
- return{value:"",warning:itemWarning};if(EFFORTS.has(raw))return{value:raw,warning:itemWarning};return{value:"",warning:`\u4E0D\u6B63\u306A effort \u5024 '${raw}'\uFF08category=${category}, skill=${name||"none"}\uFF09\u2192 \u672A\u6307\u5B9A\u3068\u3057\u3066\u6271\u3044\u307E\u3059`}}fallbackDelaySec(ai,env=process.env){const fromEnv=Number.parseInt(env[`AI_FALLBACK_DELAY_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>=0)return fromEnv;const cfg=this.raw.fallback_delay?.[ai];
32
- return Number.isInteger(cfg)&&(cfg??0)>=0?cfg:0}cooldownDefaultSec(ai,env=process.env){const fromEnv=Number.parseInt(env[`AI_COOLDOWN_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>0)return fromEnv;const cfg=this.raw.cooldown?.[ai];if(Number.isInteger(cfg)&&(cfg??0)>0)return cfg;const backoff=Number.parseInt(env.RATE_LIMIT_BACKOFF??"",10);return Number.isInteger(backoff)&&backoff>0?backoff:DEFAULT_COOLDOWN_SEC}limitKey(ai,slot){return slot===null||slot===void 0||slot===""?ai:
33
- `${ai}@${slot}`}hasCooldownFor(ai,now=Date.now()){for(const[key,until]of this.limitedUntil){if(until<=now)continue;if(key===ai||key.startsWith(`${ai}@`))return true}return false}isRateLimited(ai,now=Date.now(),slot=null){return(this.limitedUntil.get(this.limitKey(ai,slot))??0)>now}markRateLimited(ai,seconds,now=Date.now(),slot=null){const capped=Math.min(Math.max(Math.trunc(seconds),1),MAX_COOLDOWN_SEC);this.limitedUntil.set(this.limitKey(ai,slot),now+capped*1e3);return capped}markAiUnusable(ai,now=Date.
34
- now()){this.unusableUntil.set(ai,now+AI_UNUSABLE_COOLDOWN_SEC*1e3);return AI_UNUSABLE_COOLDOWN_SEC}isAiUnusable(ai,now=Date.now()){return(this.unusableUntil.get(ai)??0)>now}minCooldownRemainingSec(now=Date.now()){let min=null;for(const until of this.limitedUntil.values()){if(until<=now)continue;const remaining=Math.ceil((until-now)/1e3);if(min===null||remaining<min)min=remaining}return min}};var HIGH_RISK_LABEL=/本番|リリース|認証|認可|権限|セキュリティ|課金|給与|勤怠計算/;
35
- var TIER_ALIASES=new Set(["opus","sonnet","haiku","default"]);function modelFitsRoute(model,env=process.env){if(TIER_ALIASES.has(model.trim().toLowerCase()))return true;if(model.startsWith("arn:aws:bedrock:"))return usesBedrock(env);const bedrockShaped=/(^|[./])anthropic\./.test(model);return usesBedrock(env)?bedrockShaped:!bedrockShaped}function isUsableModelId(value){return value!==""&&!value.startsWith("-")&&/^[A-Za-z0-9._:\-/[\]]+$/.test(value)}function stripPrefix2(skill){return skill.startsWith(
36
- "twp-")?skill.slice(4):skill}export{resolveSpawnTarget,spawnSyncResolved,DEFAULT_CLAUDE_LAUNCHER,detectClaudeAutoSwitch,wrapWithAutoSwitch,activeSlotPath,isClaudeAi,normalizeSkillName,skillOfItem,exclusiveInflightEntries,formatExclusiveEntry,usesBedrock,loadAiConfig,reloadAiConfig,AiConfig,modelFitsRoute,isUsableModelId};
@@ -1,27 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{isModeId,isPermissionModeId}from"./chunk-BOBSH3QN.js";import{API_TOKEN,HELP_TOKEN,isDomainName}from"./chunk-ZGG7TRAM.js";import{splitFlagToken}from"./chunk-QQRJLH6B.js";var BUILTIN_COMMANDS=["login","logout","whoami","update","task-loop"];var TASK_LOOP_ACTIONS=["run","status","stop","schedule","setup"];var VALUE_FLAGS=new Set(["-p","--print","--profile","--tenant","--mode","--permission-mode","--model","--allowed-tools","--disallowed-tools","--project","--engine","--interval","--max-cycles","--ai","--workspace","--ai-config-file","--now","--counts","--gate","--output","--query"]);var BOOLEAN_FLAGS=new Set(["-h","--help","-v","--version","--no-tui","--doctor","-\
4
- -password","--token","--no-browser","--safe","--daemon","--force-runner","--force","--drain","--yes","-y","--no-ai-config-file","--verbose","--dry-run","--debug","--refresh"]);function dispatch(argv,limit=2){const tokens=[];const indexes=[];let truncated=false;for(let i=0;i<argv.length;i++){const arg=argv[i];if(arg===void 0)continue;if(arg.startsWith("-")&&arg!=="-"){const{name,value:inline}=splitFlagToken(arg);if(BOOLEAN_FLAGS.has(name)){if(inline!==void 0){truncated=true;break}continue}if(VALUE_FLAGS.
5
- has(name)){if(inline!==void 0)continue;const next=argv[i+1];if(next!==void 0&&(!next.startsWith("-")||next==="-"))i++;continue}truncated=true;break}if(arg===""||arg==="-")continue;if(tokens.length>=limit)break;tokens.push(arg);indexes.push(i)}return{tokens,indexes,truncated}}function isBuiltin(token){return token!==void 0&&BUILTIN_COMMANDS.includes(token)}function isTaskLoopAction(token){return token!==void 0&&TASK_LOOP_ACTIONS.includes(token)}function resolveRoute(result){const{tokens,indexes}=result;
6
- const[first,second]=tokens;const firstIndex=indexes[0];if(first===void 0||firstIndex===void 0)return{kind:"none",consumed:[]};const consumed=[firstIndex];const secondIndex=indexes[1];if(isBuiltin(first)){if(first==="task-loop"&&isTaskLoopAction(second)){if(secondIndex!==void 0)consumed.push(secondIndex);return{kind:"builtin",command:first,action:second,consumed}}return{kind:"builtin",command:first,...first==="task-loop"?{action:"run"}:{},consumed}}if(second!==void 0&&secondIndex!==void 0)consumed.
7
- push(secondIndex);return{kind:"domain",domain:first,...second!==void 0?{operation:second}:{},consumed}}var GLOBAL_FLAGS=new Set(["-h","--help","-v","--version","--profile","--output","--query","--dry-run","--debug","--yes","-y","--refresh"]);function parseArgv(argv){const out={command:"tui",safe:false,daemon:false,forceRunner:false,stopForce:false,logoutForce:false,stopDrain:false,noTui:false,doctor:false,yes:false,noAiConfigFile:false,verbose:false,loginMethod:"browser",loginNoBrowser:false,promptFromStdin:false,domainArgv:[],domainHelp:false,dryRun:false,debug:false,refresh:false,unknown:[],allowedTools:[],
8
- disallowedTools:[]};const route=resolveRoute(dispatch(argv));const consumed=new Set;const[firstIndex,secondIndex]=route.consumed;if(route.kind==="builtin"){out.command=route.command;if(route.action!==void 0)out.taskLoopAction=route.action;for(const index of route.consumed)consumed.add(index)}else if(route.kind==="domain"){if(route.domain===HELP_TOKEN){if(route.operation===void 0){out.command="help";if(firstIndex!==void 0)consumed.add(firstIndex)}else if(isDomainName(route.operation)){out.command=
9
- "domain";out.domain=route.operation;out.domainHelp=true;if(firstIndex!==void 0)consumed.add(firstIndex);if(secondIndex!==void 0)consumed.add(secondIndex)}else if(route.operation===API_TOKEN){out.command="api";out.domainHelp=true;if(firstIndex!==void 0)consumed.add(firstIndex);if(secondIndex!==void 0)consumed.add(secondIndex)}}else if(route.domain===API_TOKEN){out.command="api";if(firstIndex!==void 0)consumed.add(firstIndex)}else if(isDomainName(route.domain)){out.command="domain";out.domain=route.
10
- domain;if(route.operation!==void 0)out.operation=route.operation;for(const index of route.consumed)consumed.add(index)}}const hasSubcommandToken=route.kind==="builtin"||route.kind==="domain"&&(route.domain===HELP_TOKEN||route.domain===API_TOKEN||isDomainName(route.domain));const isDomainRoute=out.command==="domain"||out.command==="api";const takeValue=(i,flag,inline)=>{const value=inline??argv[i+1];if(value===void 0||inline===void 0&&value.startsWith("-")){out.unknown.push(flag);return{step:0}}if(value.
11
- trim()===""){out.unknown.push(inline===void 0?`${flag} `:`${flag}=${inline}`);return{step:0}}return{value,step:inline===void 0?1:0}};let optionsClosed=false;for(let i=0;i<argv.length;i++){if(consumed.has(i))continue;const raw=argv[i];if(raw===void 0)continue;if(isDomainRoute&&raw==="--")optionsClosed=true;const{name:arg,value:inline}=splitFlagToken(raw);if(isDomainRoute&&(optionsClosed||!GLOBAL_FLAGS.has(arg))){out.domainArgv.push(raw);continue}if(inline!==void 0&&BOOLEAN_FLAGS.has(arg)){out.unknown.
12
- push(raw);continue}switch(arg){case"-h":case"--help":if(isDomainRoute)out.domainHelp=true;else out.command="help";break;case"-v":case"--version":out.command="version";break;case"--no-tui":out.noTui=true;break;case"--doctor":out.doctor=true;break;case"--password":out.loginMethod="password";break;case"--token":out.loginMethod="token";break;case"--no-browser":out.loginNoBrowser=true;break;case"--profile":{const{value,step}=takeValue(i,"--profile",inline);if(value!==void 0){out.profile=value;i+=step}
13
- break}case"-p":case"--print":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(hasSubcommandToken){out.unknown.push(raw)}else if(next==="-"){out.command="print";out.promptFromStdin=true;out.prompt="";i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.command="print";out.prompt=next;i+=step}else{out.unknown.push(raw)}break}case"--output":{const{value,step}=takeValue(i,"--output",inline);if(value!==void 0){out.output=value;i+=step}break}case"--query":{const{
14
- value,step}=takeValue(i,"--query",inline);if(value!==void 0){out.query=value;i+=step}break}case"--dry-run":out.dryRun=true;break;case"--debug":out.debug=true;break;case"--refresh":out.refresh=true;break;case"--tenant":{const{value,step}=takeValue(i,"--tenant",inline);if(value!==void 0){out.tenant=value;i+=step}break}case"--mode":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(isModeId(next)){out.mode=next;i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.
15
- unknown.push(inline!==void 0?raw:`--mode ${next}`);i+=step}else{out.unknown.push("--mode")}break}case"--permission-mode":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(isPermissionModeId(next)){out.permissionMode=next;i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.unknown.push(inline!==void 0?raw:`--permission-mode ${next}`);i+=step}else{out.unknown.push("--permission-mode")}break}case"--allowed-tools":case"--disallowed-tools":{const{value,step}=takeValue(
16
- i,arg,inline);if(value!==void 0){(arg==="--allowed-tools"?out.allowedTools:out.disallowedTools).push(value);i+=step}break}case"--model":{const{value,step}=takeValue(i,"--model",inline);if(value!==void 0){out.model=value;i+=step}break}case"--safe":out.safe=true;break;case"--daemon":out.daemon=true;break;case"--force-runner":out.forceRunner=true;break;case"--force":out.stopForce=true;break;case"--drain":out.stopDrain=true;break;case"--project":{const{value,step}=takeValue(i,"--project",inline);if(value!==
17
- void 0){out.project=value;i+=step}break}case"--engine":{const{value,step}=takeValue(i,"--engine",inline);if(value!==void 0){out.engine=value;i+=step}break}case"--interval":case"--max-cycles":{const{value,step}=takeValue(i,arg,inline);if(value!==void 0){const n=Number.parseInt(value,10);if(Number.isInteger(n)&&n>0){if(arg==="--interval")out.interval=n;else out.maxCycles=n}else{out.unknown.push(inline!==void 0?raw:`${arg} ${value}`)}i+=step}break}case"--yes":case"-y":out.yes=true;break;case"--ai":{
18
- const{value:v,step}=takeValue(i,"--ai",inline);if(v!==void 0){out.ais=[...out.ais??[],v];i+=step}break}case"--no-ai-config-file":out.noAiConfigFile=true;break;case"--workspace":{const{value:v,step}=takeValue(i,"--workspace",inline);if(v!==void 0){out.workspace=v;i+=step}break}case"--ai-config-file":{const{value:v,step}=takeValue(i,"--ai-config-file",inline);if(v!==void 0){out.aiConfigFile=v;i+=step}break}case"--verbose":out.verbose=true;break;case"--now":{const{value:v,step}=takeValue(i,"--now",
19
- inline);if(v!==void 0){out.scheduleNow=v;i+=step}break}case"--counts":{const{value:v,step}=takeValue(i,"--counts",inline);if(v!==void 0){out.scheduleCounts=v;i+=step}break}case"--gate":{const{value:v,step}=takeValue(i,"--gate",inline);if(v!==void 0){out.scheduleGate=v;i+=step}break}default:out.unknown.push(raw)}}if(out.command!=="login"&&out.loginMethod!=="browser"){out.unknown.push(out.loginMethod==="password"?"--password":"--token");out.loginMethod="browser"}if(out.permissionMode!==void 0&&out.
20
- command!=="tui"&&out.command!=="print"){out.unknown.push("--permission-mode");delete out.permissionMode}if(out.command!=="tui"&&out.command!=="print"){if(out.allowedTools.length>0)out.unknown.push("--allowed-tools");if(out.disallowedTools.length>0)out.unknown.push("--disallowed-tools");out.allowedTools=[];out.disallowedTools=[]}if(out.loginNoBrowser&&!(out.command==="login"&&out.loginMethod==="browser")){out.unknown.push("--no-browser");out.loginNoBrowser=false}if(out.command==="logout"&&out.stopForce){
21
- out.logoutForce=true;out.stopForce=false}if(out.command!=="task-loop"){if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.stopForce)out.unknown.push("--force");if(out.stopDrain)out.unknown.push("--drain");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles");if(out.project!==void 0)out.unknown.
22
- push("--project");if(out.verbose)out.unknown.push("--verbose");if(out.scheduleNow!==void 0)out.unknown.push("--now");if(out.scheduleCounts!==void 0)out.unknown.push("--counts");if(out.scheduleGate!==void 0)out.unknown.push("--gate");if(out.ais!==void 0)out.unknown.push("--ai");if(out.workspace!==void 0)out.unknown.push("--workspace");if(out.aiConfigFile!==void 0)out.unknown.push("--ai-config-file");if(out.noAiConfigFile)out.unknown.push("--no-ai-config-file")}if(out.yes&&out.command!=="task-loop"&&
23
- !isDomainRoute)out.unknown.push("--yes");if(!isDomainRoute){if(out.output!==void 0)out.unknown.push("--output");if(out.query!==void 0)out.unknown.push("--query");if(out.dryRun)out.unknown.push("--dry-run");if(out.debug)out.unknown.push("--debug");if(out.refresh)out.unknown.push("--refresh")}if(out.command==="api"&&out.refresh){out.unknown.push("--refresh");out.refresh=false}if(out.command==="task-loop"&&out.taskLoopAction!=="schedule"){if(out.verbose)out.unknown.push("--verbose");if(out.scheduleNow!==
24
- void 0)out.unknown.push("--now");if(out.scheduleCounts!==void 0)out.unknown.push("--counts");if(out.scheduleGate!==void 0)out.unknown.push("--gate")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopForce){out.unknown.push("--force")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopDrain){out.unknown.push("--drain")}if(out.command==="task-loop"&&out.taskLoopAction==="stop"&&out.stopForce&&out.stopDrain){out.unknown.push("--force \u3068 --drain \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
25
- out.stopForce=false;out.stopDrain=false}if(out.command==="task-loop"&&out.taskLoopAction!=="setup"){if(out.yes)out.unknown.push("--yes");if(out.ais!==void 0)out.unknown.push("--ai");if(out.workspace!==void 0)out.unknown.push("--workspace");if(out.aiConfigFile!==void 0)out.unknown.push("--ai-config-file");if(out.noAiConfigFile)out.unknown.push("--no-ai-config-file")}if(out.command==="task-loop"&&(out.taskLoopAction==="stop"||out.taskLoopAction==="status")){if(out.safe)out.unknown.push("--safe");if(out.
26
- daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}if(out.command==="task-loop"&&out.taskLoopAction==="setup"){if(out.engine!==void 0)out.unknown.push("--engine");if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runn\
27
- er");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}return out}export{parseArgv};
@@ -1,69 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{stringWidth}from"./chunk-WVS4W5FY.js";import{parseOperationArgs}from"./chunk-O52CUEDO.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-TAN5I2DP.js";import{HELP_TOKEN}from"./chunk-ZGG7TRAM.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{Resolver,requireDefaultProject}from"./chunk-MIMDLO52.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JKSXUBND.js";import{httpFetch}from"./chunk-J7QYPKVK.js";
4
- import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-2VISRLWS.js";import{ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import{ResolveError}from"./chunk-5QCAIKFE.js";import fs from"fs";import path from"path";var SENSITIVE_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-vercel-protection-bypass"]);var REDACTED="***\uFF08\u4F0F\u5B57\uFF09";var SECRET_KEY_PATTERN="[A-Za-z0-9_-]*(?:token|secret|password|passwd|api[_-]?key|credential|signature)[A-Za-z0-9_-]*";var NOT_SECRET_FLAGS="(?:starting-token)";function redactSecrets(text){return text.replace(/\bBearer\s+[^\s"'`,;)\]}]+/gi,`Bearer ${REDACTED}`).replace(new RegExp(`("${SECRET_KEY_PATTERN}"\\\
5
- s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,"gi"),`$1"${REDACTED}"`).replace(new RegExp(`([?&]${SECRET_KEY_PATTERN}=)[^&\\s"'\`,;)\\]}]+`,"gi"),`$1${REDACTED}`).replace(new RegExp(`(--(?!${NOT_SECRET_FLAGS}(?:=|\\s))${SECRET_KEY_PATTERN}(?:=|\\s+))('[^']*'|"[^"]*"|[A-Za-z0-9_.~+/=|:%-]+)`,"gi"),`$1${REDACTED}`)}var SECRET_KEY_NAME=new RegExp(`^${SECRET_KEY_PATTERN}$`,"i");function redactSecretValues(value){if(Array.isArray(value))return value.map(item=>redactSecretValues(item));if(value!==null&&typeof value===
6
- "object"){const out={};for(const[key,item]of Object.entries(value)){out[key]=SECRET_KEY_NAME.test(key)?REDACTED:redactSecretValues(item)}return out}return value}function formatHeaders(headers){if(!headers)return[];const entries=headers instanceof Headers?[...headers.entries()]:Array.isArray(headers)?headers:Object.entries(headers);return entries.map(([name,value])=>{const shown=SENSITIVE_HEADERS.has(name.toLowerCase())?REDACTED:redactSecrets(String(value));return` ${name.toLowerCase()}: ${shown}`})}
7
- var BODY_LIMIT=4e3;function formatBody(raw){const safe=redactSecrets(stripTerminalControls(raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
8
- \u2026\uFF08\u4EE5\u964D ${safe.length-BODY_LIMIT} \u6587\u5B57\u3092\u7701\u7565\uFF09`:safe}function isTextualContentType(contentType){if(contentType===null)return false;return/^\s*(text\/|application\/(json|xml|javascript|x-www-form-urlencoded)|application\/[\w.+-]*\+(json|xml))/i.test(contentType)}function withDebug(inner,options={}){const write=options.write??(text=>void process.stderr.write(text));const now=options.now??(()=>Date.now());return async(input,init)=>{const method=init?.method??
9
- "GET";const lines=[`[debug] \u2192 ${method} ${redactSecrets(input)}`,...formatHeaders(init?.headers)];if(typeof init?.body==="string")lines.push(` ${formatBody(init.body)}`);write(`${lines.join("\n")}
10
- `);const started=now();let res;try{res=await inner(input,init)}catch(err){write(`[debug] \u2717 \u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F (${now()-started}ms): ${redactSecrets(err.message)}
11
- `);throw err}const out=[`[debug] \u2190 ${res.status} ${res.statusText} (${now()-started}ms)`,...formatHeaders(res.headers)];const contentType=res.headers.get("content-type");if(isTextualContentType(contentType)){const raw=await res.clone().text().catch(()=>"\uFF08\u672C\u6587\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\uFF09");if(raw!=="")out.push(` ${formatBody(raw)}`)}else{const length=res.headers.get("content-length");out.push(` \uFF08\u672C\u6587\u306F ${contentType??"content-ty\
12
- pe \u4E0D\u660E"}\u30FB${length===null?"\u30B5\u30A4\u30BA\u4E0D\u660E":`${length} \u30D0\u30A4\u30C8`}\u3002\u30C6\u30AD\u30B9\u30C8\u3067\u306A\u3044\u305F\u3081\u51FA\u529B\u3057\u306A\u3044\uFF09`)}write(`${out.join("\n")}
13
- `);return res}}var OUTPUT_FORMATS=["json","table","text","tsv"];function isOutputFormat(value){return typeof value==="string"&&OUTPUT_FORMATS.includes(value)}function resolveOutputFormat(input){if(input.flag!==void 0){return isOutputFormat(input.flag)?input.flag:null}if(isOutputFormat(input.configured))return input.configured;return input.isTty?"table":"json"}function formatOutput(value,format){switch(format){case"json":return formatJson(value);case"table":return formatTable(value);case"text":return formatDelimited(
14
- value," ");case"tsv":return formatDelimited(value," ")}}var JSON_UNSAFE_CONTROLS=/[\u007f-\u009f]/gu;function formatJson(value){const text=JSON.stringify(value===void 0?null:value,null,2);return text.replace(JSON_UNSAFE_CONTROLS,ch=>`\\u${ch.codePointAt(0)?.toString(16).padStart(4,"0")??""}`)}function cell(value){if(value===null||value===void 0)return"";if(typeof value==="string")return stripTerminalControls(value);if(typeof value==="number"||typeof value==="boolean"||typeof value==="bigint"){return String(
15
- value)}return stripTerminalControls(JSON.stringify(value)??"")}function isPlainRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function collectColumns(rows){const columns=[];const seen=new Set;for(const row of rows){for(const key of Object.keys(row)){if(!seen.has(key)){seen.add(key);columns.push(key)}}}return columns}function renderRow(cells,widths){return cells.map((text,i)=>{if(i===cells.length-1)return text;const pad=Math.max(0,(widths[i]??0)-stringWidth(text));
16
- return text+" ".repeat(pad)}).join(" ").trimEnd()}function singleLine(text){return stripTerminalControls(text).replace(/\t/g,"\\t").replace(/\n/g,"\\n")}function renderGrid(header,rows){const normalizedHeader=header?header.map(singleLine):null;const normalizedRows=rows.map(row=>row.map(singleLine));return renderGridNormalized(normalizedHeader,normalizedRows)}function renderGridNormalized(header,rows){const all=header?[header,...rows]:rows;const columnCount=all.reduce((max,row)=>Math.max(max,row.
17
- length),0);const widths=[];for(let i=0;i<columnCount;i+=1){widths.push(all.reduce((max,row)=>Math.max(max,stringWidth(row[i]??"")),0))}const lines=[];if(header){lines.push(renderRow(header,widths));lines.push(widths.map(w=>"-".repeat(Math.max(1,w))).join(" ").trimEnd())}for(const row of rows)lines.push(renderRow(row,widths));return lines.join("\n")}function formatTable(value){if(Array.isArray(value)){if(value.length===0)return"";const records=value.filter(isPlainRecord);if(records.length!==value.
18
- length){return renderGrid(null,value.map(v=>[cell(v)]))}const columns=collectColumns(records);if(columns.length===0)return"";return renderGrid(columns,records.map(row=>columns.map(c=>cell(row[c]))))}if(isPlainRecord(value)){const entries=Object.entries(value);if(entries.length===0)return"";return renderGrid(null,entries.map(([k,v])=>[k,cell(v)]))}return cell(value)}function escapeDelimited(text){return text.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}function formatDelimited(value,separator){
19
- const rows=[];if(Array.isArray(value)){const records=value.filter(isPlainRecord);if(value.length>0&&records.length===value.length){const columns=collectColumns(records);for(const row of records)rows.push(columns.map(c=>cell(row[c])))}else{for(const v of value)rows.push([cell(v)])}}else if(isPlainRecord(value)){rows.push(Object.values(value).map(cell))}else{rows.push([cell(value)])}return rows.map(row=>row.map(escapeDelimited).join(separator)).join("\n")}async function evaluateQuery(expression,value){if(expression.trim()===""){throw new UsageError("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093")}const{search}=await import("./dist-HZIZTJ4O.js");try{return search(value??null,expression)}catch(err){throw new UsageError(`--query \u306E\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}function renderOutput(value,format,noRedact=false){if(noRedact)return formatOutput(value,format);return redactSecrets(formatOutput(redactSecretValues(value),format))}var NO_REDACT_FLAG={name:"--no-redact",summary:"\u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u3066\u751F\u306E\u5024\u3092\u51FA\u3059\uFF08\u9375\u306E\u53D7\u3051\u53D6\u308A\u7B49\uFF09",takesValue:false};var NO_REDACT_NOTICE="\u6CE8\u8A18: --no-redact \u306E\u305F\u3081\u51FA\u529B\u3092\u4F0F\u5B57\u5316\u3057\u307E\u305B\u3093\uFF08\u7AEF\u672B\u3068\u30ED\u30B0\u306B\u5E73\u6587\u3067\u6B8B\u308A\u307E\u3059\uFF09\u3002";function withCommonFlags(flags){return flags.some(flag=>flag.
20
- name===NO_REDACT_FLAG.name)?flags:[...flags,NO_REDACT_FLAG]}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?"":`
21
- \u64CD\u4F5C:
22
- ${alignedList(resource.operations.map(op=>[op.name,op.summary]))}
23
- `;const subSection=subresources.length===0?"":`
24
- \u30B5\u30D6\u8CC7\u6E90:
25
- ${alignedList(subresources.map(sub=>[`${sub.name} <\u64CD\u4F5C>`,sub.summary]))}
26
- `;return`twp ${path2} \u2014 ${resource.summary}
27
-
28
- \u4F7F\u3044\u65B9:
29
- twp ${path2} <\u64CD\u4F5C> [\u5F15\u6570] [\u30AA\u30D7\u30B7\u30E7\u30F3]
30
- twp ${path2} <\u64CD\u4F5C> ${HELP_TOKEN} \u305D\u306E\u64CD\u4F5C\u306E\u8A73\u3057\u3044\u30D8\u30EB\u30D7
31
- ${operationSection}${subSection}
32
- ${GLOBAL_OPTIONS_HELP}
33
- `}function renderOperationHelp(op,path2){const sections=[`twp ${path2} ${op.name} \u2014 ${op.summary}`,"","\u4F7F\u3044\u65B9:",` ${op.usage}`];if(op.description!==void 0){sections.push("",...op.description.split("\n"))}if(op.destructive===true){sections.push("","\u26A0 \u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002")}const flags=withCommonFlags(op.flags);if(flags.length>0){sections.push("","\u30AA\u30D7\u30B7\u30E7\u30F3:",
34
- alignedList(flags.map(flag=>[flag.takesValue?`${flag.name} ${flag.placeholder??"<\u5024>"}`:flag.name,flag.summary])))}sections.push("",GLOBAL_OPTIONS_HELP,"");return sections.join("\n")}function renderUnknownOperation(resource,path2,attempted){const names=[...resource.operations.map(op=>op.name),...subresourcesOf(resource).map(sub=>`${sub.name} <\u64CD\u4F5C>`)].join(" / ");return attempted===void 0?`twp ${path2} \u306B\u306F\u64CD\u4F5C\u306E\u6307\u5B9A\u304C\u5FC5\u8981\u3067\u3059\uFF08${names}\
35
- \uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`:`twp ${path2} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`}var LOADERS={backlog:async()=>(await import("./backlog-NV7Z76R3.js")).backlogDomain,project:async()=>(await import("./project-BATJQR3F.js")).projectDomain,task:async()=>(await import("./task-6QUH5OXF.js")).taskDomain};async function loadDomain(name){return LOADERS[name]()}var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
36
- `}function outputValue(operation,format,body){return format==="json"?operation.raw(body):operation.summarize(body)}function requiresYes(operation,yes){return operation.destructive===true&&!yes}function exitCodeForStatus(status){if(status===401)return EXIT_AUTH;if(status===429)return EXIT_API_SERVER;if(status>=400&&status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}function exitCodeFor(err){if(err instanceof UsageError)return EXIT_USAGE;if(err instanceof NotLoggedInError||err instanceof SessionExpiredError)
37
- return EXIT_AUTH;if(err instanceof ApiError)return exitCodeForStatus(err.status);if(err instanceof ApiResponseError||err instanceof NetworkError)return EXIT_API_SERVER;if(err instanceof ResolveError){return err.status===null?EXIT_API_SERVER:exitCodeForStatus(err.status)}return EXIT_FAILURE}function safeText(text){return redactSecrets(stripTerminalControls(text))}function reportError(err,format,code,write=writeErr){const message=safeText(err instanceof Error?err.message:String(err));const rawHint=err instanceof
38
- UsageError?err.hint:void 0;const hint=rawHint!==void 0?safeText(rawHint):void 0;if(format==="json"){const body={code,message};if(err instanceof ApiError)body["status"]=err.status;if(err instanceof ResolveError&&err.status!==null)body["status"]=err.status;if(hint!==void 0)body["hint"]=hint;write(`${JSON.stringify({error:body},null,2)}
39
- `);return}write(`${message}
40
- `);if(hint!==void 0)write(`${hint}
41
- `)}function dryRunValue(apiUrl,plan){const value={method:plan.method,url:`${apiUrl}${appendQuery(plan.path,plan.query)}`};if(plan.body!==void 0)value["body"]=plan.body;return value}async function send(client,apiUrl,plan){try{return await client.request(plan.method,appendQuery(plan.path,plan.query),plan.body)}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError){throw err}throw new NetworkError(`${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.
42
- message}`,{cause:err})}}async function putSigned(fetchImpl,url,bytes,contentType){let res;try{res=await fetchImpl(url,{method:"PUT",headers:{"Content-Type":contentType},body:bytes})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.
43
- status}\uFF09`)}}function resolveDownloadTarget(spec,commandPath,operationName,input){const raw=input.flags.get(spec.outFlag);if(raw===void 0||raw.trim()===""){throw new UsageError(`${spec.outFlag} \u306F\u5FC5\u9808\u3067\u3059\uFF08twp ${commandPath} ${operationName}\uFF09`,`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002`)}return{out:path.
44
- resolve(raw.trim()),force:input.flags.has(spec.forceFlag)}}function assertWritableTarget(target,forceFlag){if(!target.force&&fs.existsSync(target.out)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${target.out}`,`\u4E0A\u66F8\u304D\u3059\u308B\u306A\u3089 ${forceFlag} \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A\u3067\u306F\u4E0A\u66F8\u304D\u3057\u307E\u305B\u3093\uFF09\u3002`)}const dir=path.dirname(target.out);if(!fs.existsSync(
45
- dir)){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u3042\u308A\u307E\u305B\u3093: ${dir}`,"\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u4F5C\u3063\u3066\u304B\u3089\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u81EA\u52D5\u3067\u306F\u4F5C\u6210\u3057\u307E\u305B\u3093\uFF09\u3002")}}async function download(args){let received;try{received=await args.client.requestBinary(args.plan.method,appendQuery(args.plan.path,args.plan.query))}catch(err){
46
- if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError)throw err;throw new NetworkError(`${args.apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}try{fs.writeFileSync(args.target.out,received.bytes,{flag:args.target.force?"w":"wx"})}catch(err){const code=err.code;if(code==="EEXIST"){throw new UsageError(`\u66F8\u304D\u51FA\u3057\u5148\u304C\u65E2\u306B\u3042\u308A\u307E\u3059: ${args.target.out}`,"\u4E0A\u66F8\u304D\
47
- \u3059\u308B\u306A\u3089 --force \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}throw new Error(`\u66F8\u304D\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${args.target.out}\uFF09: ${err.message}`,{cause:err})}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType}}var CURATED_PAGING_VOCABULARY={mode:"--all",resumeFlag:"--cursor",capAdvice:"--limit \u3092\u5927\u304D\u304F\u3057\u3066\u5F80\u5FA9\u3092\u6E1B\u3089\u3059\u304B\u3001--max-pages / --max-items \u3092\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\u3002"};
48
- function capExceeded(vocabulary,reason,pages,count,cursor){return new UsageError(`${vocabulary.mode} \u304C\u4E0A\u9650\u306B\u9054\u3057\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\uFF08${reason}\uFF0F${pages} \u30DA\u30FC\u30B8\u30FB${count} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`,`${vocabulary.capAdvice}\u7D9A\u304D\u3060\u3051\u3092\u53D6\u308B\u306A\u3089 ${vocabulary.resumeFlag} ${shellQuote(cursor)}\
49
- \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059`)}async function fetchAllPages(args){const{paging,maxPages,maxItems}=args;const vocabulary=args.vocabulary??CURATED_PAGING_VOCABULARY;const merged=[];const first=args.plan.query?.[paging.cursorParam];let sent=typeof first==="string"?first:"";for(let page=1;;page+=1){const plan=page===1?args.plan:{...args.plan,query:{...args.plan.query,[paging.cursorParam]:sent}};let body;try{body=page===1&&"firstPage"in args?args.firstPage:await send(args.client,
50
- args.apiUrl,plan)}catch(err){if(page>1){(args.warn??writeErr)(`${vocabulary.mode} \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-1} \u30DA\u30FC\u30B8\u30FB${merged.length} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F ${vocabulary.resumeFlag} ${shellQuote(stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
51
- `)}throw err}for(const item of paging.items(body))merged.push(item);const next=paging.nextCursor(body);if(next===null)return{body:paging.withItems(body,merged),pages:page,count:merged.length};if(merged.length>=maxItems)throw capExceeded(vocabulary,`\u6700\u5927\u4EF6\u6570 ${maxItems} \u4EF6`,page,merged.length,next);if(page>=maxPages)throw capExceeded(vocabulary,`\u6700\u5927\u30DA\u30FC\u30B8\u6570 ${maxPages}`,page,merged.length,next);if(next===sent){throw new ApiResponseError(`\u540C\u3058\u30AB\u30FC\u30BD\u30EB\uFF08${next}\
52
- \uFF09\u304C\u7E70\u308A\u8FD4\u3057\u8FD4\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\u3002${merged.length} \u4EF6\u3092\u53D6\u5F97\u3057\u305F\u6642\u70B9\u3067\u3001\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`)}sent=next}}function resolvePaging(operation,path2,input){const all=input.flags.has("--all");const maxPages=positiveInteger(input.flags,"--max-pages")??DEFAULT_MAX_PAGES;const maxItems=positiveInteger(input.flags,"--max-items")??
53
- DEFAULT_MAX_ITEMS;positiveInteger(input.flags,"--limit");if(all&&operation.paging===void 0){throw new UsageError(`twp ${path2} ${operation.name} \u306F --all \u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093`)}for(const name of["--max-pages","--max-items"]){if(!all&&input.flags.has(name)){throw new UsageError(`${name} \u306F --all \u3068\u4F75\u305B\u3066\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,`${name} \u3060\u3051\u3067\u306F\u4F55\u3082\u5909\u308F\u308A\u307E\u305B\u3093`)}}return{
54
- all,maxPages,maxItems}}function profileAliases(profileName){const aliases=loadUserConfig().profiles?.[profileName]?.aliases;return aliases!==void 0?{aliases}:{}}function buildPrepareContext(args){const cache=new Map;return{resolver:args.resolver,projectId(explicit){if(explicit!==void 0&&explicit.trim()===""){throw new UsageError("--project \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","--project <\u30B3\u30FC\u30C9|ID> \u3092\u6307\u5B9A\u3059\u308B\u304B\u3001--project \u3054\u3068\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
55
- const ref=requireDefaultProject(explicit,args.profileName,args.env,args.cwd).ref;const hit=cache.get(ref);if(hit!==void 0)return hit;const resolved=args.resolver.project(ref).then(project=>project.id);cache.set(ref,resolved);return resolved}}}async function runDomain(options){const{globals}=options;const out=options.io?.out??writeOut;const errOut=options.io?.err??writeErr;let format=null;try{const profile=resolveProfile(globals.profile);format=resolveOutputFormat({...globals.output!==void 0?{flag:globals.
56
- output}:{},...(()=>{const configured=resolveConfiguredOutput(profile.name);return configured!==void 0?{configured}:{}})(),isTty:options.io?.isTty??process.stdout.isTTY===true});if(format===null){throw new UsageError(`--output \u306B\u300C${globals.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${OUTPUT_FORMATS.join(" / ")} \u3067\u3059`)}const domain=await loadDomain(options.domain);if(options.operation===HELP_TOKEN||options.help&&options.
57
- operation===void 0){const[extra,...rest2]=options.argv;if(extra===void 0){out(renderResourceHelp(domain,domain.name));return EXIT_OK}const target=domain.subresources?.find(resource2=>resource2.name===extra);if(target===void 0||rest2.length>0){throw new UsageError(renderUnknownOperation(domain,domain.name,extra))}out(renderResourceHelp(target,`${domain.name} ${extra}`));return EXIT_OK}const sub=domain.subresources?.find(resource2=>resource2.name===options.operation);const resource=sub??domain;const path2=sub===
58
- void 0?domain.name:`${domain.name} ${sub.name}`;const operationName=sub===void 0?options.operation:options.argv[0];const rest=sub===void 0?options.argv:options.argv.slice(1);if(sub!==void 0&&(operationName===HELP_TOKEN||options.help&&operationName===void 0)){out(renderResourceHelp(sub,path2));return EXIT_OK}const operation=resource.operations.find(op=>op.name===operationName);if(operation===void 0){throw new UsageError(renderUnknownOperation(resource,path2,operationName))}if(options.help||rest[0]===
59
- HELP_TOKEN){out(renderOperationHelp(operation,path2));return EXIT_OK}const input=parseOperationArgs(rest,withCommonFlags(operation.flags));const noRedact=input.flags.has("--no-redact");if(!globals.dryRun&&requiresYes(operation,globals.yes)){throw new UsageError(`twp ${path2} ${operation.name} \u306F\u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`)}const paging=resolvePaging(operation,path2,input);
60
- const downloadTarget=operation.download===void 0?void 0:resolveDownloadTarget(operation.download,path2,operation.name,input);const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport,{write:errOut}):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);const ctx=buildPrepareContext(
61
- {resolver:new Resolver(client,{profile:profile.name,refresh:globals.refresh,...profileAliases(profile.name)}),profileName:profile.name,env:process.env,cwd:process.cwd()});const prepared=operation.prepare===void 0?input:await operation.prepare(input,ctx);const plan=operation.plan(prepared);if(operation.execute!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: execute \u306F download / paging / fetchCache\
62
- d \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.fetchCached!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.destructive===true||plan.method!=="GET")){throw new Error(`twp ${path2} ${operation.name}: fetchCached \u306F\u9001\u4FE1\u3057\u306A\u3044\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}
63
- for(const note of operation.plannedNotes?.(prepared)??[])errOut(`${safeText(note)}
64
- `);if(noRedact)errOut(`${NO_REDACT_NOTICE}
65
- `);if(globals.dryRun){out(line(renderOutput(dryRunValue(apiUrl,plan),format,noRedact)));return EXIT_OK}let body;let paged;if(operation.execute!==void 0){const executeCtx={send:next=>send(client,apiUrl,next),putSigned:(url,bytes,contentType)=>putSigned(fetchImpl,url,bytes,contentType),warn:text=>errOut(`${safeText(text)}
66
- `)};body=await operation.execute(prepared,executeCtx)}else if(operation.fetchCached!==void 0){body=await operation.fetchCached(prepared,ctx)}else if(operation.download!==void 0&&downloadTarget!==void 0){assertWritableTarget(downloadTarget,operation.download.forceFlag);body=await download({client,apiUrl,plan,target:downloadTarget})}else if(paging.all&&operation.paging!==void 0){paged=await fetchAllPages({client,apiUrl,plan,paging:operation.paging,maxPages:paging.maxPages,maxItems:paging.maxItems,
67
- warn:errOut});body=paged.body}else{body=await send(client,apiUrl,plan)}const visible=noRedact?body:redactSecretValues(body);const value=globals.query!==void 0?await evaluateQuery(globals.query,operation.raw(visible)):outputValue(operation,format,visible);out(line(renderOutput(value,format,noRedact)));if(paged!==void 0){errOut(`--all: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.count} \u4EF6\u3092\u53D6\u5F97\u3057\u307E\u3057\u305F\u3002
68
- `)}const pagingNotes=operation.paging===void 0?[]:nextPageNotes(body,prepared,{command:`twp ${path2} ${operation.name}`,flags:operation.flags,profile:globals.profile});for(const note of[...pagingNotes,...operation.notes?.(visible,prepared)??[]]){errOut(`${safeText(note)}
69
- `)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code,errOut);return code}}export{redactSecretValues,withDebug,OUTPUT_FORMATS,resolveOutputFormat,evaluateQuery,renderOutput,NO_REDACT_FLAG,NO_REDACT_NOTICE,outputValue,requiresYes,exitCodeFor,reportError,CURATED_PAGING_VOCABULARY,fetchAllPages,resolvePaging,buildPrepareContext,runDomain};
@@ -1,3 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- var DOMAIN_NAMES=["backlog","project","task"];function isDomainName(value){return value!==void 0&&DOMAIN_NAMES.includes(value)}var HELP_TOKEN="help";var API_TOKEN="api";export{isDomainName,HELP_TOKEN,API_TOKEN};
@@ -1,4 +0,0 @@
1
- import { createRequire as __twpCreateRequire } from 'node:module';
2
- const require = __twpCreateRequire(import.meta.url);
3
- import{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain}from"./chunk-SPZO6C5N.js";import"./chunk-WVS4W5FY.js";import"./chunk-O52CUEDO.js";import"./chunk-TAN5I2DP.js";import"./chunk-ZGG7TRAM.js";import"./chunk-QQRJLH6B.js";import"./chunk-XNLIEUAW.js";import"./chunk-MIMDLO52.js";import"./chunk-II5RVJQN.js";import"./chunk-JKSXUBND.js";import"./chunk-J7QYPKVK.js";
4
- import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import"./chunk-NHYMHCAT.js";import"./chunk-2VISRLWS.js";import"./chunk-M3GWY6NT.js";import"./chunk-5QCAIKFE.js";import"./chunk-VSJBJXZO.js";export{CURATED_PAGING_VOCABULARY,buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,reportError,requiresYes,resolvePaging,runDomain};