@tocca-systems/twp-cli 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.public.md +80 -0
- package/LICENSE +47 -0
- package/README.md +279 -0
- package/dist/THIRD-PARTY-NOTICES.md +1239 -0
- package/dist/ai-dispatch-T6PJ4DUG.js +82 -0
- package/dist/app-S33SNSH5.js +1370 -0
- package/dist/chunk-3WJHTPOZ.js +48 -0
- package/dist/chunk-4QI5NX4C.js +6 -0
- package/dist/chunk-5QCAIKFE.js +9 -0
- package/dist/chunk-63LDNYGW.js +23 -0
- package/dist/chunk-7ZVTACQS.js +8 -0
- package/dist/chunk-DIMZRTLE.js +37 -0
- package/dist/chunk-DXXFUNYN.js +7 -0
- package/dist/chunk-FQDYLZV3.js +6 -0
- package/dist/chunk-GY7KI5E5.js +4 -0
- package/dist/chunk-II5RVJQN.js +3 -0
- package/dist/chunk-IM4H52FC.js +109 -0
- package/dist/chunk-J7QYPKVK.js +18 -0
- package/dist/chunk-KCXVV45F.js +16 -0
- package/dist/chunk-L37NS5L2.js +8 -0
- package/dist/chunk-N2UVRM3Z.js +5 -0
- package/dist/chunk-N3B737KO.js +57 -0
- package/dist/chunk-NERYSBA4.js +9 -0
- package/dist/chunk-NHYMHCAT.js +4 -0
- package/dist/chunk-NNOYO67O.js +7 -0
- package/dist/chunk-PMOUHEJQ.js +5 -0
- package/dist/chunk-Q7YSSWTR.js +33 -0
- package/dist/chunk-RQFG3OUL.js +41 -0
- package/dist/chunk-RZVI6PMW.js +5 -0
- package/dist/chunk-VSJBJXZO.js +3 -0
- package/dist/chunk-VSQXY2VX.js +42 -0
- package/dist/chunk-WVS4W5FY.js +16 -0
- package/dist/chunk-ZZ5EYKCK.js +58 -0
- package/dist/cli.js +132 -0
- package/dist/commands-QKNOQRWT.js +60 -0
- package/dist/commands-T47RY6EH.js +365 -0
- package/dist/devtools-VZW7JDIG.js +131 -0
- package/dist/dist-HZIZTJ4O.js +93 -0
- package/dist/fuzzysort-DFVKV4B4.js +3 -0
- package/dist/oneshot-JD5LINMX.js +18 -0
- package/dist/project-BEY4CNSF.js +13 -0
- package/dist/run-EDV5273K.js +58 -0
- package/dist/schedule-command-LWUBXHBQ.js +13 -0
- package/dist/setup-GY674TII.js +74 -0
- package/dist/task-MQYRE4QC.js +135 -0
- package/dist/update-WDWUECN7.js +21 -0
- package/package.json +73 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{stringWidth}from"./chunk-WVS4W5FY.js";import{GLOBAL_OPTIONS_HELP,HELP_TOKEN,splitFlagToken}from"./chunk-VSQXY2VX.js";import{Resolver,requireDefaultProject}from"./chunk-Q7YSSWTR.js";import"./chunk-II5RVJQN.js";import{ApiResponseError,DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError,nextPageNotes,positiveInteger,shellQuote}from"./chunk-KCXVV45F.js";import{ResolveError}from"./chunk-5QCAIKFE.js";
|
|
4
|
+
import{ApiError,TwpApiClient,appendQuery}from"./chunk-7ZVTACQS.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-63LDNYGW.js";import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";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)[A-Za-z0-9_-]*";function redactSecrets(text){return text.replace(/\bBearer\s+[^\s"'`,;)\]}]+/gi,`Bearer ${REDACTED}`).replace(new RegExp(`("${SECRET_KEY_PATTERN}"\\s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,"gi"),`$1"${REDACTED}\
|
|
5
|
+
"`).replace(new RegExp(`([?&]${SECRET_KEY_PATTERN}=)[^&\\s]+`,"gi"),`$1${REDACTED}`)}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}`})}var BODY_LIMIT=4e3;function formatBody(raw){const safe=stripTerminalControls(
|
|
6
|
+
redactSecrets(raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
|
|
7
|
+
\u2026\uFF08\u4EE5\u964D ${safe.length-BODY_LIMIT} \u6587\u5B57\u3092\u7701\u7565\uFF09`:safe}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??"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")}
|
|
8
|
+
`);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)}
|
|
9
|
+
`);throw err}const out=[`[debug] \u2190 ${res.status} ${res.statusText} (${now()-started}ms)`,...formatHeaders(res.headers)];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)}`);write(`${out.join("\n")}
|
|
10
|
+
`);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(
|
|
11
|
+
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(
|
|
12
|
+
value)}return 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));return text+" ".repeat(
|
|
13
|
+
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.length),0);const widths=[];
|
|
14
|
+
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.length){return renderGrid(
|
|
15
|
+
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){
|
|
16
|
+
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 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,path){const operations=alignedList(resource.operations.map(op=>[op.name,op.summary]));const subresources=subresourcesOf(resource);const subSection=subresources.
|
|
17
|
+
length===0?"":`
|
|
18
|
+
\u30B5\u30D6\u8CC7\u6E90:
|
|
19
|
+
${alignedList(subresources.map(sub=>[`${sub.name} <\u64CD\u4F5C>`,sub.summary]))}
|
|
20
|
+
`;return`twp ${path} \u2014 ${resource.summary}
|
|
21
|
+
|
|
22
|
+
\u4F7F\u3044\u65B9:
|
|
23
|
+
twp ${path} <\u64CD\u4F5C> [\u5F15\u6570] [\u30AA\u30D7\u30B7\u30E7\u30F3]
|
|
24
|
+
twp ${path} <\u64CD\u4F5C> ${HELP_TOKEN} \u305D\u306E\u64CD\u4F5C\u306E\u8A73\u3057\u3044\u30D8\u30EB\u30D7
|
|
25
|
+
|
|
26
|
+
\u64CD\u4F5C:
|
|
27
|
+
${operations}
|
|
28
|
+
${subSection}
|
|
29
|
+
${GLOBAL_OPTIONS_HELP}
|
|
30
|
+
`}function renderOperationHelp(op,path){const sections=[`twp ${path} ${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")}if(op.flags.length>0){sections.push("","\u30AA\u30D7\u30B7\u30E7\u30F3:",alignedList(op.flags.
|
|
31
|
+
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,path,attempted){const names=[...resource.operations.map(op=>op.name),...subresourcesOf(resource).map(sub=>`${sub.name} <\u64CD\u4F5C>`)].join(" / ");return attempted===void 0?`twp ${path} \u306B\u306F\u64CD\u4F5C\u306E\u6307\u5B9A\u304C\u5FC5\u8981\u3067\u3059\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path}\
|
|
32
|
+
${HELP_TOKEN}`:`twp ${path} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path} ${HELP_TOKEN}`}function parseOperationArgs(argv,specs){const byName=new Map(specs.map(spec=>[spec.name,spec]));const args=[];const flags=new Map;let positionalOnly=false;for(let i=0;i<argv.length;i+=1){const arg=argv[i];if(arg===void 0)continue;if(!positionalOnly&&arg==="--"){positionalOnly=true;continue}if(positionalOnly||!arg.startsWith("-")||arg==="-"){args.push(arg);continue}const{name,value:inline}=splitFlagToken(arg);const spec=byName.get(name);if(spec===void 0){const shortEquals=!arg.startsWith("--")&&arg.
|
|
33
|
+
includes("=");throw new UsageError(`\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: ${arg}`,shortEquals?`\u77ED\u3044\u30D5\u30E9\u30B0\u306B = \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u7A7A\u767D\u3067\u533A\u5207\u3063\u3066\u304F\u3060\u3055\u3044: ${arg.replace("="," ")}`:void 0)}if(flags.has(name))throw new UsageError(`${name} \u304C\u8907\u6570\u56DE\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`);if(!spec.takesValue){if(inline!==void 0){throw new UsageError(`${name} \u306F\u5024\u3092\u53D6\u308A\u307E\u305B\u3093`,
|
|
34
|
+
`${name} \u306F\u6307\u5B9A\u306E\u6709\u7121\u3060\u3051\u304C\u610F\u5473\u3092\u6301\u3061\u307E\u3059\u3002`)}flags.set(name,"");continue}if(inline!==void 0){flags.set(name,inline);continue}const next=argv[i+1];if(next===void 0||next.startsWith("-")&&next!=="-"){throw new UsageError(`${name} \u306B\u306F\u5024\u304C\u5FC5\u8981\u3067\u3059`,`\`-\` \u3067\u59CB\u307E\u308B\u5024\u306F ${name}=\u5024 \u306E\u5F62\u3067\u6E21\u305B\u307E\u3059\u3002`)}flags.set(name,next);i+=1}return{args,flags}}var LOADERS={project:async()=>(await import("./project-BEY4CNSF.js")).projectDomain,task:async()=>(await import("./task-MQYRE4QC.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}
|
|
35
|
+
`}function outputValue(operation,format,body){return format==="json"?operation.raw(body):operation.summarize(body)}function requiresYes(operation,yes){return operation.destructive===true&&!yes}function exitCodeFor(err){if(err instanceof UsageError)return EXIT_USAGE;if(err instanceof NotLoggedInError||err instanceof SessionExpiredError)return EXIT_AUTH;if(err instanceof ApiError){if(err.status===401)return EXIT_AUTH;if(err.status>=400&&err.status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}
|
|
36
|
+
if(err instanceof ApiResponseError||err instanceof NetworkError)return EXIT_API_SERVER;if(err instanceof ResolveError){if(err.status===401)return EXIT_AUTH;if(err.status!==null&&err.status>=400&&err.status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}return EXIT_FAILURE}function reportError(err,format,code){const message=stripTerminalControls(err instanceof Error?err.message:String(err));const rawHint=err instanceof UsageError?err.hint:void 0;const hint=rawHint!==void 0?stripTerminalControls(
|
|
37
|
+
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;writeErr(`${JSON.stringify({error:body},null,2)}
|
|
38
|
+
`);return}writeErr(`${message}
|
|
39
|
+
`);if(hint!==void 0)writeErr(`${hint}
|
|
40
|
+
`)}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.
|
|
41
|
+
message}`,{cause:err})}}function capExceeded(reason,pages,count,cursor){return new UsageError(`--all \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`,`--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\u7D9A\u304D\u3060\u3051\u3092\u53D6\u308B\u306A\u3089 --cursor ${shellQuote(
|
|
42
|
+
cursor)} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059`)}async function fetchAllPages(args){const{paging,maxPages,maxItems}=args;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=await send(args.client,args.apiUrl,plan)}catch(err){if(page>1){writeErr(`--all \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-
|
|
43
|
+
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 --cursor ${shellQuote(stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
|
|
44
|
+
`)}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(`\u6700\u5927\u4EF6\u6570 ${maxItems} \u4EF6`,page,merged.length,next);if(page>=maxPages)throw capExceeded(`\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}\
|
|
45
|
+
\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,path,input){const all=input.flags.has("--all");const maxPages=positiveInteger(input.flags,"--max-pages")??DEFAULT_MAX_PAGES;const maxItems=positiveInteger(input.flags,"--max-items")??DEFAULT_MAX_ITEMS;
|
|
46
|
+
positiveInteger(input.flags,"--limit");if(all&&operation.paging===void 0){throw new UsageError(`twp ${path} ${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{all,maxPages,maxItems}}
|
|
47
|
+
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")}
|
|
48
|
+
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;let format=null;try{const profile=resolveProfile(globals.profile);format=resolveOutputFormat({...globals.output!==void 0?{flag:globals.output}:{},...(()=>{const configured=resolveConfiguredOutput(profile.
|
|
49
|
+
name);return configured!==void 0?{configured}:{}})(),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.operation===void 0){const[extra,...rest2]=options.argv;if(extra===void 0){writeOut(
|
|
50
|
+
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))}writeOut(renderResourceHelp(target,`${domain.name} ${extra}`));return EXIT_OK}const sub=domain.subresources?.find(resource2=>resource2.name===options.operation);const resource=sub??domain;const path=sub===void 0?domain.name:`${domain.name} ${sub.name}`;const operationName=sub===
|
|
51
|
+
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)){writeOut(renderResourceHelp(sub,path));return EXIT_OK}const operation=resource.operations.find(op=>op.name===operationName);if(operation===void 0){throw new UsageError(renderUnknownOperation(resource,path,operationName))}if(options.help||rest[0]===HELP_TOKEN){writeOut(renderOperationHelp(operation,path));return EXIT_OK}
|
|
52
|
+
const input=parseOperationArgs(rest,operation.flags);if(!globals.dryRun&&requiresYes(operation,globals.yes)){throw new UsageError(`twp ${path} ${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,path,input);const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??
|
|
53
|
+
httpFetch;const fetchImpl=globals.debug?withDebug(transport):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);const prepared=operation.prepare===void 0?input:await operation.prepare(input,buildPrepareContext({resolver:new Resolver(client,{profile:profile.name,refresh:globals.refresh,...profileAliases(profile.name)}),profileName:profile.name,env:process.env,cwd:process.cwd()}));const plan=operation.
|
|
54
|
+
plan(prepared);for(const note of operation.plannedNotes?.(prepared)??[])writeErr(`${stripTerminalControls(note)}
|
|
55
|
+
`);if(globals.dryRun){writeOut(line(redactSecrets(formatOutput(dryRunValue(apiUrl,plan),format))));return EXIT_OK}let body;let paged;if(paging.all&&operation.paging!==void 0){paged=await fetchAllPages({client,apiUrl,plan,paging:operation.paging,maxPages:paging.maxPages,maxItems:paging.maxItems});body=paged.body}else{body=await send(client,apiUrl,plan)}const value=globals.query!==void 0?await evaluateQuery(globals.query,operation.raw(body)):outputValue(operation,format,body);writeOut(line(formatOutput(
|
|
56
|
+
value,format)));if(paged!==void 0){writeErr(`--all: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.count} \u4EF6\u3092\u53D6\u5F97\u3057\u307E\u3057\u305F\u3002
|
|
57
|
+
`)}const pagingNotes=operation.paging===void 0?[]:nextPageNotes(body,prepared,{command:`twp ${path} ${operation.name}`,flags:operation.flags,profile:globals.profile});for(const note of[...pagingNotes,...operation.notes?.(body,prepared)??[]]){writeErr(`${stripTerminalControls(note)}
|
|
58
|
+
`)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code);return code}}export{buildPrepareContext,exitCodeFor,fetchAllPages,outputValue,requiresYes,resolvePaging,runDomain};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{REQUIRE_ZERO_STATUS,ScheduleApi,collectDue,gateStatus,nowInZone,parseCounts,parseTs}from"./chunk-ZZ5EYKCK.js";import"./chunk-GY7KI5E5.js";import"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";async function runScheduleCommand(deps,opts){const out=deps.out??(t=>void process.stdout.write(stripTerminalControls(t)));const err=deps.err??(t=>void process.stderr.write(stripTerminalControls(t)));const schedules=new ScheduleApi(deps.api);let now;if(opts.now){const parsed=parseTs(opts.now);if(!parsed){err(`--now \u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059: ${opts.now}\uFF08\u4F8B 2026-08-18T15:30\uFF09
|
|
4
|
+
`);return 2}now=parsed}else{now=nowInZone(deps.config.scheduleTimezone,m=>err(`${m}
|
|
5
|
+
`))}const defs=await schedules.definitions();if(defs.kind==="error"){err(`\u26D4 ${defs.message}
|
|
6
|
+
`);if(opts.gate!==void 0){err("\u5B9A\u7FA9\u304C\u53D6\u308C\u306A\u3044\u305F\u3081\u30B2\u30FC\u30C8\u306F\u8A31\u53EF\u6271\u3044\u306B\u3057\u307E\u3059\n");return 0}return 4}if(opts.gate!==void 0){const{allowed,reason}=gateStatus(opts.gate,now,defs.config.gates);if(allowed)return 0;out(`${reason}
|
|
7
|
+
`);return 3}if(defs.config.schedules.length===0){const warns=(defs.config.warnings??[]).map(w=>w&&typeof w==="object"?String(w["message"]??""):"").filter(m=>m!=="").join("; ");err("\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u306F\u5B9A\u671F\u30B9\u30B1\u30B8\u30E5\u30FC\u30EB\u5B9A\u7FA9\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u5B9A\u671F\u30BF\u30B9\u30AF\u306F\u6295\u5165\u3055\u308C\u307E\u305B\u3093\uFF09"+(warns?` / ${warns}`:"")+"\n")}const history=await schedules.history();
|
|
8
|
+
if(history.kind==="error"){err(`\u26D4 ${history.message}
|
|
9
|
+
`);return 4}const serverTz=history.history.timezone;if(serverTz&&serverTz!==deps.config.scheduleTimezone){err(`\u26A0\uFE0F \u5C65\u6B74\u306E\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\uFF08\u30B5\u30FC\u30D0: ${serverTz}\uFF09\u3068\u5224\u5B9A\u306B\u4F7F\u3046\u30BF\u30A4\u30E0\u30BE\u30FC\u30F3\uFF08${deps.config.scheduleTimezone}\uFF09\u304C\u9055\u3044\u307E\u3059
|
|
10
|
+
`)}const rows=await collectDue({config:defs.config,now,history:history.history.rows,windowCounts:history.history.windowCounts,safeMode:deps.config.safeMode,exclusiveSkills:deps.config.operations.exclusiveSkills,statusEndpoint:deps.config.operations.statusEndpoint,counts:parseCounts(opts.counts),fetchCount:async key=>{const statusId=Object.prototype.hasOwnProperty.call(REQUIRE_ZERO_STATUS,key)?REQUIRE_ZERO_STATUS[key]:void 0;if(!statusId)return null;const{total}=await deps.projectApi.countByStatus(
|
|
11
|
+
deps.config.projectId,statusId);return total},warn:m=>err(`${m}
|
|
12
|
+
`),...opts.verbose?{verbose:m=>err(`${m}
|
|
13
|
+
`)}:{}});for(const row of rows){const fields=[row.scheduleId,row.skill,row.args,row.priority,row.label,row.windowKey];out(fields.map(f=>f.replace(/[\t\r\n]/g," ")).join(" ")+"\n")}return 0}export{runScheduleCommand};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{localConfigPath,parseClaudeLauncher}from"./chunk-N3B737KO.js";import{AiConfig,detectAiClis,formatDetection,isDetectableAi,isSelectable}from"./chunk-3WJHTPOZ.js";import"./chunk-GY7KI5E5.js";import{PromptAbortedError,promptText}from"./chunk-L37NS5L2.js";import"./chunk-N2UVRM3Z.js";import"./chunk-PMOUHEJQ.js";import"./chunk-RZVI6PMW.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import fs from"fs";import path from"path";var RECOMMENDED_ROTATION={complex:["claude"],verify:["claude"],security:["claude"],support:["claude"],triage:["claude"],search:["claude"],simple:["claude"]};var RECOMMENDED_CHAINS={complex:["claude","codex"],verify:["claude","codex","copilot"],security:["claude","codex","copilot"],support:["claude","codex","copilot"],triage:["codex","gemini","copilot","claude"],search:["codex","gemini","copilot","claude"],simple:["codex","gemini","copilot","claude"]};var PREFERENCE=["claude","codex","gemini","co\
|
|
4
|
+
pilot"];function buildAiAssignment(selected){if(selected.length===0)throw new Error("\u9078\u629E\u3055\u308C\u305FAI\u304C\u7A7A\u3067\u3059");const fallbackOrder=PREFERENCE.filter(ai=>selected.includes(ai));for(const ai of selected)if(!fallbackOrder.includes(ai))fallbackOrder.push(ai);const chains={};const rotation={};for(const category of Object.keys(RECOMMENDED_CHAINS)){const filtered=(RECOMMENDED_CHAINS[category]??[]).filter(ai=>selected.includes(ai));const chain=filtered.length>0?filtered:
|
|
5
|
+
[...fallbackOrder];chains[category]=chain;const rot=(RECOMMENDED_ROTATION[category]??[]).filter(ai=>selected.includes(ai));const head=chain[0];rotation[category]=rot.length>0?rot:head===void 0?[...fallbackOrder]:[head]}return{primary_rotation:rotation,fallback_chains:chains}}var SETUP_EXIT_NO_CLI=3;var SETUP_EXIT_ABORTED=130;async function runSetup(opts){const env=opts.env??process.env;const rawOut=opts.out??(t=>void process.stdout.write(t));const rawErr=opts.err??(t=>void process.stderr.write(t));
|
|
6
|
+
const out=t=>rawOut(stripTerminalControls(t));const err=t=>rawErr(stripTerminalControls(t));const rawAsk=opts.ask??promptText;const ask=q=>rawAsk(stripTerminalControls(q));const detect=opts.detect??detectAiClis;try{return await setupFlow(opts,{env,out,err,ask,detect})}catch(e){if(e instanceof PromptAbortedError){err("\n\u4E2D\u6B62\u3057\u307E\u3057\u305F\u3002\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3057\u3066\u3044\u307E\u305B\u3093\u3002\n \u5BFE\u8A71\u305B\u305A\u306B\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002\n");
|
|
7
|
+
return SETUP_EXIT_ABORTED}throw e}}async function setupFlow(opts,io){const{env,out,err,ask,detect}=io;out(`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${opts.projectName}\uFF08${opts.projectId}\uFF09
|
|
8
|
+
`);out(`\u63A5\u7D9A\u5148: ${opts.apiUrl}
|
|
9
|
+
`);out(`\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB: ${localConfigPath(opts.projectId,env)}
|
|
10
|
+
|
|
11
|
+
`);out("AI CLI \u3092\u691C\u51FA\u3057\u3066\u3044\u307E\u3059...\n");const launcherBin=configuredLauncherBin(opts.projectId,env);const detections=detect({env,launcherBin});out("\n");const selectable=detections.filter(isSelectable);const numbers=new Map;let n=0;for(const d of detections){const index=isSelectable(d)?++n:null;if(index!==null)numbers.set(d.ai,index);out(`${formatDetection(d,index)}
|
|
12
|
+
`)}out("\n");if(selectable.length===0){err("\u4F7F\u7528\u3067\u304D\u308B AI CLI \u304C1\u3064\u3082\u3042\u308A\u307E\u305B\u3093\u3002\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3057\u3066\u3044\u307E\u305B\u3093\u3002\n \u4E0A\u306E\u4E00\u89A7\u304C\u7406\u7531\u3067\u3059\u3002\u5C0E\u5165\u3068\u30ED\u30B0\u30A4\u30F3\u3092\u6E08\u307E\u305B\u3066\u304B\u3089 setup \u3092\u3084\u308A\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n \u4F8B: claude \u2192 \u4E00\u5EA6\u8D77\u52D5\u3057\u3066\u30ED\u30B0\u30A4\u30F3 \uFF0F codex \u2192 codex login\n");
|
|
13
|
+
return SETUP_EXIT_NO_CLI}let selected;if(opts.ais!==void 0&&opts.ais.length>0){const bad=opts.ais.filter(ai=>!selectable.some(d=>d.ai===ai));if(bad.length>0){err(`--ai \u3067\u6307\u5B9A\u3057\u305F ${bad.join(" / ")} \u306F\u9078\u629E\u3067\u304D\u307E\u305B\u3093\uFF08\u4E0A\u306E\u4E00\u89A7\u306E\u7406\u7531\uFF09\u3002
|
|
14
|
+
\u9078\u629E\u3067\u304D\u308B\u306E\u306F ${selectable.map(d=>d.ai).join(" / ")} \u3067\u3059\u3002
|
|
15
|
+
\u5224\u5B9A\u3067\u304D\u306A\u3044 AI \u3092\u3069\u3046\u3057\u3066\u3082\u9396\u306B\u5165\u308C\u305F\u3044\u5834\u5408\u306F\u3001\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u660E\u793A\u3057\u3066\u304F\u3060\u3055\u3044:
|
|
16
|
+
- --ai-config-file <\u30D1\u30B9> \u3067\u65E2\u5B58\u306E\u5272\u5F53\u30D5\u30A1\u30A4\u30EB\u3092\u53C2\u7167\u3059\u308B
|
|
17
|
+
- ${localConfigPath(opts.projectId,env)} \u306E ai \u30BB\u30AF\u30B7\u30E7\u30F3\u3092\u76F4\u63A5\u7DE8\u96C6\u3059\u308B
|
|
18
|
+
`);return 2}selected=[...opts.ais]}else if(opts.yes){selected=selectable.map(d=>d.ai);out(`--yes: \u9078\u629E\u3067\u304D\u308B ${selected.join(" / ")} \u3092\u3059\u3079\u3066\u4F7F\u3044\u307E\u3059
|
|
19
|
+
`)}else{selected=await askSelection(selectable,numbers,ask,out,err);if(selected.length===0){err("1\u3064\u3082\u9078\u629E\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3057\u3066\u3044\u307E\u305B\u3093\u3002\n");return 1}}const unverified=selected.filter(ai=>detections.find(d=>d.ai===ai)?.auth==="unknown");if(unverified.length>0){out(`\u2139\uFE0F ${unverified.join(" / ")} \u306F\u30ED\u30B0\u30A4\u30F3\u72B6\u614B\u3092\u78BA\u8A8D\u3067\u304D\u3066\u3044\u307E\u305B\u3093\uFF08\u672A\u5224\u5B9A\u306E\u307E\u307E\u63A1\u7528\u3057\u307E\u3057\u305F\uFF09
|
|
20
|
+
`)}const file=localConfigPath(opts.projectId,env);const existing=readExisting(file,err);if(existing===null)return 1;const existingWorkspace=typeof existing.workspace==="string"&&existing.workspace!==""?existing.workspace:null;const defaultWorkspace=existingWorkspace??process.cwd();let workspace=opts.workspace??defaultWorkspace;if(opts.workspace===void 0&&!opts.yes){const answer=await ask(`
|
|
21
|
+
\u30B9\u30AD\u30EB\u5B9A\u7FA9\uFF08.claude/commands\uFF09\u306E\u3042\u308B\u4F5C\u696D\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA [${defaultWorkspace}]: `);if(answer!=="")workspace=answer}workspace=path.resolve(workspace);if(existingWorkspace!==null&&workspace!==path.resolve(existingWorkspace)){out(`\u2139\uFE0F \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u5909\u66F4\u3057\u307E\u3057\u305F: ${existingWorkspace} \u2192 ${workspace}
|
|
22
|
+
`)}const existingIdentity=typeof existing.git_identity==="object"&&existing.git_identity!==null?existing.git_identity:null;let gitIdentity=existingIdentity;if(!opts.yes){const curName=existingIdentity?.name??"";const curEmail=existingIdentity?.email??"";out("\ncommit \u306E author \u306B\u63C3\u3048\u308B\u5024\u3092\u8A2D\u5B9A\u3057\u307E\u3059\uFF08\u7A7A\u6B04\u3067\u8A2D\u5B9A\u3057\u306A\u3044\uFF09\u3002\n GitHub \u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u767B\u9332\u6E08\u307F\u306E\u30E1\u30FC\u30EB\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u7D10\u3065\u304B\u306A\u3044 author \u306E\n commit \u306F Vercel Preview \u304C BLOCKED \u306B\u306A\u308A\u3001\u30D6\u30E9\u30F3\u30C1\u6BB5\u968E\u306E\u78BA\u8A8D\u304C\u3067\u304D\u307E\u305B\u3093\u3002\n");
|
|
23
|
+
const nameAnswer=(await ask(` git user.name${curName===""?"":` [${curName}]`}: `)).trim();const emailAnswer=(await ask(` git user.email${curEmail===""?"":` [${curEmail}]`}: `)).trim();const name=nameAnswer!==""?nameAnswer:curName;const email=emailAnswer!==""?emailAnswer:curEmail;gitIdentity=name!==""&&email!==""?{name,email}:null;if(gitIdentity===null&&(name!==""||email!=="")){out(" \u26A0\uFE0F name \u3068 email \u306F\u4E21\u65B9\u5FC5\u8981\u3067\u3059\u3002\u4ECA\u56DE\u306F\u8A2D\u5B9A\u3057\u307E\u305B\u3093\u3067\u3057\u305F\n")}}
|
|
24
|
+
const skillDir=path.join(workspace,".claude","commands");if(!fs.existsSync(skillDir)){out(`\u26A0\uFE0F ${skillDir} \u304C\u3042\u308A\u307E\u305B\u3093\u3002v1 \u306F\u4F5C\u696D\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30B9\u30AD\u30EB\u5B9A\u7FA9\u3092\u6B63\u3068\u3059\u308B\u305F\u3081\u3001run \u307E\u3067\u306B\u7528\u610F\u3057\u3066\u304F\u3060\u3055\u3044
|
|
25
|
+
`)}const resolveAgainstWorkspace=p=>path.isAbsolute(p)?p:path.resolve(workspace,p);const candidate=path.join(workspace,"scripts","ai-skill-config.json");let aiConfigFile=opts.aiConfigFile!==void 0?resolveAgainstWorkspace(opts.aiConfigFile):null;if(aiConfigFile===null&&opts.noAiConfigFile!==true&&fs.existsSync(candidate)){if(opts.yes){aiConfigFile=candidate;out(`
|
|
26
|
+
--yes: \u65E2\u5B58\u306E AI \u5272\u5F53 ${candidate} \u3092\u53C2\u7167\u3057\u307E\u3059\uFF08\u30A4\u30F3\u30E9\u30A4\u30F3\u751F\u6210\u306F\u3057\u307E\u305B\u3093\uFF09
|
|
27
|
+
`);out(" \u30A4\u30F3\u30E9\u30A4\u30F3\u751F\u6210\u3092\u5F37\u5236\u3059\u308B\u306B\u306F --no-ai-config-file \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\n")}else{const answer=await ask(`
|
|
28
|
+
\u65E2\u5B58\u306E AI \u5272\u5F53\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: ${candidate}
|
|
29
|
+
\u3053\u308C\u3092\u53C2\u7167\u3057\u307E\u3059\u304B\uFF1F\uFF08\u53C2\u7167\u3059\u308B\u3068\u4E8C\u91CD\u7BA1\u7406\u306B\u3088\u308B\u30C9\u30EA\u30D5\u30C8\u304C\u8D77\u304D\u307E\u305B\u3093\uFF09[Y/n]: `);if(!/^n(o)?$/i.test(answer))aiConfigFile=candidate}}if(aiConfigFile!==null){const loaded=readAiFile(aiConfigFile);if(loaded===null){err(`AI \u5272\u5F53\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u3081\u307E\u305B\u3093: ${aiConfigFile}
|
|
30
|
+
\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u3053\u306E\u307E\u307E\u4FDD\u5B58\u3059\u308B\u3068 run \u306F\u7D44\u307F\u8FBC\u307F\u65E2\u5B9A\u3078\u843D\u3061\u3001
|
|
31
|
+
\u9078\u629E\u3057\u3066\u3044\u306A\u3044 AI \u304C\u9396\u306B\u5165\u308A\u307E\u3059\uFF09\u3002\u30D1\u30B9\u3068 JSON \u306E\u5185\u5BB9\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
32
|
+
`);return 2}const extra=aisIn(loaded).filter(ai=>!selected.includes(ai));if(extra.length>0){out(`\u26A0\uFE0F \u53C2\u7167\u30D5\u30A1\u30A4\u30EB\u306E\u5272\u5F53\u306B\u306F\u9078\u629E\u3057\u3066\u3044\u306A\u3044 ${extra.join(" / ")} \u304C\u542B\u307E\u308C\u307E\u3059\u3002
|
|
33
|
+
\u53C2\u7167\u3092\u9078\u3093\u3060\u5834\u5408\u3001\u9396\u306F\u30D5\u30A1\u30A4\u30EB\u306E\u5185\u5BB9\u304C\u305D\u306E\u307E\u307E\u4F7F\u308F\u308C\u307E\u3059\uFF08\u9078\u629E\u306F\u53CD\u6620\u3055\u308C\u307E\u305B\u3093\uFF09\u3002
|
|
34
|
+
\u672A\u8A8D\u8A3C\u306E AI \u304C\u9396\u306B\u3042\u308B\u3068\u3001\u305D\u306E\u6BB5\u306F\u6BCE\u56DE\u8A8D\u8A3C\u30A8\u30E9\u30FC\u3067\u5931\u6557\u3057\u3066\u304B\u3089\u6B21\u3078\u9032\u307F\u307E\u3059\u3002
|
|
35
|
+
\u9078\u629E\u3069\u304A\u308A\u306B\u7D5E\u308A\u305F\u3044\u5834\u5408\u306F --no-ai-config-file \u3092\u4ED8\u3051\u3066 setup \u3092\u3084\u308A\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
36
|
+
`)}}const next={...existing};next.workspace=workspace;next.engine="cli";if(gitIdentity!==null)next.git_identity=gitIdentity;else delete next.git_identity;if(aiConfigFile!==null){next.ai_config_file=aiConfigFile;if("ai"in next){delete next.ai;out(" \u65E2\u5B58\u306E\u30A4\u30F3\u30E9\u30A4\u30F3 ai \u8A2D\u5B9A\u306F\u524A\u9664\u3057\u307E\u3057\u305F\uFF08\u53C2\u7167\u30D5\u30A1\u30A4\u30EB\u304C\u512A\u5148\u3055\u308C\u308B\u3088\u3046\u306B\u3059\u308B\u305F\u3081\uFF09\n")}}else{const prev=typeof next.
|
|
37
|
+
ai==="object"&&next.ai!==null&&!Array.isArray(next.ai)?next.ai:{};next.ai={...prev,...buildAiAssignment(selected)};if(Object.keys(prev).some(k=>k!=="primary_rotation"&&k!=="fallback_chains")){out(" \u65E2\u5B58\u306E ai \u8A2D\u5B9A\u306E\u3046\u3061 primary_rotation / fallback_chains \u3060\u3051\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F\uFF08\u4ED6\u306E\u30AD\u30FC\u306F\u4FDD\u6301\uFF09\n")}if("ai_config_file"in next){delete next.ai_config_file;out(" \u65E2\u5B58\u306E ai_config_file \u53C2\u7167\u306F\u524A\u9664\u3057\u307E\u3057\u305F\uFF08\u30A4\u30F3\u30E9\u30A4\u30F3\u8A2D\u5B9A\u306B\u5207\
|
|
38
|
+
\u308A\u66FF\u3048\u305F\u305F\u3081\uFF09\n")}const merged=next.ai;if(merged.skill_category===void 0||Object.keys(merged.skill_category).length===0){out(`\u2139\uFE0F skill_category \u306F\u751F\u6210\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u8A2D\u5B9A\u3059\u308B\u307E\u3067**\u5168\u30B9\u30AD\u30EB\u304C complex \u6271\u3044**\u3067\u8D70\u308A\u307E\u3059
|
|
39
|
+
\uFF08triage / search / simple \u5411\u3051\u306E\u9396\u306F\u4F7F\u308F\u308C\u307E\u305B\u3093\uFF09\u3002\u5FC5\u8981\u306A\u3089 ${file} \u306E ai.skill_category \u306B
|
|
40
|
+
\u300C\u30B9\u30AD\u30EB\u540D\uFF08twp- \u306A\u3057\uFF09\u2192 \u30AB\u30C6\u30B4\u30EA\u300D\u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044
|
|
41
|
+
`)}}if(selected.some(ai=>ai!=="claude")&&next.compile_command===void 0){out(`\u26A0\uFE0F compile_command \u304C\u672A\u8A2D\u5B9A\u3067\u3059\u3002claude \u4EE5\u5916\u306F \`/\u30B9\u30AD\u30EB\u540D\` \u3092\u81EA\u5206\u3067\u89E3\u6C7A\u3067\u304D\u306A\u3044\u305F\u3081\u3001
|
|
42
|
+
\u30D7\u30ED\u30F3\u30D7\u30C8\u304C\u672A\u5C55\u958B\u306E\u307E\u307E\u6E21\u308A\u307E\u3059\uFF08\u30ED\u30B0\u306B\u3082\u8B66\u544A\u306F\u51FA\u307E\u305B\u3093\uFF09\u3002
|
|
43
|
+
${file} \u306E compile_command \u306B\u5C55\u958B\u30A2\u30C0\u30D7\u30BF\u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044
|
|
44
|
+
\uFF08TWP \u958B\u767A\u3067\u306F ["python3", "scripts/agent-adapters/compile-command.py"]\uFF09
|
|
45
|
+
`)}if(!selected.includes("claude")){out(`\u2139\uFE0F claude \u3092\u9078\u3093\u3067\u3044\u307E\u305B\u3093\u3002\u9AD8\u30EA\u30B9\u30AF\uFF08verify / security / support\u30FB\u30EA\u30EA\u30FC\u30B9\u7CFB\uFF09\u306E1\u756A\u624B\u3082
|
|
46
|
+
${selected.join(" / ")} \u306B\u306A\u308A\u307E\u3059
|
|
47
|
+
`)}try{writeConfig(file,next)}catch(e){err(`\u8A2D\u5B9A\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${file}
|
|
48
|
+
${e.message}
|
|
49
|
+
`);return 1}const saved=(aiConfigFile!==null?readAiFile(aiConfigFile):next.ai)??{};const hash=new AiConfig(saved).hash();const profileArg=opts.profile!==void 0&&opts.profile!==""?` --profile ${opts.profile}`:"";out(`
|
|
50
|
+
\u2705 \u4FDD\u5B58\u3057\u307E\u3057\u305F: ${file}
|
|
51
|
+
`);out(` \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${opts.projectName}\uFF08${opts.projectId}\uFF09
|
|
52
|
+
`);out(` \u4F7F\u7528\u3059\u308B AI: ${selected.join(" / ")}
|
|
53
|
+
`);out(` AI \u5272\u5F53: ${aiConfigFile!==null?`${aiConfigFile}\uFF08\u53C2\u7167\uFF09`:"\u30A4\u30F3\u30E9\u30A4\u30F3\u751F\u6210"}
|
|
54
|
+
`);out(` config_hash: ${hash}
|
|
55
|
+
`);out(` \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9: ${workspace}
|
|
56
|
+
|
|
57
|
+
`);out(`\u6B21\u306E\u30B3\u30DE\u30F3\u30C9\u3067\u8D77\u52D5\u3067\u304D\u307E\u3059:
|
|
58
|
+
twp task-loop run --project ${opts.projectRef}${profileArg} --max-cycles 1
|
|
59
|
+
`);return 0}async function askSelection(selectable,numbers,ask,out,err){const all=selectable.map(d=>d.ai);for(let attempt=0;attempt<3;attempt+=1){const answer=await ask(`\u4F7F\u7528\u3059\u308B AI \u3092\u756A\u53F7\u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3002\u7A7A Enter \u3067 ${all.join(" / ")} \u3059\u3079\u3066\uFF09: `);if(answer==="")return all;const picked=[];let bad=null;for(const token of answer.split(",").map(t=>t.trim()).filter(t=>t!==
|
|
60
|
+
"")){const byName=selectable.find(d=>d.ai===token.toLowerCase());const byNumber=selectable.find(d=>String(numbers.get(d.ai))===token);const hit=byName??byNumber;if(hit===void 0){bad=token;break}if(!picked.includes(hit.ai))picked.push(hit.ai)}if(bad!==null){err(` '${bad}' \u306F\u9078\u629E\u80A2\u306B\u3042\u308A\u307E\u305B\u3093\u3002
|
|
61
|
+
`);continue}if(picked.length===0){err(" 1\u3064\u4EE5\u4E0A\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002\n");continue}out(` \u9078\u629E: ${picked.join(" / ")}
|
|
62
|
+
`);return picked}err(" \u5165\u529B\u30923\u56DE\u3068\u3082\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\n");return[]}function configuredLauncherBin(projectId,env){try{const parsed=JSON.parse(fs.readFileSync(localConfigPath(projectId,env),"utf8"));const local=parsed!==null&&typeof parsed==="object"&&!Array.isArray(parsed)?parsed:{};return parseClaudeLauncher(local["claude_launcher"]).launcher.bin}catch{return parseClaudeLauncher(void 0).launcher.bin}}function readExisting(file,err){
|
|
63
|
+
let raw;try{raw=fs.readFileSync(file,"utf8")}catch(e){if(e.code==="ENOENT")return{};err(`\u65E2\u5B58\u306E\u8A2D\u5B9A\u3092\u8AAD\u3081\u307E\u305B\u3093: ${file}
|
|
64
|
+
${e.message}
|
|
65
|
+
`);return null}try{const parsed=JSON.parse(raw);if(parsed===null||typeof parsed!=="object"||Array.isArray(parsed)){err(`\u65E2\u5B58\u306E\u8A2D\u5B9A\u304C\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093: ${file}
|
|
66
|
+
\u4E0A\u66F8\u304D\u3059\u308B\u3068\u5185\u5BB9\u3092\u5931\u3046\u305F\u3081\u4E2D\u6B62\u3057\u307E\u3059\u3002
|
|
67
|
+
`);return null}return parsed}catch(e){err(`\u65E2\u5B58\u306E\u8A2D\u5B9A\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093: ${file}
|
|
68
|
+
${e.message}
|
|
69
|
+
\u4E0A\u66F8\u304D\u3059\u308B\u3068\u5185\u5BB9\u3092\u5931\u3046\u305F\u3081\u4E2D\u6B62\u3057\u307E\u3059\u3002\u9000\u907F\u3057\u3066\u304B\u3089\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
70
|
+
`);return null}}function openExclusive(file){for(let attempt=0;attempt<=16;attempt+=1){const candidate=`${file}.tmp-${process.pid}-${attempt}`;try{return{fd:fs.openSync(candidate,"wx",384),path:candidate}}catch(e){if(e.code!=="EEXIST"||attempt===16)throw e}}throw new Error("\u4E00\u6642\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F")}function writeConfig(file,data){const dir=path.dirname(file);fs.mkdirSync(dir,{recursive:true,mode:448});if(process.platform!==
|
|
71
|
+
"win32"){try{fs.chmodSync(dir,448)}catch{}}const body=`${JSON.stringify(data,null,2)}
|
|
72
|
+
`;const opened=openExclusive(file);const tmp=opened.path;let fd=opened.fd;let renamed=false;try{fs.writeFileSync(fd,body);fs.fsyncSync(fd);fs.closeSync(fd);fd=null;fs.renameSync(tmp,file);renamed=true}finally{if(fd!==null){try{fs.closeSync(fd)}catch{}}if(!renamed){try{fs.unlinkSync(tmp)}catch{}}}try{fs.chmodSync(file,384)}catch{}}function readAiFile(file){try{const parsed=JSON.parse(fs.readFileSync(file,"utf8"));return parsed!==null&&typeof parsed==="object"&&!Array.isArray(parsed)?parsed:null}catch{
|
|
73
|
+
return null}}function aisIn(raw){const found=new Set;for(const section of[raw.primary_rotation,raw.fallback_chains]){if(section===void 0||section===null||typeof section!=="object")continue;for(const list of Object.values(section)){if(!Array.isArray(list))continue;for(const ai of list)if(typeof ai==="string"&&ai!=="")found.add(ai)}}return[...found].sort()}function aisInFile(file){const raw=readAiFile(file);return raw===null?[]:aisIn(raw)}function parseAiList(raw){const ais=[];const unknown=[];for(const token of raw.
|
|
74
|
+
split(",").map(t=>t.trim().toLowerCase()).filter(t=>t!=="")){if(!isDetectableAi(token))unknown.push(token);else if(!ais.includes(token))ais.push(token)}return{ais,unknown}}export{SETUP_EXIT_ABORTED,SETUP_EXIT_NO_CLI,aisIn,aisInFile,buildAiAssignment,parseAiList,runSetup,writeConfig};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{PRIVATE_PROJECT_REF,isPrivateProjectRef}from"./chunk-GY7KI5E5.js";import{acknowledgement,isRecord,pick,requireResolved,singleRef,withResolved}from"./chunk-FQDYLZV3.js";import{PRIVATE_TASKS_PATH}from"./chunk-Q7YSSWTR.js";import{PRIVATE_TASK_KEY_PREFIX,isPrivateTaskKey,isTaskKey}from"./chunk-II5RVJQN.js";import{ApiResponseError,LIST_FLAGS,LIST_PAGING_HELP,UsageError,envelopePaging,nonEmpty,positiveInteger}from"./chunk-KCXVV45F.js";import{isSafePathSegment,safeProjectIdPolicy}from"./chunk-5QCAIKFE.js";
|
|
4
|
+
import"./chunk-7ZVTACQS.js";import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import"./chunk-J7QYPKVK.js";import"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import fs from"fs";var BOM="\uFEFF";async function readStdin(spec){if(process.stdin.isTTY===true){throw new UsageError(`${spec.fileFlag} - \u306F\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u307F\u307E\u3059\u304C\u3001\u7AEF\u672B\u304C\u7E4B\u304C\u3063\u3066\u3044\u307E\u3059`,`\u30D1\u30A4\u30D7\u304B\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: cat review.md | twp \u2026 ${spec.fileFlag} -\uFF09\u3002`)}const chunks=[];for await(const chunk of process.stdin)chunks.
|
|
5
|
+
push(Buffer.from(chunk));return Buffer.concat(chunks).toString("utf8")}function charCount(text){return[...text].length}async function readBody(input,spec){const inline=input.flags.get(spec.flag);const file=input.flags.get(spec.fileFlag);if(inline!==void 0&&file!==void 0){throw new UsageError(`${spec.label}\u304C ${spec.flag} \u3068 ${spec.fileFlag} \u306E\u4E21\u65B9\u3067\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`,`\u3069\u3061\u3089\u304B\u4E00\u65B9\u3060\u3051\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${spec.
|
|
6
|
+
fileFlag} - \u3067\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3081\u307E\u3059\uFF09\u3002`)}if(inline===void 0&&file===void 0)return void 0;const text=inline??await readFrom(file,spec);const stripped=text.startsWith(BOM)?text.slice(BOM.length):text;if(stripped.trim()===""){throw new UsageError(`${spec.label}\u304C\u7A7A\u3067\u3059\uFF08${inline!==void 0?spec.flag:`${spec.fileFlag} ${file}`}\uFF09`,spec.usage)}const count=charCount(stripped);if(count>spec.maxChars){throw new UsageError(`${spec.
|
|
7
|
+
label}\u304C\u9577\u3059\u304E\u307E\u3059\uFF08${count} \u6587\u5B57\u30FB\u4E0A\u9650 ${spec.maxChars} \u6587\u5B57\uFF09`,"\u5206\u5272\u3057\u3066\u6295\u7A3F\u3059\u308B\u304B\u3001\u8A73\u7D30\u306F\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return stripped}async function readFrom(file,spec){if(file==="-")return readStdin(spec);try{const stat=fs.statSync(file);if(!stat.isFile()){throw new UsageError(`${spec.label}\u306B\u901A\u5E38\u306E\u30D5\u30A1\u30A4\u30EB\u4EE5\u5916\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093: ${file}`,
|
|
8
|
+
`${spec.fileFlag} \u306B\u306F\u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3080\u306A\u3089 ${spec.fileFlag} -\uFF09\u3002`)}if(stat.size>spec.maxChars*4){throw new UsageError(`${spec.label}\u306E\u30D5\u30A1\u30A4\u30EB\u304C\u5927\u304D\u3059\u304E\u307E\u3059\uFF08${stat.size} \u30D0\u30A4\u30C8\u30FB\u4E0A\u9650 ${spec.maxChars} \u6587\u5B57\uFF09: ${file}`,"\u5206\u5272\u3057\u3066\u6295\u7A3F\u3059\u308B\u304B\u3001\u8A73\u7D30\u306F\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
9
|
+
return fs.readFileSync(file,"utf8")}catch(err){if(err instanceof UsageError)throw err;const reason=err.code??err.message;throw new UsageError(`${spec.label}\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u3081\u307E\u305B\u3093: ${file}\uFF08${reason}\uFF09`,`${spec.fileFlag} \u306B\u306F\u30D1\u30B9\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3080\u306A\u3089 ${spec.fileFlag} -\uFF09\u3002`)}}function classifyTaskRef(ref){const value=ref.trim();if(safeProjectIdPolicy.isDirectId(value))return{kind:"id",value};if(isTaskKey(value))return{kind:"key",value};return{kind:"unknown",value}}function wantsPrivateSurface(input){const project=input.flags.get("--project");return project!==void 0&&isPrivateProjectRef(project)}function taskSurface(input,ref){const project=input.flags.get("--project");const{kind,value}=classifyTaskRef(ref);if(project!==void 0&&isPrivateProjectRef(project)){if(kind===
|
|
10
|
+
"key"&&!isPrivateTaskKey(value)){throw new UsageError(`--project ${PRIVATE_PROJECT_REF}\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\uFF09\u306B ${value} \u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306F ${PRIVATE_TASK_KEY_PREFIX}-<\u756A\u53F7> \u306E\u5F62\u3067\u3059\u3002ID\uFF08UUID / ULID\uFF09\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
11
|
+
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u3092\u6307\u3059\u306A\u3089 --project ${PRIVATE_PROJECT_REF} \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return"private"}if(kind==="key"&&isPrivateTaskKey(value)&&project===void 0){throw new UsageError(`${value} \u306F\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306B\u3082\u3001\u30B3\u30FC\u30C9 ${PRIVATE_TASK_KEY_PREFIX} \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u30AD\u30FC\u306B\u3082\u8AAD\u3081\u307E\u3059`,
|
|
12
|
+
`\u3069\u3061\u3089\u3092\u6307\u3059\u304B --project \u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002
|
|
13
|
+
\u500B\u4EBA\u30BF\u30B9\u30AF : --project ${PRIVATE_PROJECT_REF}
|
|
14
|
+
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: --project ${PRIVATE_TASK_KEY_PREFIX}`)}return"project"}function rejectPrivateSurface(input,what){if(!wantsPrivateSurface(input))return;throw new UsageError(`--project ${PRIVATE_PROJECT_REF}\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\uFF09\u3067\u306F${what}\u3092\u6271\u3048\u307E\u305B\u3093`,`\u30B5\u30FC\u30D0\u5074\u306B\u500B\u4EBA\u30BF\u30B9\u30AF\u7528\u306E API \u304C\u3042\u308A\u307E\u305B\u3093\u3002TWP \u306E\u753B\u9762\u304B\u3089\u64CD\u4F5C\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}
|
|
15
|
+
async function resolveTaskLocation(input,ctx,ref){rejectPrivateSurface(input,"\u3053\u306E\u64CD\u4F5C");const{kind,value}=classifyTaskRef(ref);if(kind==="key"){if(isPrivateTaskKey(value)&&input.flags.get("--project")===void 0){throw new UsageError(`${value} \u306F\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306B\u3082\u3001\u30B3\u30FC\u30C9 ${PRIVATE_TASK_KEY_PREFIX} \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u30AD\u30FC\u306B\u3082\u8AAD\u3081\u307E\u3059`,`\u3053\u306E\u64CD\u4F5C\u306F\u500B\
|
|
16
|
+
\u4EBA\u30BF\u30B9\u30AF\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u30B5\u30FC\u30D0\u5074\u306B API \u304C\u3042\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
17
|
+
\u30B3\u30FC\u30C9 ${PRIVATE_TASK_KEY_PREFIX} \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u3092\u6307\u3059\u306A\u3089 --project ${PRIVATE_TASK_KEY_PREFIX} \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`)}rejectRedundantProject(input,value);const resolved=await ctx.resolver.taskByKey(value);const id=resolved.task["id"];if(!isSafePathSegment(id)){throw new ApiResponseError(`\u30BF\u30B9\u30AF\u30AD\u30FC\u89E3\u6C7A\u306E\u5FDC\u7B54\u306E task.id \u3092\u305D\u306E\u307E\u307E\u4F7F\u3048\u307E\u305B\u3093\uFF08${String(
|
|
18
|
+
id).slice(0,60)}\uFF09\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return{projectId:resolved.projectId,taskId:id}}if(kind==="unknown"){throw new UsageError(`\u30BF\u30B9\u30AF\u306E\u6307\u5B9A\u304C\u300C\u30AD\u30FC\uFF08\u4F8B ABC-123\uFF09\u300D\u306B\u3082\u300CID\uFF08UUID / ULID\uFF09\u300D\u306B\u3082\u898B\u3048\u307E\u305B\u3093: ${ref}`,"\u30AD\u30FC\u306F\u300C\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30B3\u30FC\u30C9-\u756A\u53F7\u300D\u306E\u5F62\u3067\u3059\u3002ID \u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u306F --project \u3082\u5FC5\u8981\u3067\u3059\u3002")}
|
|
19
|
+
if(kind!=="id"){const exhaustive=kind;throw new Error(`\u672A\u77E5\u306E\u30BF\u30B9\u30AF\u53C2\u7167\u306E\u7A2E\u5225\u3067\u3059: ${String(exhaustive)}`)}return{projectId:await ctx.projectId(input.flags.get("--project")),taskId:value}}function rejectRedundantProject(input,ref){const project=input.flags.get("--project");if(project===void 0)return;if(isPrivateTaskKey(ref)){if(isPrivateProjectRef(project))return;if(project.trim().toLowerCase()===PRIVATE_TASK_KEY_PREFIX.toLowerCase())return;throw new UsageError(
|
|
20
|
+
`\u30AD\u30FC ${ref} \u3068 --project ${project} \u304C\u98DF\u3044\u9055\u3063\u3066\u3044\u307E\u3059`,`${ref} \u304C\u6307\u305B\u308B\u306E\u306F\u6B21\u306E2\u3064\u3060\u3051\u3067\u3059\u3002
|
|
21
|
+
\u500B\u4EBA\u30BF\u30B9\u30AF : --project ${PRIVATE_PROJECT_REF}
|
|
22
|
+
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: --project ${PRIVATE_TASK_KEY_PREFIX}\uFF08\u30AD\u30FC\u306E\u63A5\u982D\u8F9E\u3068\u540C\u3058\u30B3\u30FC\u30C9\uFF09
|
|
23
|
+
\u5225\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u3092\u6307\u3059\u306A\u3089\u3001\u30AD\u30FC\u3067\u306F\u306A\u304F\u305D\u306E\u30BF\u30B9\u30AF\u306E ID\uFF08UUID / ULID\uFF09\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}throw new UsageError(`\u30AD\u30FC\u5F62\u5F0F\uFF08${ref}\uFF09\u3067\u6307\u5B9A\u3057\u305F\u3068\u304D\u306B --project \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08--project ${project} \u306F\u7121\u8996\u3055\u308C\u307E\u3059\uFF09`,"\
|
|
24
|
+
\u30AD\u30FC\u306F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u542B\u3093\u3067\u3044\u308B\u306E\u3067 --project \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002--project \u304C\u8981\u308B\u306E\u306F\u3001\u30BF\u30B9\u30AF\u3092 ID\uFF08UUID / ULID\uFF09\u3067\u6307\u5B9A\u3059\u308B\u3068\u304D\u3060\u3051\u3067\u3059\u3002")}var TASK_REF_FLAG={name:"--task",summary:"\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\uFF08\u4F8B ABC-123\uFF09\u307E\u305F\u306F ID\u3002\u4F4D\u7F6E\u5F15\u6570\u3068\u540C\u3058\u610F\u5473\uFF08\u4E21\u65B9\u6307\u5B9A\u306F\u30A8\u30E9\u30FC\uFF09",
|
|
25
|
+
takesValue:true,placeholder:"<\u30AD\u30FC|ID>"};var PROJECT_FLAG={name:"--project",summary:`\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30FC\u30C9\u307E\u305F\u306F ID\uFF08\u7701\u7565\u6642\u306F TWP_PROJECT / .twp/config.json / ~/.twp/config.json\uFF09\u3002\u30BF\u30B9\u30AF\u3092\u30AD\u30FC\u3067\u6307\u5B9A\u3059\u308B\u3068\u304D\u306F\u4F7F\u3048\u307E\u305B\u3093\u3002${PRIVATE_PROJECT_REF} \u3067\u500B\u4EBA\u30BF\u30B9\u30AF\u3092\u6307\u3057\u307E\u3059`,takesValue:true,placeholder:`\
|
|
26
|
+
<\u30B3\u30FC\u30C9|ID|${PRIVATE_PROJECT_REF}>`};var TASK_REF_HELP=`\u30AD\u30FC\u5F62\u5F0F\uFF08\u4F8B ABC-123\uFF09\u306A\u3089 --project \u306F\u8981\u308A\u307E\u305B\u3093\uFF081\u5F80\u5FA9\u3067\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3054\u3068\u89E3\u6C7A\u3055\u308C\u307E\u3059\uFF09\u3002
|
|
27
|
+
\u30AD\u30FC\u306F\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u542B\u3093\u3067\u3044\u308B\u306E\u3067\u3001\u30AD\u30FC\u3068 --project \u3092\u4E00\u7DD2\u306B\u6307\u5B9A\u3059\u308B\u3068\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u3059\u3002
|
|
28
|
+
ID\uFF08UUID / ULID\uFF09\u3067\u6307\u5B9A\u3059\u308B\u5834\u5408\u3060\u3051 --project\uFF08\u307E\u305F\u306F\u65E2\u5B9A\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\uFF09\u304C\u8981\u308A\u307E\u3059\u3002
|
|
29
|
+
UUID / ULID \u306E\u5F62\u3092\u3057\u305F\u5024\u306F\u3001\u30AD\u30FC\u306E\u5F62\u306B\u3082\u8AAD\u3081\u308B\u3068\u304D\u3067\u3082 ID \u3068\u3057\u3066\u6271\u3044\u307E\u3059\uFF08\u4F8B: \u672B\u5C3E12\u6841\u304C\u5168\u6570\u5B57\u306E UUID\uFF09\u3002\u3053\u306E\u5834\u5408\u306F --project \u304C\u8981\u308A\u307E\u3059\u3002
|
|
30
|
+
--task <\u30AD\u30FC|ID> \u3067\u3082\u540C\u3058\u610F\u5473\u3067\u3059\u3002\u4F4D\u7F6E\u5F15\u6570\u3068 --task \u306E\u4E21\u65B9\u3092\u6307\u5B9A\u3059\u308B\u3068\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u3059\u3002
|
|
31
|
+
${PRIVATE_TASK_KEY_PREFIX}-<\u756A\u53F7> \u306E\u5F62\u306E\u30AD\u30FC\u3060\u3051\u306F\u4F8B\u5916\u3067\u3001--project \u304C\u5FC5\u9808\u3067\u3059\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u3068\u3082\u3001\u30B3\u30FC\u30C9 ${PRIVATE_TASK_KEY_PREFIX} \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30BF\u30B9\u30AF\u30AD\u30FC\u3068\u3082\u8AAD\u3081\u308B\u305F\u3081\uFF09\u3002`;var LIST_COLUMNS=["id","created_at","created_by_name","comment_type","content"];var WRITE_COLUMNS=["id","task_id","created_at","updated_at","created_by_name","content"];var CONTENT_MAX_CHARS=1e4;var listPaging=envelopePaging({label:"\u30B3\u30E1\u30F3\u30C8\u4E00\u89A7"});function commentObject(body){const comment=isRecord(body)?body["comment"]:void 0;if(!isRecord(comment)){throw new ApiResponseError("\u30B3\u30E1\u30F3\u30C8\u306E\u5FDC\u7B54\u306B comment \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
32
|
+
return comment}var BODY_FLAGS=[{name:"--body-file",summary:"\u672C\u6587\u3092\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u8AAD\u3080\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09\u3002\u6539\u884C\u30FBMarkdown \u3092\u58CA\u3055\u306A\u3044\u4E3B\u7D4C\u8DEF",takesValue:true,placeholder:"<\u30D1\u30B9|->"},{name:"--body",summary:"\u672C\u6587\u3092\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08\u4E00\u884C\u5411\u3051\u3002--body-file \u3068\u306E\u4F75\u7528\u306F\u30A8\u30E9\u30FC\uFF09",takesValue:true,placeholder:"\
|
|
33
|
+
<\u6587\u5B57\u5217>"}];var BODY_HELP=`\u672C\u6587\u306F --body-file \u3092\u4E3B\u7D4C\u8DEF\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30B7\u30A7\u30EB\u306E\u5F15\u6570\u306B\u8F09\u305B\u308B\u3068\u6539\u884C\u30FBMarkdown \u306E\u898B\u51FA\u3057\uFF08#\uFF09\u30FB
|
|
34
|
+
\u5F15\u7528\u7B26\u3067\u58CA\u308C\u307E\u3059\uFF08gh pr create --body \u3068\u540C\u3058\u554F\u984C\uFF09\u3002--body-file - \u3067\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3081\u307E\u3059\u3002
|
|
35
|
+
|
|
36
|
+
\u672C\u6587\u306F\u52A0\u5DE5\u3057\u307E\u305B\u3093\uFF08\u6539\u884C\u30FB\u672B\u5C3E\u306E\u6539\u884C\u30FBCRLF \u306F\u305D\u306E\u307E\u307E\u9001\u308A\u307E\u3059\uFF09\u3002\u843D\u3068\u3059\u306E\u306F\u5148\u982D\u306E UTF-8 BOM \u3060\u3051\u3067\u3059\u3002
|
|
37
|
+
\u7A7A\u30FB\u7A7A\u767D\u306E\u307F\u306E\u672C\u6587\u306F\u6295\u7A3F\u3057\u307E\u305B\u3093\uFF08\u7D42\u4E86\u30B3\u30FC\u30C9 2\uFF09\u3002\u4E0A\u9650\u306F ${CONTENT_MAX_CHARS} \u6587\u5B57\u3067\u3059\u3002`;var COMMENT_REF_FLAG={name:"--comment",summary:"\u30B3\u30E1\u30F3\u30C8\u306E ID\uFF08\u4F4D\u7F6E\u5F15\u6570\u3068\u540C\u3058\u610F\u5473\u3002\u4E21\u65B9\u6307\u5B9A\u306F\u30A8\u30E9\u30FC\uFF09",takesValue:true,placeholder:"<\u30B3\u30E1\u30F3\u30C8ID>"};var COMMENT_REF_HELP="\
|
|
38
|
+
\u30B3\u30E1\u30F3\u30C8 ID \u306F twp task comment list <\u30AD\u30FC> \u306E id \u5217\u304B\u3089\u53D6\u308C\u307E\u3059\u3002\n\u5BFE\u8C61\u306E\u30BF\u30B9\u30AF\u306F --task <\u30AD\u30FC|ID> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u30B3\u30E1\u30F3\u30C8 ID \u3060\u3051\u3067\u306F\u5F15\u3051\u307E\u305B\u3093\uFF09\u3002";async function prepareCommentTarget(input,ctx,usage){const commentId=singleRef(input,{flag:"--comment",label:"\u30B3\u30E1\u30F3\u30C8",usage});
|
|
39
|
+
if(!isSafePathSegment(commentId)){throw new UsageError(`\u30B3\u30E1\u30F3\u30C8 ID \u306E\u5F62\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093: ${commentId}`,"\u30B3\u30E1\u30F3\u30C8 ID \u306F twp task comment list <\u30AD\u30FC> \u306E id \u5217\u304B\u3089\u53D6\u308C\u307E\u3059\u3002")}const task=input.flags.get("--task");if(task===void 0||task.trim()===""){throw new UsageError("\u5BFE\u8C61\u306E\u30BF\u30B9\u30AF\u3092 --task <\u30AD\u30FC|ID> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
40
|
+
usage)}const located=await resolveTaskLocation({...input,args:[]},ctx,task.trim());return withResolved(input,{...located,commentId:commentId.trim()})}function commentBody(input){return{content:requireResolved(input,"content"),content_html:null}}function commentPath(input){const projectId=encodeURIComponent(requireResolved(input,"projectId"));const taskId=encodeURIComponent(requireResolved(input,"taskId"));return`/api/v2/projects/${projectId}/tasks/${taskId}/comments`}var taskCommentResource={name:"\
|
|
41
|
+
comment",summary:"\u30BF\u30B9\u30AF\u30B3\u30E1\u30F3\u30C8\u306E\u4E00\u89A7\u30FB\u6295\u7A3F\u30FB\u66F4\u65B0\u30FB\u524A\u9664",operations:[{name:"list",summary:"\u30BF\u30B9\u30AF\u306E\u30B3\u30E1\u30F3\u30C8\u3092\u4E00\u89A7\u3059\u308B",usage:"twp task comment list <\u30AD\u30FC|ID> [--project <\u30B3\u30FC\u30C9|ID>] [--all]",description:`${TASK_REF_HELP}
|
|
42
|
+
|
|
43
|
+
\u4F5C\u6210\u65E5\u6642\u306E\u6607\u9806\u3067\u8FD4\u308A\u307E\u3059\uFF08\u30B5\u30FC\u30D0\u5074\u306E\u4E26\u3073\uFF09\u3002
|
|
44
|
+
|
|
45
|
+
${LIST_PAGING_HELP}`,flags:[...LIST_FLAGS,TASK_REF_FLAG,PROJECT_FLAG],paging:listPaging,async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task comment list help"});return withResolved(input,await resolveTaskLocation(input,ctx,ref))},plan(input){return{method:"GET",path:commentPath(input),query:{limit:positiveInteger(input.flags,"--limit"),cursor:nonEmpty(input.flags,"--cursor")}}},summarize:body=>listPaging.items(body).map(row=>pick(row,LIST_COLUMNS)),
|
|
46
|
+
raw:body=>listPaging.items(body)},{name:"create",summary:"\u30BF\u30B9\u30AF\u306B\u30B3\u30E1\u30F3\u30C8\u3092\u6295\u7A3F\u3059\u308B",usage:"twp task comment create <\u30AD\u30FC|ID> --body-file <\u30D1\u30B9> [--project <\u30B3\u30FC\u30C9|ID>]",description:`${TASK_REF_HELP}
|
|
47
|
+
|
|
48
|
+
${BODY_HELP}`,flags:[...BODY_FLAGS,TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task comment create help"});const content=await requireContent(input,"twp task comment create help");return withResolved(input,{...await resolveTaskLocation(input,ctx,ref),content})},plan:input=>({method:"POST",path:commentPath(input),body:commentBody(input)}),summarize:body=>pick(commentObject(body),WRITE_COLUMNS),raw:commentObject},
|
|
49
|
+
{name:"update",summary:"\u30B3\u30E1\u30F3\u30C8\u306E\u672C\u6587\u3092\u66F8\u304D\u63DB\u3048\u308B",usage:"twp task comment update <\u30B3\u30E1\u30F3\u30C8ID> --task <\u30AD\u30FC|ID> --body-file <\u30D1\u30B9>",description:`${COMMENT_REF_HELP}
|
|
50
|
+
|
|
51
|
+
${BODY_HELP}
|
|
52
|
+
|
|
53
|
+
\u672C\u6587\u306F\u7F6E\u304D\u63DB\u3048\u3067\u3059\uFF08\u8FFD\u8A18\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002`,flags:[...BODY_FLAGS,COMMENT_REF_FLAG,TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const content=await requireContent(input,"twp task comment update help");return withResolved(await prepareCommentTarget(input,ctx,"twp task comment update help"),{content})},plan:input=>({method:"PUT",path:`${commentPath(input)}/${encodeURIComponent(requireResolved(input,"commentI\
|
|
54
|
+
d"))}`,body:commentBody(input)}),summarize:body=>pick(commentObject(body),WRITE_COLUMNS),raw:commentObject},{name:"delete",summary:"\u30B3\u30E1\u30F3\u30C8\u3092\u524A\u9664\u3059\u308B",usage:"twp task comment delete <\u30B3\u30E1\u30F3\u30C8ID> --task <\u30AD\u30FC|ID> --yes",description:`${COMMENT_REF_HELP}
|
|
55
|
+
|
|
56
|
+
\u524A\u9664\u306F\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002`,destructive:true,flags:[COMMENT_REF_FLAG,TASK_REF_FLAG,PROJECT_FLAG],prepare:(input,ctx)=>prepareCommentTarget(input,ctx,"twp task comment delete help"),plan:input=>({method:"DELETE",path:`${commentPath(input)}/${encodeURIComponent(requireResolved(input,"commentId"))}`}),summarize:body=>acknowledgement(body,"\u30B3\u30E1\u30F3\u30C8\u524A\u9664"),raw:body=>acknowledgement(body,"\u30B3\u30E1\u30F3\u30C8\u524A\u9664")}]};async function requireContent(input,usage){
|
|
57
|
+
const content=await readBody(input,{flag:"--body",fileFlag:"--body-file",label:"\u30B3\u30E1\u30F3\u30C8\u672C\u6587",maxChars:CONTENT_MAX_CHARS,usage});if(content===void 0){throw new UsageError("\u30B3\u30E1\u30F3\u30C8\u672C\u6587\u3092 --body-file <\u30D1\u30B9> \u304B --body <\u6587\u5B57\u5217> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",usage)}return content}var ISO_DATE_RE=/^\d{4}-\d{2}-\d{2}$/;function isoDate(input,flag){const raw=input.flags.get(flag);if(raw===void 0)return void 0;const value=raw.trim();if(!ISO_DATE_RE.test(value)){throw new UsageError(`${flag} \u306F YYYY-MM-DD \u306E\u5F62\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${raw}`,"\u4F8B: 2026-09-30")}const[y,m,d]=value.split("-").map(Number);const probe=new Date(Date.UTC(y,m-1,d));if(probe.getUTCFullYear()!==y||probe.getUTCMonth()+1!==m||probe.getUTCDate()!==d){throw new UsageError(
|
|
58
|
+
`${flag} \u306B\u5B58\u5728\u3057\u306A\u3044\u65E5\u4ED8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059: ${raw}`,"\u4F8B: 2026-09-30")}return value}function priority(input,flag="--priority"){const raw=input.flags.get(flag);if(raw===void 0)return void 0;const trimmed=raw.trim();const value=/^\d+$/.test(trimmed)?Number(trimmed):Number.NaN;if(!Number.isInteger(value)||value<1||value>3){throw new UsageError(`${flag} \u306F 1 / 2 / 3 \u306E\u3044\u305A\u308C\u304B\u3067\u3059: ${raw}`,"1: \u9AD8 \uFF0F\
|
|
59
|
+
2: \u4E2D \uFF0F 3: \u4F4E")}return value}function boundedText(input,flag,options){const raw=input.flags.get(flag);if(raw===void 0)return void 0;if(raw.trim()===""){throw new UsageError(`${flag} \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`${options.label}\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}const count=[...raw].length;if(count>options.maxChars){throw new UsageError(`${options.label}\u304C\u9577\u3059\u304E\u307E\u3059\uFF08${count} \u6587\u5B57\u30FB\u4E0A\u9650 ${options.
|
|
60
|
+
maxChars} \u6587\u5B57\uFF09`,`${flag} \u3092 ${options.maxChars} \u6587\u5B57\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return raw}function rejectPrivateUnsupportedFlags(input){if(!input.flags.has("--assignee"))return;throw new UsageError(`--project ${PRIVATE_PROJECT_REF}\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\uFF09\u3067\u306F --assignee \u3092\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,"\u500B\u4EBA\u30BF\u30B9\u30AF\u306F\u5E38\u306B\u81EA\u5206\u306E\u3082\u306E\u306A\u306E\u3067\u3001\u30B5\u30FC\u30D0\u5074\u306B\u62C5\u5F53\u8005\u3092\u6307\u5B9A\u30FB\u7D5E\u308A\u8FBC\u307F\u3059\u308B\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093\u3002--assignee \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
61
|
+
function privateTaskRef(ref){const{kind,value}=classifyTaskRef(ref);if(kind==="unknown"){throw new UsageError(`\u30BF\u30B9\u30AF\u306E\u6307\u5B9A\u304C\u300C\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\uFF08\u4F8B PRIVATE-22361\uFF09\u300D\u306B\u3082\u300CID\uFF08UUID / ULID\uFF09\u300D\u306B\u3082\u898B\u3048\u307E\u305B\u3093: ${ref}`,`\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u4E00\u89A7\u306F twp task list --project ${PRIVATE_PROJECT_REF} \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002`)}
|
|
62
|
+
return{kind,value}}async function resolvePrivateTaskId(ctx,ref){const{kind,value}=privateTaskRef(ref);if(kind==="id")return value;const task=await ctx.resolver.privateTask(value);const id=task["id"];if(!isSafePathSegment(id)){throw new ApiResponseError(`\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u5FDC\u7B54\u306E task.id \u3092\u305D\u306E\u307E\u307E\u4F7F\u3048\u307E\u305B\u3093\uFF08${String(id).slice(0,60)}\uFF09\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}
|
|
63
|
+
return id}async function resolvePrivateStatusAndType(input,ctx,options){const out={};const status=nonEmpty(input.flags,"--status");if(status!==void 0){out["status_id"]=(await ctx.resolver.privateStatus(status)).id}else if(options.useDefaults){const ref=await ctx.resolver.privateDefaultStatus();out["status_id"]=ref.id;out["status_defaulted"]=ref.name}const type=nonEmpty(input.flags,"--type");if(type!==void 0){out["type_id"]=(await ctx.resolver.privateTaskType(type)).id}else if(options.useDefaults){
|
|
64
|
+
const ref=await ctx.resolver.privateDefaultTaskType();out["type_id"]=ref.id;out["type_defaulted"]=ref.name}return out}var LIST_COLUMNS2=["key","subject","status_id","assignee_id","priority","due_date","updated_at"];var GET_COLUMNS=["id","key","project_id","subject","description","status_id","type_id","category_id","milestone_id","assignee_id","priority","start_date","due_date","estimated_hours","actual_hours","progress","parent_id","subtask_count","created_by","created_at","updated_by","updated_at"];var listPaging2=envelopePaging({label:"\u30BF\u30B9\u30AF\u4E00\u89A7"});var PRIVATE_HELP=`\u500B\u4EBA\u30BF\u30B9\u30AF\uFF08\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u5C5E\u3055\u306A\u3044\u81EA\u5206\u3060\u3051\u306E\
|
|
65
|
+
\u30BF\u30B9\u30AF\uFF09\u306F --project ${PRIVATE_PROJECT_REF} \u3067\u64CD\u4F5C\u3057\u307E\u3059\u3002
|
|
66
|
+
twp task list --project ${PRIVATE_PROJECT_REF}
|
|
67
|
+
\u500B\u4EBA\u30BF\u30B9\u30AF\u306E\u30AD\u30FC\u306F PRIVATE-<\u756A\u53F7> \u3067\u3059\u3002\u62C5\u5F53\u8005\u306E\u6307\u5B9A\u30FB\u7D5E\u308A\u8FBC\u307F\uFF08--assignee\uFF09\u306F\u3067\u304D\u307E\u305B\u3093
|
|
68
|
+
\uFF08\u500B\u4EBA\u30BF\u30B9\u30AF\u306F\u5E38\u306B\u81EA\u5206\u306E\u3082\u306E\u306A\u306E\u3067\u3001\u30B5\u30FC\u30D0\u5074\u306B\u62C5\u5F53\u8005\u306E\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
69
|
+
\u30B3\u30E1\u30F3\u30C8\uFF08twp task comment\uFF09\u306F\u500B\u4EBA\u30BF\u30B9\u30AF\u3067\u306F\u4F7F\u3048\u307E\u305B\u3093\u3002TWP \u306E\u753B\u9762\u304B\u3089\u64CD\u4F5C\u3057\u3066\u304F\u3060\u3055\u3044\u3002`;var PRIVATE_SURFACE="private";function isPrivatePlan(input){return input.resolved?.["surface"]===PRIVATE_SURFACE}function taskObject(body){const task=isRecord(body)?body["task"]:void 0;if(!isRecord(task)){throw new ApiResponseError("\u30BF\u30B9\u30AF\u8A73\u7D30\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")}
|
|
70
|
+
return task}function subtaskItems(body){const items=isRecord(body)?body["items"]:void 0;if(!Array.isArray(items)){throw new ApiResponseError("\u30B5\u30D6\u30BF\u30B9\u30AF\u4E00\u89A7\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return items}var SUBJECT_MAX_CHARS=500;var DESCRIPTION_MAX_CHARS=1e4;var FIELD_FLAGS=[{name:"--subject",summary:"\u4EF6\u540D",takesValue:true,placeholder:"\
|
|
71
|
+
<\u6587\u5B57\u5217>"},{name:"--description",summary:"\u672C\u6587\u3092\u76F4\u63A5\u6307\u5B9A\u3059\u308B\uFF08--description-file \u3068\u306E\u4F75\u7528\u306F\u30A8\u30E9\u30FC\uFF09",takesValue:true,placeholder:"<\u6587\u5B57\u5217>"},{name:"--description-file",summary:"\u672C\u6587\u3092\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u8AAD\u3080\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09\u3002\u6539\u884C\u30FBMarkdown \u3092\u58CA\u3055\u306A\u3044",takesValue:true,placeholder:"<\u30D1\u30B9|->"},
|
|
72
|
+
{name:"--status",summary:"\u30B9\u30C6\u30FC\u30BF\u30B9\uFF08\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID\uFF09",takesValue:true,placeholder:"<\u540D\u524D|ID>"},{name:"--type",summary:"\u7A2E\u5225\uFF08\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID\uFF09",takesValue:true,placeholder:"<\u540D\u524D|ID>"},{name:"--assignee",summary:"\u62C5\u5F53\u8005\uFF08me / \u540D\u524D / \u30E1\u30FC\u30EB / ID\uFF09",takesValue:true,placeholder:"<me|\u540D\u524D|ID>"},{name:"--due-date",summary:"\u671F\u65E5\uFF08YYYY-MM-\
|
|
73
|
+
DD\uFF09",takesValue:true,placeholder:"<YYYY-MM-DD>"},{name:"--start-date",summary:"\u958B\u59CB\u65E5\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<YYYY-MM-DD>"},{name:"--priority",summary:"\u512A\u5148\u5EA6\uFF081: \u9AD8 / 2: \u4E2D / 3: \u4F4E\uFF09",takesValue:true,placeholder:"<1|2|3>"}];var FIELD_HELP="--status / --type / --assignee \u306F\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID \u306E\u3044\u305A\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n\u5B8C\u5168\u4E00\u81F4\u3060\u3051\u3067\u89E3\u6C7A\u3057\u3001\u8907\u6570\u306B\u5F53\u305F\u308B\u30FB1\u4EF6\u3082\u5F53\u305F\u3089\u306A\u3044\u5834\u5408\u306F\u5019\u88DC\u3092\u51FA\u3057\u3066\u7D42\u4E86\u30B3\u30FC\u30C9 2 \u3067\u6B62\u307E\u308A\u307E\u3059\u3002\n--assignee me \u306F\u300C\u3044\u307E\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u308B\u30E6\u30FC\u30B6\u30FC\u300D\u3067\u3059\u3002\n\n\u672C\u6587\u306F --description-file \u3092\u4E3B\u7D4C\u8DEF\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u30B7\u30A7\u30EB\
|
|
74
|
+
\u306E\u5F15\u6570\u306B\u8F09\u305B\u308B\u3068\u6539\u884C\u30FBMarkdown \u306E\n\u898B\u51FA\u3057\uFF08#\uFF09\u30FB\u5F15\u7528\u7B26\u3067\u58CA\u308C\u307E\u3059\uFF09\u3002--description-file - \u3067\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3081\u307E\u3059\u3002\u672C\u6587\u306F\u52A0\u5DE5\u3057\u307E\u305B\u3093\n\uFF08\u6539\u884C\u30FBCRLF \u306F\u305D\u306E\u307E\u307E\u9001\u308A\u307E\u3059\u3002\u843D\u3068\u3059\u306E\u306F\u5148\u982D\u306E UTF-8 BOM \u3060\u3051\u3067\u3059\uFF09\u3002\n\n\u5024\u306E\u89E3\u9664\uFF08\u62C5\u5F53\u8005\u3092\u5916\u3059\u30FB\u671F\u65E5\u3092\u6D88\u3059\uFF09\u306F\u3053\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3067\u306F\u3067\u304D\u307E\u305B\u3093\u3002TWP \u306E\u753B\u9762\u304B\u3089\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
75
|
+
function readDescription(input,usage){return readBody(input,{flag:"--description",fileFlag:"--description-file",label:"\u672C\u6587",maxChars:DESCRIPTION_MAX_CHARS,usage})}function checkPureFields(input){boundedText(input,"--subject",{maxChars:SUBJECT_MAX_CHARS,label:"\u4EF6\u540D"});isoDate(input,"--due-date");isoDate(input,"--start-date");priority(input)}function taskBody(input){const body={};const put=(key,value)=>{if(value!==void 0)body[key]=value};put("subject",boundedText(input,"--subject",
|
|
76
|
+
{maxChars:SUBJECT_MAX_CHARS,label:"\u4EF6\u540D"}));const description=input.resolved?.["description"];put("description",description);if(description!==void 0)body["description_html"]=null;put("status_id",input.resolved?.["status_id"]);put("type_id",input.resolved?.["type_id"]);put("assignee_id",input.resolved?.["assignee_id"]);put("due_date",isoDate(input,"--due-date"));put("start_date",isoDate(input,"--start-date"));put("priority",priority(input));return body}async function resolveStatusAndType(input,ctx,projectId,options){
|
|
77
|
+
const out={};const status=nonEmpty(input.flags,"--status");if(status!==void 0){out["status_id"]=(await ctx.resolver.status(projectId,status)).id}else if(options.useDefaults){const ref=await ctx.resolver.defaultStatus(projectId);out["status_id"]=ref.id;out["status_defaulted"]=ref.name}const type=nonEmpty(input.flags,"--type");if(type!==void 0){out["type_id"]=(await ctx.resolver.taskType(projectId,type)).id}else if(options.useDefaults){const ref=await ctx.resolver.defaultTaskType(projectId);out["t\
|
|
78
|
+
ype_id"]=ref.id;out["type_defaulted"]=ref.name}const assignee=nonEmpty(input.flags,"--assignee");if(assignee!==void 0)out["assignee_id"]=(await ctx.resolver.assignee(projectId,assignee)).id;return out}var taskDomain={name:"task",summary:"\u30BF\u30B9\u30AF\u306E\u4E00\u89A7\u30FB\u8A73\u7D30\u30FB\u30B5\u30D6\u30BF\u30B9\u30AF\u30FB\u4F5C\u6210\u30FB\u66F4\u65B0\u30FB\u524A\u9664",operations:[{name:"list",summary:"\u30BF\u30B9\u30AF\u3092\u4E00\u89A7\u3059\u308B",usage:"twp task list [--project \
|
|
79
|
+
<\u30B3\u30FC\u30C9|ID|__private__>] [--status <\u540D\u524D>] [--type <\u540D\u524D>] [--assignee <me|\u540D\u524D>] [--keyword <\u8A9E>] [--all]",description:`--output json \u306F API \u304C\u8FD4\u3059\u5168\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u51FA\u3057\u307E\u3059\u3002
|
|
80
|
+
--output table / text / tsv \u306F\u8981\u7D04\u5217\uFF08key / subject / status_id / assignee_id / priority / due_date / updated_at\uFF09\u3067\u3059\u3002
|
|
81
|
+
\u6B32\u3057\u3044\u5217\u3060\u3051\u3092\u6A5F\u68B0\u51E6\u7406\u3057\u305F\u3044\u3068\u304D\u306F --query \u3067\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08--query \u306F\u751F\u30C7\u30FC\u30BF\u306B\u5BFE\u3057\u3066\u8A55\u4FA1\u3055\u308C\u307E\u3059\uFF09\u3002
|
|
82
|
+
|
|
83
|
+
--status / --type / --assignee \u306F\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID \u306E\u3044\u305A\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002
|
|
84
|
+
\u5B8C\u5168\u4E00\u81F4\u3060\u3051\u3067\u89E3\u6C7A\u3057\u3001\u8907\u6570\u306B\u5F53\u305F\u308B\u30FB1\u4EF6\u3082\u5F53\u305F\u3089\u306A\u3044\u5834\u5408\u306F\u5019\u88DC\u3092\u51FA\u3057\u3066\u7D42\u4E86\u30B3\u30FC\u30C9 2 \u3067\u6B62\u307E\u308A\u307E\u3059
|
|
85
|
+
\uFF08\u524D\u65B9\u4E00\u81F4\u3067\u52DD\u624B\u306B\u6C7A\u3081\u307E\u305B\u3093\uFF09\u3002\u540D\u524D \u2192 ID \u306E\u5BFE\u5FDC\u306F 10 \u5206\u30AD\u30E3\u30C3\u30B7\u30E5\u3055\u308C\u3001--refresh \u3067\u53D6\u308A\u76F4\u305B\u307E\u3059\u3002
|
|
86
|
+
--assignee me \u306F\u300C\u3044\u307E\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u3044\u308B\u30E6\u30FC\u30B6\u30FC\u300D\u3067\u3059\u3002
|
|
87
|
+
|
|
88
|
+
${PRIVATE_HELP}
|
|
89
|
+
|
|
90
|
+
`+LIST_PAGING_HELP,flags:[...LIST_FLAGS,PROJECT_FLAG,{name:"--status",summary:"\u30B9\u30C6\u30FC\u30BF\u30B9\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID\uFF09",takesValue:true,placeholder:"<\u540D\u524D|ID>"},{name:"--type",summary:"\u7A2E\u5225\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u540D\u524D\u30FB\u30B3\u30FC\u30C9\u30FBID\uFF09",takesValue:true,placeholder:"<\u540D\u524D|ID>"},{name:"--assignee",summary:"\u62C5\u5F53\u8005\u3067\u7D5E\u308A\u8FBC\u3080\uFF08me / \u540D\u524D / \u30E1\u30FC\u30EB / ID\uFF09",
|
|
91
|
+
takesValue:true,placeholder:"<me|\u540D\u524D|ID>"},{name:"--keyword",summary:"\u4EF6\u540D\u30FB\u672C\u6587\u306E\u90E8\u5206\u4E00\u81F4\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u691C\u7D22\u7D4C\u8DEF\u306B\u5207\u308A\u66FF\u308F\u308A\u307E\u3059\uFF09",takesValue:true,placeholder:"<\u8A9E>"}],paging:listPaging2,async prepare(input,ctx){if(input.args.length>0){throw new UsageError(`list \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,"twp task list h\
|
|
92
|
+
elp")}if(wantsPrivateSurface(input)){rejectPrivateUnsupportedFlags(input);return withResolved(input,{surface:PRIVATE_SURFACE,...await resolvePrivateStatusAndType(input,ctx,{useDefaults:false})})}const projectId=await ctx.projectId(input.flags.get("--project"));const resolved={projectId};const status=nonEmpty(input.flags,"--status");if(status!==void 0)resolved["status_id"]=(await ctx.resolver.status(projectId,status)).id;const type=nonEmpty(input.flags,"--type");if(type!==void 0)resolved["type_id"]=
|
|
93
|
+
(await ctx.resolver.taskType(projectId,type)).id;const assignee=nonEmpty(input.flags,"--assignee");if(assignee!==void 0)resolved["assignee_id"]=(await ctx.resolver.assignee(projectId,assignee)).id;return withResolved(input,resolved)},plan(input){const query={limit:positiveInteger(input.flags,"--limit"),cursor:nonEmpty(input.flags,"--cursor"),keyword:nonEmpty(input.flags,"--keyword"),status_id:input.resolved?.["status_id"],type_id:input.resolved?.["type_id"],assignee_id:input.resolved?.["assignee\
|
|
94
|
+
_id"]};if(isPrivatePlan(input))return{method:"GET",path:PRIVATE_TASKS_PATH,query};const projectId=requireResolved(input,"projectId");return{method:"GET",path:`/api/v2/projects/${encodeURIComponent(projectId)}/tasks`,query}},summarize:body=>listPaging2.items(body).map(row=>pick(row,LIST_COLUMNS2)),raw:body=>listPaging2.items(body)},{name:"get",summary:"\u30BF\u30B9\u30AF1\u4EF6\u306E\u8A73\u7D30\u3092\u8868\u793A\u3059\u308B",usage:"twp task get <\u30AD\u30FC|ID> [--project <\u30B3\u30FC\u30C9|ID|__private__>]",
|
|
95
|
+
description:`${TASK_REF_HELP}
|
|
96
|
+
|
|
97
|
+
${PRIVATE_HELP}`,flags:[TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task get help"});if(taskSurface(input,ref)===PRIVATE_SURFACE){return withResolved(input,{surface:PRIVATE_SURFACE,privateRef:privateTaskRef(ref).value})}const classified=classifyTaskRef(ref);if(classified.kind==="key"){rejectRedundantProject(input,classified.value);return withResolved(input,{mode:"key",key:classified.value})}const{projectId,taskId}=await resolveTaskLocation(
|
|
98
|
+
input,ctx,classified.value);return withResolved(input,{mode:"id",projectId,taskId})},plan(input){if(isPrivatePlan(input)){return{method:"GET",path:`${PRIVATE_TASKS_PATH}/${encodeURIComponent(requireResolved(input,"privateRef"))}`}}if(requireResolved(input,"mode")==="key"){return{method:"GET",path:`/api/v2/tasks/resolve-by-key/${encodeURIComponent(requireResolved(input,"key"))}`}}const projectId=encodeURIComponent(requireResolved(input,"projectId"));return{method:"GET",path:`/api/v2/projects/${projectId}\
|
|
99
|
+
/tasks/${encodeURIComponent(requireResolved(input,"taskId"))}`}},summarize:body=>pick(taskObject(body),GET_COLUMNS),raw:body=>taskObject(body)},{name:"subtasks",summary:"\u30BF\u30B9\u30AF\u306E\u30B5\u30D6\u30BF\u30B9\u30AF\u3092\u4E00\u89A7\u3059\u308B",usage:"twp task subtasks <\u30AD\u30FC|ID> [--project <\u30B3\u30FC\u30C9|ID|__private__>]",description:`${TASK_REF_HELP}
|
|
100
|
+
|
|
101
|
+
${PRIVATE_HELP}
|
|
102
|
+
|
|
103
|
+
\u3053\u306E API \u306F\u30DA\u30FC\u30B8\u30F3\u30B0\u3092\u6301\u305F\u305A\u3001\u5E38\u306B\u5168\u4EF6\u3092\u8FD4\u3057\u307E\u3059\uFF08--all / --limit \u306F\u3042\u308A\u307E\u305B\u3093\uFF09\u3002`,flags:[TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task subtasks help"});if(taskSurface(input,ref)===PRIVATE_SURFACE){return withResolved(input,{surface:PRIVATE_SURFACE,taskId:await resolvePrivateTaskId(
|
|
104
|
+
ctx,ref)})}return withResolved(input,await resolveTaskLocation(input,ctx,ref))},plan(input){const taskId=encodeURIComponent(requireResolved(input,"taskId"));if(isPrivatePlan(input)){return{method:"GET",path:`${PRIVATE_TASKS_PATH}/${taskId}/subtasks`}}const projectId=encodeURIComponent(requireResolved(input,"projectId"));return{method:"GET",path:`/api/v2/projects/${projectId}/tasks/${taskId}/subtasks`}},summarize:body=>subtaskItems(body).map(row=>pick(row,LIST_COLUMNS2)),raw:body=>subtaskItems(body)},
|
|
105
|
+
{name:"create",summary:"\u30BF\u30B9\u30AF\u3092\u4F5C\u6210\u3059\u308B",usage:'twp task create --subject "<\u4EF6\u540D>" [--project <\u30B3\u30FC\u30C9|ID|__private__>] [--type <\u540D\u524D>] [--status <\u540D\u524D>] [--assignee <me|\u540D\u524D>]',description:`--subject \u3060\u3051\u304C\u5FC5\u9808\u3067\u3059\u3002--status / --type \u3092\u7701\u304F\u3068\u3001\u305D\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u65E2\u5B9A\u306B\u6307\u5B9A\u3057\u3066\u3044\u308B
|
|
106
|
+
\u3082\u306E\u3092\u4F7F\u3044\u307E\u3059\uFF08\u30B5\u30FC\u30D0\u5074\u3067\u306F\u3069\u3061\u3089\u3082\u5FC5\u9808\u9805\u76EE\u3067\u3059\uFF09\u3002\u65E2\u5B9A\u3092\u4F7F\u3063\u305F\u5834\u5408\u306F stderr \u306B\u6CE8\u8A18\u304C\u51FA\u307E\u3059\u3002
|
|
107
|
+
|
|
108
|
+
\u30B5\u30D6\u30BF\u30B9\u30AF\u306E\u4F5C\u6210\uFF08\u89AA\u30BF\u30B9\u30AF\u306E\u6307\u5B9A\uFF09\u306F\u3053\u306E\u30B3\u30DE\u30F3\u30C9\u3067\u306F\u884C\u3048\u307E\u305B\u3093\u3002\u540C\u3058\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u304C
|
|
109
|
+
\u89AA\u306E\u6307\u5B9A\u3092\u53D7\u3051\u307E\u3059\u304C\u3001\u30B5\u30FC\u30D0\u5074\u306F\u968E\u5C64\u306E\u691C\u8A3C\u3068\u6DF1\u3055\u306E\u8A08\u7B97\u3092\u542B\u3080\u5225\u306E\u51E6\u7406\u3078\u5206\u5C90\u3057\u307E\u3059\u3002
|
|
110
|
+
\u6271\u3044\u304C\u5909\u308F\u308B\u306E\u3067\u3001\u5225\u30B3\u30DE\u30F3\u30C9\u3068\u3057\u3066\u7528\u610F\u3057\u307E\u3059\u3002
|
|
111
|
+
|
|
112
|
+
${PRIVATE_HELP}
|
|
113
|
+
|
|
114
|
+
`+FIELD_HELP,flags:[...FIELD_FLAGS,PROJECT_FLAG],async prepare(input,ctx){if(input.args.length>0){throw new UsageError(`create \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,'\u4EF6\u540D\u306F --subject "<\u4EF6\u540D>" \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002')}checkPureFields(input);if(boundedText(input,"--subject",{maxChars:SUBJECT_MAX_CHARS,label:"\u4EF6\u540D"})===void 0){throw new UsageError('\u4EF6\u540D\u3092 --subject "<\u4EF6\u540D>" \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044',
|
|
115
|
+
"twp task create help")}if(wantsPrivateSurface(input)){rejectPrivateUnsupportedFlags(input);const privateDescription=await readDescription(input,"twp task create help");return withResolved(input,{surface:PRIVATE_SURFACE,...privateDescription!==void 0?{description:privateDescription}:{},...await resolvePrivateStatusAndType(input,ctx,{useDefaults:true})})}const description=await readDescription(input,"twp task create help");const projectId=await ctx.projectId(input.flags.get("--project"));return withResolved(
|
|
116
|
+
input,{projectId,...description!==void 0?{description}:{},...await resolveStatusAndType(input,ctx,projectId,{useDefaults:true})})},plan:input=>isPrivatePlan(input)?{method:"POST",path:PRIVATE_TASKS_PATH,body:taskBody(input)}:{method:"POST",path:`/api/v2/projects/${encodeURIComponent(requireResolved(input,"projectId"))}/tasks`,body:taskBody(input)},summarize:body=>pick(taskObject(body),GET_COLUMNS),raw:taskObject,plannedNotes:input=>{const notes=[];const status=input.resolved?.["status_defaulted"];
|
|
117
|
+
const type=input.resolved?.["type_defaulted"];if(status!==void 0)notes.push(`--status \u672A\u6307\u5B9A\u306E\u305F\u3081\u3001\u65E2\u5B9A\u306E\u30B9\u30C6\u30FC\u30BF\u30B9\u300C${status}\u300D\u3092\u4F7F\u3044\u307E\u3059\u3002`);if(type!==void 0)notes.push(`--type \u672A\u6307\u5B9A\u306E\u305F\u3081\u3001\u65E2\u5B9A\u306E\u7A2E\u5225\u300C${type}\u300D\u3092\u4F7F\u3044\u307E\u3059\u3002`);return notes}},{name:"update",summary:"\u30BF\u30B9\u30AF\u3092\u66F4\u65B0\u3059\u308B",usage:'tw\
|
|
118
|
+
p task update <\u30AD\u30FC|ID> [--status <\u540D\u524D>] [--assignee <me|\u540D\u524D>] [--subject "<\u4EF6\u540D>"]',description:`${TASK_REF_HELP}
|
|
119
|
+
|
|
120
|
+
\u6307\u5B9A\u3057\u305F\u9805\u76EE\u3060\u3051\u3092\u5909\u66F4\u3057\u307E\u3059\uFF08\u6307\u5B9A\u3057\u306A\u304B\u3063\u305F\u9805\u76EE\u306F\u5909\u308F\u308A\u307E\u305B\u3093\uFF09\u3002
|
|
121
|
+
\u5909\u66F4\u3059\u308B\u9805\u76EE\u30921\u3064\u3082\u6307\u5B9A\u3057\u306A\u3044\u3068\u30A8\u30E9\u30FC\u306B\u306A\u308A\u307E\u3059\u2014\u2014\u4F55\u3082\u5909\u308F\u3089\u306A\u3044\u66F4\u65B0\u3067\u3082\u3001
|
|
122
|
+
\u30B5\u30FC\u30D0\u5074\u3067\u306F\u66F4\u65B0\u65E5\u6642\u3068\u5909\u66F4\u5C65\u6B74\u304C\u52D5\u304F\u305F\u3081\u3067\u3059\u3002
|
|
123
|
+
|
|
124
|
+
${PRIVATE_HELP}
|
|
125
|
+
|
|
126
|
+
`+FIELD_HELP,flags:[...FIELD_FLAGS,TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task update help"});checkPureFields(input);if(!FIELD_FLAGS.some(flag=>input.flags.has(flag.name))){throw new UsageError("\u5909\u66F4\u3059\u308B\u9805\u76EE\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",`\u6307\u5B9A\u3067\u304D\u308B\u9805\u76EE: ${FIELD_FLAGS.map(flag=>flag.name).join(" / ")}`)}const surface=taskSurface(
|
|
127
|
+
input,ref);if(surface===PRIVATE_SURFACE)rejectPrivateUnsupportedFlags(input);const description=await readDescription(input,"twp task update help");if(surface===PRIVATE_SURFACE){return withResolved(input,{surface:PRIVATE_SURFACE,taskId:await resolvePrivateTaskId(ctx,ref),...description!==void 0?{description}:{},...await resolvePrivateStatusAndType(input,ctx,{useDefaults:false})})}const located=await resolveTaskLocation(input,ctx,ref);return withResolved(input,{...located,...description!==void 0?{
|
|
128
|
+
description}:{},...await resolveStatusAndType(input,ctx,located.projectId,{useDefaults:false})})},plan:input=>{const taskId=encodeURIComponent(requireResolved(input,"taskId"));const body=taskBody(input);if(isPrivatePlan(input))return{method:"PUT",path:`${PRIVATE_TASKS_PATH}/${taskId}`,body};return{method:"PUT",path:`/api/v2/projects/${encodeURIComponent(requireResolved(input,"projectId"))}/tasks/${taskId}`,body}},summarize:body=>pick(taskObject(body),GET_COLUMNS),raw:taskObject},{name:"delete",summary:"\
|
|
129
|
+
\u30BF\u30B9\u30AF\u3092\u524A\u9664\u3059\u308B",usage:"twp task delete <\u30AD\u30FC|ID> --yes [--project <\u30B3\u30FC\u30C9|ID|__private__>]",description:`${TASK_REF_HELP}
|
|
130
|
+
|
|
131
|
+
\u524A\u9664\u306F\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002\u30B5\u30D6\u30BF\u30B9\u30AF\u3092\u6301\u3064\u30BF\u30B9\u30AF\u3092\u6D88\u3059\u3068\u3001\u30B5\u30FC\u30D0\u5074\u306E\u898F\u5247\u306B\u5F93\u3063\u3066
|
|
132
|
+
\u5B50\u3082\u4E00\u7DD2\u306B\u6271\u308F\u308C\u307E\u3059\u3002\u5148\u306B twp task subtasks <\u30AD\u30FC> \u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
133
|
+
|
|
134
|
+
`+PRIVATE_HELP,destructive:true,flags:[TASK_REF_FLAG,PROJECT_FLAG],async prepare(input,ctx){const ref=singleRef(input,{flag:"--task",label:"\u30BF\u30B9\u30AF",usage:"twp task delete help"});if(taskSurface(input,ref)===PRIVATE_SURFACE){return withResolved(input,{surface:PRIVATE_SURFACE,taskId:await resolvePrivateTaskId(ctx,ref)})}return withResolved(input,await resolveTaskLocation(input,ctx,ref))},plan:input=>{const taskId=encodeURIComponent(requireResolved(input,"taskId"));if(isPrivatePlan(input))
|
|
135
|
+
return{method:"DELETE",path:`${PRIVATE_TASKS_PATH}/${taskId}`};return{method:"DELETE",path:`/api/v2/projects/${encodeURIComponent(requireResolved(input,"projectId"))}/tasks/${taskId}`}},summarize:body=>acknowledgement(body,"\u30BF\u30B9\u30AF\u524A\u9664"),raw:body=>acknowledgement(body,"\u30BF\u30B9\u30AF\u524A\u9664")}],subresources:[taskCommentResource]};export{taskDomain};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{createRuntime}from"./chunk-RQFG3OUL.js";import{PACKAGE_NAME,UPDATE_COMMAND,compareVersionCores,isBelowMinSupported,parseVersionCore}from"./chunk-DXXFUNYN.js";import{findExecutable}from"./chunk-PMOUHEJQ.js";import"./chunk-63LDNYGW.js";import"./chunk-NERYSBA4.js";import"./chunk-RZVI6PMW.js";import{httpFetch}from"./chunk-J7QYPKVK.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import"./chunk-VSJBJXZO.js";import{execFile}from"child_process";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(
|
|
4
|
+
"/","%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:"\
|
|
5
|
+
registry"}}async function fetchFromNpmCli(){const npmPath=findExecutable("npm");if(npmPath===null){throw new Error("npm \u304C PATH \u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093")}const stdout=await new Promise((resolve,reject)=>{execFile(npmPath,["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(latest)===
|
|
6
|
+
null){throw new Error("npm view \u306E\u51FA\u529B\u304B\u3089\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F")}return{version:latest,source:"npm"}}function firstLine(message){const line=message.split("\n").map(l=>l.trim()).find(l=>l!=="")??message;return line.length>200?`${line.slice(0,200)}\u2026`:line}async function fetchLatestVersion(deps={}){const errors=[];for(const attempt of[()=>fetchFromRegistry(deps.fetchImpl??httpFetch,deps.env??process.env),()=>(deps.
|
|
7
|
+
npmView??fetchFromNpmCli)()]){try{return await attempt()}catch(err){errors.push(firstLine(err instanceof Error?err.message:String(err)))}}return{version:null,source:null,error:errors.join(" / ")}}function isPrerelease(version){return/-/.test(version.trim())}function isBehindLatest(current,latest){const currentCore=parseVersionCore(current);const latestCore=parseVersionCore(latest);if(currentCore===null||latestCore===null||latest===null)return false;const diff=compareVersionCores(currentCore,latestCore);
|
|
8
|
+
if(diff!==0)return diff<0;return isPrerelease(current)&&!isPrerelease(latest)}async function runUpdate(opts,deps={}){const out=deps.out??(text=>void process.stdout.write(stripTerminalControls(text)));const err=deps.err??(text=>void process.stderr.write(stripTerminalControls(text)));const runtime=deps.runtime??createRuntime({...opts.profile!==void 0?{profile:opts.profile}:{},cliVersion:opts.version});let floor;let floorSource;if(runtime.loggedIn){const catalog=await runtime.loadCatalog();floor=catalog.
|
|
9
|
+
minSupportedVersion;floorSource=catalog.source==="server"?"\u30B5\u30FC\u30D0":catalog.source==="cache"?"\u30AD\u30E3\u30C3\u30B7\u30E5":"\u672A\u53D6\u5F97";if(floor===null){const cached=runtime.loadCachedFloor().minSupportedVersion;if(cached!==null){floor=cached;floorSource="\u30AD\u30E3\u30C3\u30B7\u30E5"}}}else{floor=runtime.loadCachedFloor().minSupportedVersion;floorSource="\u30AD\u30E3\u30C3\u30B7\u30E5\uFF08\u672A\u30ED\u30B0\u30A4\u30F3\uFF09"}const latest=deps.fetchLatest?await deps.fetchLatest():
|
|
10
|
+
await fetchLatestVersion();const behindLatest=isBehindLatest(opts.version,latest.version);const blocked=isBelowMinSupported(opts.version,floor);out(`twp ${opts.version}
|
|
11
|
+
|
|
12
|
+
`);out(latest.version!==null?` \u6700\u65B0\u7248 ${latest.version}\uFF08${latest.source==="registry"?"npm registry":"npm view"}\uFF09
|
|
13
|
+
`:" \u6700\u65B0\u7248 \u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\n");out(` \u6700\u5C0F\u30B5\u30DD\u30FC\u30C8 ${floor??"\u6307\u5B9A\u306A\u3057"}\uFF08${floorSource} / ${runtime.relayUrl}\uFF09
|
|
14
|
+
`);if(blocked){out(` \u5224\u5B9A \u26A0 \u66F4\u65B0\u304C\u5FC5\u8981\u3067\u3059\uFF08${floor} \u672A\u6E80\u306E\u305F\u3081\u4F1A\u8A71\u3092\u958B\u59CB\u3067\u304D\u307E\u305B\u3093\uFF09
|
|
15
|
+
|
|
16
|
+
`);out(` ${UPDATE_COMMAND}
|
|
17
|
+
`);return 1}if(behindLatest){out(" \u5224\u5B9A \u66F4\u65B0\u3067\u304D\u307E\u3059\uFF08\u5FC5\u9808\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF09\n\n");out(` ${UPDATE_COMMAND}
|
|
18
|
+
`);return 0}out(latest.version!==null?" \u5224\u5B9A \u6700\u65B0\u3067\u3059\n":" \u5224\u5B9A \u5224\u5B9A\u3067\u304D\u307E\u305B\u3093\n");if(latest.version===null&&latest.error!==void 0){err(`
|
|
19
|
+
\u6700\u65B0\u7248\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${latest.error}
|
|
20
|
+
`);err(`\u66F4\u65B0\u3059\u308B\u5834\u5408: ${UPDATE_COMMAND}
|
|
21
|
+
`)}return 0}export{fetchLatestVersion,isBehindLatest,runUpdate};
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tocca-systems/twp-cli",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "TWP CLI — Tocca Working Platform の CLI 型統合インターフェース(AIエージェントハーネス)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"twp": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"!dist/metafile-*.json",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"CHANGELOG.public.md"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"provenance": false
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"bench:startup": "node scripts/bench-startup.mjs",
|
|
26
|
+
"build": "tsup && node scripts/generate-third-party-notices.mjs",
|
|
27
|
+
"changeset": "changeset",
|
|
28
|
+
"check:dist": "node scripts/check-dist-externals.mjs",
|
|
29
|
+
"check:notices": "node scripts/generate-third-party-notices.mjs --check",
|
|
30
|
+
"check:package": "node scripts/check-package-contents.mjs",
|
|
31
|
+
"check:public-changelog": "node scripts/generate-public-changelog.mjs --check",
|
|
32
|
+
"dev": "tsx src/cli.ts",
|
|
33
|
+
"lint": "eslint .",
|
|
34
|
+
"lint:fix": "eslint . --fix",
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm test",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"version": "node scripts/generate-public-changelog.mjs && changeset version"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"undici": "^8.10.2"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@changesets/cli": "3.0.2",
|
|
47
|
+
"@eslint/js": "^10.0.1",
|
|
48
|
+
"@jmespath-community/jmespath": "^1.3.0",
|
|
49
|
+
"@types/node": "^26.5.1",
|
|
50
|
+
"@types/react": "^19.3.0",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.69.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.70.0",
|
|
53
|
+
"diff": "^9.0.0",
|
|
54
|
+
"eslint": "^10.9.1",
|
|
55
|
+
"fuzzysort": "^3.1.0",
|
|
56
|
+
"ink": "^7.1.1",
|
|
57
|
+
"react": "^19.3.0",
|
|
58
|
+
"string-width": "^8.2.2",
|
|
59
|
+
"tsup": "^8.5.1",
|
|
60
|
+
"tsx": "^4.23.13",
|
|
61
|
+
"typescript": "^6.0.3",
|
|
62
|
+
"vitest": "^4.1.11"
|
|
63
|
+
},
|
|
64
|
+
"overrides": {
|
|
65
|
+
"esbuild": "^0.28.2"
|
|
66
|
+
},
|
|
67
|
+
"homepage": "https://docs.tocca.systems/",
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://app.tocca.systems/v1/support"
|
|
70
|
+
},
|
|
71
|
+
"author": "Tocca Systems",
|
|
72
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
73
|
+
}
|