@tocca-systems/twp-cli 0.19.0 → 0.21.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 +20 -0
- package/README.md +63 -4
- package/dist/{ai-dispatch-PNA4UF4I.js → ai-dispatch-36HRDRLF.js} +33 -33
- package/dist/{api-command-JJJOEIZQ.js → api-command-2OPQMSTE.js} +24 -24
- package/dist/{app-SOQPONUU.js → app-CPMS4ICA.js} +164 -101
- package/dist/charter-command-UPKTVL7H.js +36 -0
- package/dist/{chunk-DEVIQH5U.js → chunk-24ZZFFA3.js} +1 -1
- package/dist/{chunk-BYRM4NSC.js → chunk-G2QYUQJE.js} +1 -1
- package/dist/chunk-ODLJ2LNQ.js +13 -0
- package/dist/chunk-RCDOQ6TT.js +15 -0
- package/dist/{chunk-VGK2JMBW.js → chunk-SPZO6C5N.js} +27 -24
- package/dist/{chunk-FKIZ5ZJU.js → chunk-TAN5I2DP.js} +2 -2
- package/dist/chunk-TYNCXQSN.js +38 -0
- package/dist/{chunk-N56AWWTM.js → chunk-UG2I6VRD.js} +2 -12
- package/dist/chunk-VRBI2NPI.js +15 -0
- package/dist/chunk-WH65FZJV.js +30 -0
- package/dist/{chunk-MGKVUKU5.js → chunk-YV2TFD7D.js} +97 -77
- package/dist/chunk-ZGG7TRAM.js +3 -0
- package/dist/cli.js +16 -32
- package/dist/{commands-7D5EEQBY.js → commands-R4KQCXXA.js} +1 -1
- package/dist/{commands-EWRHQZYM.js → commands-XF5G3GIE.js} +26 -25
- package/dist/{logout-guard-Q4MQFEGR.js → logout-guard-JMGI6NPB.js} +1 -1
- package/dist/{oneshot-XLLRNRLK.js → oneshot-QLIXOLN2.js} +1 -1
- package/dist/run-2OQQAOHL.js +4 -0
- package/dist/{schedule-command-YPKIO3FK.js → schedule-command-GKXKNMLG.js} +1 -1
- package/dist/server-settings-ROZUOMC2.js +3 -0
- package/dist/{setup-ROGEF3UO.js → setup-3UEZTO4T.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-NWABK3RZ.js +0 -36
- package/dist/run-OB3JFPSH.js +0 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{buildDiffLines,diffStat}from"./chunk-VRBI2NPI.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE}from"./chunk-M3GWY6NT.js";import"./chunk-VSJBJXZO.js";import*as fs from"fs";var DEFAULT_CHARTER_FILE="CONSTITUTION.md";async function runCharterCommand(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 readFile=deps.readFile??(p=>new TextDecoder("utf-8",{fatal:true,ignoreBOM:true}).decode(fs.readFileSync(p)));const writeFile=deps.writeFile??((p,c)=>fs.writeFileSync(p,c,"utf8"));const exists=deps.exists??(p=>fs.existsSync(p));return opts.op==="push"?push(
|
|
4
|
+
deps.api,opts,{out,err,readFile}):pull(deps.api,opts,{out,err,readFile,writeFile,exists})}async function push(api,opts,io){if(opts.file===void 0){io.err("--file <\u30D1\u30B9> \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: --file CONSTITUTION.md\uFF09\n");return EXIT_USAGE}let expected;if(opts.revision!==void 0){if(!/^\d+$/.test(opts.revision)){io.err(`--revision \u306F0\u4EE5\u4E0A\u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${opts.revision}
|
|
5
|
+
`);return EXIT_USAGE}if(!opts.yes){io.err("--revision \u306F --yes \u3068\u4E00\u7DD2\u306B\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08--yes \u306A\u3057\u3067\u306F\u767B\u9332\u3057\u307E\u305B\u3093\uFF09\n");return EXIT_USAGE}expected=Number(opts.revision)}let local;try{local=io.readFile(opts.file)}catch(e){io.err(`\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u3081\u307E\u305B\u3093: ${opts.file}\uFF08${e.message}\uFF09
|
|
6
|
+
`);return EXIT_USAGE}const current=await fetchState(api,io.err);if(typeof current==="number")return current;const before=current.charter??"";if(current.charter!==null&¤t.charter===local){io.out(`\u5DEE\u5206\u306F\u3042\u308A\u307E\u305B\u3093\uFF08revision ${current.revision}\uFF09\u3002\u767B\u9332\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002
|
|
7
|
+
`);return EXIT_OK}printDiff(io.out,`\u30B5\u30FC\u30D0\uFF08revision ${current.revision}${current.charter===null?"\u30FB\u672A\u767B\u9332":""}\uFF09`,opts.file,before,local);if(current.charter===null&&local===""){io.out("\u26A0\uFE0F \u30D5\u30A1\u30A4\u30EB\u304C\u7A7A\u3067\u3059\u3002\u767B\u9332\u3059\u308B\u3068\u7D44\u307F\u8FBC\u307F\u65E2\u5B9A\u3067\u306F\u306A\u304F\u300C\u7A7A\u306E\u61B2\u7AE0\u300D\u306B\u306A\u308A\u307E\u3059\n")}const revision=expected??current.revision;if(!opts.
|
|
8
|
+
yes){io.out(`
|
|
9
|
+
\u767B\u9332\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u3053\u306E\u5DEE\u5206\u3067\u78BA\u5B9A\u3059\u308B\u306B\u306F\u6B21\u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\uFF08revision ${current.revision} \u3092\u9001\u308B\u306E\u3067\u3001\u305D\u306E\u5F8C\u30B5\u30FC\u30D0\u304C\u66F4\u65B0\u3055\u308C\u3066\u3044\u308C\u3070 409 \u3067\u6B62\u307E\u308A\u307E\u3059\uFF09:
|
|
10
|
+
${confirmCommand(opts,current.revision)}
|
|
11
|
+
`);return EXIT_USAGE}const res=await api.request("PUT","/settings/charter",{charter:local,revision});if(!res.ok){if(res.status===409){const json=res.json??{};const data=json["data"]&&typeof json["data"]==="object"?json["data"]:{};const now=pickNumber(json,"current_revision")??pickNumber(data,"current_revision");io.err(`\u26D4 409: revision ${revision} \u3067\u9001\u308A\u307E\u3057\u305F\u304C\u3001\u30B5\u30FC\u30D0\u306F${now!==null?` revision ${now} \u306B`:""}\u66F4\u65B0\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u753B\u9762\u3067\u7DE8\u96C6\u3055\u308C\u305F\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u4E0A\u66F8\u304D\u305B\u305A\u306B\
|
|
12
|
+
\u6B62\u3081\u307E\u3057\u305F\uFF08\u5DEE\u5206\u3092\u78BA\u8A8D\u3057\u3066\u304B\u3089\u3084\u308A\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF09
|
|
13
|
+
${errorDetail(res)}
|
|
14
|
+
`);return apiExit(res)}io.err(`\u26D4 \u61B2\u7AE0\u3092\u767B\u9332\u3067\u304D\u307E\u305B\u3093\uFF08${errorDetail(res)}\uFF09
|
|
15
|
+
`);return apiExit(res)}const saved=parseState(res);if(saved===null){io.err(`\u26A0\uFE0F \u5FDC\u7B54\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\u3002\u53CD\u6620\u3055\u308C\u305F\u304B\u3092 GET \u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09
|
|
16
|
+
`);return EXIT_API_SERVER}io.out(`\u767B\u9332\u3057\u307E\u3057\u305F: revision ${saved.revision}\uFF08\u66F4\u65B0\u8005: ${saved.updatedByName||"\u4E0D\u660E"}${saved.updatedAt?`\u30FB${saved.updatedAt}`:""}\uFF09
|
|
17
|
+
`);return EXIT_OK}async function pull(api,opts,io){const target=opts.out??DEFAULT_CHARTER_FILE;const current=await fetchState(api,io.err);if(typeof current==="number")return current;if(current.charter===null){io.err(`\u30B5\u30FC\u30D0\u306B\u61B2\u7AE0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u307E\u305B\u3093\uFF08revision ${current.revision}\uFF09\u3002${target} \u306F\u5909\u66F4\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002
|
|
18
|
+
`);return EXIT_FAILURE}const source=`\u30B5\u30FC\u30D0\uFF08revision ${current.revision}${current.updatedByName?`\u30FB${current.updatedByName}`:""}\uFF09`;if(io.exists(target)){let local;try{local=io.readFile(target)}catch(e){io.err(`\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u3081\u307E\u305B\u3093: ${target}\uFF08${e.message}\uFF09
|
|
19
|
+
`);return EXIT_FAILURE}if(local===current.charter){io.out(`${target} \u306F\u30B5\u30FC\u30D0\uFF08revision ${current.revision}\uFF09\u3068\u540C\u3058\u3067\u3059\u3002\u5909\u66F4\u3057\u307E\u305B\u3093\u3067\u3057\u305F\u3002
|
|
20
|
+
`);return EXIT_OK}printDiff(io.out,target,source,local,current.charter);if(!opts.yes){io.out(`
|
|
21
|
+
${target} \u3092\u4E0A\u66F8\u304D\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u4E0A\u66F8\u304D\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
22
|
+
`);return EXIT_USAGE}}try{io.writeFile(target,current.charter)}catch(e){io.err(`\u66F8\u304D\u8FBC\u3081\u307E\u305B\u3093: ${target}\uFF08${e.message}\uFF09
|
|
23
|
+
`);return EXIT_FAILURE}io.out(`${target} \u306B\u5C55\u958B\u3057\u307E\u3057\u305F\uFF08revision ${current.revision}\uFF09\u3002
|
|
24
|
+
`);return EXIT_OK}async function fetchState(api,err){const res=await api.request("GET","/settings");if(!res.ok){err(`\u26D4 \u30EB\u30FC\u30D7\u8A2D\u5B9A\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\uFF08${errorDetail(res)}\uFF09
|
|
25
|
+
`);return apiExit(res)}const state=parseState(res);if(state===null){err(`\u26D4 \u30EB\u30FC\u30D7\u8A2D\u5B9A\u306E\u5FDC\u7B54\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09
|
|
26
|
+
`);return EXIT_API_SERVER}return state}function apiExit(res){if(res.status===401)return EXIT_AUTH;if(res.status!==null&&res.status>=400&&res.status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}function body(res){const json=res.json??{};const data=json["data"];if(data&&typeof data==="object"&&!Array.isArray(data)&&"revision"in data){return data}return json}function parseState(res){const b=body(res);const revision=pickNumber(b,"revision");if(revision===null)return null;const prompts=b["prompt\
|
|
27
|
+
s"];let charter=null;if(prompts&&typeof prompts==="object"){const v=prompts["charter"];if(typeof v==="string")charter=v}return{charter,revision,updatedByName:typeof b["updated_by_name"]==="string"?b["updated_by_name"]:"",updatedAt:typeof b["updated_at"]==="string"?b["updated_at"]:""}}function pickNumber(b,key){const v=b[key];return typeof v==="number"&&Number.isInteger(v)&&v>=0?v:null}function errorDetail(res){if(res.status===null)return`transport_error=${res.transportError??"\u4E0D\u660E"}`;const json=res.
|
|
28
|
+
json??{};const data=json["data"]&&typeof json["data"]==="object"?json["data"]:{};const errorField=json["error"];const errorObj=errorField&&typeof errorField==="object"?errorField:{};const reason=(typeof errorField==="string"?errorField:"")||str(errorObj["code"])||str(json["reason"])||str(data["reason"]);const message=str(json["error_description"])||str(errorObj["message"])||str(json["message"])||str(data["message"]);const parts=[`http=${res.status}`];if(reason)parts.push(`reason=${reason}`);if(message)
|
|
29
|
+
parts.push(message.slice(0,300));const errors=json["errors"]??data["errors"];if(errors&&typeof errors==="object")parts.push(JSON.stringify(errors).slice(0,300));if(!reason&&!message)parts.push(`\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,160)}`);return parts.join(" ")}function str(v){return typeof v==="string"?v:""}var HIDDEN_CHARS=/[\x00-\x08\x0B-\x1F\x7F-\x9F\u200B-\u200F\u202A-\u202E\u2060-\u2069\uFEFF]/g;function printDiff(out,fromLabel,toLabel,before,after){const lines=buildDiffLines(
|
|
30
|
+
before,after);const{added,removed}=diffStat(lines);out(`--- ${fromLabel}
|
|
31
|
+
+++ ${toLabel}
|
|
32
|
+
`);for(const l of lines)out(`${l.sign} ${l.text}
|
|
33
|
+
`);out(`\uFF08+${added} / -${removed} \u884C\uFF09
|
|
34
|
+
`);if(before!==after&&before.replace(/\n$/,"")===after.replace(/\n$/,"")){out(`\uFF08\u9055\u3044\u306F\u672B\u5C3E\u306E\u6539\u884C\u306E\u6709\u7121\u3060\u3051\u3067\u3059: ${after.endsWith("\n")?"\u6539\u884C\u3092\u8DB3\u3059":"\u6539\u884C\u3092\u6D88\u3059"}\uFF09
|
|
35
|
+
`)}const hidden=(after.match(HIDDEN_CHARS)??[]).length;if(hidden>0){out(`\u26A0\uFE0F \u66F8\u304D\u8FBC\u307E\u308C\u308B\u5185\u5BB9\u306B\u3001\u5DEE\u5206\u8868\u793A\u3067\u306F\u898B\u3048\u306A\u3044\u6587\u5B57\uFF08\u5236\u5FA1\u6587\u5B57\u30FBCR\u30FB\u53CC\u65B9\u5411\u5236\u5FA1\u30FB\u30BC\u30ED\u5E45\uFF09\u304C ${hidden} \u7B87\u6240\u3042\u308A\u307E\u3059\u3002\u78BA\u5B9A\u3059\u308B\u524D\u306B\u5185\u5BB9\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044
|
|
36
|
+
`)}}function confirmCommand(opts,revision){const parts=["twp task-loop charter push","--project",shellQuote(opts.projectRef)];if(opts.profile!==void 0)parts.push("--profile",shellQuote(opts.profile));parts.push("--file",shellQuote(opts.file??DEFAULT_CHARTER_FILE),"--yes","--revision",String(revision));return parts.join(" ")}function shellQuote(v){return/^[A-Za-z0-9_./:@=-]+$/.test(v)?v:`'${v.replace(/'/g,`'\\''`)}'`}export{DEFAULT_CHARTER_FILE,runCharterCommand};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,spawnSyncResolved}from"./chunk-
|
|
3
|
+
import{DEFAULT_CLAUDE_LAUNCHER,activeSlotPath,detectClaudeAutoSwitch,spawnSyncResolved}from"./chunk-TYNCXQSN.js";import{defaultIsExecutableFile,findOnPath,joinFor}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{spawnSync}from"child_process";import{createHash}from"crypto";import fs from"fs";import os from"os";import path from"path";var DETECTABLE_AIS=["claude","codex","gemini","copilot"];function isDetectableAi(value){return DETECTABLE_AIS.includes(value)}function isSelectable(d){return d.installed&&d.blockedReason===null&&d.auth!=="unauthenticated"}function resolveDetectDeps(deps={}){return resolve(deps)}function resolve(deps){const platform=deps.platform??process.platform;return{run:deps.run??spawnSync,env:deps.env??process.env,homedir:deps.homedir??os.homedir,isExecutableFile:deps.isExecutableFile??(p=>defaultIsExecutableFile(p,platform)),existsSync:deps.existsSync??fs.existsSync,readFileSync:deps.readFileSync??(p=>fs.readFileSync(p,"utf8")),platform,
|
|
4
4
|
now:deps.now??Date.now,launcherBin:nonEmptyBin(deps.launcherBin)??DEFAULT_CLAUDE_LAUNCHER.bin}}function nonEmptyBin(value){const t=value?.trim();return t===void 0||t===""?void 0:t}var PROBE_TIMEOUT_MS=1e4;function oneLine(text){return text.replace(/\s+/g," ").trim()}function claudeConfigDir(d){const lookup={env:d.env,platform:d.platform};const bin=nonEmptyBin(d.launcherBin)??DEFAULT_CLAUDE_LAUNCHER.bin;const cas=detectClaudeAutoSwitch(bin,d.run,lookup);if(cas!==null){const active=activeSlotPath(
|
|
5
5
|
cas,d.run,lookup);if(active!==null){return{dir:active,via:`${bin} ${DEFAULT_CLAUDE_LAUNCHER.activeArgs.join(" ")}`}}}const explicit=d.env.CLAUDE_CONFIG_DIR?.trim();if(explicit!==void 0&&explicit!=="")return{dir:explicit,via:"CLAUDE_CONFIG_DIR"};return{dir:joinFor(d.platform)(d.homedir(),".claude"),via:"\u65E2\u5B9A\uFF08~/.claude\uFF09"}}var CLAUDE_AUTH_ENV=[{key:"ANTHROPIC_API_KEY",label:"ANTHROPIC_API_KEY",boolish:false},{key:"ANTHROPIC_AUTH_TOKEN",label:"ANTHROPIC_AUTH_TOKEN",boolish:false},{
|
|
6
6
|
key:"CLAUDE_CODE_OAUTH_TOKEN",label:"CLAUDE_CODE_OAUTH_TOKEN",boolish:false},{key:"AWS_BEARER_TOKEN_BEDROCK",label:"AWS_BEARER_TOKEN_BEDROCK",boolish:false},{key:"CLAUDE_CODE_USE_BEDROCK",label:"CLAUDE_CODE_USE_BEDROCK\uFF08AWS \u8CC7\u683C\u60C5\u5831\u3067\u52D5\u304D\u307E\u3059\uFF09",boolish:true},{key:"CLAUDE_CODE_USE_VERTEX",label:"CLAUDE_CODE_USE_VERTEX\uFF08GCP \u8CC7\u683C\u60C5\u5831\u3067\u52D5\u304D\u307E\u3059\uFF09",boolish:true}];function envEnabled(raw,boolish){if(boolish)return isBoolishTrue(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{projectFileKey}from"./chunk-GY7KI5E5.js";import{killProcessTree}from"./chunk-N2UVRM3Z.js";import{DEFAULT_CLAUDE_LAUNCHER,loadAiConfig}from"./chunk-TYNCXQSN.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{twpHomeDir}from"./chunk-RZVI6PMW.js";function stringField(value,key,fallback,warnings){if(value===void 0||value===null)return fallback;if(typeof value!=="string"||value.trim()===""){warnings.push(`claude_launcher.${key} \u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A '${fallback}' \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}return value.trim()}function argvField(value,key,fallback,warnings,allowEmpty){if(value===void 0||value===null)return fallback;
|
|
4
4
|
if(!Array.isArray(value)){warnings.push(`claude_launcher.${key} \u306F\u6587\u5B57\u5217\u306E\u914D\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A [${fallback.join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}for(const v of value){if(typeof v!=="string"||v.trim()===""){warnings.push(`claude_launcher.${key} \u306E\u8981\u7D20\u306F\u7A7A\u3067\u306A\u3044\u6587\u5B57\u5217\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u65E2\u5B9A [${fallback.
|
|
5
5
|
join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}}if(value.length===0&&!allowEmpty){warnings.push(`claude_launcher.${key} \u306F1\u3064\u4EE5\u4E0A\u306E\u5F15\u6570\u304C\u8981\u308A\u307E\u3059\uFF08\u65E2\u5B9A [${fallback.join(", ")}] \u3092\u4F7F\u3044\u307E\u3059\uFF09`);return fallback}return value.map(v=>v.trim())}function probeMatchField(value,warnings){const raw=stringField(value,"probe_match",DEFAULT_CLAUDE_LAUNCHER.probeMatch,warnings);try{new RegExp(raw,"m")}catch(err){
|
|
6
6
|
warnings.push(`claude_launcher.probe_match \u306F\u6B63\u898F\u8868\u73FE\u3068\u3057\u3066\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08${err.message}\uFF09\u3002\u65E2\u5B9A '${DEFAULT_CLAUDE_LAUNCHER.probeMatch}' \u3092\u4F7F\u3044\u307E\u3059`);return DEFAULT_CLAUDE_LAUNCHER.probeMatch}return raw}var NOT_YET_APPLIED=[{key:"probe",get:c=>c.probe},{key:"probe_match",get:c=>c.probeMatch},{key:"exec_args",get:c=>c.execArgs},{key:"active_args",get:c=>c.activeArgs}];function sameAsDefault(key,parsed){
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{isPrivateProjectId}from"./chunk-GY7KI5E5.js";import{httpFetch}from"./chunk-J7QYPKVK.js";function describeError(res){if(res.status===null)return`transport_error=${res.transportError??"\u4E0D\u660E"}`;const body=res.json;const parts=[`http=${res.status}`];const reason=typeof body?.["reason"]==="string"?body["reason"]:"";if(reason)parts.push(`reason=${reason}`);const error=body?.["error"];const code=typeof error?.["code"]==="string"?error["code"]:"";if(code)parts.push(`code=${code}`);const message=(typeof body?.["message"]==="string"?body["message"]:"")||(typeof error?.["message"]==="\
|
|
4
|
+
string"?error["message"]:"");if(message)parts.push(message.slice(0,160));if(!reason&&!code&&!message)parts.push(`\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,160)}`);return parts.join(" ")}function isPermanent(res){return res.status!==null&&res.status>=400&&res.status<500}function filterByStatus(items,status){return items.filter(item=>item.status===void 0||item.status===status)}var AgentLoopApi=class{constructor(opts){this.opts=opts;const root=opts.apiUrl.replace(/\/+$/,"");this.base=isPrivateProjectId(
|
|
5
|
+
opts.projectId)?`${root}/api/v2/tasks/private/agent-loop`:`${root}/api/v2/projects/${opts.projectId}/agent-loop`}opts;base;get baseUrl(){return this.base}list(query){const qs=new URLSearchParams;for(const[k,v]of Object.entries(query)){if(v!==void 0&&v!=="")qs.set(k,String(v))}const suffix=qs.toString()?`?${qs.toString()}`:"";return this.request("GET",suffix)}create(body){return this.request("POST","",body)}getItem(itemId){return this.request("GET",`/${encodeURIComponent(itemId)}`)}update(itemId,body,runId){
|
|
6
|
+
return this.request("PUT",`/${encodeURIComponent(itemId)}`,{...body,run_id:runId})}updateUnowned(itemId,body){return this.request("PUT",`/${encodeURIComponent(itemId)}`,body)}reorder(itemIds){return this.request("PUT","/reorder",{item_ids:itemIds})}claim(runnerId,runId){return this.request("POST","/claim",{runner_id:runnerId,run_id:runId})}reclaim(){return this.request("POST","/reclaim",{})}runners(){return this.request("GET","/runners")}registerRunner(payload){return this.request("POST","/runne\
|
|
7
|
+
rs/register",payload)}heartbeatRunner(payload){return this.request("POST","/runners/heartbeat",payload)}deregisterRunner(payload){return this.request("POST","/runners/deregister",payload)}planStart(runnerId,runId){return this.request("POST","/plan/start",{runner_id:runnerId,run_id:runId})}planFinish(runnerId,runId,planStartedAt,result){return this.request("POST","/plan/finish",{runner_id:runnerId,run_id:runId,plan_started_at:planStartedAt,result})}consumeCounter(key,date,limit){return this.request(
|
|
8
|
+
"POST","/counters/consume",{key,date,limit})}listCounters(date){return this.request("GET",`/counters?date=${encodeURIComponent(date)}`)}async queuedSnapshot(){return this.snapshotOf(["pending","processing"])}async processingSnapshot(){return this.snapshotOf(["processing"])}async pendingSnapshot(){return this.snapshotOf(["pending"])}async completedSince(sinceMicros,maxPages=10){const all=[];let cursor=String(Math.trunc(sinceMicros));for(let page=0;page<maxPages;page++){const res=await this.list({
|
|
9
|
+
status:"completed",limit:100,cursor});if(!res.ok)return null;const body=res.json;const items=body?.["items"];if(!Array.isArray(items))return null;all.push(...filterByStatus(items,"completed"));const pagination=body?.["pagination"];const hasMore=(pagination?.["has_more"]??body?.["has_more"])===true;const next=pagination?.["next_cursor"]??body?.["next_cursor"];if(!hasMore||!next)return all;cursor=next}return null}async snapshotOf(statuses){const all=[];for(const status of statuses){let cursor;for(let page=0;page<
|
|
10
|
+
20;page++){const res=await this.list({status,limit:100,cursor});if(!res.ok)return null;const body=res.json;const items=body?.["items"];if(!Array.isArray(items))return null;all.push(...filterByStatus(items,status));const pagination=body?.["pagination"];const hasMore=(pagination?.["has_more"]??body?.["has_more"])===true;const next=pagination?.["next_cursor"]??body?.["next_cursor"];if(!hasMore||!next)break;cursor=next;if(page===19)return null}}return all}async request(method,suffix,body){let token;
|
|
11
|
+
try{token=await this.opts.session.getAccessToken()}catch(err){return{ok:false,status:null,json:null,raw:"",transportError:err.message}}let res=await this.send(method,suffix,token,body);if(res.status===401){try{token=await this.opts.session.refresh(token);res=await this.send(method,suffix,token,body)}catch(err){return{ok:false,status:401,json:null,raw:res.raw,transportError:err.message}}}return res}async send(method,suffix,token,body){const fetchImpl=this.opts.fetchImpl??httpFetch;const controller=new AbortController;
|
|
12
|
+
const timer=setTimeout(()=>controller.abort(),this.opts.timeoutMs??6e4);try{const res=await fetchImpl(`${this.base}${suffix}`,{method,headers:{Authorization:`Bearer ${token}`,"Content-Type":"application/json",Accept:"application/json"},signal:controller.signal,...body===void 0?{}:{body:JSON.stringify(body)}});const raw=await res.text();let json=null;if(raw.trim()!==""){try{json=JSON.parse(raw)}catch{json=null}}return{ok:res.ok,status:res.status,json,raw,transportError:null}}catch(err){const reason=err.
|
|
13
|
+
name==="AbortError"?"timeout":err.message;return{ok:false,status:null,json:null,raw:"",transportError:reason}}finally{clearTimeout(timer)}}};function pick(json,path){let cur=json;for(const part of path.split(".")){if(cur===null||typeof cur!=="object")return void 0;cur=cur[part]}return cur===null?void 0:cur}function pickString(json,path){const v=pick(json,path);if(typeof v==="string")return v;if(typeof v==="number")return String(v);if(typeof v==="boolean")return v?"true":"false";return""}export{describeError,isPermanent,filterByStatus,AgentLoopApi,pick,pickString};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{describeError}from"./chunk-ODLJ2LNQ.js";import{isPrivateProjectId}from"./chunk-GY7KI5E5.js";import{CHAIN_KEYS,reloadAiConfig}from"./chunk-TYNCXQSN.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs from"fs";import path from"path";var PROMPT_KEYS=["charter","charter_prefix","charter_suffix","plan_preamble","step_budget","non_interactive_note","safe_mode_note"];function parseServerSettings(res){const json=res.json;if(json===null||typeof json!=="object"||Array.isArray(json))return null;const top=json;const data=top["data"];const b=data!==null&&typeof data==="object"&&!Array.isArray(data)&&"revision"in data?data:top;const revision=b["revision"];if(typeof revision!=="number"||!Number.isInteger(revision)||revision<0)return null;
|
|
4
|
+
const rawAi=b["ai"];const ai=rawAi!==null&&typeof rawAi==="object"&&!Array.isArray(rawAi)?Object.fromEntries(Object.entries(rawAi).filter(([,v])=>v!==null&&v!==void 0)):{};const prompts={};const rawPrompts=b["prompts"];if(rawPrompts!==null&&typeof rawPrompts==="object"&&!Array.isArray(rawPrompts)){for(const key of PROMPT_KEYS){const v=rawPrompts[key];if(typeof v==="string")prompts[key]=v}}return{revision,ai,prompts}}function formatConfigHash(aiHash,revision,ai,charter){return`${aiHash};r=${revision}\
|
|
5
|
+
;ai=${ai};charter=${charter}`}function renderStepBudget(template,vars){return template.replaceAll("{timeout_min}",String(vars.timeoutMin)).replaceAll("{soft_min}",String(vars.softMin)).replaceAll("{wrap_up_min}",String(vars.wrapUpMin))}var LoopSettingsApplier=class{constructor(deps){this.deps=deps}deps;last=null;lastWarning="";lastAiWarning="";lastSummary="";serverAiApplied=false;lastSafeWarning="";async apply(){const{config,log}=this.deps;const outcome=await this.fetch();const warning=outcome.warning??
|
|
6
|
+
"";if(warning!==""&&warning!==this.lastWarning)log(` \u26A0\uFE0F ${warning}`);else if(warning===""&&this.lastWarning!=="")log("\u30EB\u30FC\u30D7\u8A2D\u5B9A\u3092\u30B5\u30FC\u30D0\u304B\u3089\u518D\u3073\u53D6\u5F97\u3067\u304D\u308B\u3088\u3046\u306B\u306A\u308A\u307E\u3057\u305F");this.lastWarning=warning;const settings=outcome.settings;config.serverPrompts=settings?.prompts??{};const safeNote=config.serverPrompts.safe_mode_note;const safeWarning=config.safeMode&&safeNote!==void 0?safeNote===
|
|
7
|
+
""?"\u5B89\u5168\u30E2\u30FC\u30C9\u3067\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u30B5\u30FC\u30D0\u306E\u30EB\u30FC\u30D7\u8A2D\u5B9A\u304C\u5B89\u5168\u30E2\u30FC\u30C9\u306E\u6CE8\u8A18\u3092\u7A7A\u306B\u3057\u3066\u3044\u307E\u3059\uFF08\u672C\u756A\u30EA\u30EA\u30FC\u30B9\u7981\u6B62\u306E\u6307\u793A\u304C\u30D7\u30ED\u30F3\u30D7\u30C8\u306B\u8F09\u308A\u307E\u305B\u3093\uFF09":"\u5B89\u5168\u30E2\u30FC\u30C9\u3067\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059\u3002\u5B89\u5168\u30E2\u30FC\u30C9\u306E\u6CE8\u8A18\u306F\u30B5\u30FC\u30D0\u306E\u30EB\u30FC\u30D7\u8A2D\u5B9A\u306E\u6587\u9762\u306B\u5DEE\u3057\u66FF\u308F\u3063\u3066\u3044\u307E\u3059":
|
|
8
|
+
"";if(safeWarning!==""&&safeWarning!==this.lastSafeWarning)log(` \u26A0\uFE0F ${safeWarning}`);this.lastSafeWarning=safeWarning;const serverAi=settings!==null&&Object.keys(settings.ai).length>0?settings.ai:null;const layer=serverAi??(this.serverAiApplied?{}:null);const r=reloadAiConfig(config.ai,config.aiSource.inline,config.aiSource.file,config.workspace,layer);if(r.status!=="kept"||layer!==null)this.serverAiApplied=serverAi!==null;const aiWarning=r.warnings.join("\n");if(aiWarning!==""&&aiWarning!==
|
|
9
|
+
this.lastAiWarning){for(const w of r.warnings)log(` \u26A0\uFE0F ${w}`)}else if(aiWarning===""&&this.lastAiWarning!==""&&r.status!=="skipped"){log("AI \u5272\u5F53\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u3073\u8AAD\u3081\u308B\u3088\u3046\u306B\u306A\u308A\u307E\u3057\u305F")}this.lastAiWarning=aiWarning;if(r.status==="updated"){log(r.hashBefore===r.hashAfter?`AI \u5272\u5F53\u306E\u5909\u66F4\u3092\u53CD\u6620\u3057\u307E\u3057\u305F\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${r.hashAfter} \u306F\u4E0D\u5909\
|
|
10
|
+
\uFF1D\u9396\u304B\u30B3\u30E1\u30F3\u30C8\u3060\u3051\u306E\u5909\u66F4\uFF09`:`AI \u5272\u5F53\u306E\u5909\u66F4\u3092\u53CD\u6620\u3057\u307E\u3057\u305F\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${r.hashBefore} \u2192 ${r.hashAfter}\uFF09`)}const fromServer=outcome.source==="cached"?"cached":"server";const inline=config.aiSource.inline;const effectiveServerKeys=serverAi===null?[]:Object.keys(serverAi).filter(k=>!(CHAIN_KEYS.includes(k)&&inline!==void 0&&k in inline));const aiOrigin=effectiveServerKeys.
|
|
11
|
+
length>0?fromServer:inline!==void 0&&Object.keys(inline).length>0||config.ai.fileLayer!==null?"local":"builtin";const charterOrigin=this.charterOrigin(settings,fromServer);const revision=settings?.revision??0;config.configHash=formatConfigHash(config.ai.hash(),revision,aiOrigin,charterOrigin);const serverPromptKeys=Object.keys(config.serverPrompts);const summary=`\u30EB\u30FC\u30D7\u8A2D\u5B9A: ${settings===null?"\u30B5\u30FC\u30D0\u5024\u306A\u3057":`${outcome.source==="cached"?"\u76F4\u524D\u306B\u53D6\u5F97\u3057\u305F\u30B5\u30FC\u30D0\u5024":
|
|
12
|
+
"\u30B5\u30FC\u30D0"} revision ${revision}`}\uFF08AI\u5272\u5F53=${aiOrigin}${effectiveServerKeys.length>0?`\u30FB\u30B5\u30FC\u30D0 ${effectiveServerKeys.length}\u30AD\u30FC`:""} \uFF0F \u61B2\u7AE0=${charterOrigin} \uFF0F \u30B5\u30FC\u30D0\u306E\u6587\u9762=${serverPromptKeys.length>0?serverPromptKeys.join(","):"\u306A\u3057"}\uFF09`;if(summary!==this.lastSummary)log(summary);this.lastSummary=summary}charterOrigin(settings,fromServer){const{config}=this.deps;if(!config.charterEnabled)return"o\
|
|
13
|
+
ff";if(settings!==null&&settings.prompts.charter!==void 0)return fromServer;const file=config.charterFile;if(file===null||file.trim()==="")return"builtin";const resolved=path.isAbsolute(file)?file:path.resolve(config.workspace,file);try{fs.accessSync(resolved,fs.constants.R_OK);return fs.statSync(resolved).isFile()?"local":"builtin"}catch{return"builtin"}}async fetch(){if(isPrivateProjectId(this.deps.config.projectId??""))return{settings:null,source:"none",warning:null};const res=await this.deps.
|
|
14
|
+
api.request("GET","/settings");const parsed=res.ok?parseServerSettings(res):null;if(parsed!==null){this.last=parsed;return{settings:parsed,source:"server",warning:null}}const transient=res.status===null||res.status>=500||res.ok;const reason=stripTerminalControls(res.ok?`\u5FDC\u7B54\u3092\u89E3\u91C8\u3067\u304D\u307E\u305B\u3093\uFF08\u5148\u982D: ${res.raw.slice(0,120)}\uFF09`:describeError(res));if(transient&&this.last!==null){return{settings:this.last,source:"cached",warning:`\u30EB\u30FC\u30D7\u8A2D\u5B9A\u3092\u30B5\u30FC\u30D0\u304B\u3089\u53D6\u5F97\u3067\u304D\
|
|
15
|
+
\u307E\u305B\u3093\uFF08${reason}\uFF09\u3002\u76F4\u524D\u306B\u53D6\u5F97\u3057\u305F revision ${this.last.revision} \u3067\u8D70\u308A\u307E\u3059`}}return{settings:null,source:"none",warning:`\u30EB\u30FC\u30D7\u8A2D\u5B9A\u3092\u30B5\u30FC\u30D0\u304B\u3089\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\uFF08${reason}\uFF09\u3002\u30ED\u30FC\u30AB\u30EB\u8A2D\u5B9A\uFF08ai_config_file / charter_file\uFF09\u3068\u7D44\u307F\u8FBC\u307F\u65E2\u5B9A\u3067\u8D70\u308A\u307E\u3059`}}};export{PROMPT_KEYS,parseServerSettings,formatConfigHash,renderStepBudget,LoopSettingsApplier};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{stringWidth}from"./chunk-WVS4W5FY.js";import{parseOperationArgs}from"./chunk-O52CUEDO.js";import{GLOBAL_OPTIONS_HELP
|
|
4
|
-
resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-2VISRLWS.js";import{ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import{ResolveError}from"./chunk-5QCAIKFE.js";import fs from"fs";import path from"path";var SENSITIVE_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-vercel-protection-bypass"]);var REDACTED="***\uFF08\u4F0F\u5B57\uFF09";var SECRET_KEY_PATTERN="[A-Za-z0-9_-]*(?:token|secret|password|passwd|api[_-]?key|credential|signature)[A-Za-z0-9_-]*";var NOT_SECRET_FLAGS="(?:starting-token)";function redactSecrets(text){return text.replace(/\bBearer\s+[^\s"'`,;)\]}]+/gi,`Bearer ${REDACTED}`).replace(new RegExp(`("${SECRET_KEY_PATTERN}"\\\
|
|
3
|
+
import{stringWidth}from"./chunk-WVS4W5FY.js";import{parseOperationArgs}from"./chunk-O52CUEDO.js";import{GLOBAL_OPTIONS_HELP}from"./chunk-TAN5I2DP.js";import{HELP_TOKEN}from"./chunk-ZGG7TRAM.js";import{AuthSession,NotLoggedInError,SessionExpiredError,loadCredentials}from"./chunk-XNLIEUAW.js";import{Resolver,requireDefaultProject}from"./chunk-MIMDLO52.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-JKSXUBND.js";import{httpFetch}from"./chunk-J7QYPKVK.js";
|
|
4
|
+
import{effectiveApiUrl,loadUserConfig,resolveConfiguredOutput,resolveProfile}from"./chunk-NERYSBA4.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import{DEFAULT_MAX_ITEMS,DEFAULT_MAX_PAGES,nextPageNotes,positiveInteger,shellQuote}from"./chunk-2VISRLWS.js";import{ApiResponseError,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_FAILURE,EXIT_OK,EXIT_USAGE,NetworkError,UsageError}from"./chunk-M3GWY6NT.js";import{ResolveError}from"./chunk-5QCAIKFE.js";import fs from"fs";import path from"path";var SENSITIVE_HEADERS=new Set(["authorization","proxy-authorization","cookie","set-cookie","x-api-key","x-auth-token","x-vercel-protection-bypass"]);var REDACTED="***\uFF08\u4F0F\u5B57\uFF09";var SECRET_KEY_PATTERN="[A-Za-z0-9_-]*(?:token|secret|password|passwd|api[_-]?key|credential|signature)[A-Za-z0-9_-]*";var NOT_SECRET_FLAGS="(?:starting-token)";function redactSecrets(text){return text.replace(/\bBearer\s+[^\s"'`,;)\]}]+/gi,`Bearer ${REDACTED}`).replace(new RegExp(`("${SECRET_KEY_PATTERN}"\\\
|
|
5
5
|
s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,"gi"),`$1"${REDACTED}"`).replace(new RegExp(`([?&]${SECRET_KEY_PATTERN}=)[^&\\s"'\`,;)\\]}]+`,"gi"),`$1${REDACTED}`).replace(new RegExp(`(--(?!${NOT_SECRET_FLAGS}(?:=|\\s))${SECRET_KEY_PATTERN}(?:=|\\s+))('[^']*'|"[^"]*"|[A-Za-z0-9_.~+/=|:%-]+)`,"gi"),`$1${REDACTED}`)}var SECRET_KEY_NAME=new RegExp(`^${SECRET_KEY_PATTERN}$`,"i");function redactSecretValues(value){if(Array.isArray(value))return value.map(item=>redactSecretValues(item));if(value!==null&&typeof value===
|
|
6
6
|
"object"){const out={};for(const[key,item]of Object.entries(value)){out[key]=SECRET_KEY_NAME.test(key)?REDACTED:redactSecretValues(item)}return out}return value}function formatHeaders(headers){if(!headers)return[];const entries=headers instanceof Headers?[...headers.entries()]:Array.isArray(headers)?headers:Object.entries(headers);return entries.map(([name,value])=>{const shown=SENSITIVE_HEADERS.has(name.toLowerCase())?REDACTED:redactSecrets(String(value));return` ${name.toLowerCase()}: ${shown}`})}
|
|
7
7
|
var BODY_LIMIT=4e3;function formatBody(raw){const safe=redactSecrets(stripTerminalControls(raw));return safe.length>BODY_LIMIT?`${safe.slice(0,BODY_LIMIT)}
|
|
@@ -16,7 +16,8 @@ value)}return stripTerminalControls(JSON.stringify(value)??"")}function isPlainR
|
|
|
16
16
|
return text+" ".repeat(pad)}).join(" ").trimEnd()}function singleLine(text){return stripTerminalControls(text).replace(/\t/g,"\\t").replace(/\n/g,"\\n")}function renderGrid(header,rows){const normalizedHeader=header?header.map(singleLine):null;const normalizedRows=rows.map(row=>row.map(singleLine));return renderGridNormalized(normalizedHeader,normalizedRows)}function renderGridNormalized(header,rows){const all=header?[header,...rows]:rows;const columnCount=all.reduce((max,row)=>Math.max(max,row.
|
|
17
17
|
length),0);const widths=[];for(let i=0;i<columnCount;i+=1){widths.push(all.reduce((max,row)=>Math.max(max,stringWidth(row[i]??"")),0))}const lines=[];if(header){lines.push(renderRow(header,widths));lines.push(widths.map(w=>"-".repeat(Math.max(1,w))).join(" ").trimEnd())}for(const row of rows)lines.push(renderRow(row,widths));return lines.join("\n")}function formatTable(value){if(Array.isArray(value)){if(value.length===0)return"";const records=value.filter(isPlainRecord);if(records.length!==value.
|
|
18
18
|
length){return renderGrid(null,value.map(v=>[cell(v)]))}const columns=collectColumns(records);if(columns.length===0)return"";return renderGrid(columns,records.map(row=>columns.map(c=>cell(row[c]))))}if(isPlainRecord(value)){const entries=Object.entries(value);if(entries.length===0)return"";return renderGrid(null,entries.map(([k,v])=>[k,cell(v)]))}return cell(value)}function escapeDelimited(text){return text.replace(/\\/g,"\\\\").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/\n/g,"\\n")}function formatDelimited(value,separator){
|
|
19
|
-
const rows=[];if(Array.isArray(value)){const records=value.filter(isPlainRecord);if(value.length>0&&records.length===value.length){const columns=collectColumns(records);for(const row of records)rows.push(columns.map(c=>cell(row[c])))}else{for(const v of value)rows.push([cell(v)])}}else if(isPlainRecord(value)){rows.push(Object.values(value).map(cell))}else{rows.push([cell(value)])}return rows.map(row=>row.map(escapeDelimited).join(separator)).join("\n")}async function evaluateQuery(expression,value){if(expression.trim()===""){throw new UsageError("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093")}const{search}=await import("./dist-HZIZTJ4O.js");try{return search(value??null,expression)}catch(err){throw new UsageError(`--query \u306E\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}function renderOutput(value,format,noRedact=false){if(noRedact)return formatOutput(value,format);return redactSecrets(formatOutput(redactSecretValues(value),format))}
|
|
19
|
+
const rows=[];if(Array.isArray(value)){const records=value.filter(isPlainRecord);if(value.length>0&&records.length===value.length){const columns=collectColumns(records);for(const row of records)rows.push(columns.map(c=>cell(row[c])))}else{for(const v of value)rows.push([cell(v)])}}else if(isPlainRecord(value)){rows.push(Object.values(value).map(cell))}else{rows.push([cell(value)])}return rows.map(row=>row.map(escapeDelimited).join(separator)).join("\n")}async function evaluateQuery(expression,value){if(expression.trim()===""){throw new UsageError("--query \u306B\u7A7A\u306E\u5F0F\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093")}const{search}=await import("./dist-HZIZTJ4O.js");try{return search(value??null,expression)}catch(err){throw new UsageError(`--query \u306E\u5F0F\u3092\u8A55\u4FA1\u3067\u304D\u307E\u305B\u3093: ${err.message}`)}}function renderOutput(value,format,noRedact=false){if(noRedact)return formatOutput(value,format);return redactSecrets(formatOutput(redactSecretValues(value),format))}var NO_REDACT_FLAG={name:"--no-redact",summary:"\u5FDC\u7B54\u306E\u4F0F\u5B57\u5316\u3092\u89E3\u9664\u3057\u3066\u751F\u306E\u5024\u3092\u51FA\u3059\uFF08\u9375\u306E\u53D7\u3051\u53D6\u308A\u7B49\uFF09",takesValue:false};var NO_REDACT_NOTICE="\u6CE8\u8A18: --no-redact \u306E\u305F\u3081\u51FA\u529B\u3092\u4F0F\u5B57\u5316\u3057\u307E\u305B\u3093\uFF08\u7AEF\u672B\u3068\u30ED\u30B0\u306B\u5E73\u6587\u3067\u6B8B\u308A\u307E\u3059\uFF09\u3002";function withCommonFlags(flags){return flags.some(flag=>flag.
|
|
20
|
+
name===NO_REDACT_FLAG.name)?flags:[...flags,NO_REDACT_FLAG]}function alignedList(entries,indent=" "){const width=entries.reduce((max,[left])=>Math.max(max,stringWidth(left)),0);return entries.map(([left,right])=>`${indent}${left}${" ".repeat(Math.max(0,width-stringWidth(left)))} ${right}`).join("\n")}function subresourcesOf(resource){return resource.subresources??[]}function renderResourceHelp(resource,path2){const subresources=subresourcesOf(resource);const operationSection=resource.operations.length===0?"":`
|
|
20
21
|
\u64CD\u4F5C:
|
|
21
22
|
${alignedList(resource.operations.map(op=>[op.name,op.summary]))}
|
|
22
23
|
`;const subSection=subresources.length===0?"":`
|
|
@@ -29,14 +30,14 @@ ${alignedList(subresources.map(sub=>[`${sub.name} <\u64CD\u4F5C>`,sub.summary]))
|
|
|
29
30
|
twp ${path2} <\u64CD\u4F5C> ${HELP_TOKEN} \u305D\u306E\u64CD\u4F5C\u306E\u8A73\u3057\u3044\u30D8\u30EB\u30D7
|
|
30
31
|
${operationSection}${subSection}
|
|
31
32
|
${GLOBAL_OPTIONS_HELP}
|
|
32
|
-
`}function renderOperationHelp(op,path2){const sections=[`twp ${path2} ${op.name} \u2014 ${op.summary}`,"","\u4F7F\u3044\u65B9:",` ${op.usage}`];if(op.description!==void 0){sections.push("",...op.description.split("\n"))}if(op.destructive===true){sections.push("","\u26A0 \u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002")}
|
|
33
|
-
map(flag=>[flag.takesValue?`${flag.name} ${flag.placeholder??"<\u5024>"}`:flag.name,flag.summary])))}sections.push("",GLOBAL_OPTIONS_HELP,"");return sections.join("\n")}function renderUnknownOperation(resource,path2,attempted){const names=[...resource.operations.map(op=>op.name),...subresourcesOf(resource).map(sub=>`${sub.name} <\u64CD\u4F5C>`)].join(" / ");return attempted===void 0?`twp ${path2} \u306B\u306F\u64CD\u4F5C\u306E\u6307\u5B9A\u304C\u5FC5\u8981\u3067\u3059\uFF08${names}\
|
|
34
|
-
${HELP_TOKEN}`:`twp ${path2} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`}var LOADERS={backlog:async()=>(await import("./backlog-NV7Z76R3.js")).backlogDomain,project:async()=>(await import("./project-BATJQR3F.js")).projectDomain,task:async()=>(await import("./task-6QUH5OXF.js")).taskDomain};async function loadDomain(name){return LOADERS[name]()}var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
|
|
33
|
+
`}function renderOperationHelp(op,path2){const sections=[`twp ${path2} ${op.name} \u2014 ${op.summary}`,"","\u4F7F\u3044\u65B9:",` ${op.usage}`];if(op.description!==void 0){sections.push("",...op.description.split("\n"))}if(op.destructive===true){sections.push("","\u26A0 \u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u304C\u5FC5\u8981\u3067\u3059\u3002")}const flags=withCommonFlags(op.flags);if(flags.length>0){sections.push("","\u30AA\u30D7\u30B7\u30E7\u30F3:",
|
|
34
|
+
alignedList(flags.map(flag=>[flag.takesValue?`${flag.name} ${flag.placeholder??"<\u5024>"}`:flag.name,flag.summary])))}sections.push("",GLOBAL_OPTIONS_HELP,"");return sections.join("\n")}function renderUnknownOperation(resource,path2,attempted){const names=[...resource.operations.map(op=>op.name),...subresourcesOf(resource).map(sub=>`${sub.name} <\u64CD\u4F5C>`)].join(" / ");return attempted===void 0?`twp ${path2} \u306B\u306F\u64CD\u4F5C\u306E\u6307\u5B9A\u304C\u5FC5\u8981\u3067\u3059\uFF08${names}\
|
|
35
|
+
\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`:`twp ${path2} \u306B\u300C${attempted}\u300D\u3068\u3044\u3046\u64CD\u4F5C\u306F\u3042\u308A\u307E\u305B\u3093\uFF08${names}\uFF09\u3002\u8A73\u3057\u304F\u306F twp ${path2} ${HELP_TOKEN}`}var LOADERS={backlog:async()=>(await import("./backlog-NV7Z76R3.js")).backlogDomain,project:async()=>(await import("./project-BATJQR3F.js")).projectDomain,task:async()=>(await import("./task-6QUH5OXF.js")).taskDomain};async function loadDomain(name){return LOADERS[name]()}var writeOut=text=>void process.stdout.write(text);var writeErr=text=>void process.stderr.write(text);function line(text){return text===""?"":text.endsWith("\n")?text:`${text}
|
|
35
36
|
`}function outputValue(operation,format,body){return format==="json"?operation.raw(body):operation.summarize(body)}function requiresYes(operation,yes){return operation.destructive===true&&!yes}function exitCodeForStatus(status){if(status===401)return EXIT_AUTH;if(status===429)return EXIT_API_SERVER;if(status>=400&&status<500)return EXIT_API_CLIENT;return EXIT_API_SERVER}function exitCodeFor(err){if(err instanceof UsageError)return EXIT_USAGE;if(err instanceof NotLoggedInError||err instanceof SessionExpiredError)
|
|
36
|
-
return EXIT_AUTH;if(err instanceof ApiError)return exitCodeForStatus(err.status);if(err instanceof ApiResponseError||err instanceof NetworkError)return EXIT_API_SERVER;if(err instanceof ResolveError){return err.status===null?EXIT_API_SERVER:exitCodeForStatus(err.status)}return EXIT_FAILURE}function safeText(text){return redactSecrets(stripTerminalControls(text))}function reportError(err,format,code){const message=safeText(err instanceof Error?err.message:String(err));const rawHint=err instanceof
|
|
37
|
-
UsageError?err.hint:void 0;const hint=rawHint!==void 0?safeText(rawHint):void 0;if(format==="json"){const body={code,message};if(err instanceof ApiError)body["status"]=err.status;if(err instanceof ResolveError&&err.status!==null)body["status"]=err.status;if(hint!==void 0)body["hint"]=hint;
|
|
38
|
-
`);return}
|
|
39
|
-
`);if(hint!==void 0)
|
|
37
|
+
return EXIT_AUTH;if(err instanceof ApiError)return exitCodeForStatus(err.status);if(err instanceof ApiResponseError||err instanceof NetworkError)return EXIT_API_SERVER;if(err instanceof ResolveError){return err.status===null?EXIT_API_SERVER:exitCodeForStatus(err.status)}return EXIT_FAILURE}function safeText(text){return redactSecrets(stripTerminalControls(text))}function reportError(err,format,code,write=writeErr){const message=safeText(err instanceof Error?err.message:String(err));const rawHint=err instanceof
|
|
38
|
+
UsageError?err.hint:void 0;const hint=rawHint!==void 0?safeText(rawHint):void 0;if(format==="json"){const body={code,message};if(err instanceof ApiError)body["status"]=err.status;if(err instanceof ResolveError&&err.status!==null)body["status"]=err.status;if(hint!==void 0)body["hint"]=hint;write(`${JSON.stringify({error:body},null,2)}
|
|
39
|
+
`);return}write(`${message}
|
|
40
|
+
`);if(hint!==void 0)write(`${hint}
|
|
40
41
|
`)}function dryRunValue(apiUrl,plan){const value={method:plan.method,url:`${apiUrl}${appendQuery(plan.path,plan.query)}`};if(plan.body!==void 0)value["body"]=plan.body;return value}async function send(client,apiUrl,plan){try{return await client.request(plan.method,appendQuery(plan.path,plan.query),plan.body)}catch(err){if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof SessionExpiredError){throw err}throw new NetworkError(`${apiUrl} \u3078\u306E\u901A\u4FE1\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.
|
|
41
42
|
message}`,{cause:err})}}async function putSigned(fetchImpl,url,bytes,contentType){let res;try{res=await fetchImpl(url,{method:"PUT",headers:{"Content-Type":contentType},body:bytes})}catch(err){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${err.message}`,{cause:err})}if(!res.ok){throw new NetworkError(`\u30B9\u30C8\u30EC\u30FC\u30B8\u3078\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u304C\u62D2\u5426\u3055\u308C\u307E\u3057\u305F\uFF08HTTP ${res.
|
|
42
43
|
status}\uFF09`)}}function resolveDownloadTarget(spec,commandPath,operationName,input){const raw=input.flags.get(spec.outFlag);if(raw===void 0||raw.trim()===""){throw new UsageError(`${spec.outFlag} \u306F\u5FC5\u9808\u3067\u3059\uFF08twp ${commandPath} ${operationName}\uFF09`,`\u66F8\u304D\u51FA\u3057\u5148\u306E\u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6A19\u6E96\u51FA\u529B\u3078\u306F\u51FA\u3057\u307E\u305B\u3093\uFF09\u3002`)}return{out:path.
|
|
@@ -46,21 +47,23 @@ if(err instanceof ApiError||err instanceof NotLoggedInError||err instanceof Sess
|
|
|
46
47
|
\u3059\u308B\u306A\u3089 --force \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002")}throw new Error(`\u66F8\u304D\u51FA\u3057\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${args.target.out}\uFF09: ${err.message}`,{cause:err})}return{path:args.target.out,size:received.bytes.byteLength,contentType:received.contentType}}var CURATED_PAGING_VOCABULARY={mode:"--all",resumeFlag:"--cursor",capAdvice:"--limit \u3092\u5927\u304D\u304F\u3057\u3066\u5F80\u5FA9\u3092\u6E1B\u3089\u3059\u304B\u3001--max-pages / --max-items \u3092\u4E0A\u3052\u3066\u304F\u3060\u3055\u3044\u3002"};
|
|
47
48
|
function capExceeded(vocabulary,reason,pages,count,cursor){return new UsageError(`${vocabulary.mode} \u304C\u4E0A\u9650\u306B\u9054\u3057\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\uFF08${reason}\uFF0F${pages} \u30DA\u30FC\u30B8\u30FB${count} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`,`${vocabulary.capAdvice}\u7D9A\u304D\u3060\u3051\u3092\u53D6\u308B\u306A\u3089 ${vocabulary.resumeFlag} ${shellQuote(cursor)}\
|
|
48
49
|
\u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059`)}async function fetchAllPages(args){const{paging,maxPages,maxItems}=args;const vocabulary=args.vocabulary??CURATED_PAGING_VOCABULARY;const merged=[];const first=args.plan.query?.[paging.cursorParam];let sent=typeof first==="string"?first:"";for(let page=1;;page+=1){const plan=page===1?args.plan:{...args.plan,query:{...args.plan.query,[paging.cursorParam]:sent}};let body;try{body=page===1&&"firstPage"in args?args.firstPage:await send(args.client,
|
|
49
|
-
args.apiUrl,plan)}catch(err){if(page>1){writeErr(`${vocabulary.mode} \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-1} \u30DA\u30FC\u30B8\u30FB${merged.length} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F ${vocabulary.resumeFlag} ${shellQuote(stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
|
|
50
|
+
args.apiUrl,plan)}catch(err){if(page>1){(args.warn??writeErr)(`${vocabulary.mode} \u306F ${page} \u30DA\u30FC\u30B8\u76EE\u3067\u5931\u6557\u3057\u307E\u3057\u305F\uFF08${page-1} \u30DA\u30FC\u30B8\u30FB${merged.length} \u4EF6\u3092\u53D6\u5F97\u6E08\u307F\uFF09\u3002\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7D9A\u304D\u306F ${vocabulary.resumeFlag} ${shellQuote(stripTerminalControls(sent))} \u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002
|
|
50
51
|
`)}throw err}for(const item of paging.items(body))merged.push(item);const next=paging.nextCursor(body);if(next===null)return{body:paging.withItems(body,merged),pages:page,count:merged.length};if(merged.length>=maxItems)throw capExceeded(vocabulary,`\u6700\u5927\u4EF6\u6570 ${maxItems} \u4EF6`,page,merged.length,next);if(page>=maxPages)throw capExceeded(vocabulary,`\u6700\u5927\u30DA\u30FC\u30B8\u6570 ${maxPages}`,page,merged.length,next);if(next===sent){throw new ApiResponseError(`\u540C\u3058\u30AB\u30FC\u30BD\u30EB\uFF08${next}\
|
|
51
52
|
\uFF09\u304C\u7E70\u308A\u8FD4\u3057\u8FD4\u3055\u308C\u305F\u305F\u3081\u4E2D\u65AD\u3057\u307E\u3057\u305F\u3002${merged.length} \u4EF6\u3092\u53D6\u5F97\u3057\u305F\u6642\u70B9\u3067\u3001\u3053\u308C\u306F\u5168\u4EF6\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`)}sent=next}}function resolvePaging(operation,path2,input){const all=input.flags.has("--all");const maxPages=positiveInteger(input.flags,"--max-pages")??DEFAULT_MAX_PAGES;const maxItems=positiveInteger(input.flags,"--max-items")??
|
|
52
53
|
DEFAULT_MAX_ITEMS;positiveInteger(input.flags,"--limit");if(all&&operation.paging===void 0){throw new UsageError(`twp ${path2} ${operation.name} \u306F --all \u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093`)}for(const name of["--max-pages","--max-items"]){if(!all&&input.flags.has(name)){throw new UsageError(`${name} \u306F --all \u3068\u4F75\u305B\u3066\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`,`${name} \u3060\u3051\u3067\u306F\u4F55\u3082\u5909\u308F\u308A\u307E\u305B\u3093`)}}return{
|
|
53
54
|
all,maxPages,maxItems}}function profileAliases(profileName){const aliases=loadUserConfig().profiles?.[profileName]?.aliases;return aliases!==void 0?{aliases}:{}}function buildPrepareContext(args){const cache=new Map;return{resolver:args.resolver,projectId(explicit){if(explicit!==void 0&&explicit.trim()===""){throw new UsageError("--project \u306B\u7A7A\u306E\u5024\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093","--project <\u30B3\u30FC\u30C9|ID> \u3092\u6307\u5B9A\u3059\u308B\u304B\u3001--project \u3054\u3068\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}
|
|
54
|
-
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.
|
|
55
|
-
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.
|
|
56
|
-
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))}
|
|
57
|
-
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)){
|
|
58
|
-
const input=parseOperationArgs(rest,operation.flags);if(!globals.dryRun&&requiresYes(operation,globals.yes)){throw new UsageError(`twp ${path2} ${operation.name} \u306F\u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`)}const paging=resolvePaging(operation,path2,input);
|
|
59
|
-
profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??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 ctx=buildPrepareContext(
|
|
60
|
-
cwd:process.cwd()});const prepared=operation.prepare===void 0?input:await operation.prepare(input,ctx);const plan=operation.plan(prepared);if(operation.execute!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: execute \u306F download / paging /
|
|
61
|
-
(operation.download!==void 0||operation.paging!==void 0||operation.destructive===true||plan.method!=="GET")){throw new Error(`twp ${path2} ${operation.name}: fetchCached \u306F\u9001\u4FE1\u3057\u306A\u3044\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}
|
|
62
|
-
|
|
63
|
-
`)
|
|
64
|
-
|
|
65
|
-
`)}
|
|
66
|
-
|
|
55
|
+
const ref=requireDefaultProject(explicit,args.profileName,args.env,args.cwd).ref;const hit=cache.get(ref);if(hit!==void 0)return hit;const resolved=args.resolver.project(ref).then(project=>project.id);cache.set(ref,resolved);return resolved}}}async function runDomain(options){const{globals}=options;const out=options.io?.out??writeOut;const errOut=options.io?.err??writeErr;let format=null;try{const profile=resolveProfile(globals.profile);format=resolveOutputFormat({...globals.output!==void 0?{flag:globals.
|
|
56
|
+
output}:{},...(()=>{const configured=resolveConfiguredOutput(profile.name);return configured!==void 0?{configured}:{}})(),isTty:options.io?.isTty??process.stdout.isTTY===true});if(format===null){throw new UsageError(`--output \u306B\u300C${globals.output??""}\u300D\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093`,`\u6307\u5B9A\u3067\u304D\u308B\u306E\u306F ${OUTPUT_FORMATS.join(" / ")} \u3067\u3059`)}const domain=await loadDomain(options.domain);if(options.operation===HELP_TOKEN||options.help&&options.
|
|
57
|
+
operation===void 0){const[extra,...rest2]=options.argv;if(extra===void 0){out(renderResourceHelp(domain,domain.name));return EXIT_OK}const target=domain.subresources?.find(resource2=>resource2.name===extra);if(target===void 0||rest2.length>0){throw new UsageError(renderUnknownOperation(domain,domain.name,extra))}out(renderResourceHelp(target,`${domain.name} ${extra}`));return EXIT_OK}const sub=domain.subresources?.find(resource2=>resource2.name===options.operation);const resource=sub??domain;const path2=sub===
|
|
58
|
+
void 0?domain.name:`${domain.name} ${sub.name}`;const operationName=sub===void 0?options.operation:options.argv[0];const rest=sub===void 0?options.argv:options.argv.slice(1);if(sub!==void 0&&(operationName===HELP_TOKEN||options.help&&operationName===void 0)){out(renderResourceHelp(sub,path2));return EXIT_OK}const operation=resource.operations.find(op=>op.name===operationName);if(operation===void 0){throw new UsageError(renderUnknownOperation(resource,path2,operationName))}if(options.help||rest[0]===
|
|
59
|
+
HELP_TOKEN){out(renderOperationHelp(operation,path2));return EXIT_OK}const input=parseOperationArgs(rest,withCommonFlags(operation.flags));const noRedact=input.flags.has("--no-redact");if(!globals.dryRun&&requiresYes(operation,globals.yes)){throw new UsageError(`twp ${path2} ${operation.name} \u306F\u7834\u58CA\u7684\u306A\u64CD\u4F5C\u3067\u3059\u3002\u5B9F\u884C\u3059\u308B\u306B\u306F --yes \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\u3002`)}const paging=resolvePaging(operation,path2,input);
|
|
60
|
+
const downloadTarget=operation.download===void 0?void 0:resolveDownloadTarget(operation.download,path2,operation.name,input);const stored=loadCredentials(profile.name);const apiUrl=effectiveApiUrl(profile,stored?.api_url);const transport=options.fetchImpl??httpFetch;const fetchImpl=globals.debug?withDebug(transport,{write:errOut}):transport;const session=new AuthSession(profile.name,apiUrl,process.env,fetchImpl);const client=new TwpApiClient(apiUrl,session,fetchImpl,options.version);const ctx=buildPrepareContext(
|
|
61
|
+
{resolver:new Resolver(client,{profile:profile.name,refresh:globals.refresh,...profileAliases(profile.name)}),profileName:profile.name,env:process.env,cwd:process.cwd()});const prepared=operation.prepare===void 0?input:await operation.prepare(input,ctx);const plan=operation.plan(prepared);if(operation.execute!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.fetchCached!==void 0)){throw new Error(`twp ${path2} ${operation.name}: execute \u306F download / paging / fetchCache\
|
|
62
|
+
d \u3068\u540C\u6642\u306B\u5BA3\u8A00\u3067\u304D\u307E\u305B\u3093\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}if(operation.fetchCached!==void 0&&(operation.download!==void 0||operation.paging!==void 0||operation.destructive===true||plan.method!=="GET")){throw new Error(`twp ${path2} ${operation.name}: fetchCached \u306F\u9001\u4FE1\u3057\u306A\u3044\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u64CD\u4F5C\u306B\u3060\u3051\u5BA3\u8A00\u3067\u304D\u307E\u3059\uFF08\u914D\u7DDA\u306E\u8AA4\u308A\uFF09`)}
|
|
63
|
+
for(const note of operation.plannedNotes?.(prepared)??[])errOut(`${safeText(note)}
|
|
64
|
+
`);if(noRedact)errOut(`${NO_REDACT_NOTICE}
|
|
65
|
+
`);if(globals.dryRun){out(line(renderOutput(dryRunValue(apiUrl,plan),format,noRedact)));return EXIT_OK}let body;let paged;if(operation.execute!==void 0){const executeCtx={send:next=>send(client,apiUrl,next),putSigned:(url,bytes,contentType)=>putSigned(fetchImpl,url,bytes,contentType),warn:text=>errOut(`${safeText(text)}
|
|
66
|
+
`)};body=await operation.execute(prepared,executeCtx)}else if(operation.fetchCached!==void 0){body=await operation.fetchCached(prepared,ctx)}else if(operation.download!==void 0&&downloadTarget!==void 0){assertWritableTarget(downloadTarget,operation.download.forceFlag);body=await download({client,apiUrl,plan,target:downloadTarget})}else if(paging.all&&operation.paging!==void 0){paged=await fetchAllPages({client,apiUrl,plan,paging:operation.paging,maxPages:paging.maxPages,maxItems:paging.maxItems,
|
|
67
|
+
warn:errOut});body=paged.body}else{body=await send(client,apiUrl,plan)}const visible=noRedact?body:redactSecretValues(body);const value=globals.query!==void 0?await evaluateQuery(globals.query,operation.raw(visible)):outputValue(operation,format,visible);out(line(renderOutput(value,format,noRedact)));if(paged!==void 0){errOut(`--all: ${paged.pages} \u30DA\u30FC\u30B8\u3092\u8FBF\u3063\u3066 ${paged.count} \u4EF6\u3092\u53D6\u5F97\u3057\u307E\u3057\u305F\u3002
|
|
68
|
+
`)}const pagingNotes=operation.paging===void 0?[]:nextPageNotes(body,prepared,{command:`twp ${path2} ${operation.name}`,flags:operation.flags,profile:globals.profile});for(const note of[...pagingNotes,...operation.notes?.(visible,prepared)??[]]){errOut(`${safeText(note)}
|
|
69
|
+
`)}return EXIT_OK}catch(err){const code=exitCodeFor(err);reportError(err,format,code,errOut);return code}}export{redactSecretValues,withDebug,OUTPUT_FORMATS,resolveOutputFormat,evaluateQuery,renderOutput,NO_REDACT_FLAG,NO_REDACT_NOTICE,outputValue,requiresYes,exitCodeFor,reportError,CURATED_PAGING_VOCABULARY,fetchAllPages,resolvePaging,buildPrepareContext,runDomain};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
3
|
+
var GLOBAL_OPTIONS_HELP=`\u30B0\u30ED\u30FC\u30D0\u30EB\u30AA\u30D7\u30B7\u30E7\u30F3\uFF08\u30C9\u30E1\u30A4\u30F3\u30B3\u30DE\u30F3\u30C9\u5171\u901A\uFF09:
|
|
4
4
|
--profile <\u540D\u524D> \u63A5\u7D9A\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\uFF08\u30C6\u30CA\u30F3\u30C8\uFF09\u3092\u6307\u5B9A\uFF08TWP_PROFILE \u3067\u3082\u53EF\uFF09
|
|
5
5
|
--output <\u5F62\u5F0F> json | table | text | tsv
|
|
6
6
|
\u65E2\u5B9A\u306F\u7AEF\u672B\u306A\u3089 table\u3001\u30D1\u30A4\u30D7\u306A\u3089 json
|
|
@@ -39,4 +39,4 @@ var DOMAIN_NAMES=["backlog","project","task"];function isDomainName(value){retur
|
|
|
39
39
|
\u5B9F\u4F53\u304C\u8907\u6570\u3042\u308B\u64CD\u4F5C\u3067\u306F\u4E3B\u305F\u308B\u5B9F\u4F53\u3060\u3051\u3092\u51FA\u3057\u307E\u3059\uFF08task update \u306E changes \u306F\u51FA\u307E\u305B\u3093\u3002
|
|
40
40
|
task delete / task comment delete \u306F result \u3068 message \u3060\u3051\u3067\u3059\uFF09\u3002
|
|
41
41
|
table / text / tsv \u306F\u4EBA\u304C\u8AAD\u3080\u305F\u3081\u306B\u9078\u3093\u3060\u8981\u7D04\u5217\u3067\u30013\u5F62\u5F0F\u3068\u3082\u540C\u3058\u5217\u3067\u3059\u3002
|
|
42
|
-
\u3053\u306E\u5217\u306F\u5951\u7D04\u3067\u306F\u306A\u304F\u4E88\u544A\u306A\u304F\u5909\u308F\u308A\u307E\u3059\u3002\u6A5F\u68B0\u51E6\u7406\u306F --output json \u304B --query \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`;export{
|
|
42
|
+
\u3053\u306E\u5217\u306F\u5951\u7D04\u3067\u306F\u306A\u304F\u4E88\u544A\u306A\u304F\u5909\u308F\u308A\u307E\u3059\u3002\u6A5F\u68B0\u51E6\u7406\u306F --output json \u304B --query \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`;export{GLOBAL_OPTIONS_HELP};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{isBoolishTrue}from"./chunk-5WGOHFAS.js";import{spawnSync as spawnSync2}from"child_process";import{spawnSync}from"child_process";import fs from"fs";import path from"path";function resolveDeps(d){return{platform:d.platform??process.platform,env:d.env??process.env,findExecutable:d.findExecutable??((name,env,platform)=>findExecutable(name,{env,platform})),readFileSync:d.readFileSync??(p=>fs.readFileSync(p,"utf8")),existsSync:d.existsSync??fs.existsSync,sizeOf:d.sizeOf??(p=>fs.statSync(p).size),nodePath:d.nodePath??process.execPath}}var MAX_SHIM_BYTES=64*1024;var DENIED_NODE_FLAGS=["--require","-r","--import","--loader","--experimental-loader","--env-file","--eval","\
|
|
4
|
+
-e","--print","-p","--inspect"];function deniedNodeFlag(arg){const name=arg.split("=")[0]??arg;if(name.startsWith("--inspect"))return true;return DENIED_NODE_FLAGS.includes(name)}function escapeRegExp(v){return v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function parseCmdShim(text){const paths=[];const re=/"%~?dp0%?[\\/]*([^"]+)"/gi;for(let m=re.exec(text);m!==null;m=re.exec(text))paths.push(m[1]??"");for(const script of paths.filter(v=>/\.[cm]?js$/i.test(v))){const esc=escapeRegExp(script);const adjacent=new RegExp(
|
|
5
|
+
`"%_prog%"([^"]*)"%~?dp0%?[\\\\/]*${esc}"`,"i").exec(text)??new RegExp(`"%~?dp0%?[\\\\/]*node\\.exe"([^"]*)"%~?dp0%?[\\\\/]*${esc}"`,"i").exec(text);if(adjacent===null)continue;const middle=adjacent[1]??"";return{target:script,viaNode:true,nodeArgs:middle.trim().split(/\s+/).filter(a=>a!=="")}}const exe=paths.find(v=>/\.(exe|com)$/i.test(v)&&!/(^|[\\/])node\.exe$/i.test(v));if(exe!==void 0)return{target:exe,viaNode:false,nodeArgs:[]};return null}function resolveSpawnTarget(file,args,deps={}){const d=resolveDeps(
|
|
6
|
+
deps);if(d.platform!=="win32")return{ok:true,file,args:[...args],note:null};const hasSeparator=/[\\/]/.test(file);const isAbsolute=isWindowsDriveAbsolute(file);if(hasSeparator&&!isAbsolute){return{ok:false,reason:`${file} \u306F\u76F8\u5BFE\u30D1\u30B9\u3067\u3059\u3002bare name \u304B\u7D76\u5BFE\u30D1\u30B9\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`}}const resolved=isAbsolute?file:d.findExecutable(file,d.env,d.platform);if(resolved===null||resolved===""){return{ok:false,reason:`${file}\
|
|
7
|
+
\u304C PATH \u4E0A\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08PATHEXT \u306E\u62E1\u5F35\u5B50\u3082\u542B\u3081\u3066\u63A2\u3057\u307E\u3057\u305F\uFF09`}}const describe=to=>file===to?null:`${file} \u2192 ${to}`;const ext=path.win32.extname(resolved).toLowerCase();if(ext===".exe"||ext===".com"){return{ok:true,file:resolved,args:[...args],note:describe(resolved)}}if(ext!==".cmd"&&ext!==".bat"){return{ok:false,reason:`${resolved} \u306F Windows \u306E spawn \u3067\u8D77\u52D5\u3067\u304D\u306A\u3044\u5F62\u3067\u3059\uFF08\u62E1\u5F35\u5B50 ${ext===
|
|
8
|
+
""?"\u306A\u3057":ext}\uFF09\u3002native \u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\uFF08.exe\uFF09\u304B npm \u30B0\u30ED\u30FC\u30D0\u30EB\uFF08.cmd\uFF09\u3067\u5165\u308C\u76F4\u3057\u3066\u304F\u3060\u3055\u3044`}}let text;try{const size=d.sizeOf(resolved);if(size>MAX_SHIM_BYTES){return{ok:false,reason:`${resolved} \u304C\u5927\u304D\u3059\u304E\u307E\u3059\uFF08${size} \u30D0\u30A4\u30C8\uFF09\u3002npm \u306E cmd \u30B7\u30E0\u3067\u306F\u3042\u308A\u307E\u305B\u3093`}}text=d.readFileSync(resolved)}catch(e){
|
|
9
|
+
return{ok:false,reason:`${resolved} \u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F: ${e.message}`}}const shim=parseCmdShim(text);if(shim===null){return{ok:false,reason:`${resolved} \u306F npm \u306E cmd \u30B7\u30E0\u306E\u5F62\u3067\u306F\u306A\u3044\u305F\u3081\u3001\u5B9F\u4F53\u3092\u7279\u5B9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002cmd.exe \u7D4C\u7531\u306E\u8D77\u52D5\u306F\u5F15\u6570\u3092\u6700\u521D\u306E\u6539\u884C\u3067\u5207\u308A\u6368\u3066\u308B\u305F\u3081\u4F7F\u3044\u307E\u305B\u3093\u3002native \u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\uFF08.exe\uFF09\u3067\u5165\u308C\u76F4\u3059\u304B\u3001npm \u3067\u30B0\u30ED\u30FC\u30D0\u30EB\u306B\u5165\u308C\u76F4\u3057\u3066\u304F\u3060\u3055\u3044`}}
|
|
10
|
+
const dir=path.win32.dirname(resolved);if(path.win32.isAbsolute(shim.target)||/^[\\/]{2}/.test(shim.target)){return{ok:false,reason:`${resolved} \u304C\u7D76\u5BFE\u30D1\u30B9\uFF08${shim.target}\uFF09\u3092\u6307\u3057\u3066\u3044\u307E\u3059\u3002npm \u306E cmd \u30B7\u30E0\u3067\u306F\u3042\u308A\u307E\u305B\u3093`}}const target=path.win32.resolve(dir,shim.target);if(!d.existsSync(target)){return{ok:false,reason:`${resolved} \u304C\u6307\u3059 ${target} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08\u5C0E\u5165\u304C\u58CA\u308C\u3066\u3044\u307E\u3059\uFF09`}}
|
|
11
|
+
if(!shim.viaNode){return{ok:true,file:target,args:[...args],note:`${file} \u2192 ${resolved} \u2192 ${target}`}}const bad=shim.nodeArgs.filter(a=>!a.startsWith("-")||deniedNodeFlag(a));if(bad.length>0){return{ok:false,reason:`${resolved} \u304C node \u3078\u6E21\u305D\u3046\u3068\u3057\u3066\u3044\u308B\u5F15\u6570\u3092\u8A31\u53EF\u3067\u304D\u307E\u305B\u3093\uFF08${bad.join(" ")}\uFF09`}}const colocated=path.win32.join(dir,"node.exe");const prog=d.existsSync(colocated)?colocated:d.nodePath;return{
|
|
12
|
+
ok:true,file:prog,args:[...shim.nodeArgs,target,...args],note:`${file} \u2192 ${resolved}\uFF08cmd \u30B7\u30E0\u3092\u89E3\u6C7A: ${prog} ${target}\uFF09`}}function spawnSyncResolved(file,args,options,deps={},run=spawnSync){const target=resolveSpawnTarget(file,args,deps);if(!target.ok){return{pid:0,output:[],stdout:"",stderr:"",status:null,signal:null,error:new Error(target.reason)}}return run(target.file,target.args,options)}var DEFAULT_CLAUDE_LAUNCHER={bin:"claude-auto-switch",probe:["--help"],probeMatch:"^\\s*exec\\s",execArgs:["exec","--"],activeArgs:["active","--path"]};function detectClaudeAutoSwitch(bin=DEFAULT_CLAUDE_LAUNCHER.bin,run=spawnSync2,lookup={}){const r=spawnSyncResolved(bin,[...DEFAULT_CLAUDE_LAUNCHER.probe],{encoding:"utf8",timeout:1e4},lookup,run);if(r.error!==void 0||r.status!==0)return null;const help=`${r.stdout??""}${r.stderr??""}`;return{bin,hasExec:new RegExp(DEFAULT_CLAUDE_LAUNCHER.probeMatch,
|
|
13
|
+
"m").test(help)}}function wrapWithAutoSwitch(cas,file,args){if(cas===null||!cas.hasExec)return{file,args:[...args]};return{file:cas.bin,args:[...DEFAULT_CLAUDE_LAUNCHER.execArgs,file,...args]}}function activeSlotPath(cas,run=spawnSync2,lookup={}){if(cas===null)return null;const r=spawnSyncResolved(cas.bin,[...DEFAULT_CLAUDE_LAUNCHER.activeArgs],{encoding:"utf8",timeout:1e4},lookup,run);if(r.error!==void 0||r.status!==0)return null;const out=(r.stdout??"").trim();return out===""?null:out}function isClaudeAi(ai){
|
|
14
|
+
return ai==="claude"||!["gemini","codex","copilot"].includes(ai)}import{createHash}from"crypto";import fs2 from"fs";var EXCLUSIVE_SKILL_FLOOR=["support-triage"];function normalizeSkillName(skill){return skill.trim().replace(/^twp-/,"")}var stripPrefix=normalizeSkillName;function skillOfItem(item){const explicit=(item.ai_skill??"").trim();if(explicit)return stripPrefix(explicit);const m=/\/twp-([a-z0-9-]+)/.exec(item.prompt??"");return m?.[1]??""}function ageMinutesOf(item,now){for(const raw of[item.started_at,item.updated_at,item.dequeued_at,item.created_at]){if(!raw)continue;const ts=Date.parse(raw);if(Number.
|
|
15
|
+
isNaN(ts))continue;return Math.floor((now.getTime()-ts)/6e4)}return null}function exclusiveInflightEntries(groups,opts){const now=opts.now??new Date;const staleMinutes=opts.staleHours*60;const bySkill=new Map;for(const group of groups){for(const item of group.items){const skill=skillOfItem(item);if(!skill)continue;const status=group.status==="mixed"?item.status??"unknown":group.status;const ageMinutes=ageMinutesOf(item,now);if(status==="processing"&&ageMinutes!==null&&ageMinutes>staleMinutes)continue;
|
|
16
|
+
const entry={skill,status,runner:item.runner_id??"-",ageMinutes};const prev=bySkill.get(skill);if(!prev||(entry.ageMinutes??-1)>(prev.ageMinutes??-1))bySkill.set(skill,entry)}}return[...bySkill.values()].sort((a,b)=>a.skill.localeCompare(b.skill))}function formatExclusiveEntry(entry){const age=entry.ageMinutes===null?"\u4E0D\u660E":`${entry.ageMinutes}\u5206`;return`${entry.skill} status=${entry.status} runner=${entry.runner} \u7D4C\u904E=${age}`}import path2 from"path";var BUILTIN={primary_rotation:{complex:["claude"],search:["claude"],simple:["claude"]},fallback_chains:{complex:["claude","codex"],search:["codex","gemini","copilot","claude"],simple:["codex","gemini","copilot","claude"]}};function usesBedrock(env){return isBoolishTrue(env.CLAUDE_CODE_USE_BEDROCK)}var DEFAULT_CATEGORY="complex";var EFFORTS=new Set(["low","medium","high","xhigh","max"]);var MAX_COOLDOWN_SEC=3600;var DEFAULT_COOLDOWN_SEC=300;var AI_UNUSABLE_COOLDOWN_SEC=1800;
|
|
17
|
+
function loadAiConfig(inline,file,workspace){const read=readAiConfigFile(file,workspace);const warnings=read.problem===null?[]:[read.problem.startsWith("ai_config_file \u3092\u8AAD\u3081\u307E\u305B\u3093")?`${read.problem}
|
|
18
|
+
\u3053\u306E\u72B6\u614B\u3067\u306F\u5168\u30B9\u30AD\u30EB\u304C\u65E2\u5B9A\u30AB\u30C6\u30B4\u30EA\u3067\u8D70\u308A\u307E\u3059\u3002\u78BA\u8A8D: python3 -m json.tool <file>`:read.problem];return{config:new AiConfig(mergeAiConfig(read.file,inline),read.file),warnings}}function readAiConfigFile(file,workspace){if(file===void 0||file.trim()==="")return{file:null,problem:null};const resolved=path2.isAbsolute(file)?file:path2.resolve(workspace,file);try{const parsed=JSON.parse(fs2.readFileSync(
|
|
19
|
+
resolved,"utf8"));if(parsed===null||typeof parsed!=="object"||Array.isArray(parsed)){return{file:null,problem:`ai_config_file \u304C\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093: ${resolved}`}}return{file:parsed,problem:null}}catch(err){return{file:null,problem:`ai_config_file \u3092\u8AAD\u3081\u307E\u305B\u3093: ${resolved}\uFF08${err.message}\uFF09`}}}function mergeAiConfig(fromFile,inline,server=null){if(server===null)return{...fromFile??{},...inline??{}};const inlineChains=Object.
|
|
20
|
+
fromEntries(Object.entries(inline??{}).filter(([k])=>CHAIN_KEYS.includes(k)));return{...fromFile??{},...inline??{},...server,...inlineChains}}function reloadAiConfig(target,inline,file,workspace,server=null){const hashBefore=target.hash();const read=readAiConfigFile(file,workspace);if(read.file===null){if(read.problem===null){if(server===null)return{status:"skipped",hashBefore,hashAfter:hashBefore,warnings:[]};const changed2=target.replace(mergeAiConfig(null,inline,server));return{status:changed2?
|
|
21
|
+
"updated":"unchanged",hashBefore,hashAfter:target.hash(),warnings:[]}}if(server!==null)target.replace(mergeAiConfig(target.fileLayer,inline,server));return{status:"kept",hashBefore,hashAfter:target.hash(),warnings:[server===null?`${read.problem}
|
|
22
|
+
\u73FE\u5728\u306E\u8A2D\u5B9A\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${hashBefore}\uFF09\u306E\u307E\u307E\u8D70\u308A\u307E\u3059\u3002\u78BA\u8A8D: python3 -m json.tool <file>`:`${read.problem}
|
|
23
|
+
\u6700\u5F8C\u306B\u8AAD\u3081\u305F\u5185\u5BB9\u306B\u30B5\u30FC\u30D0\u5024\u3092\u91CD\u306D\u3066\u8D70\u308A\u307E\u3059\uFF08AI\u5272\u5F53\u30CF\u30C3\u30B7\u30E5 ${target.hash()}\uFF09\u3002\u78BA\u8A8D: python3 -m json.tool <file>`]}}target.setFileLayer(read.file);const changed=target.replace(mergeAiConfig(read.file,inline,server));return{status:changed?"updated":"unchanged",hashBefore,hashAfter:target.hash(),warnings:[]}}function stableJson(value){return JSON.stringify(value,(_key,v)=>v!==
|
|
24
|
+
null&&typeof v==="object"&&!Array.isArray(v)?Object.fromEntries(Object.entries(v).sort(([a],[b])=>a.localeCompare(b))):v)}var CHAIN_KEYS=["primary_rotation","fallback_chains"];var AiConfig=class _AiConfig{rotation=new Map;limitedUntil=new Map;unusableUntil=new Map;highRiskSkills;raw;fileLayerValue;constructor(raw,fileLayer=null){this.raw=raw;this.highRiskSkills=_AiConfig.highRiskSet(raw);this.fileLayerValue=fileLayer}get fileLayer(){return this.fileLayerValue}static highRiskSet(raw){return new Set(
|
|
25
|
+
(raw.high_risk_skills??[]).filter(v=>typeof v==="string"&&v!==""))}setFileLayer(file){this.fileLayerValue=file}replace(next){if(stableJson(next)===stableJson(this.raw))return false;this.raw=next;this.highRiskSkills=_AiConfig.highRiskSet(next);return true}hash(){const significant=Object.fromEntries(Object.entries(this.raw).filter(([k])=>!k.startsWith("_")&&!CHAIN_KEYS.includes(k)).sort(([a],[b])=>a.localeCompare(b)));return createHash("sha256").update(JSON.stringify(significant)).digest("hex").slice(
|
|
26
|
+
0,16)}categoryForSkill(skill){const name=stripPrefix2(skill);return this.raw.skill_category?.[name]??DEFAULT_CATEGORY}usesAi(ai){const rotations=this.raw.primary_rotation??BUILTIN.primary_rotation;const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;const categories=new Set([DEFAULT_CATEGORY,...Object.keys(rotations),...Object.keys(chains),...Object.values(this.raw.skill_category??{})]);const matches=name=>isClaudeAi(ai)?isClaudeAi(name):name===ai;for(const category of categories){const rotation=rotations[category]??
|
|
27
|
+
rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];const chain=chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"];for(const name of[...rotation,...chain]){if(matches(name))return true}}return false}chainFor(category){const chains=this.raw.fallback_chains??BUILTIN.fallback_chains;return chains[category]??chains[DEFAULT_CATEGORY]??BUILTIN.fallback_chains[DEFAULT_CATEGORY]??["claude"]}primaryFor(category,skill){const rotations=this.
|
|
28
|
+
raw.primary_rotation??BUILTIN.primary_rotation;const entries=rotations[category]??rotations[DEFAULT_CATEGORY]??BUILTIN.primary_rotation[DEFAULT_CATEGORY]??[];if(entries.length===0)return"";const start=this.rotation.get(category)??0;for(let i=0;i<entries.length;i+=1){const ai=entries[(start+i)%entries.length];if(ai!==void 0&&this.isAllowed(ai,category,skill)){this.rotation.set(category,(start+i+1)%entries.length);return ai}}return""}isHighRisk(category,skill,priority,label){if(["verify","security",
|
|
29
|
+
"support"].includes(category))return true;if(priority==="P0"||priority==="P0.5")return true;const name=stripPrefix2(skill);if(this.highRiskSkills.has(name))return true;return HIGH_RISK_LABEL.test(label)}selectPrimary(category,skill,priority,label){if(this.isHighRisk(category,skill,priority,label)&&this.chainFor(category).includes("claude")){return"claude"}return this.primaryFor(category,skill)}isAllowed(ai,category,skill){if(ai!=="gemini")return true;if(["complex","verify","security","support"].
|
|
30
|
+
includes(category))return false;return!this.requiresGitRemote(skill)}requiresGitRemote(skill){return(this.raw.git_remote_skills??[]).includes(stripPrefix2(skill))}exclusiveSkills(){const configured=(this.raw.exclusive_skills??[]).map(s=>stripPrefix2((s??"").trim())).filter(s=>s!=="");return new Set([...configured,...EXCLUSIVE_SKILL_FLOOR])}isExclusiveSkill(skill){const name=stripPrefix2(skill.trim());return name!==""&&this.exclusiveSkills().has(name)}modelFor(ai,category,env=process.env){switch(ai){case"\
|
|
31
|
+
gemini":return this.raw.gemini_models?.[category]??"";case"codex":return this.raw.codex_models?.[category]??this.raw.codex_models?.[DEFAULT_CATEGORY]??"";case"claude":return this.claudeModelFor(category,env);default:return isClaudeAi(ai)?this.claudeModelFor(category,env):""}}claudeModelFor(category,env){const table=usesBedrock(env)?this.raw.claude_models_bedrock:this.raw.claude_models;return table?.[category]??env.CLAUDE_MODEL??""}maxTurnsFor(category,env=process.env){const fallback=Number.parseInt(
|
|
32
|
+
env.CLAUDE_MAX_TURNS??"",10);const base=Number.isInteger(fallback)&&fallback>0?fallback:200;const configured=this.raw.claude_max_turns?.[category];return Number.isInteger(configured)&&(configured??0)>0?configured:base}effortFor(category,skill,env=process.env,explicit){const name=stripPrefix2(skill);const item=(explicit??"").trim();if(item!==""&&EFFORTS.has(item))return{value:item,warning:null};const itemWarning=item!==""?`\u4E0D\u6B63\u306A ai_effort '${item}'\uFF08\u30A2\u30A4\u30C6\u30E0\u6307\u5B9A\uFF09\u2192 \u30B9\u30AD\u30EB\uFF0F\u30AB\u30C6\u30B4\u30EA\u65E2\u5B9A\u3092\u4F7F\u3044\u307E\u3059`:
|
|
33
|
+
null;const raw=(name!==""?this.raw.claude_effort_by_skill?.[name]:void 0)??this.raw.claude_effort?.[category]??env.CLAUDE_EFFORT??"";if(raw==="")return{value:"",warning:itemWarning};if(EFFORTS.has(raw))return{value:raw,warning:itemWarning};return{value:"",warning:`\u4E0D\u6B63\u306A effort \u5024 '${raw}'\uFF08category=${category}, skill=${name||"none"}\uFF09\u2192 \u672A\u6307\u5B9A\u3068\u3057\u3066\u6271\u3044\u307E\u3059`}}fallbackDelaySec(ai,env=process.env){const fromEnv=Number.parseInt(env[`\
|
|
34
|
+
AI_FALLBACK_DELAY_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>=0)return fromEnv;const cfg=this.raw.fallback_delay?.[ai];return Number.isInteger(cfg)&&(cfg??0)>=0?cfg:0}cooldownDefaultSec(ai,env=process.env){const fromEnv=Number.parseInt(env[`AI_COOLDOWN_${ai.toUpperCase()}`]??"",10);if(Number.isInteger(fromEnv)&&fromEnv>0)return fromEnv;const cfg=this.raw.cooldown?.[ai];if(Number.isInteger(cfg)&&(cfg??0)>0)return cfg;const backoff=Number.parseInt(env.RATE_LIMIT_BACKOFF??"",
|
|
35
|
+
10);return Number.isInteger(backoff)&&backoff>0?backoff:DEFAULT_COOLDOWN_SEC}limitKey(ai,slot){return slot===null||slot===void 0||slot===""?ai:`${ai}@${slot}`}hasCooldownFor(ai,now=Date.now()){for(const[key,until]of this.limitedUntil){if(until<=now)continue;if(key===ai||key.startsWith(`${ai}@`))return true}return false}isRateLimited(ai,now=Date.now(),slot=null){return(this.limitedUntil.get(this.limitKey(ai,slot))??0)>now}markRateLimited(ai,seconds,now=Date.now(),slot=null){const capped=Math.min(
|
|
36
|
+
Math.max(Math.trunc(seconds),1),MAX_COOLDOWN_SEC);this.limitedUntil.set(this.limitKey(ai,slot),now+capped*1e3);return capped}markAiUnusable(ai,now=Date.now()){this.unusableUntil.set(ai,now+AI_UNUSABLE_COOLDOWN_SEC*1e3);return AI_UNUSABLE_COOLDOWN_SEC}isAiUnusable(ai,now=Date.now()){return(this.unusableUntil.get(ai)??0)>now}minCooldownRemainingSec(now=Date.now()){let min=null;for(const until of this.limitedUntil.values()){if(until<=now)continue;const remaining=Math.ceil((until-now)/1e3);if(min===
|
|
37
|
+
null||remaining<min)min=remaining}return min}};var HIGH_RISK_LABEL=/本番|リリース|認証|認可|権限|セキュリティ|課金|給与|勤怠計算/;var TIER_ALIASES=new Set(["opus","sonnet","haiku","default"]);function modelFitsRoute(model,env=process.env){if(TIER_ALIASES.has(model.trim().toLowerCase()))return true;if(model.startsWith("arn:aws:bedrock:"))return usesBedrock(env);const bedrockShaped=/(^|[./])anthropic\./.test(model);return usesBedrock(env)?bedrockShaped:!bedrockShaped}function isUsableModelId(value){
|
|
38
|
+
return value!==""&&!value.startsWith("-")&&/^[A-Za-z0-9._:\-/[\]]+$/.test(value)}function stripPrefix2(skill){return skill.startsWith("twp-")?skill.slice(4):skill}export{resolveSpawnTarget,spawnSyncResolved,DEFAULT_CLAUDE_LAUNCHER,detectClaudeAutoSwitch,wrapWithAutoSwitch,activeSlotPath,isClaudeAi,normalizeSkillName,skillOfItem,exclusiveInflightEntries,formatExclusiveEntry,usesBedrock,loadAiConfig,reloadAiConfig,CHAIN_KEYS,AiConfig,modelFitsRoute,isUsableModelId};
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
4
|
-
string"?error["message"]:"");if(message)parts.push(message.slice(0,160));if(!reason&&!code&&!message)parts.push(`\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,160)}`);return parts.join(" ")}function isPermanent(res){return res.status!==null&&res.status>=400&&res.status<500}function filterByStatus(items,status){return items.filter(item=>item.status===void 0||item.status===status)}var AgentLoopApi=class{constructor(opts){this.opts=opts;const root=opts.apiUrl.replace(/\/+$/,"");this.base=isPrivateProjectId(
|
|
5
|
-
opts.projectId)?`${root}/api/v2/tasks/private/agent-loop`:`${root}/api/v2/projects/${opts.projectId}/agent-loop`}opts;base;get baseUrl(){return this.base}list(query){const qs=new URLSearchParams;for(const[k,v]of Object.entries(query)){if(v!==void 0&&v!=="")qs.set(k,String(v))}const suffix=qs.toString()?`?${qs.toString()}`:"";return this.request("GET",suffix)}create(body){return this.request("POST","",body)}getItem(itemId){return this.request("GET",`/${encodeURIComponent(itemId)}`)}update(itemId,body,runId){
|
|
6
|
-
return this.request("PUT",`/${encodeURIComponent(itemId)}`,{...body,run_id:runId})}updateUnowned(itemId,body){return this.request("PUT",`/${encodeURIComponent(itemId)}`,body)}reorder(itemIds){return this.request("PUT","/reorder",{item_ids:itemIds})}claim(runnerId,runId){return this.request("POST","/claim",{runner_id:runnerId,run_id:runId})}reclaim(){return this.request("POST","/reclaim",{})}runners(){return this.request("GET","/runners")}registerRunner(payload){return this.request("POST","/runne\
|
|
7
|
-
rs/register",payload)}heartbeatRunner(payload){return this.request("POST","/runners/heartbeat",payload)}deregisterRunner(payload){return this.request("POST","/runners/deregister",payload)}planStart(runnerId,runId){return this.request("POST","/plan/start",{runner_id:runnerId,run_id:runId})}planFinish(runnerId,runId,planStartedAt,result){return this.request("POST","/plan/finish",{runner_id:runnerId,run_id:runId,plan_started_at:planStartedAt,result})}consumeCounter(key,date,limit){return this.request(
|
|
8
|
-
"POST","/counters/consume",{key,date,limit})}listCounters(date){return this.request("GET",`/counters?date=${encodeURIComponent(date)}`)}async queuedSnapshot(){return this.snapshotOf(["pending","processing"])}async processingSnapshot(){return this.snapshotOf(["processing"])}async pendingSnapshot(){return this.snapshotOf(["pending"])}async completedSince(sinceMicros,maxPages=10){const all=[];let cursor=String(Math.trunc(sinceMicros));for(let page=0;page<maxPages;page++){const res=await this.list({
|
|
9
|
-
status:"completed",limit:100,cursor});if(!res.ok)return null;const body=res.json;const items=body?.["items"];if(!Array.isArray(items))return null;all.push(...filterByStatus(items,"completed"));const pagination=body?.["pagination"];const hasMore=(pagination?.["has_more"]??body?.["has_more"])===true;const next=pagination?.["next_cursor"]??body?.["next_cursor"];if(!hasMore||!next)return all;cursor=next}return null}async snapshotOf(statuses){const all=[];for(const status of statuses){let cursor;for(let page=0;page<
|
|
10
|
-
20;page++){const res=await this.list({status,limit:100,cursor});if(!res.ok)return null;const body=res.json;const items=body?.["items"];if(!Array.isArray(items))return null;all.push(...filterByStatus(items,status));const pagination=body?.["pagination"];const hasMore=(pagination?.["has_more"]??body?.["has_more"])===true;const next=pagination?.["next_cursor"]??body?.["next_cursor"];if(!hasMore||!next)break;cursor=next;if(page===19)return null}}return all}async request(method,suffix,body){let token;
|
|
11
|
-
try{token=await this.opts.session.getAccessToken()}catch(err){return{ok:false,status:null,json:null,raw:"",transportError:err.message}}let res=await this.send(method,suffix,token,body);if(res.status===401){try{token=await this.opts.session.refresh(token);res=await this.send(method,suffix,token,body)}catch(err){return{ok:false,status:401,json:null,raw:res.raw,transportError:err.message}}}return res}async send(method,suffix,token,body){const fetchImpl=this.opts.fetchImpl??httpFetch;const controller=new AbortController;
|
|
12
|
-
const timer=setTimeout(()=>controller.abort(),this.opts.timeoutMs??6e4);try{const res=await fetchImpl(`${this.base}${suffix}`,{method,headers:{Authorization:`Bearer ${token}`,"Content-Type":"application/json",Accept:"application/json"},signal:controller.signal,...body===void 0?{}:{body:JSON.stringify(body)}});const raw=await res.text();let json=null;if(raw.trim()!==""){try{json=JSON.parse(raw)}catch{json=null}}return{ok:res.ok,status:res.status,json,raw,transportError:null}}catch(err){const reason=err.
|
|
13
|
-
name==="AbortError"?"timeout":err.message;return{ok:false,status:null,json:null,raw:"",transportError:reason}}finally{clearTimeout(timer)}}};function pick(json,path){let cur=json;for(const part of path.split(".")){if(cur===null||typeof cur!=="object")return void 0;cur=cur[part]}return cur===null?void 0:cur}function pickString(json,path){const v=pick(json,path);if(typeof v==="string")return v;if(typeof v==="number")return String(v);if(typeof v==="boolean")return v?"true":"false";return""}var ScheduleApi=class{constructor(api){this.api=api}api;async definitions(){const res=await this.api.request("GET","/schedules/definitions");if(!res.ok)return fetchError("\u5B9A\u671F\u30B9\u30B1\u30B8\u30E5\u30FC\u30EB\u306E\u5B9A\u7FA9\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093",res);const body=res.json??{};const schedules=body["schedules"];if(!Array.isArray(schedules)){return{kind:"error",message:`\u5B9A\u7FA9\u306E\u5FDC\u7B54\u306B schedules \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.
|
|
3
|
+
import{describeError}from"./chunk-ODLJ2LNQ.js";import{httpFetch}from"./chunk-J7QYPKVK.js";var ScheduleApi=class{constructor(api){this.api=api}api;async definitions(){const res=await this.api.request("GET","/schedules/definitions");if(!res.ok)return fetchError("\u5B9A\u671F\u30B9\u30B1\u30B8\u30E5\u30FC\u30EB\u306E\u5B9A\u7FA9\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093",res);const body=res.json??{};const schedules=body["schedules"];if(!Array.isArray(schedules)){return{kind:"error",message:`\u5B9A\u7FA9\u306E\u5FDC\u7B54\u306B schedules \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.
|
|
14
4
|
raw.slice(0,120)}\uFF09`,status:res.status}}const gates=Array.isArray(body["gates"])?body["gates"]:[];return{kind:"ok",config:{schedules,gates,max_per_cycle:body["max_per_cycle"],warnings:Array.isArray(body["warnings"])?body["warnings"]:[]}}}async history(since){const suffix=since?`/schedules/history?since=${encodeURIComponent(since)}`:"/schedules/history";const res=await this.api.request("GET",suffix);if(!res.ok)return fetchError("\u5B9A\u671F\u30B9\u30B1\u30B8\u30E5\u30FC\u30EB\u306E\u5C65\u6B74\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093",
|
|
15
5
|
res);const body=res.json??{};const rows=body["rows"];if(!Array.isArray(rows)){return{kind:"error",message:`\u5C65\u6B74\u306E\u5FDC\u7B54\u306B rows \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\uFF08\u5FDC\u7B54\u306E\u5148\u982D: ${res.raw.slice(0,120)}\uFF09`,status:res.status}}if(body["truncated"]===true||body["reason"]==="history_truncated"){return{kind:"error",message:"\u5C65\u6B74\u306E\u8D70\u67FB\u304C\u6253\u3061\u5207\u3089\u308C\u307E\u3057\u305F\uFF08\u5224\u5B9A\u306B\u4F7F\u3048\u307E\u305B\u3093\uFF09",
|
|
16
6
|
status:res.status}}const windowCounts={};const counts=body["window_counts"];if(counts&&typeof counts==="object"){for(const[k,v]of Object.entries(counts)){if(typeof v==="number"){if(Number.isInteger(v))windowCounts[k]=v}else if(/^-?\d+$/.test(String(v))){windowCounts[k]=Number(String(v))}}}const normalized=rows.map(r=>{const row=r??{};return{ts:str(row["ts"]),schedule_id:str(row["schedule_id"]),window_key:str(row["window_key"]),status:str(row["status"]),item_id:str(row["item_id"]),args:str(row["a\
|
|
@@ -55,4 +45,4 @@ slice(limit)){verbose?.(` hold ${pad28(held.scheduleId)} max_per_cycle=${limit}
|
|
|
55
45
|
schedules??[]){if(!flag(sch,"enabled",true))continue;const nxt=nextWindowStart(sch,now,history);if(!nxt)continue;upcoming.push([nxt,sch])}upcoming.sort((a,b)=>a[0].getTime()-b[0].getTime());const out=["\u3010\u5B9A\u671F\u30B9\u30B1\u30B8\u30E5\u30FC\u30EB\uFF08scripts/ops-schedule.json\uFF09\u3011"];if(enqueuedLines.length>0){out.push("\u4ECA\u30B5\u30A4\u30AF\u30EB\u306E\u5B9A\u671F\u5B9F\u884C\u5206\u3068\u3057\u3066\u3001\u4EE5\u4E0B\u306F**\u30B9\u30AF\u30EA\u30D7\u30C8\u304C\u65E2\u306B\u30AD\u30E5\u30FC\u3078\u6295\u5165\u6E08\u307F**\u3067\u3059\u3002steps \u306B\u91CD\u8907\u3057\u3066\u542B\u3081\u306A\u3044\u3067\u304F\u3060\u3055\u3044\uFF08\u91CD\u8907\u3059\u308B\u3068\u30AD\u30E5\u30FC\u306B\u4E8C\u91CD\u767B\u9332\u3055\u308C\u307E\u3059\uFF09:");
|
|
56
46
|
out.push(...enqueuedLines)}else{out.push("\u4ECA\u30B5\u30A4\u30AF\u30EB\u3067\u767A\u706B\u3057\u305F\u5B9A\u671F\u30BF\u30B9\u30AF\u306F\u3042\u308A\u307E\u305B\u3093\u3002")}if(blocked.length>0){out.push("");out.push("\u73FE\u5728\u6642\u523B\u306F\u4EE5\u4E0B\u306E\u30B9\u30AD\u30EB\u306E\u5B9F\u884C\u6642\u9593\u5E2F\u5916\u3067\u3059\u3002**steps \u306B\u542B\u3081\u306A\u3044\u3067\u304F\u3060\u3055\u3044**:");for(const[skill,reason]of blocked)out.push(`- ${skill} \u2014 ${reason}`)}if(includeUpcoming&&
|
|
57
47
|
upcoming.length>0){out.push("");out.push("\u5B9A\u671F\u30BF\u30B9\u30AF\u306E\u6B21\u56DE\u767A\u706B\u4E88\u5B9A\uFF08\u53C2\u8003\u3002\u8A08\u753B\u306B\u542B\u3081\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\uFF09:");for(const[nxt,sch]of upcoming.slice(0,8)){const whenTxt=nxt.getTime()<=now.getTime()?"\u767A\u706B\u5F85\u3061\uFF08\u6B21\u30B5\u30A4\u30AF\u30EB\u4EE5\u964D\u306B\u81EA\u52D5\u6295\u5165\uFF09":fmtMonthDayTime(nxt);out.push(`- ${whenTxt} ${sch.label||`/twp-${String(
|
|
58
|
-
sch.skill)}`}\uFF08${describeWhen(sch)}\uFF09`)}}out.push("");out.push("\u5B9A\u671F\u30BF\u30B9\u30AF\u306F\u6642\u9593\u30D9\u30FC\u30B9\u3067\u30B9\u30AF\u30EA\u30D7\u30C8\u304C\u7BA1\u7406\u3057\u3066\u3044\u307E\u3059\u3002\u300C\u524D\u56DE\u5B9F\u884C\u304B\u3089\u6642\u9593\u304C\u7D4C\u3063\u305F\u304B\u300D\u3092\u63A8\u6E2C\u3057\u3066\u8A08\u753B\u306B\u5165\u308C\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\u3002");return out.join("\n")}export{
|
|
48
|
+
sch.skill)}`}\uFF08${describeWhen(sch)}\uFF09`)}}out.push("");out.push("\u5B9A\u671F\u30BF\u30B9\u30AF\u306F\u6642\u9593\u30D9\u30FC\u30B9\u3067\u30B9\u30AF\u30EA\u30D7\u30C8\u304C\u7BA1\u7406\u3057\u3066\u3044\u307E\u3059\u3002\u300C\u524D\u56DE\u5B9F\u884C\u304B\u3089\u6642\u9593\u304C\u7D4C\u3063\u305F\u304B\u300D\u3092\u63A8\u6E2C\u3057\u3066\u8A08\u753B\u306B\u5165\u308C\u308B\u5FC5\u8981\u306F\u3042\u308A\u307E\u305B\u3093\u3002");return out.join("\n")}export{ScheduleApi,nowInZone,parseTs,gateStatus,REQUIRE_ZERO_STATUS,parseCounts,collectDue,promptSection};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
var Diff=class{diff(oldStr,newStr,options={}){let callback;if(typeof options==="function"){callback=options;options={}}else if("callback"in options){callback=options.callback}const oldString=this.castInput(oldStr,options);const newString=this.castInput(newStr,options);const oldTokens=this.removeEmpty(this.tokenize(oldString,options));const newTokens=this.removeEmpty(this.tokenize(newString,options));return this.diffWithOptionsObj(oldTokens,newTokens,options,callback)}diffWithOptionsObj(oldTokens,newTokens,options,callback){
|
|
4
|
+
var _a;const done=value=>{value=this.postProcess(value,options);if(callback){setTimeout(function(){callback(value)},0);return void 0}else{return value}};const newLen=newTokens.length,oldLen=oldTokens.length;let editLength=1;let maxEditLength=newLen+oldLen;if(options.maxEditLength!=null){maxEditLength=Math.min(maxEditLength,options.maxEditLength)}const maxExecutionTime=(_a=options.timeout)!==null&&_a!==void 0?_a:Infinity;const abortAfterTimestamp=Date.now()+maxExecutionTime;const bestPath=[{oldPos:-1,
|
|
5
|
+
lastComponent:void 0}];let newPos=this.extractCommon(bestPath[0],newTokens,oldTokens,0,options);if(bestPath[0].oldPos+1>=oldLen&&newPos+1>=newLen){return done(this.buildValues(bestPath[0].lastComponent,newTokens,oldTokens))}let minDiagonalToConsider=-Infinity,maxDiagonalToConsider=Infinity;const execEditLength=()=>{for(let diagonalPath=Math.max(minDiagonalToConsider,-editLength);diagonalPath<=Math.min(maxDiagonalToConsider,editLength);diagonalPath+=2){let basePath;const removePath=bestPath[diagonalPath-
|
|
6
|
+
1],addPath=bestPath[diagonalPath+1];if(removePath){bestPath[diagonalPath-1]=void 0}let canAdd=false;if(addPath){const addPathNewPos=addPath.oldPos-diagonalPath;canAdd=addPath&&0<=addPathNewPos&&addPathNewPos<newLen}const canRemove=removePath&&removePath.oldPos+1<oldLen;if(!canAdd&&!canRemove){bestPath[diagonalPath]=void 0;continue}if(!canRemove||canAdd&&removePath.oldPos<addPath.oldPos){basePath=this.addToPath(addPath,true,false,0,options)}else{basePath=this.addToPath(removePath,false,true,1,options)}
|
|
7
|
+
newPos=this.extractCommon(basePath,newTokens,oldTokens,diagonalPath,options);if(basePath.oldPos+1>=oldLen&&newPos+1>=newLen){return done(this.buildValues(basePath.lastComponent,newTokens,oldTokens))||true}else{bestPath[diagonalPath]=basePath;if(basePath.oldPos+1>=oldLen){maxDiagonalToConsider=Math.min(maxDiagonalToConsider,diagonalPath-1)}if(newPos+1>=newLen){minDiagonalToConsider=Math.max(minDiagonalToConsider,diagonalPath+1)}}}editLength++};if(callback){(function exec(){setTimeout(function(){if(editLength>
|
|
8
|
+
maxEditLength||Date.now()>abortAfterTimestamp){return callback(void 0)}if(!execEditLength()){exec()}},0)})()}else{while(editLength<=maxEditLength&&Date.now()<=abortAfterTimestamp){const ret=execEditLength();if(ret){return ret}}}}addToPath(path,added,removed,oldPosInc,options){const last=path.lastComponent;if(last&&!options.oneChangePerToken&&last.added===added&&last.removed===removed){return{oldPos:path.oldPos+oldPosInc,lastComponent:{count:last.count+1,added,removed,previousComponent:last.previousComponent}}}else{
|
|
9
|
+
return{oldPos:path.oldPos+oldPosInc,lastComponent:{count:1,added,removed,previousComponent:last}}}}extractCommon(basePath,newTokens,oldTokens,diagonalPath,options){const newLen=newTokens.length,oldLen=oldTokens.length;let oldPos=basePath.oldPos,newPos=oldPos-diagonalPath,commonCount=0;while(newPos+1<newLen&&oldPos+1<oldLen&&this.equals(oldTokens[oldPos+1],newTokens[newPos+1],options)){newPos++;oldPos++;commonCount++;if(options.oneChangePerToken){basePath.lastComponent={count:1,previousComponent:basePath.
|
|
10
|
+
lastComponent,added:false,removed:false}}}if(commonCount&&!options.oneChangePerToken){basePath.lastComponent={count:commonCount,previousComponent:basePath.lastComponent,added:false,removed:false}}basePath.oldPos=oldPos;return newPos}equals(left,right,options){if(options.comparator){return options.comparator(left,right)}else{return left===right||!!options.ignoreCase&&left.toLowerCase()===right.toLowerCase()}}removeEmpty(array){const ret=[];for(let i=0;i<array.length;i++){if(array[i]){ret.push(array[i])}}
|
|
11
|
+
return ret}castInput(value,options){return value}tokenize(value,options){return Array.from(value)}join(chars){return chars.join("")}postProcess(changeObjects,options){return changeObjects}get useLongestToken(){return false}buildValues(lastComponent,newTokens,oldTokens){const components=[];let nextComponent;while(lastComponent){components.push(lastComponent);nextComponent=lastComponent.previousComponent;delete lastComponent.previousComponent;lastComponent=nextComponent}components.reverse();const componentLen=components.
|
|
12
|
+
length;let componentPos=0,newPos=0,oldPos=0;for(;componentPos<componentLen;componentPos++){const component=components[componentPos];if(!component.removed){if(!component.added&&this.useLongestToken){let value=newTokens.slice(newPos,newPos+component.count);value=value.map(function(value2,i){const oldValue=oldTokens[oldPos+i];return oldValue.length>value2.length?oldValue:value2});component.value=this.join(value)}else{component.value=this.join(newTokens.slice(newPos,newPos+component.count))}newPos+=
|
|
13
|
+
component.count;if(!component.added){oldPos+=component.count}}else{component.value=this.join(oldTokens.slice(oldPos,oldPos+component.count));oldPos+=component.count}}return components}};var LineDiff=class extends Diff{constructor(){super(...arguments);this.tokenize=tokenize}equals(left,right,options){if(options.ignoreWhitespace){if(!options.newlineIsToken||!left.includes("\n")){left=left.trim()}if(!options.newlineIsToken||!right.includes("\n")){right=right.trim()}}else if(options.ignoreNewlineAtEof&&!options.newlineIsToken){if(left.endsWith("\n")){left=left.slice(0,-1)}if(right.endsWith("\n")){right=right.slice(0,-1)}}return super.equals(left,right,options)}};var lineDiff=new LineDiff;
|
|
14
|
+
function diffLines(oldStr,newStr,options){return lineDiff.diff(oldStr,newStr,options)}function tokenize(value,options){if(options.stripTrailingCr){value=value.replace(/\r\n/g,"\n")}const retLines=[],linesAndNewlines=value.split(/(\n|\r\n)/);if(!linesAndNewlines[linesAndNewlines.length-1]){linesAndNewlines.pop()}for(let i=0;i<linesAndNewlines.length;i++){const line=linesAndNewlines[i];if(i%2&&!options.newlineIsToken){retLines[retLines.length-1]+=line}else{retLines.push(line)}}return retLines}function buildDiffLines(before,after,contextLines=3){const parts=diffLines(before,after);const out=[];for(const part of parts){const lines=part.value.replace(/\n$/,"").split("\n");if(part.added){for(const l of lines)out.push({sign:"+",text:l})}else if(part.removed){for(const l of lines)out.push({sign:"-",text:l})}else if(lines.length>contextLines*2+1){for(const l of lines.slice(0,contextLines))out.push({sign:" ",text:l});out.push({sign:" ",text:`\u22EF ${lines.length-contextLines*2} \u884C\u7701\u7565`});
|
|
15
|
+
for(const l of lines.slice(-contextLines))out.push({sign:" ",text:l})}else{for(const l of lines)out.push({sign:" ",text:l})}}return out}function diffStat(lines){return{added:lines.filter(l=>l.sign==="+").length,removed:lines.filter(l=>l.sign==="-").length}}export{buildDiffLines,diffStat};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{isModeId,isPermissionModeId}from"./chunk-BOBSH3QN.js";import{API_TOKEN,HELP_TOKEN,isDomainName}from"./chunk-ZGG7TRAM.js";import{splitFlagToken}from"./chunk-QQRJLH6B.js";var BUILTIN_COMMANDS=["login","logout","whoami","update","task-loop"];var TASK_LOOP_ACTIONS=["run","status","stop","schedule","setup","charter"];var VALUE_FLAGS=new Set(["-p","--print","--profile","--tenant","--mode","--permission-mode","--model","--allowed-tools","--disallowed-tools","--project","--engine","--interval","--max-cycles","--ai","--workspace","--ai-config-file","--now","--counts","--gate","--file","--out","--revision","--output","--query"]);var BOOLEAN_FLAGS=new Set(["-h","--help","\
|
|
4
|
+
-v","--version","--no-tui","--doctor","--password","--token","--no-browser","--safe","--daemon","--force-runner","--force","--drain","--yes","-y","--no-ai-config-file","--verbose","--dry-run","--debug","--refresh"]);function dispatch(argv,limit=2){const tokens=[];const indexes=[];let truncated=false;for(let i=0;i<argv.length;i++){const arg=argv[i];if(arg===void 0)continue;if(arg.startsWith("-")&&arg!=="-"){const{name,value:inline}=splitFlagToken(arg);if(BOOLEAN_FLAGS.has(name)){if(inline!==void 0){
|
|
5
|
+
truncated=true;break}continue}if(VALUE_FLAGS.has(name)){if(inline!==void 0)continue;const next=argv[i+1];if(next!==void 0&&(!next.startsWith("-")||next==="-"))i++;continue}truncated=true;break}if(arg===""||arg==="-")continue;if(tokens.length>=limit)break;tokens.push(arg);indexes.push(i)}return{tokens,indexes,truncated}}function isBuiltin(token){return token!==void 0&&BUILTIN_COMMANDS.includes(token)}function isTaskLoopAction(token){return token!==void 0&&TASK_LOOP_ACTIONS.includes(token)}function resolveRoute(result){
|
|
6
|
+
const{tokens,indexes}=result;const[first,second]=tokens;const firstIndex=indexes[0];if(first===void 0||firstIndex===void 0)return{kind:"none",consumed:[]};const consumed=[firstIndex];const secondIndex=indexes[1];if(isBuiltin(first)){if(first==="task-loop"&&isTaskLoopAction(second)){if(secondIndex!==void 0)consumed.push(secondIndex);return{kind:"builtin",command:first,action:second,consumed}}return{kind:"builtin",command:first,...first==="task-loop"?{action:"run"}:{},consumed}}if(second!==void 0&&
|
|
7
|
+
secondIndex!==void 0)consumed.push(secondIndex);return{kind:"domain",domain:first,...second!==void 0?{operation:second}:{},consumed}}var GLOBAL_FLAGS=new Set(["-h","--help","-v","--version","--profile","--output","--query","--dry-run","--debug","--yes","-y","--refresh"]);function parseArgv(argv){const out={command:"tui",safe:false,daemon:false,forceRunner:false,stopForce:false,logoutForce:false,stopDrain:false,noTui:false,doctor:false,yes:false,noAiConfigFile:false,verbose:false,loginMethod:"browser",loginNoBrowser:false,promptFromStdin:false,domainArgv:[],domainHelp:false,dryRun:false,debug:false,refresh:false,unknown:[],allowedTools:[],
|
|
8
|
+
disallowedTools:[]};const route=resolveRoute(dispatch(argv));const consumed=new Set;const[firstIndex,secondIndex]=route.consumed;if(route.kind==="builtin"){out.command=route.command;if(route.action!==void 0)out.taskLoopAction=route.action;for(const index of route.consumed)consumed.add(index)}else if(route.kind==="domain"){if(route.domain===HELP_TOKEN){if(route.operation===void 0){out.command="help";if(firstIndex!==void 0)consumed.add(firstIndex)}else if(isDomainName(route.operation)){out.command=
|
|
9
|
+
"domain";out.domain=route.operation;out.domainHelp=true;if(firstIndex!==void 0)consumed.add(firstIndex);if(secondIndex!==void 0)consumed.add(secondIndex)}else if(route.operation===API_TOKEN){out.command="api";out.domainHelp=true;if(firstIndex!==void 0)consumed.add(firstIndex);if(secondIndex!==void 0)consumed.add(secondIndex)}}else if(route.domain===API_TOKEN){out.command="api";if(firstIndex!==void 0)consumed.add(firstIndex)}else if(isDomainName(route.domain)){out.command="domain";out.domain=route.
|
|
10
|
+
domain;if(route.operation!==void 0)out.operation=route.operation;for(const index of route.consumed)consumed.add(index)}}const hasSubcommandToken=route.kind==="builtin"||route.kind==="domain"&&(route.domain===HELP_TOKEN||route.domain===API_TOKEN||isDomainName(route.domain));const isDomainRoute=out.command==="domain"||out.command==="api";const takeValue=(i,flag,inline)=>{const value=inline??argv[i+1];if(value===void 0||inline===void 0&&value.startsWith("-")){out.unknown.push(flag);return{step:0}}if(value.
|
|
11
|
+
trim()===""){out.unknown.push(inline===void 0?`${flag} `:`${flag}=${inline}`);return{step:0}}return{value,step:inline===void 0?1:0}};let optionsClosed=false;for(let i=0;i<argv.length;i++){if(consumed.has(i))continue;const raw=argv[i];if(raw===void 0)continue;if(isDomainRoute&&raw==="--")optionsClosed=true;const{name:arg,value:inline}=splitFlagToken(raw);if(isDomainRoute&&(optionsClosed||!GLOBAL_FLAGS.has(arg))){out.domainArgv.push(raw);continue}if(inline!==void 0&&BOOLEAN_FLAGS.has(arg)){out.unknown.
|
|
12
|
+
push(raw);continue}switch(arg){case"-h":case"--help":if(isDomainRoute)out.domainHelp=true;else out.command="help";break;case"-v":case"--version":out.command="version";break;case"--no-tui":out.noTui=true;break;case"--doctor":out.doctor=true;break;case"--password":out.loginMethod="password";break;case"--token":out.loginMethod="token";break;case"--no-browser":out.loginNoBrowser=true;break;case"--profile":{const{value,step}=takeValue(i,"--profile",inline);if(value!==void 0){out.profile=value;i+=step}
|
|
13
|
+
break}case"-p":case"--print":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(hasSubcommandToken){out.unknown.push(raw)}else if(next==="-"){out.command="print";out.promptFromStdin=true;out.prompt="";i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.command="print";out.prompt=next;i+=step}else{out.unknown.push(raw)}break}case"--output":{const{value,step}=takeValue(i,"--output",inline);if(value!==void 0){out.output=value;i+=step}break}case"--query":{const{
|
|
14
|
+
value,step}=takeValue(i,"--query",inline);if(value!==void 0){out.query=value;i+=step}break}case"--dry-run":out.dryRun=true;break;case"--debug":out.debug=true;break;case"--refresh":out.refresh=true;break;case"--tenant":{const{value,step}=takeValue(i,"--tenant",inline);if(value!==void 0){out.tenant=value;i+=step}break}case"--mode":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(isModeId(next)){out.mode=next;i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.
|
|
15
|
+
unknown.push(inline!==void 0?raw:`--mode ${next}`);i+=step}else{out.unknown.push("--mode")}break}case"--permission-mode":{const next=inline??argv[i+1];const step=inline===void 0?1:0;if(isPermissionModeId(next)){out.permissionMode=next;i+=step}else if(next!==void 0&&(inline!==void 0||!next.startsWith("-"))){out.unknown.push(inline!==void 0?raw:`--permission-mode ${next}`);i+=step}else{out.unknown.push("--permission-mode")}break}case"--allowed-tools":case"--disallowed-tools":{const{value,step}=takeValue(
|
|
16
|
+
i,arg,inline);if(value!==void 0){(arg==="--allowed-tools"?out.allowedTools:out.disallowedTools).push(value);i+=step}break}case"--model":{const{value,step}=takeValue(i,"--model",inline);if(value!==void 0){out.model=value;i+=step}break}case"--safe":out.safe=true;break;case"--daemon":out.daemon=true;break;case"--force-runner":out.forceRunner=true;break;case"--force":out.stopForce=true;break;case"--drain":out.stopDrain=true;break;case"--project":{const{value,step}=takeValue(i,"--project",inline);if(value!==
|
|
17
|
+
void 0){out.project=value;i+=step}break}case"--engine":{const{value,step}=takeValue(i,"--engine",inline);if(value!==void 0){out.engine=value;i+=step}break}case"--interval":case"--max-cycles":{const{value,step}=takeValue(i,arg,inline);if(value!==void 0){const n=Number.parseInt(value,10);if(Number.isInteger(n)&&n>0){if(arg==="--interval")out.interval=n;else out.maxCycles=n}else{out.unknown.push(inline!==void 0?raw:`${arg} ${value}`)}i+=step}break}case"--yes":case"-y":out.yes=true;break;case"--ai":{
|
|
18
|
+
const{value:v,step}=takeValue(i,"--ai",inline);if(v!==void 0){out.ais=[...out.ais??[],v];i+=step}break}case"--no-ai-config-file":out.noAiConfigFile=true;break;case"--workspace":{const{value:v,step}=takeValue(i,"--workspace",inline);if(v!==void 0){out.workspace=v;i+=step}break}case"--ai-config-file":{const{value:v,step}=takeValue(i,"--ai-config-file",inline);if(v!==void 0){out.aiConfigFile=v;i+=step}break}case"--verbose":out.verbose=true;break;case"--now":{const{value:v,step}=takeValue(i,"--now",
|
|
19
|
+
inline);if(v!==void 0){out.scheduleNow=v;i+=step}break}case"--counts":{const{value:v,step}=takeValue(i,"--counts",inline);if(v!==void 0){out.scheduleCounts=v;i+=step}break}case"--gate":{const{value:v,step}=takeValue(i,"--gate",inline);if(v!==void 0){out.scheduleGate=v;i+=step}break}case"--file":{const{value:v,step}=takeValue(i,"--file",inline);if(v!==void 0){out.charterFile=v;i+=step}break}case"--out":{const{value:v,step}=takeValue(i,"--out",inline);if(v!==void 0){out.charterOut=v;i+=step}break}case"\
|
|
20
|
+
--revision":{const{value:v,step}=takeValue(i,"--revision",inline);if(v!==void 0){out.charterRevision=v;i+=step}break}default:if(out.command==="task-loop"&&out.taskLoopAction==="charter"&&out.charterOp===void 0&&(raw==="push"||raw==="pull")){out.charterOp=raw;break}out.unknown.push(raw)}}if(out.command!=="login"&&out.loginMethod!=="browser"){out.unknown.push(out.loginMethod==="password"?"--password":"--token");out.loginMethod="browser"}if(out.permissionMode!==void 0&&out.command!=="tui"&&out.command!==
|
|
21
|
+
"print"){out.unknown.push("--permission-mode");delete out.permissionMode}if(out.command!=="tui"&&out.command!=="print"){if(out.allowedTools.length>0)out.unknown.push("--allowed-tools");if(out.disallowedTools.length>0)out.unknown.push("--disallowed-tools");out.allowedTools=[];out.disallowedTools=[]}if(out.loginNoBrowser&&!(out.command==="login"&&out.loginMethod==="browser")){out.unknown.push("--no-browser");out.loginNoBrowser=false}if(out.command==="logout"&&out.stopForce){out.logoutForce=true;out.
|
|
22
|
+
stopForce=false}if(out.command!=="task-loop"){if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.stopForce)out.unknown.push("--force");if(out.stopDrain)out.unknown.push("--drain");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles");if(out.project!==void 0)out.unknown.push("--project");if(out.
|
|
23
|
+
verbose)out.unknown.push("--verbose");if(out.scheduleNow!==void 0)out.unknown.push("--now");if(out.scheduleCounts!==void 0)out.unknown.push("--counts");if(out.scheduleGate!==void 0)out.unknown.push("--gate");if(out.ais!==void 0)out.unknown.push("--ai");if(out.workspace!==void 0)out.unknown.push("--workspace");if(out.aiConfigFile!==void 0)out.unknown.push("--ai-config-file");if(out.noAiConfigFile)out.unknown.push("--no-ai-config-file");if(out.charterFile!==void 0)out.unknown.push("--file");if(out.
|
|
24
|
+
charterOut!==void 0)out.unknown.push("--out");if(out.charterRevision!==void 0)out.unknown.push("--revision")}if(out.yes&&out.command!=="task-loop"&&!isDomainRoute)out.unknown.push("--yes");if(!isDomainRoute){if(out.output!==void 0)out.unknown.push("--output");if(out.query!==void 0)out.unknown.push("--query");if(out.dryRun)out.unknown.push("--dry-run");if(out.debug)out.unknown.push("--debug");if(out.refresh)out.unknown.push("--refresh")}if(out.command==="api"&&out.refresh){out.unknown.push("--ref\
|
|
25
|
+
resh");out.refresh=false}if(out.command==="task-loop"&&out.taskLoopAction!=="schedule"){if(out.verbose)out.unknown.push("--verbose");if(out.scheduleNow!==void 0)out.unknown.push("--now");if(out.scheduleCounts!==void 0)out.unknown.push("--counts");if(out.scheduleGate!==void 0)out.unknown.push("--gate")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopForce){out.unknown.push("--force")}if(out.command==="task-loop"&&out.taskLoopAction!=="stop"&&out.stopDrain){out.unknown.push("--d\
|
|
26
|
+
rain")}if(out.command==="task-loop"&&out.taskLoopAction==="stop"&&out.stopForce&&out.stopDrain){out.unknown.push("--force \u3068 --drain \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");out.stopForce=false;out.stopDrain=false}if(out.command==="task-loop"&&out.taskLoopAction!=="setup"){if(out.yes&&out.taskLoopAction!=="charter")out.unknown.push("--yes");if(out.ais!==void 0)out.unknown.push("--ai");if(out.workspace!==void 0)out.unknown.push("--workspace");if(out.aiConfigFile!==
|
|
27
|
+
void 0)out.unknown.push("--ai-config-file");if(out.noAiConfigFile)out.unknown.push("--no-ai-config-file")}if(out.command==="task-loop"&&(out.taskLoopAction==="stop"||out.taskLoopAction==="status")){if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}
|
|
28
|
+
if(out.command==="task-loop"&&out.taskLoopAction==="setup"){if(out.engine!==void 0)out.unknown.push("--engine");if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.interval!==void 0)out.unknown.push("--interval");if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}if(out.command==="task-loop"&&out.taskLoopAction==="charter"){if(out.charterOp===void 0){out.unknown.push("charter \u306B\u306F push \u304B pull \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\
|
|
29
|
+
\u3055\u3044")}if(out.charterOp!=="push"&&out.charterFile!==void 0)out.unknown.push("--file");if(out.charterOp!=="push"&&out.charterRevision!==void 0)out.unknown.push("--revision");if(out.charterOp!=="pull"&&out.charterOut!==void 0)out.unknown.push("--out");if(out.safe)out.unknown.push("--safe");if(out.daemon)out.unknown.push("--daemon");if(out.forceRunner)out.unknown.push("--force-runner");if(out.engine!==void 0)out.unknown.push("--engine");if(out.interval!==void 0)out.unknown.push("--interval");
|
|
30
|
+
if(out.maxCycles!==void 0)out.unknown.push("--max-cycles")}else if(out.command==="task-loop"){if(out.charterFile!==void 0)out.unknown.push("--file");if(out.charterOut!==void 0)out.unknown.push("--out");if(out.charterRevision!==void 0)out.unknown.push("--revision")}return out}export{parseArgv};
|