@tocca-systems/twp-cli 0.133.0 → 0.135.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 +6 -0
- package/README.md +57 -3
- package/dist/{agent-VMSL5KHC.js → agent-RKDXMENR.js} +2 -2
- package/dist/{agent-loop-UDVQKGDK.js → agent-loop-JJUNRUK3.js} +2 -2
- package/dist/{ai-dispatch-IZXR7LHN.js → ai-dispatch-5GINX5YQ.js} +2 -2
- package/dist/{analysis-IHPEFRMJ.js → analysis-G5ACF62Y.js} +3 -3
- package/dist/{announcement-77BM6C2F.js → announcement-SR5R2CY2.js} +2 -2
- package/dist/{api-command-QKW72A5P.js → api-command-EWPKWAXV.js} +3 -3
- package/dist/{api-key-TH4FGLMP.js → api-key-XIZFXWAN.js} +2 -2
- package/dist/{app-2SLB7DZQ.js → app-XFS47KBS.js} +4 -4
- package/dist/{attendance-correct-BIOLK5US.js → attendance-correct-ILQUSSZQ.js} +2 -2
- package/dist/{attendance-lists-O6GVIJQA.js → attendance-lists-UTQIIOZ5.js} +2 -2
- package/dist/{audit-log-ZGK7IVLD.js → audit-log-DLRQGPIX.js} +1 -1
- package/dist/{backlog-J4BDNFXR.js → backlog-HTA2X2YS.js} +2 -2
- package/dist/{brief-LATNYACH.js → brief-467WEZKT.js} +3 -3
- package/dist/budget-2CRF4362.js +5 -0
- package/dist/{business-hours-37MRL53C.js → business-hours-QL763KSA.js} +1 -1
- package/dist/{capacity-list-command-EUU3H5ZE.js → capacity-list-command-W6SYFB77.js} +2 -2
- package/dist/charter-command-CBCJQGIY.js +3 -0
- package/dist/{chunk-57RI73JO.js → chunk-22BYE7UH.js} +2 -2
- package/dist/{chunk-WVCEKC7V.js → chunk-3EFJQDC4.js} +1 -1
- package/dist/{chunk-3F7AKTXL.js → chunk-3RWP7OCE.js} +1 -1
- package/dist/{chunk-5JUE6FZC.js → chunk-43RLWH2F.js} +1 -1
- package/dist/{chunk-6FGR3U5C.js → chunk-52SRQFVJ.js} +2 -2
- package/dist/{chunk-53SHXSNB.js → chunk-65IPXSC6.js} +1 -1
- package/dist/{chunk-VGT2EGH6.js → chunk-6NHLWYI2.js} +1 -1
- package/dist/{chunk-OTQ3D7SR.js → chunk-6NNI2JPL.js} +2 -2
- package/dist/{chunk-PIUPLUW5.js → chunk-6UPHU6RP.js} +2 -2
- package/dist/{chunk-PYJP4RPG.js → chunk-7CVIIHMY.js} +2 -2
- package/dist/{chunk-PS5QFKHB.js → chunk-7DCWZ2NF.js} +1 -1
- package/dist/{chunk-VAC2M4RC.js → chunk-7HV76VYJ.js} +1 -1
- package/dist/{chunk-7QHDTO2Z.js → chunk-7KFJL6FU.js} +1 -1
- package/dist/{chunk-FKGWRBIZ.js → chunk-AFGV5U4B.js} +2 -2
- package/dist/{chunk-736YBZLM.js → chunk-AK5QSKDO.js} +6 -5
- package/dist/{chunk-QFVEHUPM.js → chunk-B6JU2VBH.js} +2 -2
- package/dist/{chunk-A4LFG7MW.js → chunk-BLDQ6PY3.js} +1 -1
- package/dist/{chunk-H2XVPFJL.js → chunk-BTJJZEVF.js} +2 -2
- package/dist/{chunk-JJSBBWJ5.js → chunk-CHT6EP5C.js} +1 -1
- package/dist/{chunk-BY4HCJGN.js → chunk-CMIY33IL.js} +2 -2
- package/dist/{chunk-PJD4KJUU.js → chunk-D6RZ6CGP.js} +2 -2
- package/dist/{chunk-L2QIDHPK.js → chunk-DXA33JMI.js} +1 -1
- package/dist/{chunk-MI6HVYR2.js → chunk-DYT22FTA.js} +1 -1
- package/dist/{chunk-FBTOIECJ.js → chunk-E6KLOTR2.js} +1 -1
- package/dist/{chunk-PKN4HVVY.js → chunk-EYA5VYQV.js} +1 -1
- package/dist/{chunk-76WVQ45F.js → chunk-FDECUPTW.js} +1 -1
- package/dist/{chunk-RB74YCRT.js → chunk-GAHTWMDU.js} +1 -1
- package/dist/{chunk-V64CGX7V.js → chunk-GNSZOYBQ.js} +1 -1
- package/dist/{chunk-3ZRMMBP5.js → chunk-HCTPCUST.js} +1 -1
- package/dist/{chunk-62OAYVUX.js → chunk-HXX7OCN6.js} +2 -2
- package/dist/{chunk-LZHNR537.js → chunk-ICM4VM3K.js} +2 -2
- package/dist/{chunk-LH4AZKLT.js → chunk-IDE5SXJG.js} +1 -1
- package/dist/{chunk-P2RWZXNJ.js → chunk-IPDUJDQA.js} +2 -2
- package/dist/{chunk-M37IYSEG.js → chunk-K2TO4DFJ.js} +1 -1
- package/dist/{chunk-MYBIPHZ7.js → chunk-KGKSXGX7.js} +1 -1
- package/dist/{chunk-FFRQGBMA.js → chunk-KOL4P7LC.js} +2 -2
- package/dist/{chunk-44U6JBPQ.js → chunk-LQKHOOAV.js} +2 -2
- package/dist/{chunk-F5QDUPQO.js → chunk-LXFLA3PZ.js} +1 -1
- package/dist/{chunk-KYGDPWMC.js → chunk-MDBSXN4P.js} +1 -1
- package/dist/{chunk-EN357I2K.js → chunk-MNPGGAKL.js} +1 -1
- package/dist/{chunk-UVCJXHWN.js → chunk-O756DX6D.js} +1 -1
- package/dist/{chunk-QLENN5DD.js → chunk-OMW6BBAY.js} +1 -1
- package/dist/{chunk-FSRSJZND.js → chunk-OPQ66X5A.js} +3 -3
- package/dist/{chunk-TKYY25ER.js → chunk-OZ66X3YI.js} +1 -1
- package/dist/{chunk-WDTGZ5G6.js → chunk-P3D4HKWC.js} +1 -1
- package/dist/{chunk-MTK4WY54.js → chunk-Q4HSIOZL.js} +1 -1
- package/dist/{chunk-5X4OUMZT.js → chunk-R76JZIZ5.js} +2 -2
- package/dist/chunk-STILP3Z6.js +4 -0
- package/dist/{chunk-G2GFWPV6.js → chunk-T7Z6XJ3U.js} +27 -33
- package/dist/{chunk-KIZIRVW6.js → chunk-TZL2342W.js} +1 -0
- package/dist/{chunk-DZFULJR3.js → chunk-U3LDJ6JP.js} +1 -1
- package/dist/{chunk-HEH3PUW2.js → chunk-V5WDGX4S.js} +1 -1
- package/dist/chunk-WA2Q4BR3.js +14 -0
- package/dist/{chunk-RILZ457A.js → chunk-X3FDKKVS.js} +1 -1
- package/dist/chunk-XCU3PDQV.js +9 -0
- package/dist/{chunk-MMVXE2CJ.js → chunk-YJP4FUY4.js} +1 -1
- package/dist/{chunk-EXT4AIDF.js → chunk-YLF4S4MC.js} +1 -1
- package/dist/{chunk-XT5RB7XJ.js → chunk-YNZJA3KF.js} +2 -2
- package/dist/{chunk-G3LESKAB.js → chunk-YPKORZLP.js} +2 -2
- package/dist/{chunk-QV4K6V2L.js → chunk-ZOUOJQ7J.js} +2 -2
- package/dist/cli.js +29 -9
- package/dist/{commands-CVXOFGAH.js → commands-3DRZLUHO.js} +2 -2
- package/dist/{commands-KWQLHY2V.js → commands-OKU5OXD5.js} +3 -3
- package/dist/{commands-SBO7N6TG.js → commands-VAY4M4MI.js} +22 -22
- package/dist/{company-HBNJ32PY.js → company-PCUVVYIV.js} +3 -3
- package/dist/{content-MLJ6MLWA.js → content-D2QYEOXA.js} +2 -2
- package/dist/{contract-THZIHL3G.js → contract-RDTDBSC6.js} +2 -2
- package/dist/{corporate-POQVWFKC.js → corporate-ZRXJA2J2.js} +2 -2
- package/dist/{department-S3DWJHGT.js → department-GFYKDAQT.js} +2 -2
- package/dist/{deposit-NLX7OAMP.js → deposit-BFRC5LEP.js} +2 -2
- package/dist/{domain-knowledge-TGJ4AFPJ.js → domain-knowledge-WZMEHMQQ.js} +2 -2
- package/dist/{estimate-3CJGKIFQ.js → estimate-Y3JHXT7I.js} +4 -4
- package/dist/{evaluation-M7CWWFYU.js → evaluation-SA7UXTGY.js} +3 -3
- package/dist/{expense-SIL6XPVV.js → expense-44SXCE5I.js} +2 -2
- package/dist/{faq-KXKVX2GT.js → faq-IEIZQTRI.js} +3 -3
- package/dist/{fiscal-year-XO657XXK.js → fiscal-year-NQSPGOSE.js} +2 -2
- package/dist/{github-LWRGYHUT.js → github-5LLNKAHY.js} +45 -5
- package/dist/github-git-SXENYNA4.js +40 -0
- package/dist/{holiday-D7IDQD7O.js → holiday-5XBCAYSA.js} +2 -2
- package/dist/{inquiry-7PVPTY6L.js → inquiry-WUGCRUWS.js} +2 -2
- package/dist/{invoice-3U5BA3N5.js → invoice-EDSKFTTU.js} +3 -3
- package/dist/{job-title-RON7XPAX.js → job-title-KZEVWJMZ.js} +1 -1
- package/dist/journal-DCKH6PAR.js +113 -0
- package/dist/{knowledge-LFK6JLI6.js → knowledge-HWNIKVSM.js} +2 -2
- package/dist/{leave-ODNAVI3F.js → leave-HWEK7LGE.js} +3 -3
- package/dist/{license-77OLX3JH.js → license-EBU32T7S.js} +1 -1
- package/dist/{login-history-UFYI3EXG.js → login-history-YJMOHIGW.js} +2 -2
- package/dist/{logout-guard-HXUAZ24F.js → logout-guard-SWISJ6M2.js} +1 -1
- package/dist/{media-H3LGN3DV.js → media-2J5JIEAH.js} +3 -3
- package/dist/{note-FXJBYKDJ.js → note-KNUKF6IT.js} +2 -2
- package/dist/{notification-WRJWXTVV.js → notification-BMAKU66X.js} +1 -1
- package/dist/{ojt-CA57LGQV.js → ojt-QVIQZOD5.js} +1 -1
- package/dist/{onedrive-Z43D26SJ.js → onedrive-NYRDUBIQ.js} +1 -1
- package/dist/{oneshot-GYXSX3VV.js → oneshot-MTMASGFX.js} +3 -3
- package/dist/{orientation-command-PQ3QXDPE.js → orientation-command-35UWDVEJ.js} +1 -1
- package/dist/outlook-OE7CUTAJ.js +4 -0
- package/dist/{plan-submit-FWC3UUQD.js → plan-submit-26YXUKLU.js} +1 -1
- package/dist/{position-IQ57YOK6.js → position-QNX72LXV.js} +1 -1
- package/dist/project-OBZ4SJVK.js +5 -0
- package/dist/{prospect-QFT3AHLN.js → prospect-6I4LQPEZ.js} +3 -3
- package/dist/{purchase-NYI44K6P.js → purchase-BUP5MYSQ.js} +4 -4
- package/dist/query-E22FS2XX.js +3 -0
- package/dist/receivable-M6UE72X6.js +4 -0
- package/dist/{redmine-H2IGEHH5.js → redmine-4VSQ64WO.js} +2 -2
- package/dist/{registry-HD574GXO.js → registry-OX276PZJ.js} +1 -1
- package/dist/{report-CPUCZWJI.js → report-WI7UCP5H.js} +2 -2
- package/dist/{revision-command-KT7NMRES.js → revision-command-ASMYJBZU.js} +1 -1
- package/dist/{run-IIVASPAK.js → run-RE46IWOS.js} +2 -2
- package/dist/{runner-command-YVY25WNU.js → runner-command-BQJ3WONI.js} +1 -1
- package/dist/{sales-ai-review-BKPJ7TSE.js → sales-ai-review-6SE3UFAK.js} +2 -2
- package/dist/{sales-master-7WZ4VM3E.js → sales-master-TRZFZKRH.js} +3 -3
- package/dist/{sales-numbering-7C5V5R5P.js → sales-numbering-3VCQOHNO.js} +2 -2
- package/dist/{schedule-def-command-QZB4FGWV.js → schedule-def-command-GOBV2HBH.js} +1 -1
- package/dist/{search-BLABJVLN.js → search-VDGIQD6Z.js} +2 -2
- package/dist/{secret-P42JCOI4.js → secret-57ZPEBCJ.js} +1 -1
- package/dist/{segment-ABWMWTDO.js → segment-FRGMNPHV.js} +1 -1
- package/dist/{server-settings-4YMJDRUP.js → server-settings-FXLXYHD6.js} +1 -1
- package/dist/{server-skills-XMVBCSAY.js → server-skills-X6AKHGMB.js} +1 -1
- package/dist/{settings-command-3SLINN5N.js → settings-command-NHJWW33Q.js} +1 -1
- package/dist/{setup-XYXOMNKJ.js → setup-2KNJ6KCX.js} +1 -1
- package/dist/{skill-EAJMCUNG.js → skill-CAJ7KXP2.js} +2 -2
- package/dist/{skill-check-WHY7NUYS.js → skill-check-GRJAEOGD.js} +2 -2
- package/dist/{skill-command-4VMZ2H6A.js → skill-command-7RIHA2M6.js} +1 -1
- package/dist/{skill-manage-command-HGLXVSJB.js → skill-manage-command-5EPL2VZA.js} +3 -3
- package/dist/{slack-C6UJDHPZ.js → slack-PS5ACRYL.js} +2 -2
- package/dist/{sns-37HJIZPD.js → sns-KXCZ42TC.js} +2 -2
- package/dist/{staffing-board-RR4FJBJJ.js → staffing-board-A6SNNSRB.js} +3 -3
- package/dist/{status-command-TK44NJJR.js → status-command-5HBUAGWX.js} +2 -2
- package/dist/{storage-AQDCEBDJ.js → storage-LJH2J7GU.js} +1 -1
- package/dist/{supplier-payment-GFNM3V5U.js → supplier-payment-ZP6EK22P.js} +3 -3
- package/dist/{support-STDLB7EO.js → support-FO4RLDNQ.js} +2 -2
- package/dist/{task-WXOWJ5VV.js → task-W6VLD6X7.js} +4 -4
- package/dist/teams-WMKWQCLH.js +4 -0
- package/dist/{trigger-command-QUWGCSXO.js → trigger-command-JXPPZBKT.js} +2 -2
- package/dist/{user-B7XDDSRX.js → user-SKIUDKWE.js} +4 -4
- package/dist/{user-contract-type-NCO5QWQD.js → user-contract-type-2XXNPP27.js} +2 -2
- package/dist/{user-group-AAY546AB.js → user-group-EEXQBLIC.js} +2 -2
- package/dist/{worker-agent-P3VHKVHE.js → worker-agent-BJVP2MPH.js} +2 -2
- package/dist/{workflow-MG4LJH3M.js → workflow-WOQKGIUU.js} +2 -2
- package/package.json +1 -1
- package/dist/budget-NBOOIARX.js +0 -5
- package/dist/charter-command-A4MFFBGE.js +0 -3
- package/dist/chunk-VFPY2A23.js +0 -4
- package/dist/chunk-Z6Q7ATX2.js +0 -14
- package/dist/journal-GGGYNNXX.js +0 -63
- package/dist/outlook-LU42AHOQ.js +0 -4
- package/dist/project-4J7UVMDK.js +0 -5
- package/dist/query-J76QIXWR.js +0 -3
- package/dist/receivable-NJG4BGDR.js +0 -4
- package/dist/teams-V7CF4Y7E.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{buildDiffLines,diffStat}from"./chunk-VRBI2NPI.js";import{PRIVATE_PROJECT_REF,isPrivateProjectRef}from"./chunk-RMFLTSOV.js";import{dateFlag}from"./chunk-
|
|
4
|
-
import{ApiError}from"./chunk-SH2YLLVL.js";import{ResolveError,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-
|
|
3
|
+
import{buildDiffLines,diffStat}from"./chunk-VRBI2NPI.js";import{PRIVATE_PROJECT_REF,isPrivateProjectRef}from"./chunk-RMFLTSOV.js";import{dateFlag}from"./chunk-YLF4S4MC.js";import{composeDocument,meetingContentToText,metaLine,noteContentToText,oneLine,textOutline,textSection,wikiContentToText}from"./chunk-62GRAKUD.js";import{boundedText}from"./chunk-CHT6EP5C.js";import{charCount,readBody}from"./chunk-V5WDGX4S.js";import{repeatedValues}from"./chunk-6NHLWYI2.js";
|
|
4
|
+
import{ApiError}from"./chunk-SH2YLLVL.js";import{ResolveError,isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-DYT22FTA.js";import{requireResolved,withResolved}from"./chunk-7DCWZ2NF.js";import{acknowledgement,isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiRejectedError,ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";import path from"path";var WIKI_PATH="/api/v2/wiki";var WIKI_SUMMARY_FIELDS="summary";function withoutContent(page){const rest={...page};delete rest["content"];return rest}var NOTES_PATH="/api/v2/notes";var MEETINGS_PATH="/api/v2/meetings";var ROOT_PARENT="root";var WIKI_STATUSES=["draft","published"];var WIKI_CONTENT_FORMATS=["html","markdown"];var NOTE_STATUSES=["draft","published"];var NOTE_VISIBILITIES=["private","tenant","external","public"];var NOTE_SORTS=["manual","created_at","updated_at","view_count","comment\
|
|
5
5
|
_count","reaction_count"];var MEETING_STATUSES=["draft","published","archived"];var MEETING_TYPES=["regular","client","internal","retrospective","decision","one_on_one"];var MEETING_SORTS=["meeting_date","created_at","updated_at","title"];var SORT_ORDERS=["asc","desc"];var MEETING_TAGS_MAX=20;var MEETING_TAG_MAX_CHARS=50;var DATE_FLOOR="0000-01-01";var DATE_CEIL="9999-12-31";var WIKI_LIST_COLUMNS=["id","title","status","parent_page_id","updated_at","updated_by_name"];var WIKI_STALE_COLUMNS=["id",
|
|
6
6
|
"title","status","verified_at","knowledge_kind","evidence_task_keys","updated_at"];var WIKI_CHILD_COLUMNS=["id","title","status","child_count","updated_at","updated_by_name"];var WIKI_SEARCH_COLUMNS=["id","title","status","search_excerpt","updated_at","updated_by_name"];var WIKI_GET_COLUMNS=["id","title","status","content_format","parent_page_id","version","tags","verified_at","evidence_task_keys","knowledge_kind","updated_at","updated_by_name"];var NOTE_LIST_COLUMNS=["id","title","status","visi\
|
|
7
7
|
bility","created_by_name","updated_at","comment_count","reaction_count"];var NOTE_GET_COLUMNS=["id","title","status","visibility","content_type","category_name","tags","created_by_name","updated_at","view_count"];var MEETING_LIST_COLUMNS=["id","meeting_date","title","meeting_type","status","project_name","created_by_name"];var MEETING_GET_COLUMNS=["id","title","meeting_date","meeting_type","status","project_name","category_name","created_by_name","updated_at"];var TEXT_OUTPUT_HELP="--output text\
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{UsageError}from"./chunk-
|
|
3
|
+
import{UsageError}from"./chunk-STILP3Z6.js";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-B4FAEXU4.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}`)}}export{evaluateQuery};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{DEFAULT_INTERVAL_SEC}from"./chunk-
|
|
3
|
+
import{DEFAULT_INTERVAL_SEC}from"./chunk-7KFJL6FU.js";import{CHAIN_KEYS,reloadAiConfig}from"./chunk-ZFSWQQH3.js";import{describeError}from"./chunk-GYX2ZXQM.js";import{isPrivateProjectId}from"./chunk-RMFLTSOV.js";import{parseOrientation}from"./chunk-NJL3H2BB.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
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}}const rawLoop=b["loop"];const rawInterval=rawLoop!==null&&typeof rawLoop==="object"&&!Array.isArray(rawLoop)?
|
|
5
5
|
rawLoop["interval_sec"]:void 0;const intervalSec=typeof rawInterval==="number"&&Number.isInteger(rawInterval)&&rawInterval>0?rawInterval:null;const rawOutcomes=b["outcomes"];const outcomeSkills=Array.isArray(rawOutcomes)?[...new Set(rawOutcomes.map(r=>r!==null&&typeof r==="object"?r["skill"]:void 0).filter(v=>typeof v==="string"&&v.trim()!==""))]:[];return{revision,ai,prompts,intervalSec,outcomeSkills,orientation:parseOrientation(b["orientation"])}}function formatConfigHash(aiHash,revision,ai,charter){
|
|
6
6
|
return`${aiHash};r=${revision};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="";lastInterval="";async apply(){const{config,log}=this.deps;const outcome=await this.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{decodeCsvText}from"./chunk-
|
|
3
|
+
import{decodeCsvText}from"./chunk-OMW6BBAY.js";import{ApiError}from"./chunk-SH2YLLVL.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{envelopePaging,flagSegment,positiveInteger,shellQuote}from"./chunk-DYT22FTA.js";import{requireResolved,withResolved}from"./chunk-7DCWZ2NF.js";import{isRecord}from"./chunk-HCTPCUST.js";import{ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";import fs from"fs";var LOGIN_HISTORY_RETENTION_DAYS=90;var DEFAULT_INACTIVE_DAYS=60;var DEFAULT_MAX_USERS=2e3;var LIST_PAGE_LIMIT=100;var MATRIX_PAGE_LIMIT=200;var LOGIN_HISTORY_LIMIT=500;var CONCURRENCY=4;var SEND_PER_MINUTE=200;var SEND_BURST=30;var RATE_LIMIT_WAIT_MS=6e4;var RATE_LIMIT_RETRIES=2;var LEDGER_MAX_BYTES=5*1024*1024;var USAGE="twp user export [--file <\u53F0\u5E33CSV>] [--include-disabled] [--exclude-hidden] [--inactive-days <\u65E5\u6570>] [--code-column <\u5217\u540D>] [--name-column <\u5217\u540D>] [--email-column <\u5217\u540D>] [--department-c\
|
|
4
4
|
olumn <\u5217\u540D>] [--position-column <\u5217\u540D>] [--max-users <\u4EBA\u6570>]";var HELP="twp user export help";var listPaging=envelopePaging({label:"\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7"});var LEDGER_ROLES=["code","name","email","department","position"];var ROLE_LABEL={code:"\u793E\u54E1\u756A\u53F7",name:"\u6C0F\u540D",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",department:"\u90E8\u7F72",position:"\u5F79\u8077"};var COLUMN_CANDIDATES={code:["\u793E\u54E1\u756A\u53F7","\u5F93\u696D\u54E1\u756A\u53F7",
|
|
5
5
|
"\u793E\u54E1\u30B3\u30FC\u30C9","\u5F93\u696D\u54E1\u30B3\u30FC\u30C9","employee_code","employee_no"],name:["\u6C0F\u540D","\u540D\u524D","\u793E\u54E1\u540D","\u5F93\u696D\u54E1\u540D","name","user_name"],email:["\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9","\u4F1A\u793E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9","email","login_id"],department:["\u90E8\u7F72","\u90E8\u7F72\u540D","\u6240\u5C5E\u90E8\u7F72","department","department_name"],position:["\u5F79\u8077","\u5F79\u8077\u540D","position",
|
|
6
6
|
"position_name"]};function parseCsvRecords(text){const records=[];let cells=[];let field="";let quoted=false;let started=false;let line=1;let recordLine=1;let i=0;const pushRecord=()=>{cells.push(field);records.push({line:recordLine,cells});cells=[];field="";started=false};while(i<text.length){const ch=text[i];if(quoted){if(ch==='"'){if(text[i+1]==='"'){field+='"';i+=2;continue}quoted=false}else if(ch==="\r"||ch==="\n"){if(ch==="\r"&&text[i+1]==="\n")i+=1;line+=1;field+="\n"}else{field+=ch}i+=1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{requireResolved,singleRef,withResolved}from"./chunk-
|
|
3
|
+
import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{requireResolved,singleRef,withResolved}from"./chunk-7DCWZ2NF.js";import{ApiResponseError}from"./chunk-STILP3Z6.js";var USER_REF_HELP="<\u30E6\u30FC\u30B6\u30FC> \u306F ID\u30FB\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u30FB\u793E\u54E1\u756A\u53F7\u30FB\u6C0F\u540D\u30FBme\uFF08\u81EA\u5206\uFF09\u306E\u3069\u308C\u3067\u3082\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n\u6C0F\u540D\u306F\u5B8C\u5168\u4E00\u81F4\u30671\u4EBA\u306B\u7D5E\u308C\u305F\u3068\u304D\u3060\u3051\u53D7\u3051\u4ED8\u3051\u307E\u3059\uFF08\u540C\u59D3\u540C\u540D\u306A\u3089\u5019\u88DC\u3092\u51FA\u3057\u3066\u6B62\u307E\u308B\u306E\u3067\u3001\n\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304B\u793E\u54E1\u756A\u53F7\u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002ID \u4EE5\u5916\u306F\u3001\u30C6\u30CA\u30F3\u30C8\u306E\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7\n\uFF08\u65E2\u5B9A10\u5206\u30AD\u30E3\u30C3\u30B7\u30E5\u30FB--refresh \u3067\u53D6\u308A\u76F4\u3057\uFF09\u3068\u7167\u5408\u3057\u307E\u3059\u3002\n\u8868\u793A\u30D5\u30E9\u30B0\u3092\u5916\u3057\u305F\u30E6\u30FC\u30B6\u30FC\u306F\u793E\u54E1\u756A\u53F7\u3067\u306F\u5F15\u3051\u307E\u305B\u3093\u3002\u7D44\u7E54\u7BA1\u7406\u8005\u3067\u306A\u3044\u5834\u5408\u306F ID \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
4
4
|
function userPath(input,suffix=""){const userId=requireResolved(input,"userId");if(!isSafePathSegment(userId)){throw new ApiResponseError(`\u30B5\u30FC\u30D0\u304C\u8FD4\u3057\u305F\u30E6\u30FC\u30B6\u30FC ID \u3092\u30D1\u30B9\u306B\u4F7F\u3048\u307E\u305B\u3093: ${userId}\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)}return`${encodeURIComponent(userId)}${suffix}`}var USER_REF_FLAG={name:"--user",summary:"\u5BFE\u8C61\u306E\u30E6\u30FC\u30B6\u30FC\uFF08\u4F4D\u7F6E\u5F15\u6570\u306E\u4EE3\u308F\u308A\u306B\u4F7F\u3048\u308B\uFF09",
|
|
5
5
|
takesValue:true,placeholder:"<\u30E6\u30FC\u30B6\u30FC>"};async function prepareUser(input,ctx,usage){const ref=singleRef(input,{flag:"--user",label:"\u30E6\u30FC\u30B6\u30FC",usage});const user=await ctx.resolver.user(ref);return withResolved(input,{userId:user.id})}export{USER_REF_HELP,userPath,USER_REF_FLAG,prepareUser};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{UsageError}from"./chunk-
|
|
3
|
+
import{UsageError}from"./chunk-STILP3Z6.js";import fs from"fs";var BOM=new RegExp(`^${String.fromCharCode(65279)}`);function decodeCsvText(bytes){try{return new TextDecoder("utf-8",{fatal:true}).decode(bytes).replace(BOM,"")}catch{return new TextDecoder("shift_jis").decode(bytes)}}function readCsvFileText(file,usage,maxBytes,tooLarge){try{const stat=fs.statSync(file);if(!stat.isFile())throw new UsageError(`--file \u306B\u901A\u5E38\u306E\u30D5\u30A1\u30A4\u30EB\u4EE5\u5916\u306F\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093: ${file}`,usage);if(stat.size>maxBytes)
|
|
4
4
|
throw tooLarge(stat.size);return decodeCsvText(fs.readFileSync(file))}catch(err){if(err instanceof UsageError)throw err;const reason=err.code??err.message;throw new UsageError(`--file \u306E\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u3081\u307E\u305B\u3093: ${file}\uFF08${reason}\uFF09`,usage)}}export{decodeCsvText,readCsvFileText};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{projectEvaluationResource}from"./chunk-
|
|
4
|
-
resolveRefFields,updateFlags}from"./chunk-
|
|
5
|
-
import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger,shellQuote}from"./chunk-
|
|
3
|
+
import{projectEvaluationResource}from"./chunk-E6KLOTR2.js";import{JsonBodyWithView}from"./chunk-Q3B65OFC.js";import{FROM_FLAG,MANHOUR_DESCRIPTION,MANHOUR_FROM_FLAG,MANHOUR_TO_FLAG,MONTH_FLAG,TO_FLAG,dataOf,listIn,manhourNotes,manhourQuery,manhourRows,monthRange,rangeNotes,recordOf,workloadDistributionNotes,workloadDistributionRows}from"./chunk-OZ66X3YI.js";import{USER_REF_FLAG,USER_REF_HELP,userPath}from"./chunk-O756DX6D.js";import{createFlags,fieldBody,hasAnyField,idSegment,
|
|
4
|
+
resolveRefFields,updateFlags}from"./chunk-65IPXSC6.js";import{booleanText,boundedText,isoDate}from"./chunk-CHT6EP5C.js";import{containsRedactedMarker,readBody}from"./chunk-V5WDGX4S.js";import{ALLOW_REDACTED_FLAG}from"./chunk-W4NLJ2YK.js";import{REDACTED}from"./chunk-BD7O73GK.js";import{repeatedValues}from"./chunk-6NHLWYI2.js";import{PROJECT_MEMBERS_LIMIT,PROJECT_TEMPLATES_PATH,resolveNamed}from"./chunk-ZOUOJQ7J.js";import{collapsesInUrlPath,safeProjectIdPolicy}from"./chunk-HVZUXLQ4.js";
|
|
5
|
+
import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger,shellQuote}from"./chunk-DYT22FTA.js";import{requireResolved,singleRef,withResolved}from"./chunk-7DCWZ2NF.js";import{acknowledgement,isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiRejectedError,ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";var PROJECT_FLAG={name:"--project",summary:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30FC\u30C9\u307E\u305F\u306F ID\uFF08\u7701\u7565\u6642\u306F TWP_PROJECT / .twp/config.json / ~/.twp/config.json\uFF09",takesValue:true,placeholder:"<\u30B3\u30FC\u30C9|ID>"};var ROLE_FLAG={name:"--role",summary:"\u5F79\u5272\uFF08member / manager \u306A\u3069\u30FB\u5024\u306F\u30B5\u30FC\u30D0\u304C\u691C\u67FB\u3059\u308B\uFF09",takesValue:true,placeholder:"<\u5F79\u5272>"};var START_DATE_FLAG={name:"\
|
|
6
6
|
--start-date",summary:"\u53C2\u753B\u958B\u59CB\u65E5\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<YYYY-MM-DD>"};var END_DATE_FLAG={name:"--end-date",summary:"\u53C2\u753B\u7D42\u4E86\u65E5\uFF08YYYY-MM-DD\uFF09",takesValue:true,placeholder:"<YYYY-MM-DD>"};var PERIOD_FILE_FLAG={name:"--period-file",summary:"\u7A3C\u50CD\u671F\u9593\uFF08assignment_periods\uFF09\u306E JSON \u914D\u5217\u30D5\u30A1\u30A4\u30EB\uFF08- \u3067\u6A19\u6E96\u5165\u529B\uFF09",takesValue:true,placeholder:"<\u30D1\u30B9>"};
|
|
7
7
|
var WIKI_ROLE_FLAG={name:"--wiki-role",summary:"\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E Wiki \u6A29\u9650\uFF08admin\uFF1DWiki \u7BA1\u7406\u8005 / member\uFF1D\u4E00\u822C\uFF09",takesValue:true,placeholder:"<admin|member>"};var MEMO_FLAG={name:"--memo",summary:"\u30E1\u30E2\uFF0810,000 \u6587\u5B57\u307E\u3067\uFF09",takesValue:true,placeholder:"<\u6587\u5B57\u5217>"};var CLEAR_FLAG={name:"--clear",summary:"\u5225\u540D\u3092\u6D88\u3059",takesValue:false};var WIKI_ROLES=["admin",
|
|
8
8
|
"member"];var MEMO_MAX_CHARS=1e4;var PERIOD_FILE_MAX_CHARS=2e5;var ALIAS_MAX_CHARS=255;var PERIOD_KEYS=["id","start_date","end_date","daily_hours","total_hours","input_mode"];var PERIOD_REQUIRED=["start_date","end_date","daily_hours"];var ROLE_HELP="--role \u306E\u5024\u306F\u30B5\u30FC\u30D0\u304C\u691C\u67FB\u3057\u307E\u3059\uFF08CLI \u306F\u691C\u67FB\u3057\u307E\u305B\u3093\uFF09\u30022026-10-01 \u6642\u70B9\u306E\u5024\u306F\n member\uFF08\u30E1\u30F3\u30D0\u30FC\uFF09/ manager\uFF08\u7BA1\u7406\u8005\uFF09/ approver\uFF08\u7BA1\u7406\u8005\uFF08\u627F\u8A8D\u8005\uFF09\uFF09/ manager_no_punch\uFF08\u7BA1\u7406\u8005\uFF08\u6253\u523B\u7121\uFF09\uFF09\u3067\u3059\u3002\n \u5024\u306F\u5897\u3048\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002\u4ECA\u306E\u30E1\u30F3\u30D0\u30FC\u306E\u5024\u306F twp project members \u306E role \u5217\u3067\u78BA\u304B\u3081\u3089\u308C\u307E\u3059\u3002";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{hoursMinutes}from"./chunk-
|
|
3
|
+
import{hoursMinutes}from"./chunk-YNZJA3KF.js";import{dateFlag,monthFlag}from"./chunk-YLF4S4MC.js";import{repeatedValues}from"./chunk-6NHLWYI2.js";import{requireResolved,withResolved}from"./chunk-7DCWZ2NF.js";import{isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";var ANALYSIS_PATH="/api/v2/analysis";var ACCESSIBLE_PAGES_HINT="\u958B\u3051\u308B\u5206\u6790\u30DA\u30FC\u30B8\u306F twp api /api/v2/analysis/accessible-pages \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059\u3002";var LICENSE_GUIDANCE="\u5206\u6790\u3092\u4F7F\u3046\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u30C6\u30CA\u30F3\u30C8\u304C\u5206\u6790\u3092\u5951\u7D04\u3057\u3066\u3044\u306A\u3044\u304B\u3001\u3042\u306A\u305F\u306E\u5206\u6790\u306E\u6A29\u9650\u304C\u300C\u306A\u3057\u300D\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002";
|
|
4
4
|
var PAGE_GUIDANCE=`\u3053\u306E\u5206\u6790\u30DA\u30FC\u30B8\u306E\u95B2\u89A7\u5BFE\u8C61\u306B\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u5206\u6790\u306E\u7BA1\u7406\u8005\u306B\u5BFE\u8C61\u3078\u306E\u8FFD\u52A0\u3092\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002${ACCESSIBLE_PAGES_HINT}`;var PAGE_DENIED_MARK="\u5206\u6790\u30DA\u30FC\u30B8";function analysisForbidden(levelGuidance2){return body=>{if(body?.error==="permission_denied"){const text=body.error_description??"";
|
|
5
5
|
if(text.includes(PAGE_DENIED_MARK))return PAGE_GUIDANCE;if(text.includes("\u3053\u306E\u6A5F\u80FD"))return LICENSE_GUIDANCE;return void 0}if(body?.error==="forbidden")return levelGuidance2;return void 0}}function levelGuidance(page,features){return`${page}\u3092\u958B\u304F\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u5206\u6790\u62C5\u5F53\u8005\u30D5\u30E9\u30B0\u3001\u307E\u305F\u306F${features}\u306E\u6A29\u9650\uFF08\u300C\u306A\u3057\u300D\u4EE5\u5916\uFF09\u304C\u8981\u308A\u307E\u3059\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}
|
|
6
6
|
var FROM_FLAG={name:"--from",summary:"\u958B\u59CB\u306E\u5E74\u6708\uFF08YYYY-MM\uFF09",takesValue:true,placeholder:"<YYYY-MM>"};var TO_FLAG={name:"--to",summary:"\u7D42\u4E86\u306E\u5E74\u6708\uFF08YYYY-MM\uFF09",takesValue:true,placeholder:"<YYYY-MM>"};var MONTH_FLAG={name:"--month",summary:"1\u304B\u6708\u3060\u3051\uFF08YYYY-MM\uFF09\u3002--from / --to \u3068\u306F\u4F75\u7528\u4E0D\u53EF",takesValue:true,placeholder:"<YYYY-MM>"};var YEAR_FLAG={name:"--year",summary:"1\u5E74\u5206\uFF081\u301C12\u6708\u30FBYYYY\uFF09\u3002--from \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{boundedText}from"./chunk-
|
|
3
|
+
import{boundedText}from"./chunk-CHT6EP5C.js";import{NOTIFICATIONS_PATH}from"./chunk-ZOUOJQ7J.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{LIST_FLAGS,LIST_PAGING_HELP,envelopePaging,nonEmpty,positiveInteger}from"./chunk-DYT22FTA.js";import{requireResolved,withResolved}from"./chunk-7DCWZ2NF.js";import{isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";var LABEL="\u901A\u77E5";var LIST_COLUMNS=["id","datetime","category_name","status_name","title"];var GET_COLUMNS=["id","datetime","category","category_name","status_name","read_time","title","content","url"];var CATEGORY_FLAG={name:"--category",summary:"\u901A\u77E5\u30AB\u30C6\u30B4\u30EA\u3067\u7D5E\u308A\u8FBC\u3080\uFF08\u30AD\u30FC\u304B\u540D\u524D\u3002twp notification categories \u3067\u4E00\u89A7\u3067\u304D\u308B\uFF09",takesValue:true,placeholder:"<\u30AB\u30C6\u30B4\u30EA>"};var CATEGORY_HELP="\
|
|
4
4
|
--category \u306F\u30AB\u30C6\u30B4\u30EA\u306E\u30AD\u30FC\uFF08workflow_approval\uFF09\u304B\u540D\u524D\uFF08\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u627F\u8A8D\u4F9D\u983C\uFF09\u3067\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\n\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7\u3068\u7167\u5408\u3059\u308B\u306E\u3067\u3001\u6253\u3061\u9593\u9055\u3048\u305F\u30AB\u30C6\u30B4\u30EA\u3092\u300C0\u4EF6\u300D\u3068\u3057\u3066\u8FD4\u3059\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u4E00\u89A7\u306F\u65E2\u5B9A10\u5206\u30AD\u30E3\u30C3\u30B7\u30E5\u30FB--refresh \u3067\u53D6\u308A\u76F4\u3057\uFF09\u3002";
|
|
5
5
|
async function resolveCategory(input,ctx){const raw=nonEmpty(input.flags,CATEGORY_FLAG.name);if(raw===void 0)return input;return withResolved(input,{category:(await ctx.resolver.notificationCategory(raw.trim())).id})}function noArgs(input,op){if(input.args.length>0){throw new UsageError(`${op} \u306F\u4F4D\u7F6E\u5F15\u6570\u3092\u53D6\u308A\u307E\u305B\u3093: ${input.args.join(" ")}`,`twp notification ${op} help`)}}function notificationId(input,op){const[raw,...rest]=input.args;const id=raw?.trim()??
|
|
6
6
|
"";if(id==="")throw new UsageError("\u901A\u77E5\u306E ID \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044",`twp notification ${op} help`);if(rest.length>0)throw new UsageError(`${op} \u304C\u53D7\u3051\u53D6\u308C\u308B\u901A\u77E5 ID \u306F1\u3064\u3060\u3051\u3067\u3059: ${rest.join(" ")}`,`twp notification ${op} help`);if(!isSafePathSegment(id)){throw new UsageError(`\u901A\u77E5\u306E ID \u3068\u3057\u3066\u4F7F\u3048\u306A\u3044\u5024\u3067\u3059: ${id}`,"\u901A\u77E5\u306E ID \u306F twp notification li\
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{apiExit,currentRevisionOf,errorDetail,pickNumber,printDiff,readUtf8Strict,shellQuote}from"./chunk-
|
|
3
|
+
import{apiExit,currentRevisionOf,errorDetail,pickNumber,printDiff,readUtf8Strict,shellQuote}from"./chunk-BLDQ6PY3.js";import{EXIT_API_SERVER,EXIT_FAILURE,EXIT_OK,EXIT_USAGE}from"./chunk-STILP3Z6.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import*as fs from"fs";var DEFAULT_SETTINGS_FILE="loop-settings.json";var MAP_SECTIONS=["ai","prompts","loop"];var SECTIONS=[...MAP_SECTIONS,"outcomes","orientation"];var REVISION_KEY="revision";async function runSettingsCommand(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??readUtf8Strict;const writeFile=deps.writeFile??((p,c)=>fs.writeFileSync(p,c,"utf8"));const exists=deps.
|
|
4
4
|
exists??(p=>fs.existsSync(p));return opts.op==="push"?push(deps.api,opts,{out,err,readFile}):pull(deps.api,opts,{out,err,readFile,writeFile,exists})}function serializeSettings(s){const prompts={...s.prompts};delete prompts["charter"];return`${JSON.stringify({[REVISION_KEY]:s.revision,ai:s.ai,prompts,loop:s.loop,outcomes:s.outcomes,orientation:s.orientation},null,2)}
|
|
5
5
|
`}async function pull(api,opts,io){const target=opts.out??DEFAULT_SETTINGS_FILE;const current=await fetchState(api,io.err);if(typeof current==="number")return current;const content=serializeSettings(current);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}\
|
|
6
6
|
\uFF08${e.message}\uFF09
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{textToHtml}from"./chunk-
|
|
4
|
-
withResolved}from"./chunk-
|
|
3
|
+
import{textToHtml}from"./chunk-43RLWH2F.js";import{cursorFlag,graphData,graphListFlags,graphPaging,graphPagingHelp,graphPagingNotes,graphValue,ms365Forbidden,plainText,str,teamsFromText,topFlag}from"./chunk-K2TO4DFJ.js";import{readBody}from"./chunk-V5WDGX4S.js";import{repeatedValues}from"./chunk-6NHLWYI2.js";import{assertMs365PathSegment,ms365Path,ms365Segment}from"./chunk-YJP4FUY4.js";import{nonEmpty}from"./chunk-DYT22FTA.js";import{requireResolved,singleRef,
|
|
4
|
+
withResolved}from"./chunk-7DCWZ2NF.js";import{isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiRejectedError,ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";var KINDS=["channel","chat"];var TEAM_ID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;var DESCRIPTION_MAX=2e3;var NAME_MAX=255;var FAVORITE_COLUMNS=["kind","display_name","description","sort_order","team_id","id"];var KIND_FLAG={name:"--kind",summary:"\u7A2E\u5225\u3067\u7D5E\u308B\uFF08channel | chat\uFF09",takesValue:true,placeholder:"<\u7A2E\u5225>"};var TEAM_FLAG={name:"--team",summary:"\u30C1\u30FC\u30E0\uFF08\u540D\u524D\u304B ID\uFF09",takesValue:true,placeholder:"<\u540D\u524D\
|
|
5
5
|
|ID>"};var CHANNEL_FLAG={name:"--channel",summary:"\u30C1\u30E3\u30CD\u30EB\uFF08\u540D\u524D\u304B ID\uFF09",takesValue:true,placeholder:"<\u540D\u524D|ID>"};var CHAT_FLAG={name:"--chat",summary:"\u30C1\u30E3\u30C3\u30C8ID\uFF08twp teams chat list \u306E id\uFF09",takesValue:true,placeholder:"<ID>"};var DESCRIPTION_FLAG={name:"--description",summary:`\u7528\u9014\u306E\u8AAC\u660E\uFF08${DESCRIPTION_MAX}\u6587\u5B57\u307E\u3067\u3002"" \u3067\u7A7A\u306B\u3059\u308B\uFF09`,takesValue:true,placeholder:"\
|
|
6
6
|
<\u6587>"};var NAME_FLAG={name:"--name",summary:"\u8868\u793A\u540D\uFF08\u7701\u304F\u3068\u30C1\u30E3\u30CD\u30EB\u306F\u30C1\u30E3\u30CD\u30EB\u540D\u3001\u30C1\u30E3\u30C3\u30C8\u306F\u30C8\u30D4\u30C3\u30AF\u304B\u81EA\u5206\u4EE5\u5916\u306E\u53C2\u52A0\u8005\u540D\uFF09",takesValue:true,placeholder:"<\u540D\u524D>"};var FAVORITES_PATH="/teams/favorites";function parseKind(raw,usage){if(raw===void 0)return void 0;const kind=raw.trim();if(!KINDS.includes(kind)){throw new UsageError(`\u7A2E\u5225\u306B\u6307\u5B9A\u3067\u304D\
|
|
7
7
|
\u308B\u306E\u306F channel / chat \u3067\u3059\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`,usage)}return kind}function parseKey(raw,usage){const slash=raw.indexOf("/");if(slash<0){throw new UsageError(`\u304A\u6C17\u306B\u5165\u308A\u306F <\u7A2E\u5225>/<ID> \u306E\u5F62\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u53D7\u3051\u53D6\u3063\u305F\u5024: ${raw}\uFF09`,usage)}const kind=parseKind(raw.slice(0,slash),usage);const id=assertMs365PathSegment(raw.slice(slash+1).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
var EXIT_OK=0;var EXIT_FAILURE=1;var EXIT_USAGE=2;var EXIT_API_CLIENT=3;var EXIT_API_SERVER=4;var EXIT_AUTH=5;var EXIT_WAIT_TIMEOUT=6;var EXIT_CONFLICT=7;var UsageError=class extends Error{constructor(message,hint){super(message);this.hint=hint;this.name="UsageError"}hint};var ApiResponseError=class extends Error{constructor(message){super(message);this.name="ApiResponseError"}};var ApiRejectedError=class extends Error{constructor(message){super(message);this.name="ApiRejectedError"}};var WaitTimeoutError=class extends Error{constructor(message){
|
|
4
|
+
super(message);this.name="WaitTimeoutError"}};var ConflictError=class extends Error{constructor(message,status,details={},hint){super(message);this.status=status;this.details=details;this.hint=hint;this.name="ConflictError"}status;details;hint};var NetworkError=class extends Error{constructor(message,options){super(message,options);this.name="NetworkError"}};export{EXIT_OK,EXIT_FAILURE,EXIT_USAGE,EXIT_API_CLIENT,EXIT_API_SERVER,EXIT_AUTH,EXIT_WAIT_TIMEOUT,EXIT_CONFLICT,UsageError,ApiResponseError,ApiRejectedError,WaitTimeoutError,ConflictError,NetworkError};
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelIndex,validateBody,validateQuery,withCommonQueryParams}from"./chunk-4UVHLNUA.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{redactSecretValues}from"./chunk-BD7O73GK.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-SH2YLLVL.js";
|
|
4
|
-
emptyUsage}from"./chunk-3TZ2S5D7.js";import{isPrivateTwpHome,isTrustworthyCacheFile,writePrivateFileAtomic}from"./chunk-D233KKXW.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{AuthSession,NotLoggedInError,SessionExpiredError}from"./chunk-ITFO5GPX.js";import{withFileLock}from"./chunk-GWVREACM.js";import{httpFetch}from"./chunk-J7QYPKVK.js";
|
|
5
|
-
applyPermissionMode,checkPermission,isModeId,setActiveModes}from"./chunk-2LOT54OO.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs2 from"fs";import path3 from"path";import os2 from"os";import
|
|
6
|
-
abs){assertInside(real,root,abs);assertNotSecret(real,home)}return abs}function realToolPath(input,cwd,home=homedir()){return realOrSelf(resolveToolPath(input,cwd,home))}function assertInside(target,root,reported){const rel=relative(root,target);const outside=rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel);if(outside){throw new PathDeniedError(`path escapes the working directory (${reported}). Only paths under ${root} can be accessed.`)}}function realOrSelf(target){let current=target;const rest=[];
|
|
7
|
-
for(;;){try{const real=realpathSync(current);return rest.length===0?real:resolve(real,...rest.reverse())}catch{const parent=dirname(current);if(parent===current)return target;rest.push(current.slice(parent.length+1));current=parent}}}function assertNotSecret(absPath,home=homedir(),env=process.env){const reason=secretReason(absPath,home,env);if(reason!==null)throw new PathDeniedError(`refusing to access ${absPath}: ${reason}`)}function secretReason(absPath,_home=homedir(),env=process.env){const lower=absPath.
|
|
8
|
-
toLowerCase();const segments=lower.split(sep);const base=segments[segments.length-1]??"";const parent=segments[segments.length-2]??"";if(base===".env"||base.startsWith(".env."))return".env files are denied (design \xA77)";if(segments.includes(".ssh"))return"SSH key material is denied (design \xA77)";if(parent===".git"&&base==="config"){return".git/config is denied (it can hold a GitHub token in the remote URL)"}if(base===".netrc"||base==="_netrc"||base===".npmrc")return"credential files are deni\
|
|
9
|
-
ed";if(parent===".aws"&&(base==="credentials"||base==="config"))return"AWS credentials are denied";for(const dir of configReadDirs(env)){if(lower===resolve(dir,"credentials.json").toLowerCase()){return"TWP credentials are denied (design \xA77)"}}if(parent===".twp"&&base==="credentials.json")return"TWP credentials are denied (design \xA77)";if(parent==="logs"&&base.startsWith("session-")&&base.endsWith(".jsonl")){const grandparent=segments[segments.length-3]??"";if(grandparent===".twp")return"TWP\
|
|
10
|
-
audit logs are denied (design \xA77)";for(const dir of configReadDirs(env)){if(lower.startsWith(resolve(dir,"logs").toLowerCase()+sep)){return"TWP audit logs are denied (design \xA77)"}}}return null}function toolRelative(cwd,absPath){const rel=relative(cwd,absPath);return sep==="\\"?rel.split("\\").join("/"):rel}function isInsideCwd(absPath,cwd){const root=resolve(cwd);if(!withinLexically(absPath,root))return false;const real=realOrSelf(absPath);return real===absPath||withinLexically(real,realOrSelf(
|
|
11
|
-
root))}function withinLexically(target,root){const rel=relative(root,target);return!(rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel))}function expandHome(input,home){if(input==="~")return home;if(input.startsWith("~/")||input.startsWith(`~${sep}`))return resolve(home,input.slice(2));return input}import path from"path";import{homedir as homedir2}from"os";import{sep as sep2}from"path";function isSingleCommand(command){let quote=null;for(let i=0;i<command.length;i++){const ch=command[i];const next=command[i+1];if(quote==="'"){if(ch==="'")quote=null;continue}if(quote==='"'){if(ch==="\\"){i++;continue}if(ch==="`")return false;if(ch==="$"&&next==="(")return false;if(ch==='"')quote=null;continue}switch(ch){case'"':case"'":quote=ch;continue;case"\\":i++;continue;case";":case"&":case"|":case"\n":case"`":case">":case"<":return false;case"$":if(next==="(")return false;if(next==="'")return false;
|
|
3
|
+
import{CommandModelMissingError,MAX_REPORTED_VIOLATIONS,loadCommandModelDomain,loadCommandModelIndex,validateBody,validateQuery,withCommonQueryParams}from"./chunk-4UVHLNUA.js";import{PathDeniedError,isInsideCwd,realOrSelf,realToolPath,resolveToolPath,secretReason,toolRelative}from"./chunk-XCU3PDQV.js";import{isForceOnly,killProcessTree,system32}from"./chunk-N2UVRM3Z.js";import{redactSecretValues}from"./chunk-BD7O73GK.js";import{ApiError,TwpApiClient,appendQuery}from"./chunk-SH2YLLVL.js";
|
|
4
|
+
import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{DEFAULT_MAX_HISTORY_BYTES,DEFAULT_MAX_TOKENS,effectiveModelSpec,emptyUsage}from"./chunk-3TZ2S5D7.js";import{isPrivateTwpHome,isTrustworthyCacheFile,writePrivateFileAtomic}from"./chunk-D233KKXW.js";import{findExecutable,isWindowsDriveAbsolute}from"./chunk-PMOUHEJQ.js";import{AuthSession,NotLoggedInError,SessionExpiredError}from"./chunk-ITFO5GPX.js";import{withFileLock}from"./chunk-GWVREACM.js";import{httpFetch}from"./chunk-J7QYPKVK.js";
|
|
5
|
+
import{configReadDirs,ensureTwpHome,twpHomeDir}from"./chunk-RZVI6PMW.js";import{MODES,applyPermissionMode,checkPermission,isModeId,setActiveModes}from"./chunk-2LOT54OO.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs2 from"fs";import path3 from"path";import os2 from"os";import path from"path";import{homedir}from"os";import{sep}from"path";function isSingleCommand(command){let quote=null;for(let i=0;i<command.length;i++){const ch=command[i];const next=command[i+1];if(quote==="'"){if(ch==="'")quote=null;continue}if(quote==='"'){if(ch==="\\"){i++;continue}if(ch==="`")return false;if(ch==="$"&&next==="(")return false;if(ch==='"')quote=null;continue}switch(ch){case'"':case"'":quote=ch;continue;case"\\":i++;continue;case";":case"&":case"|":case"\n":case"`":case">":case"<":return false;case"$":if(next==="(")return false;if(next==="'")return false;
|
|
12
6
|
continue;case"#":{const prev=command[i-1];if(i===0||prev===" "||prev===" ")return false;continue}default:continue}}return true}function isRecursiveForceRemove(command){const re=/(^|[^\w.-])(rm|rmdir)([^\w.-]|$)/g;for(;;){const m=re.exec(command);if(m===null)return false;const tail=command.slice(m.index+m[0].length);const segment=tail.split(/[;&|\n]/)[0]??"";const tokens=segment.split(/\s+/).filter(t=>t.startsWith("-"));let recursive=false;let force=false;for(const flag of tokens){if(flag==="--re\
|
|
13
7
|
cursive")recursive=true;if(flag==="--force")force=true;if(!flag.startsWith("--")){if(flag.includes("r")||flag.includes("R"))recursive=true;if(flag.includes("f"))force=true}}if(recursive&&force)return true}}function neverAutoAllowReason(tool,input){if(tool.risk!=="exec")return null;let declared;try{declared=tool.execCommands?.(input)??null}catch{declared=null}const shell=(declared?.shell??[]).filter(command=>typeof command==="string"&&command!=="");const argv=(declared?.argv??[]).map(entry=>Array.
|
|
14
8
|
isArray(entry)?entry.join(" "):"").filter(command=>command!=="");if(shell.length===0&&argv.length===0){return`${tool.name} \u304C\u5B9F\u884C\u3059\u308B\u30B3\u30DE\u30F3\u30C9\u3092\u7279\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059`}for(const command of[...shell,...argv]){if(isRecursiveForceRemove(command))return"rm -rf \u3092\u542B\u3080\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059"}for(const command of shell){if(!isSingleCommand(command)){
|
|
15
9
|
return"\u8907\u6570\u306E\u30B3\u30DE\u30F3\u30C9\u306B\u5206\u5C90\u3057\u3066\u3044\u308B\u305F\u3081\uFF08&& ; | $() \u306A\u3069\uFF09\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059"}}return null}function autoApproveExemptReason(tool,input,cwd){if(tool.risk!=="write")return null;const raw=input["path"]??input["file_path"]??input["dest"]??input["target"]??input["filename"];if(typeof raw!=="string"||raw==="")return"\u66F8\u304D\u8FBC\u307F\u5148\u3092\u5224\u5B9A\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059";
|
|
16
|
-
let absolute;try{absolute=realToolPath(raw,cwd)}catch{return"\u66F8\u304D\u8FBC\u307F\u5148\u3092\u89E3\u6C7A\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059"}const segments=absolute.toLowerCase().split(
|
|
17
|
-
|
|
10
|
+
let absolute;try{absolute=realToolPath(raw,cwd)}catch{return"\u66F8\u304D\u8FBC\u307F\u5148\u3092\u89E3\u6C7A\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059"}const segments=absolute.toLowerCase().split(sep);const base=segments[segments.length-1]??"";if(segments.includes(".git"))return".git/ \u914D\u4E0B\u306F\u6B21\u306E git \u64CD\u4F5C\u3067\u5B9F\u884C\u3055\u308C\u308B\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059";if(segments.includes(".git\
|
|
11
|
+
hub"))return".github/ \u914D\u4E0B\u306F CI \u304C\u5B9F\u884C\u3059\u308B\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059";if(segments.includes(".claude"))return".claude/ \u914D\u4E0B\u306F\u30D5\u30C3\u30AF\u5B9A\u7FA9\u3092\u542B\u3080\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059";if(segments.includes(".twp"))return".twp/ \u914D\u4E0B\u306F\u6A29\u9650\u8A2D\u5B9A\u30FB\u30E2\u30FC\u30C9\u5B9A\u7FA9\u3092\u542B\u3080\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059";
|
|
18
12
|
if(segments.includes(".husky")||segments.includes(".githooks")){return"git hook \u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306A\u306E\u3067\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059"}if(base==="package.json"||base==="makefile"||base===".envrc"||base===".mcp.json"){return`${base} \u306F\u5F8C\u7D9A\u306E\u5B9F\u884C\u306B\u5F71\u97FF\u3059\u308B\u305F\u3081\u3001\u6BCE\u56DE\u78BA\u8A8D\u3057\u307E\u3059`}return null}var TOOL_ALIASES={bash:["bash","shell"],shell:["bash","shell"],read:["read_file"],write:["write_file"],edit:["edit_file","write_file"],multiedit:["edit_file"],glob:["glob"],grep:["grep"]};var TIGHTEN_ALIASES={read:["read_file","grep","glob"],read_file:["read_file","grep","glob"],write:["write_file","edit_file"],write_file:["write_file","edit_file"],edit:["edit_file","write_file"],edit_file:["edit_file","write_file"],multiedit:["edit_file","write_file"]};var COMMAND_TOOLS=new Set(["bash","shell",
|
|
19
13
|
"git"]);var PATH_TOOLS=new Set(["read_file","write_file","edit_file","grep","glob"]);var TOOL_NAME=/^[A-Za-z][A-Za-z0-9_.-]*$/;function parseRule(raw,kind){if(typeof raw!=="string"||raw.trim()===""){return{rule:null,warning:`\u6A29\u9650\u30EB\u30FC\u30EB\u304C\u6587\u5B57\u5217\u3067\u306F\u306A\u3044\u305F\u3081\u7121\u8996\u3057\u307E\u3059: ${JSON.stringify(raw)}`}}const text=raw.trim();const open=text.indexOf("(");const name=open===-1?text:text.slice(0,open);if(!TOOL_NAME.test(name)){return{
|
|
20
14
|
rule:null,warning:`\u30C4\u30FC\u30EB\u540D\u3092\u89E3\u91C8\u3067\u304D\u306A\u3044\u6A29\u9650\u30EB\u30FC\u30EB\u3092\u7121\u8996\u3057\u307E\u3059: ${text}`}}const key=name.toLowerCase();const table=kind==="allow"?TOOL_ALIASES:{...TOOL_ALIASES,...TIGHTEN_ALIASES};const tools=Object.hasOwn(table,key)?table[key]??[key]:[key];if(open===-1)return{rule:{raw:text,kind,tools,pattern:null},warning:null};if(!text.endsWith(")"))return invalid(text,kind,tools,"\u62EC\u5F27\u304C\u9589\u3058\u3066\u3044\u306A\u3044");
|
|
@@ -27,9 +21,9 @@ kind==="allow");if(candidates.length===0)return rule.kind!=="allow";const patter
|
|
|
27
21
|
"string")return null;const args=Array.isArray(input["args"])?input["args"].filter(a=>typeof a==="string"):[];return[sub,...args].join(" ")}const command=input["command"];return typeof command==="string"?command:null}function normalizeSpaces(text){return text.trim().replace(/[ \t]+/g," ")}var SAFE_COMMAND=/^[A-Za-z0-9_\-./=:,@%+ ]*$/;function prefixMatch(pattern,command){const c=normalizeSpaces(command);if(pattern.glob)return matchWildcards(pattern.glob,c,false);if(pattern.exact)return c===pattern.
|
|
28
22
|
prefix;return c===pattern.prefix||c.startsWith(`${pattern.prefix} `)}function commandMatchesNarrow(pattern,command,toolName){if(toolName==="shell")return false;if(toolName!=="git"&&(!isSingleCommand(command)||!SAFE_COMMAND.test(normalizeSpaces(command))))return false;if(isRecursiveForceRemove(command))return false;return prefixMatch(pattern,command)}var PRECOMMAND_WORDS=new Set(["sudo","doas","env","command","builtin","exec","nohup","time","nice","xargs","then","do","else","elif","if","while","u\
|
|
29
23
|
ntil","!"]);function commandHeads(segment){const words=normalizeSpaces(segment.replace(/^[\s({]+/,"")).split(" ");const heads=[];for(let i=0;i<words.length;i++){const rest=words.slice(i);const first=rest[0]??"";const bare=first.replace(/^\\/,"").replace(/["']/g,"").replace(/^.*\//,"");heads.push([bare,...rest.slice(1)].join(" "));if(!(PRECOMMAND_WORDS.has(first)||/^[A-Za-z_][A-Za-z0-9_]*=/.test(first)||first.startsWith("-")))break}return heads}function commandMatchesBroad(pattern,command){if(prefixMatch(
|
|
30
|
-
pattern,command))return true;const segments=command.split(/;|&&|\|\||&|\||\n|\$\(|<\(|>\(|`|\)|\{|\}/);return segments.some(segment=>commandHeads(segment).some(head=>prefixMatch(pattern,head)))}function pathCandidates(subject,strict){const searchRoot=subject.toolName==="grep"||subject.toolName==="glob"?subject.input["path"]??".":void 0;const raw=searchRoot??subject.input["path"]??subject.input["file_path"];if(typeof raw!=="string"||raw==="")return[];const out=[];const home=subject.home??
|
|
24
|
+
pattern,command))return true;const segments=command.split(/;|&&|\|\||&|\||\n|\$\(|<\(|>\(|`|\)|\{|\}/);return segments.some(segment=>commandHeads(segment).some(head=>prefixMatch(pattern,head)))}function pathCandidates(subject,strict){const searchRoot=subject.toolName==="grep"||subject.toolName==="glob"?subject.input["path"]??".":void 0;const raw=searchRoot??subject.input["path"]??subject.input["file_path"];if(typeof raw!=="string"||raw==="")return[];const out=[];const home=subject.home??homedir();
|
|
31
25
|
if(!strict){const expanded=raw==="~"?home:raw.startsWith("~/")?path.join(home,raw.slice(2)):raw;out.push(path.resolve(subject.cwd,expanded));out.push(realOrSelf(path.resolve(subject.cwd,expanded)));return[...new Set(out)]}try{out.push(resolveToolPath(raw,subject.cwd,home))}catch{}try{const real=realToolPath(raw,subject.cwd,home);if(!out.includes(real))out.push(real)}catch{}return out}function matchPath(pattern,insensitive,absolute,subject){const toPosix=p=>p.split(path.sep).join("/");const test=text=>matchWildcards(
|
|
32
|
-
pattern.matcher,text,insensitive);if(pattern.base==="absolute")return test(toPosix(absolute).replace(/^\/+/,""));const base=pattern.base==="home"?subject.home??
|
|
26
|
+
pattern.matcher,text,insensitive);if(pattern.base==="absolute")return test(toPosix(absolute).replace(/^\/+/,""));const base=pattern.base==="home"?subject.home??homedir():pattern.base==="root"?subject.root??subject.cwd:subject.cwd;for(const b of new Set([base,realOrSelf(base)])){const rel=path.relative(b,absolute);if(rel===""||rel===".."||rel.startsWith(`..${path.sep}`)||path.isAbsolute(rel))continue;if(test(toPosix(rel)))return true}return false}function stripPathBase(glob3){if(glob3.startsWith(
|
|
33
27
|
"//"))return{base:"absolute",body:glob3.slice(2)};if(glob3.startsWith("~/"))return{base:"home",body:glob3.slice(2)};if(glob3.startsWith("./"))return{base:"cwd",body:glob3.slice(2)};if(glob3.startsWith("/"))return{base:"root",body:glob3.slice(1)};return{base:"cwd",body:glob3}}function compilePathGlob(glob3){const stripped=stripPathBase(glob3.replace(/\\/g,"/"));const base=stripped.base;let body=stripped.body;if(body.endsWith("/"))body=`${body}**`;const anyDepth=!body.includes("/")&&base==="cwd"&&
|
|
34
28
|
!glob3.startsWith("./");return{base,matcher:compileWildcards(anyDepth?`**/${body}`:body,"path",false)}}var MAX_WILDCARDS=16;function countWildcards(text){return(text.match(/[*?]/g)??[]).length}function compileWildcards(text,mode,trailingArgs){const tokens=[];const push=tok=>{const last=tokens[tokens.length-1];if(last&&(tok.t==="star"||tok.t==="any")&&(last.t==="star"||last.t==="any")){if(tok.t==="any")tokens[tokens.length-1]=tok;return}tokens.push(tok)};for(let i=0;i<text.length;i++){const ch=text[i]??
|
|
35
29
|
"";if(ch==="*"){if(mode==="any"){push({t:"any"})}else if(text[i+1]==="*"){if(text[i+2]==="/"){tokens.push({t:"dirs"});i+=2}else{push({t:"any"});i+=1}}else{push({t:"star"})}}else if(ch==="?"&&mode==="path"){tokens.push({t:"one"})}else{tokens.push({t:"lit",c:ch})}}if(trailingArgs){tokens.push({t:"lit",c:"\0"})}return{tokens}}function matchWildcards(pattern,input,insensitive){const text=insensitive?input.toLowerCase():input;const toks=pattern.tokens;const n=text.length;let reach=new Uint8Array(n+1);
|
|
@@ -151,9 +145,9 @@ for(const[key,child]of Object.entries(value)){if(REDACT_KEYS.has(key.toLowerCase
|
|
|
151
145
|
if(value===null||typeof value==="number"||typeof value==="boolean")return value;if(typeof value==="string"){return clamp(registry.scrub(scrubSecrets(value)),MAX_STRING_BYTES)}if(depth>=3)return"<depth>";if(Array.isArray(value)){const head=value.slice(0,10).map(v=>sanitizeValue(v,depth+1,registry));return value.length>10?[...head,`\u2026(+${value.length-10})`]:head}if(typeof value==="object")return sanitizeObject(value,depth,registry);return`<${typeof value}>`}function byteLengthOf(value){if(typeof value===
|
|
152
146
|
"string")return Buffer.byteLength(value);try{return Buffer.byteLength(JSON.stringify(value)??"")}catch{return 0}}function prune(dir,nowMs=Date.now()){let entries;try{entries=fs4.readdirSync(dir).filter(n=>/^session-.*\.jsonl$/.test(n))}catch{return}const stats=[];for(const name of entries){try{stats.push({name,mtime:fs4.statSync(path5.join(dir,name)).mtimeMs})}catch{}}stats.sort((a,b)=>b.mtime-a.mtime);const cutoff=nowMs-MAX_AGE_DAYS*24*60*60*1e3;stats.forEach((entry,index)=>{const overCount=index>=
|
|
153
147
|
MAX_FILES-1;const tooOld=entry.mtime<cutoff;if(!tooOld&&!overCount)return;if(!tooOld&&nowMs-entry.mtime<PRUNE_GRACE_MS)return;try{fs4.unlinkSync(path5.join(dir,entry.name))}catch{}})}var CROCKFORD="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function newSessionId(nowMs=Date.now()){let time="";let remaining=nowMs;for(let i=0;i<10;i++){time=`${CROCKFORD[remaining%32]??"0"}${time}`;remaining=Math.floor(remaining/32)}const bytes=crypto.randomBytes(16);let rand="";for(const byte of bytes)rand+=CROCKFORD[byte%32]??
|
|
154
|
-
"0";return`${time}${rand}`}import{readFileSync}from"fs";import{dirname
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
"0";return`${time}${rand}`}import{readFileSync}from"fs";import{dirname,join,resolve,sep as sep2}from"path";function currentBranch(cwd=process.cwd()){let dir=cwd;for(;;){const gitPath=join(dir,".git");const head=readHead(gitPath);if(head!==null)return head;const parent=dirname(dir);if(parent===dir)return null;dir=parent}}function readHead(gitPath){let headFile=join(gitPath,"HEAD");try{const stat2=readFileSync(gitPath,"utf8");const m=/^gitdir:\s*(.+)$/m.exec(stat2);if(m?.[1])headFile=join(resolve(dirname(gitPath),m[1].trim()),
|
|
149
|
+
"HEAD")}catch{}try{const head=readFileSync(headFile,"utf8").trim();const ref=/^ref:\s*refs\/heads\/(.+)$/.exec(head);if(ref?.[1])return ref[1];return head.slice(0,7)}catch{return null}}function displayCwd(cwd=process.cwd(),home=process.env["HOME"]??process.env["USERPROFILE"]??""){if(!home)return cwd;const stripped=home.replace(new RegExp(`${escapeSep()}+$`),"");if(stripped==="")return cwd;const normalize=p=>process.platform==="win32"?p.toLowerCase():p;const h=normalize(stripped);const c=normalize(
|
|
150
|
+
cwd);if(c===h)return"~";if(c.startsWith(h+sep2))return`~${cwd.slice(stripped.length)}`;return cwd}function escapeSep(){return sep2==="\\"?"\\\\":sep2}import{spawn}from"child_process";function keepTailBytes(buf,maxBytes){if(buf.length<=maxBytes)return{text:buf.toString("utf8"),droppedBytes:0};const start=buf.length-maxBytes;let cut=start;while(cut<buf.length&&(buf[cut]&192)===128)cut++;return{text:buf.subarray(cut).toString("utf8"),droppedBytes:cut}}function keepHeadBytes(text,maxBytes){const buf=Buffer.from(text,"utf8");if(buf.length<=maxBytes)return{text,truncated:false};let cut=maxBytes;while(cut>0&&(buf[cut]&192)===128)cut--;return{text:buf.subarray(0,cut).toString("utf8"),
|
|
157
151
|
truncated:true}}import{existsSync}from"fs";import path6 from"path";var GIT_BASH_CANDIDATES=["C:\\Program Files\\Git\\bin\\bash.exe","C:\\Program Files (x86)\\Git\\bin\\bash.exe","C:\\Program Files\\Git\\usr\\bin\\bash.exe"];function system32Path(env,...rest){return system32(env,...rest)??path6.win32.join("C:\\Windows\\System32",...rest)}function defaultProbe(filePath){try{return existsSync(filePath)}catch{return false}}function selectShell(platform=process.platform,probe=defaultProbe,env=process.env){if(platform!=="win32"){return{toolName:"bash",command:"/bin/b\
|
|
158
152
|
ash",args:["-c"],kind:"bash",note:null}}const sys={wsl:system32Path(env,"wsl.exe"),powershell:system32Path(env,"WindowsPowerShell","v1.0","powershell.exe"),cmd:system32Path(env,"cmd.exe")};for(const candidate of gitBashCandidates(env)){if(probe(candidate)){return{toolName:"bash",command:candidate,args:["-c"],kind:"git-bash",note:null}}}if(probe(sys.wsl)){return{toolName:"bash",command:sys.wsl,args:["-e","bash","-c"],kind:"wsl",note:"WSL \u306E bash \u3067\u5B9F\u884C\u3057\u307E\u3059\uFF08Windows \u306E\u30D1\u30B9\u306F /mnt/c/... \u5F62\u5F0F\u306B\u306A\u308A\u307E\u3059\uFF09"}}
|
|
159
153
|
const pwsh=pwshPath(probe,env);if(pwsh!==null){return{toolName:"shell",command:pwsh,args:["-NoProfile","-NonInteractive","-Command"],kind:"pwsh",note:"\u3053\u306E\u74B0\u5883\u306B bash \u304C\u306A\u3044\u305F\u3081 PowerShell \u3067\u5B9F\u884C\u3057\u307E\u3059\u3002**bash \u69CB\u6587\u306F\u4F7F\u3048\u307E\u305B\u3093**\uFF08`&&` \u306E\u9023\u7D50\u30FB`grep` / `rm` \u306A\u3069\u306E POSIX \u30B3\u30DE\u30F3\u30C9\u306F PowerShell \u306E\u69CB\u6587\u3068\u30B3\u30DE\u30F3\u30C9\u30EC\u30C3\u30C8\u306B\u7F6E\u304D\u63DB\u3048\u3066\u304F\u3060\u3055\u3044\uFF09"}}
|
|
@@ -162,12 +156,12 @@ ash \u3082 PowerShell \u3082\u306A\u3044\u305F\u3081 cmd.exe \u3067\u5B9F\u884C\
|
|
|
162
156
|
base))fromEnv.push(`${base}\\Git\\bin\\bash.exe`,`${base}\\Git\\usr\\bin\\bash.exe`)}return[...fromEnv,...GIT_BASH_CANDIDATES]}function pwshPath(probe,env){const bases=[env["ProgramFiles"],env["ProgramW6432"],"C:\\Program Files"].filter(trustedBase);for(const base of bases){for(const major of["7","6"]){const candidate=`${base}\\PowerShell\\${major}\\pwsh.exe`;if(probe(candidate))return candidate}}return null}var DEFAULT_TIMEOUT_MS=12e4;var MAX_TIMEOUT_MS=6e5;var MAX_OUTPUT_BYTES=1e5;function createBashTool(choice=selectShell()){const base=choice.toolName==="bash"?"Run a shell command with bash. Prefer specific tools (read_file / glob / grep) when they fit \u2014 they are cheaper and safer.":"Run a shell command. NOTE: bash is not available in this environment.";return{name:choice.toolName,domain:"local",risk:"exec",description:choice.note===null?base:`${base}
|
|
163
157
|
${choice.note}`,inputSchema:{type:"object",additionalProperties:false,properties:{command:{type:"string",description:"The command line to run"},timeout_ms:{type:"integer",description:`Timeout in milliseconds (default ${DEFAULT_TIMEOUT_MS}, max ${MAX_TIMEOUT_MS})`,minimum:1e3,maximum:MAX_TIMEOUT_MS}},required:["command"]},execCommands(input){const command=typeof input["command"]==="string"?input["command"]:"";return{shell:[command]}},preview(input){const command=typeof input["command"]==="string"?
|
|
164
158
|
input["command"]:"";const line=command.split("\n")[0]??"";return`${choice.toolName} \xB7 ${line.slice(0,80)}${line.length>80||command.includes("\n")?"\u2026":""}`},async run(input,ctx){const command=String(input["command"]);const timeout=clampTimeout(input["timeout_ms"]);return runCommand(choice,command,timeout,ctx.cwd,ctx.signal,ctx.env)}}}function clampTimeout(value){if(typeof value!=="number"||!Number.isFinite(value))return DEFAULT_TIMEOUT_MS;return Math.min(MAX_TIMEOUT_MS,Math.max(1e3,Math.floor(
|
|
165
|
-
value)))}function runCommand(choice,command,timeoutMs,cwd,signal,env=process.env){return new Promise(
|
|
159
|
+
value)))}function runCommand(choice,command,timeoutMs,cwd,signal,env=process.env){return new Promise(resolve4=>{const child=spawn(choice.command,[...choice.args,command],{cwd,env,shell:false,detached:process.platform!=="win32",stdio:["ignore","pipe","pipe"]});const chunks=[];let bytes=0;const collect=buf=>{chunks.push(buf);bytes+=buf.length;while(bytes-(chunks[0]?.length??0)>MAX_OUTPUT_BYTES*2&&chunks.length>1){const dropped=chunks.shift();if(!dropped)break;bytes-=dropped.length}};child.stdout.on(
|
|
166
160
|
"data",collect);child.stderr.on("data",collect);let outcome="ok";const kill=()=>{if(child.killed||child.exitCode!==null)return;if(isForceOnly()){killProcessTree(child,"SIGKILL");return}killProcessTree(child,"SIGTERM");setTimeout(()=>killProcessTree(child,"SIGKILL"),2e3).unref()};const timer=setTimeout(()=>{outcome="timeout";kill()},timeoutMs);const onAbort=()=>{outcome="aborted";kill()};if(signal){if(signal.aborted)onAbort();else signal.addEventListener("abort",onAbort,{once:true})}const finish=(exitCode,spawnError)=>{
|
|
167
161
|
clearTimeout(timer);signal?.removeEventListener("abort",onAbort);const raw=Buffer.concat(chunks);const kept=keepTailBytes(raw,MAX_OUTPUT_BYTES);const body=kept.text;const head=kept.droppedBytes>0?`[output truncated: dropped the first ${kept.droppedBytes} bytes, showing the last ${Buffer.byteLength(body,"utf8")}]
|
|
168
|
-
`:"";if(spawnError){
|
|
169
|
-
[timed out after ${timeoutMs}ms and was killed]`,isError:true,summary:`${choice.toolName} \xB7 \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8 (${timeoutMs}ms)`});return}if(outcome==="aborted"){
|
|
170
|
-
[interrupted by the user]`,isError:true,summary:`${choice.toolName} \xB7 \u4E2D\u65AD`});return}
|
|
162
|
+
`:"";if(spawnError){resolve4({content:`Failed to start ${choice.command}: ${spawnError.message}`,isError:true,summary:`${choice.toolName} \xB7 \u8D77\u52D5\u3067\u304D\u307E\u305B\u3093`});return}if(outcome==="timeout"){resolve4({content:`${head}${body}
|
|
163
|
+
[timed out after ${timeoutMs}ms and was killed]`,isError:true,summary:`${choice.toolName} \xB7 \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8 (${timeoutMs}ms)`});return}if(outcome==="aborted"){resolve4({content:`${head}${body}
|
|
164
|
+
[interrupted by the user]`,isError:true,summary:`${choice.toolName} \xB7 \u4E2D\u65AD`});return}resolve4({content:body===""?`(no output, exit code ${exitCode??0})`:`${head}${body}`,...exitCode!==0?{isError:true}:{},summary:`${choice.toolName} \xB7 exit ${exitCode??0}`})};child.on("error",err=>finish(null,err));child.on("close",code=>finish(code))})}import{readFile,writeFile}from"fs/promises";function detectEol(text){let crlf=0;let lf=0;for(let i=0;i<text.length;i++){if(text.charCodeAt(i)!==10)continue;if(i>0&&text.charCodeAt(i-1)===13)crlf++;else lf++}return crlf>lf?"\r\n":"\n"}function toLf(text){return text.replace(/\r\n/g,"\n")}function applyEol(text,eol){if(eol==="\n")return toLf(text);return toLf(text).replace(/\n/g,"\r\n")}var editFileTool={name:"edit_file",domain:"local",risk:"write",description:"Replace an exact string in a file. old_string must match exactly and be unique unless replace_all is true. Read the file first \u2014 the match includes indentation. Line endings of the file are preserved.",inputSchema:{type:"object",additionalProperties:false,properties:{path:{type:"string",description:"File path, relative to the working directory"},old_string:{type:"string",description:"Exact text to replace (without l\
|
|
171
165
|
ine-number prefixes)"},new_string:{type:"string",description:"Replacement text"},replace_all:{type:"boolean",description:"Replace every occurrence instead of requiring uniqueness",default:false}},required:["path","old_string","new_string"]},preview(input){const old=typeof input["old_string"]==="string"?input["old_string"]:"";const head=old.split("\n")[0]??"";return`edit_file \xB7 ${String(input["path"]??"")} \xB7 ${head.slice(0,48)}${head.length>48?"\u2026":""}`},async prepare(input,ctx){const abs=resolveToolPath(
|
|
172
166
|
String(input["path"]),ctx.cwd);const before=await readFile(abs,"utf8").catch(()=>null);if(before===null)return null;const applied=apply(before,input);if(!applied.ok)return null;return{path:toolRelative(ctx.cwd,abs),before,after:applied.after}},async run(input,ctx){const abs=resolveToolPath(String(input["path"]),ctx.cwd);const before=await readFile(abs,"utf8").catch(()=>null);if(before===null)return{content:`File not found: ${input["path"]}`,isError:true};const applied=apply(before,input);if(!applied.
|
|
173
167
|
ok)return{content:applied.error,isError:true};await writeFile(abs,applied.after,"utf8");const rel=toolRelative(ctx.cwd,abs);return{content:`Edited ${rel} (${applied.count} replacement${applied.count===1?"":"s"}).`,summary:`edit_file \xB7 ${rel}`,diff:{path:rel,before,after:applied.after}}}};function apply(before,input){const eol=detectEol(before);const oldRaw=String(input["old_string"]);const newRaw=String(input["new_string"]);const replaceAll=input["replace_all"]===true;if(oldRaw==="")return{ok:false,
|
|
@@ -180,20 +174,20 @@ input["subcommand"]??"");const args=Array.isArray(input["args"])?input["args"].m
|
|
|
180
174
|
join(", ")}). Use bash for write operations.`,isError:true}}const args=Array.isArray(input["args"])?input["args"].map(String):[];for(const arg of args){const head=arg.split("=")[0]??arg;if(DENIED_ARGS.has(head)){return{content:`Argument ${arg} is not allowed for the git tool.`,isError:true}}if(sub==="status"&&isStatusVerbose(arg)){return{content:`Argument ${arg} is not allowed for git status (it renders diffs through the repository's textconv drivers). Use the git tool's diff subcommand with --c\
|
|
181
175
|
ached instead.`,isError:true}}}const argv=buildGitArgv(sub,args);const env=ctx.env??process.env;const exe=resolveGitExecutable({env});if(exe===null){return{content:'git executable was not found on PATH. On Windows the git tool resolves the executable to an absolute path from PATH (it never runs a bare "git", because Windows searches the current directory before PATH). Install Git for Windows or add its bin directory to PATH.',isError:true,summary:"git \xB7 \u5B9F\u884C\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093"}}
|
|
182
176
|
return runGit(exe,argv,ctx.cwd,env,ctx.signal)}};function resolveGitExecutable(deps={}){const platform=deps.platform??process.platform;if(platform!=="win32")return"git";const env=deps.env??process.env;const common={platform,...deps.isExecutableFile!==void 0?{isExecutableFile:deps.isExecutableFile}:{}};const spawnable=findExecutable("git",{...common,env:{...env,PATHEXT:".EXE;.COM"}});return spawnable??findExecutable("git",{...common,env})}function runGit(exe,argv,cwd,baseEnv,signal){return new Promise(
|
|
183
|
-
|
|
177
|
+
resolve4=>{let child;try{child=spawn2(exe,["--no-pager",...argv],{cwd,shell:false,env:{...baseEnv,GIT_PAGER:"cat",PAGER:"cat",GIT_TERMINAL_PROMPT:"0",GIT_EDITOR:"true",EDITOR:"true"},detached:process.platform!=="win32",stdio:["ignore","pipe","pipe"]})}catch(e){const err=e;const name=path7.basename(exe);resolve4({content:err.code==="EINVAL"?`Failed to start git: the resolved executable (${name}) is a .cmd/.bat shim, which Node refuses to spawn without a shell. Install Git for Windows (which provi\
|
|
184
178
|
des git.exe) or put its bin directory earlier on PATH.`:`Failed to start git (${name}): ${err.code??"unknown error"}`,isError:true,summary:"git \xB7 \u8D77\u52D5\u3067\u304D\u307E\u305B\u3093"});return}const chunks=[];let bytes=0;const collect=buf=>{chunks.push(buf);bytes+=buf.length;while(bytes-(chunks[0]?.length??0)>MAX_GIT_OUTPUT_BYTES*2&&chunks.length>1){const dropped=chunks.shift();if(!dropped)break;bytes-=dropped.length}};child.stdout?.on("data",collect);child.stderr?.on("data",collect);let timedOut=false;
|
|
185
179
|
const timer=setTimeout(()=>{timedOut=true;killProcessTree(child,"SIGKILL")},GIT_TIMEOUT_MS);const onAbort=()=>{killProcessTree(child,"SIGKILL")};if(signal){if(signal.aborted)onAbort();else signal.addEventListener("abort",onAbort,{once:true})}const finish=(code,err)=>{clearTimeout(timer);signal?.removeEventListener("abort",onAbort);const kept=keepTailBytes(Buffer.concat(chunks),MAX_GIT_OUTPUT_BYTES);const body=kept.text;const note=kept.droppedBytes>0?`
|
|
186
|
-
[output truncated: dropped the first ${kept.droppedBytes} bytes]`:"";if(err){
|
|
187
|
-
[timed out after ${GIT_TIMEOUT_MS}ms]`,isError:true,summary:"git \xB7 \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8"});return}
|
|
188
|
-
path:{type:"string",description:"Directory to search in (default: the working directory)"},include_ignored:{type:"boolean",description:"Include node_modules / dist / vendor etc.",default:false}},required:["pattern"]},preview(input){return`glob \xB7 ${String(input["pattern"]??"")}`},async run(input,ctx){const root=input["path"]===void 0?
|
|
189
|
-
const found=[];let hardStop=false;let skipped=0;try{for await(const entry of glob(pattern,{cwd:root,exclude})){const abs=
|
|
180
|
+
[output truncated: dropped the first ${kept.droppedBytes} bytes]`:"";if(err){resolve4({content:`Failed to run git (${path7.basename(exe)}): ${err.code??err.message}`,isError:true,summary:"git \xB7 \u8D77\u52D5\u3067\u304D\u307E\u305B\u3093"});return}if(timedOut){resolve4({content:`${body}${note}
|
|
181
|
+
[timed out after ${GIT_TIMEOUT_MS}ms]`,isError:true,summary:"git \xB7 \u30BF\u30A4\u30E0\u30A2\u30A6\u30C8"});return}resolve4({content:body===""?`(no output, exit code ${code??0})`:`${body}${note}`,...code!==0?{isError:true}:{},summary:`git ${argv[0]??""} \xB7 exit ${code??0}`})};child.on("error",e=>finish(null,e));child.on("close",code=>finish(code))})}import{glob}from"fs/promises";import{resolve as resolve2}from"path";var MAX_GLOB_RESULTS=500;var DEFAULT_EXCLUDES=["**/node_modules/**","**/.git/**","**/dist/**","**/.next/**","**/vendor/**"];var globTool={name:"glob",domain:"local",risk:"read",description:'Find files by glob pattern (e.g. "src/**/*.ts"). Returns paths relative to the working directory, sorted. node_modules, .git, dist, .next and vendor are excluded by default.',inputSchema:{type:"object",additionalProperties:false,properties:{pattern:{type:"string",description:'Glob pattern, e.g. "**/*.test.ts"'},
|
|
182
|
+
path:{type:"string",description:"Directory to search in (default: the working directory)"},include_ignored:{type:"boolean",description:"Include node_modules / dist / vendor etc.",default:false}},required:["pattern"]},preview(input){return`glob \xB7 ${String(input["pattern"]??"")}`},async run(input,ctx){const root=input["path"]===void 0?resolve2(ctx.cwd):resolveToolPath(String(input["path"]),ctx.cwd);const pattern=String(input["pattern"]);const exclude=input["include_ignored"]===true?[]:DEFAULT_EXCLUDES;
|
|
183
|
+
const found=[];let hardStop=false;let skipped=0;try{for await(const entry of glob(pattern,{cwd:root,exclude})){const abs=resolve2(root,typeof entry==="string"?entry:String(entry));if(!isInsideCwd(abs,ctx.cwd)||secretReason(abs)!==null){skipped+=1;continue}found.push(abs);if(found.length>=MAX_GLOB_RESULTS*4){hardStop=true;break}}}catch(err){return{content:`glob failed: ${err.message}`,isError:true}}const sorted=found.map(abs=>toolRelative(ctx.cwd,abs)).sort();const shown=sorted.slice(0,MAX_GLOB_RESULTS);
|
|
190
184
|
const note=hardStop?`
|
|
191
185
|
[stopped scanning after ${found.length} matches \u2014 there may be many more. Narrow the pattern.]`:sorted.length>shown.length?`
|
|
192
186
|
[${sorted.length-shown.length} more matches not shown \u2014 narrow the pattern]`:"";const denied=skipped>0?`
|
|
193
|
-
[${skipped} path(s) outside the working directory or denied were omitted]`:"";return{content:shown.length===0?`No files matched ${pattern}${denied}`:shown.join("\n")+note+denied,summary:`glob \xB7 ${pattern} \u2192 ${shown.length}\u4EF6`}}};import{glob as glob2}from"fs/promises";import{readFile as readFile2}from"fs/promises";import{resolve as
|
|
187
|
+
[${skipped} path(s) outside the working directory or denied were omitted]`:"";return{content:shown.length===0?`No files matched ${pattern}${denied}`:shown.join("\n")+note+denied,summary:`glob \xB7 ${pattern} \u2192 ${shown.length}\u4EF6`}}};import{glob as glob2}from"fs/promises";import{readFile as readFile2}from"fs/promises";import{resolve as resolve3}from"path";var MAX_GREP_MATCHES=200;var MAX_GREP_RESULTS_LIMIT=2e3;var MAX_LINE_LENGTH=2e4;var GREP_DEADLINE_MS=2e4;var MAX_FILE_BYTES2=2e6;var DEFAULT_EXCLUDES2=["**/node_modules/**","**/.git/**","**/dist/**","**/.next/**","**/vendor/**"];var grepTool={name:"grep",domain:"local",risk:"read",description:'Search file contents with a JavaScript regular expression. Returns "path:line: text" for each match. Use the glob parameter to limit which files are searched.',inputSchema:{type:"object",additionalProperties:false,
|
|
194
188
|
properties:{pattern:{type:"string",description:"JavaScript regular expression"},path:{type:"string",description:"Directory to search in (default: the working directory)"},glob:{type:"string",description:'Limit to files matching this glob, e.g. "**/*.ts"',default:"**/*"},ignore_case:{type:"boolean",description:"Case-insensitive match",default:false},max_results:{type:"integer",description:`Maximum matches (default ${MAX_GREP_MATCHES}, max ${MAX_GREP_RESULTS_LIMIT})`,minimum:1,maximum:MAX_GREP_RESULTS_LIMIT}},
|
|
195
|
-
required:["pattern"]},preview(input){return`grep \xB7 /${String(input["pattern"]??"")}/ ${String(input["glob"]??"")}`.trim()},async run(input,ctx){let re;try{re=new RegExp(String(input["pattern"]),input["ignore_case"]===true?"i":"")}catch(err){return{content:`Invalid regular expression: ${err.message}`,isError:true}}const root=input["path"]===void 0?
|
|
196
|
-
max_results"]==="number"?Math.min(MAX_GREP_RESULTS_LIMIT,Math.max(1,Math.floor(input["max_results"]))):MAX_GREP_MATCHES;const matches=[];let scanned=0;let skipped=0;let longLines=0;let hitLimit=false;let timedOut=false;const deadline=Date.now()+GREP_DEADLINE_MS;const aborted=()=>ctx.signal?.aborted===true;try{for await(const entry of glob2(filePattern,{cwd:root,exclude:DEFAULT_EXCLUDES2})){if(aborted())break;const abs=
|
|
189
|
+
required:["pattern"]},preview(input){return`grep \xB7 /${String(input["pattern"]??"")}/ ${String(input["glob"]??"")}`.trim()},async run(input,ctx){let re;try{re=new RegExp(String(input["pattern"]),input["ignore_case"]===true?"i":"")}catch(err){return{content:`Invalid regular expression: ${err.message}`,isError:true}}const root=input["path"]===void 0?resolve3(ctx.cwd):resolveToolPath(String(input["path"]),ctx.cwd);const filePattern=typeof input["glob"]==="string"?input["glob"]:"**/*";const limit=typeof input["\
|
|
190
|
+
max_results"]==="number"?Math.min(MAX_GREP_RESULTS_LIMIT,Math.max(1,Math.floor(input["max_results"]))):MAX_GREP_MATCHES;const matches=[];let scanned=0;let skipped=0;let longLines=0;let hitLimit=false;let timedOut=false;const deadline=Date.now()+GREP_DEADLINE_MS;const aborted=()=>ctx.signal?.aborted===true;try{for await(const entry of glob2(filePattern,{cwd:root,exclude:DEFAULT_EXCLUDES2})){if(aborted())break;const abs=resolve3(root,typeof entry==="string"?entry:String(entry));if(!isInsideCwd(abs,
|
|
197
191
|
ctx.cwd)||secretReason(abs)!==null){skipped+=1;continue}const buf=await readFile2(abs).catch(()=>null);if(buf===null||buf.length>MAX_FILE_BYTES2||buf.includes(0))continue;scanned+=1;const rel=toolRelative(ctx.cwd,abs);const lines=toLf(buf.toString("utf8")).split("\n");for(let i=0;i<lines.length;i++){if(aborted())break;if(Date.now()>deadline){timedOut=true;break}const line=lines[i]??"";if(line.length>MAX_LINE_LENGTH){longLines+=1;continue}if(!re.test(line))continue;matches.push(`${rel}:${i+1}: ${line.
|
|
198
192
|
slice(0,400)}`);if(matches.length>=limit){hitLimit=true;break}}if(hitLimit||timedOut||aborted())break}}catch(err){return{content:`grep failed: ${err.message}`,isError:true}}const notes=[hitLimit?`[stopped at ${limit} matches \u2014 narrow the pattern or the glob]`:"",timedOut?`[stopped after ${GREP_DEADLINE_MS}ms \u2014 narrow the glob]`:"",longLines>0?`[${longLines} line(s) longer than ${MAX_LINE_LENGTH} chars were not searched]`:"",skipped>0?`[${skipped} path(s) outside the working directory o\
|
|
199
193
|
r denied were omitted]`:""].filter(n=>n!=="");const suffix=notes.length>0?`
|
|
@@ -202,9 +196,9 @@ minimum:1},limit:{type:"integer",description:`Maximum lines to return (default $
|
|
|
202
196
|
ents.`,isError:true}}const buf=await readFile3(abs);if(buf.includes(0)){return{content:`Binary file (${info.size} bytes) \u2014 not returned. Use bash if you need to inspect it.`,isError:true,summary:`read_file \xB7 ${toolRelative(ctx.cwd,abs)} (binary)`}}const raw=buf.toString("utf8");const eol=detectEol(raw);const lines=toLf(raw).split("\n");if(lines[lines.length-1]==="")lines.pop();const offset=typeof input["offset"]==="number"?input["offset"]:1;const limit=typeof input["limit"]==="number"?input["\
|
|
203
197
|
limit"]:DEFAULT_LIMIT_LINES;const slice=lines.slice(offset-1,offset-1+limit);let body=slice.map((line,i)=>`${offset+i} ${line}`).join("\n");let truncated=offset-1+slice.length<lines.length;const clipped=keepHeadBytes(body,MAX_READ_BYTES);body=clipped.text;if(clipped.truncated)truncated=true;const note=truncated?`
|
|
204
198
|
|
|
205
|
-
[truncated: file has ${lines.length} lines; re-read with offset/limit for the rest]`:"";if(body===""){const reason=lines.length===0?"(empty file)":`(no lines at offset ${offset}; the file has ${lines.length} lines)`;return{content:reason,summary:`read_file \xB7 ${toolRelative(ctx.cwd,abs)} (0 \u884C)`}}return{content:body+note,summary:`read_file \xB7 ${toolRelative(ctx.cwd,abs)} (${slice.length} \u884C${eol==="\r\n"?" \xB7 CRLF":""})`}}};import{mkdir,readFile as readFile4,writeFile as writeFile2}from"fs/promises";import{dirname as
|
|
199
|
+
[truncated: file has ${lines.length} lines; re-read with offset/limit for the rest]`:"";if(body===""){const reason=lines.length===0?"(empty file)":`(no lines at offset ${offset}; the file has ${lines.length} lines)`;return{content:reason,summary:`read_file \xB7 ${toolRelative(ctx.cwd,abs)} (0 \u884C)`}}return{content:body+note,summary:`read_file \xB7 ${toolRelative(ctx.cwd,abs)} (${slice.length} \u884C${eol==="\r\n"?" \xB7 CRLF":""})`}}};import{mkdir,readFile as readFile4,writeFile as writeFile2}from"fs/promises";import{dirname as dirname2}from"path";var writeFileTool={name:"write_file",domain:"local",risk:"write",description:"Write the full content of a file, creating it (and parent directories) if needed. Overwrites the whole file \u2014 prefer edit_file for partial changes. The existing line ending style (LF/CRLF) is preserved.",inputSchema:{type:"object",additionalProperties:false,properties:{path:{type:"string",description:"File path, relative to the working directory"},content:{type:"string",description:"Full new content. Use \\n for li\
|
|
206
200
|
ne breaks."}},required:["path","content"]},preview(input){const content=typeof input["content"]==="string"?input["content"]:"";return`write_file \xB7 ${String(input["path"]??"")} (${content.split("\n").length} \u884C)`},async prepare(input,ctx){const abs=resolveToolPath(String(input["path"]),ctx.cwd);const before=await readFile4(abs,"utf8").catch(()=>"");return{path:toolRelative(ctx.cwd,abs),before,after:String(input["content"]??"")}},async run(input,ctx){const abs=resolveToolPath(String(input["\
|
|
207
|
-
path"]),ctx.cwd);const existing=await readFile4(abs,"utf8").catch(()=>null);const eol=existing===null?"\n":detectEol(existing);const body=applyEol(String(input["content"]),eol);await mkdir(
|
|
201
|
+
path"]),ctx.cwd);const existing=await readFile4(abs,"utf8").catch(()=>null);const eol=existing===null?"\n":detectEol(existing);const body=applyEol(String(input["content"]),eol);await mkdir(dirname2(abs),{recursive:true});await writeFile2(abs,body,"utf8");const rel=toolRelative(ctx.cwd,abs);return{content:`Wrote ${rel} (${body.split(eol).length} lines${eol==="\r\n"?", CRLF preserved":""}).`,summary:`write_file \xB7 ${rel}`,diff:{path:rel,before:existing??"",after:String(input["content"])}}}};var RESIDENT_TOKEN_CAP=8e3;function localTools(choice=selectShell()){return[readFileTool,writeFileTool,editFileTool,createBashTool(choice),globTool,grepTool,gitTool]}function buildResidentSet(mode,opts={}){const all=opts.tools??localTools();const cap=opts.cap??RESIDENT_TOKEN_CAP;const eligible=all.filter(tool=>matchesAnyGlob(tool.name,mode.tools)&&applyPermissionMode(checkPermission(tool.name,mode),tool.risk,opts.permissionMode).decision!=="deny"&&!isWholeToolDenied(tool.name,opts.permissionLayers??[]));const usage=opts.usage;
|
|
208
202
|
const pinned=opts.pinned;const ordered=usage===void 0&&pinned===void 0?eligible:eligible.map((tool,i)=>({tool,i,pin:pinned?.has(tool.name)===true,uses:usage?.get(tool.name)??0})).sort((a,b)=>Number(b.pin)-Number(a.pin)||b.uses-a.uses||a.i-b.i).map(entry=>entry.tool);const tools=[];const dropped=[];let tokens=0;for(const tool of ordered){const cost=estimateToolTokens(tool);if(tokens+cost>cap){dropped.push(tool.name);continue}tools.push(tool);tokens+=cost}return{tools,wire:tools.map(toWireTool),tokens,
|
|
209
203
|
dropped}}function estimateToolTokens(tool){return Math.ceil(JSON.stringify(toWireTool(tool)).length/4)}function matchesAnyGlob(name,patterns){return patterns.some(pattern=>globToRegExp(pattern).test(name))}function globToRegExp(pattern){const escaped=pattern.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${escaped}$`)}import fs5 from"fs";import path8 from"path";import{createHash}from"crypto";var TOOL_CATALOG_PATH="/api/v2/cli/tool-catalog";var CACHE_LOCK_WAIT_MS=2e3;var bundledReader={index:loadCommandModelIndex,domain:loadCommandModelDomain};function cacheKey(profile,apiUrl){return createHash("sha256").update(`${profile}
|
|
210
204
|
${apiUrl}`).digest("hex").slice(0,24)}function toolCatalogCachePaths(profile,apiUrl,env=process.env){const base=path8.join(twpHomeDir(env),`tool-catalog-${cacheKey(profile,apiUrl)}`);return{meta:`${base}.meta.json`,body:`${base}.json`,lock:`${base}.lock`}}function homeIsPrivate(env){return isPrivateTwpHome(twpHomeDir(env))}var REASON_NO_CACHE="\u30B5\u30FC\u30D0\u914D\u4FE1\u306E\u30AD\u30E3\u30C3\u30B7\u30E5\u304C\u3042\u308A\u307E\u305B\u3093";var REASON_UNTRUSTED_HOME="~/.twp \u304C\u4ED6\u30E6\u30FC\u30B6\u30FC\u304B\u3089\u66F8\u3051\u308B\u30FB\u30EA\u30F3\u30AF\u3067\
|
|
@@ -229,8 +223,8 @@ fetched_at:at,checked_at:at,last_result:"updated"})})}catch(err){return{result:"
|
|
|
229
223
|
`)}catch{}}iso(){return new Date(this.now()).toISOString()}};function metaFields(meta){if(meta===void 0)return{};return{version:meta.version,toolCount:meta.tool_count,...meta.fetched_at!==""?{fetchedAt:meta.fetched_at}:{},...meta.checked_at!==""?{checkedAt:meta.checked_at}:{}}}function statusOf(err){const status=err?.status;return typeof status==="number"?status:null}function isAuthError(err){return err instanceof NotLoggedInError||err instanceof SessionExpiredError}function messageOf(err){return err instanceof
|
|
230
224
|
Error?err.message:String(err)}function removeQuietly(file){try{fs5.rmSync(file,{force:true})}catch{}}function describeToolCatalog(status){const origin=status.origin==="undecided"?status.next:status.origin;const head=origin==="server-cache"?`\u30B5\u30FC\u30D0\u914D\u4FE1\uFF08${status.toolCount??"?"} \u64CD\u4F5C\u30FB\u7248 ${status.version?.slice(0,12)??"?"}\u30FB\u53D6\u5F97 ${status.fetchedAt??"?"}\uFF09`:`\u540C\u68B1\u7248\uFF08${status.reason??"\u7406\u7531\u4E0D\u660E"}\uFF09`;const when=status.
|
|
231
225
|
origin==="undecided"?"\uFF08\u3053\u306E\u30BB\u30C3\u30B7\u30E7\u30F3\u3067\u306F\u307E\u3060\u672A\u4F7F\u7528\u30FB\u6B21\u306B\u4F7F\u3046\u51FA\u3069\u3053\u308D\uFF09":"";const refresh=status.refresh;const tail=refresh===void 0?"\u66F4\u65B0: \u672A\u5B9F\u884C":refresh==="running"?"\u66F4\u65B0: \u53D6\u5F97\u4E2D":`\u66F4\u65B0: ${REFRESH_LABEL[refresh.result]}${refresh.detail!==void 0?`\uFF08${refresh.detail}\uFF09`:""}`;return`TWP \u30C4\u30FC\u30EB\u30AB\u30BF\u30ED\u30B0: ${head}${when}\
|
|
232
|
-
\xB7 ${tail}`}var REFRESH_LABEL={updated:"\u65B0\u3057\u3044\u7248\u3092\u53D6\u5F97\u3057\u3066\u4FDD\u5B58","not-modified":"\u6700\u65B0\uFF08304\uFF09",unavailable:"\u30B5\u30FC\u30D0\u914D\u4FE1\u306A\u3057\u30FB\u6B21\u56DE\u304B\u3089\u540C\u68B1\u7248",failed:"\u5931\u6557\u30FB\u30AD\u30E3\u30C3\u30B7\u30E5\u3092\u7DAD\u6301"};var CATALOG_TOOL_PREFIX="twp_";var WIRE_NAME_RE=/^[A-Za-z0-9_-]{1,64}$/;var MAX_RESULT_CHARS=4e4;function catalogToolName(op){if(op.name.includes("_")||op.domain.includes("_"))return null;const name=`${CATALOG_TOOL_PREFIX}${op.name.replace(/\./g,"-")}_${op.domain}`;return WIRE_NAME_RE.test(name)?name:null}function parseCatalogToolName(name){if(!name.startsWith(CATALOG_TOOL_PREFIX))return null;const rest=name.slice(CATALOG_TOOL_PREFIX.length);const
|
|
233
|
-
1)return null;const domain=rest.slice(
|
|
226
|
+
\xB7 ${tail}`}var REFRESH_LABEL={updated:"\u65B0\u3057\u3044\u7248\u3092\u53D6\u5F97\u3057\u3066\u4FDD\u5B58","not-modified":"\u6700\u65B0\uFF08304\uFF09",unavailable:"\u30B5\u30FC\u30D0\u914D\u4FE1\u306A\u3057\u30FB\u6B21\u56DE\u304B\u3089\u540C\u68B1\u7248",failed:"\u5931\u6557\u30FB\u30AD\u30E3\u30C3\u30B7\u30E5\u3092\u7DAD\u6301"};var CATALOG_TOOL_PREFIX="twp_";var WIRE_NAME_RE=/^[A-Za-z0-9_-]{1,64}$/;var MAX_RESULT_CHARS=4e4;function catalogToolName(op){if(op.name.includes("_")||op.domain.includes("_"))return null;const name=`${CATALOG_TOOL_PREFIX}${op.name.replace(/\./g,"-")}_${op.domain}`;return WIRE_NAME_RE.test(name)?name:null}function parseCatalogToolName(name){if(!name.startsWith(CATALOG_TOOL_PREFIX))return null;const rest=name.slice(CATALOG_TOOL_PREFIX.length);const sep3=rest.indexOf("_");if(sep3<=0||sep3===rest.length-
|
|
227
|
+
1)return null;const domain=rest.slice(sep3+1);return/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(domain)?{domain}:null}function toolRiskOf(risk){switch(risk){case"read":return"read";case"write":return"write";default:return"exec"}}var SIMPLE_TYPES=new Set(["string","integer","number","boolean","array","object"]);function paramSchema(param){const declared=param.type;const schema={};if(typeof declared==="string"&&SIMPLE_TYPES.has(declared)&&declared!=="integer"&&declared!=="number"){schema.type=declared}if(param.
|
|
234
228
|
description!==void 0&¶m.description!=="")schema.description=param.description;return schema}function inputSchemaOf(op){const properties={};const required=[];for(const param of op.pathParams){properties[param.name]={description:param.description||`path parameter ${param.name}`};required.push(param.name)}for(const param of op.queryParams){if(Object.hasOwn(properties,param.name))continue;properties[param.name]=paramSchema(param);if(param.required)required.push(param.name)}if(op.body!==null&&op.
|
|
235
229
|
method!=="GET"){properties["body"]={type:"object",description:"JSON request body (see twp_describe_tools for its schema)"}}return{type:"object",properties,...required.length>0?{required}:{},additionalProperties:false}}function catalogTool(op,deps){const name=catalogToolName(op);if(name===null)return null;const summary=op.summary!==""?op.summary:`${op.method} ${op.path}`;const risk=toolRiskOf(op.risk);return{name,domain:op.domain,risk,description:`${summary} (${op.method} ${op.path})`,inputSchema:inputSchemaOf(
|
|
236
230
|
op),preview:input=>previewOf(op,input),run:async input=>runOperation(op,name,input,deps)}}function previewOf(op,input){let path9=op.path;for(const param of op.pathParams){const value=input[param.name];path9=path9.split(`{${param.name}}`).join(typeof value==="string"||typeof value==="number"?String(value):`{${param.name}}`)}return`${op.method} ${path9}`}function buildRequest(op,input){const errors=[];let path9=op.path;const pathNames=new Set;for(const param of op.pathParams){pathNames.add(param.name);
|
|
@@ -256,4 +250,4 @@ ain"],additionalProperties:false},preview:input=>`twp_mount ${String(input["doma
|
|
|
256
250
|
const order={read:0,write:1,destructive:2};return[...ops].sort((a,b)=>order[a.risk]-order[b.risk]).slice(0,MOUNT_LIMIT)}function searchCatalog(entries,query,domain,limit=SEARCH_LIMIT){const words=query.toLowerCase().split(/\s+/).filter(w=>w!=="");if(words.length===0)return[];const hits=[];for(const[name,op]of entries){if(domain!==null&&op.domain!==domain)continue;const haystack=`${name} ${op.domain} ${op.path} ${op.summary} ${op.aliases.join(" ")}`.toLowerCase();let score=0;for(const word of words)
|
|
257
251
|
if(haystack.includes(word))score+=op.summary.toLowerCase().includes(word)?2:1;if(score>0)hits.push({name,op,score})}return hits.sort((a,b)=>b.score-a.score||a.name.localeCompare(b.name)).slice(0,limit)}async function guarded(fn){try{return await fn()}catch(err){if(err instanceof CommandModelMissingError)return{content:err.message,isError:true};throw err}}function safe(fn,fallback){try{return fn()}catch{return fallback}}function createTwpToolkit(runtime,cliVersion,fetchImpl=httpFetch){let session=null;const sharedSession=()=>session??=runtime.session??new AuthSession(runtime.profileName,runtime.apiUrl);let client=null;const abort=new AbortController;const get=(path9,query)=>new TwpApiClient(runtime.apiUrl,sharedSession(),withSignal(fetchImpl,()=>AbortSignal.any([abort.signal,AbortSignal.timeout(CATALOG_FETCH_TIMEOUT_MS)])),cliVersion).get(path9,query);const account=()=>{try{const creds=sharedSession().loadOrThrow();
|
|
258
252
|
return`${creds.tenant_code??""}:${creds.user?.id??""}`}catch{return null}};return new TwpToolkit({client:()=>{client??=new TwpApiClient(runtime.apiUrl,sharedSession(),fetchImpl,cliVersion);return client},catalog:{reader:new ToolCatalog({profile:runtime.profileName,apiUrl:runtime.apiUrl,account}),get,cancel:()=>abort.abort()}})}var CATALOG_FETCH_TIMEOUT_MS=2e4;function withSignal(fetchImpl,signal){return(input,init)=>fetchImpl(input,{...init,signal:signal()})}function residentInputs(toolkit,local=localTools()){
|
|
259
|
-
const meta=toolkit.metaTools();return{tools:[...local,...meta,...toolkit.mountedTools()],usage:toolkit.usage,pinned:new Set([...local,...meta].map(t=>t.name))}}export{
|
|
253
|
+
const meta=toolkit.metaTools();return{tools:[...local,...meta,...toolkit.mountedTools()],usage:toolkit.usage,pinned:new Set([...local,...meta].map(t=>t.name))}}export{parseRule,projectPermissionsPath,projectRootFor,persistProjectAllow,activatePermissionSettings,executeTool,buildSystemPrompt,runTurn,parseFrontMatter,lstatOrNull,findProjectTwpSubdir,activateModeFiles,describeAuditLog,createAuditLogger,currentBranch,displayCwd,resolveGitExecutable,readFileTool,RESIDENT_TOKEN_CAP,localTools,buildResidentSet,describeToolCatalog,createTwpToolkit,residentInputs};
|
|
@@ -42,6 +42,7 @@ var GLOBAL_OPTIONS_HELP=`\u30B0\u30ED\u30FC\u30D0\u30EB\u30AA\u30D7\u30B7\u30E7\
|
|
|
42
42
|
\u7D42\u4E86\u30B3\u30FC\u30C9:
|
|
43
43
|
0 \u6210\u529F / 2 \u5F15\u6570\u30A8\u30E9\u30FC / 3 API 4xx / 4 API 5xx\u30FB\u901A\u4FE1\u5931\u6557 / 5 \u8A8D\u8A3C\u5931\u6557
|
|
44
44
|
6 \u5F85\u6A5F\u306E\u4E0A\u9650\u306B\u9054\u3057\u305F\uFF1D\u672A\u5B8C\u4E86\uFF08twp api --wait \u306E\u307F\uFF09
|
|
45
|
+
7 \u66F8\u304D\u8FBC\u307F\u5148\u304C\u5148\u306B\u9032\u3093\u3067\u3044\u305F\uFF1D\u53D6\u308A\u8FBC\u307F\u76F4\u3057\u3066\u304B\u3089\u9001\u308A\u76F4\u3059\uFF08twp github commit create\uFF09
|
|
45
46
|
|
|
46
47
|
\u51FA\u529B\u5148\u306E\u898F\u7D04:
|
|
47
48
|
\u6A5F\u68B0\u53EF\u8AAD\u306A\u7D50\u679C\u306F stdout\u3001\u9032\u6357\u30FB\u8B66\u544A\u30FB\u30A8\u30E9\u30FC\u306F stderr\u3002
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{isValidSkillName,skillDigest}from"./chunk-
|
|
3
|
+
import{isValidSkillName,skillDigest}from"./chunk-KGKSXGX7.js";import{describeError}from"./chunk-GYX2ZXQM.js";import{isPrivateProjectId}from"./chunk-RMFLTSOV.js";import{stripTerminalControls}from"./chunk-NHYMHCAT.js";import fs from"fs";import path from"path";var SKILL_REF=/^([ \t]*)\/([a-z][a-z0-9-]*)(?=[ \t\n]|$)([ \t]+[^\n]*)?/gm;function stripFrontmatter(content){if(!content.startsWith("---"))return content;const m=/^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n)?/.exec(content);return m===null?content:content.slice(m[0].length)}function referencedSkills(prompt){const out=[];for(const m of prompt.matchAll(SKILL_REF)){const name=m[2]??"";if(!out.includes(name))out.push(name)}return out}function expandServerSkills(prompt,bodies){if(bodies.size===0)return prompt;
|
|
4
4
|
return prompt.replace(SKILL_REF,(whole,_indent,name,args)=>{const body=bodies.get(name);if(body===void 0)return whole;return applyArguments(stripFrontmatter(body),(args??"").trim())})}function applyArguments(body,args){if(body.includes("$ARGUMENTS")){return body.replaceAll("$ARGUMENTS",()=>args)}return args===""?body:`${body}
|
|
5
5
|
|
|
6
6
|
ARGUMENTS: ${args}`}function prepareSkillOverlay(root,workspace,bodies,provider){const commands=path.join(root,".claude","commands");fs.rmSync(root,{recursive:true,force:true});fs.mkdirSync(commands,{recursive:true});const src=path.join(workspace,".claude","commands");let names=[];try{names=fs.readdirSync(src).filter(f=>f.endsWith(".md"))}catch{}for(const f of names){const from=path.join(src,f);try{if(fs.statSync(from).isFile())fs.copyFileSync(from,path.join(commands,f))}catch{}}for(const[name,body]of bodies){
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{ALLOW_REDACTED_FLAG}from"./chunk-W4NLJ2YK.js";import{REDACTED}from"./chunk-BD7O73GK.js";import{UsageError}from"./chunk-
|
|
3
|
+
import{ALLOW_REDACTED_FLAG}from"./chunk-W4NLJ2YK.js";import{REDACTED}from"./chunk-BD7O73GK.js";import{UsageError}from"./chunk-STILP3Z6.js";import fs from"fs";var BOM="\uFEFF";async function readStdin(spec){if(process.stdin.isTTY===true){throw new UsageError(`${spec.fileFlag} - \u306F\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u307F\u307E\u3059\u304C\u3001\u7AEF\u672B\u304C\u7E4B\u304C\u3063\u3066\u3044\u307E\u3059`,`\u30D1\u30A4\u30D7\u304B\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: cat review.md | twp \u2026 ${spec.fileFlag} -\uFF09\u3002`)}const chunks=[];for await(const chunk of process.stdin)chunks.
|
|
4
4
|
push(Buffer.from(chunk));return Buffer.concat(chunks).toString("utf8")}function charCount(text){return[...text].length}function containsRedactedMarker(text){if(text.includes(REDACTED))return true;let parsed;try{parsed=JSON.parse(text)}catch(error){if(error instanceof SyntaxError)return false;throw error}const pending=[parsed];while(pending.length>0){const value=pending.pop();if(typeof value==="string"){if(value.includes(REDACTED))return true}else if(Array.isArray(value)){for(const item of value)
|
|
5
5
|
pending.push(item)}else if(value!==null&&typeof value==="object"){for(const[key,item]of Object.entries(value)){if(key.includes(REDACTED))return true;pending.push(item)}}}return false}async function readBody(input,spec){const inline=input.flags.get(spec.flag);const file=input.flags.get(spec.fileFlag);if(inline!==void 0&&file!==void 0){throw new UsageError(`${spec.label}\u304C ${spec.flag} \u3068 ${spec.fileFlag} \u306E\u4E21\u65B9\u3067\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059`,`\u3069\u3061\u3089\u304B\u4E00\u65B9\u3060\u3051\u3092\u6307\
|
|
6
6
|
\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${spec.fileFlag} - \u3067\u6A19\u6E96\u5165\u529B\u304B\u3089\u8AAD\u3081\u307E\u3059\uFF09\u3002`)}if(inline===void 0&&file===void 0)return void 0;const text=inline??await readFrom(file,spec);const stripped=text.startsWith(BOM)?text.slice(BOM.length):text;if(stripped.trim()===""){throw new UsageError(`${spec.label}\u304C\u7A7A\u3067\u3059\uFF08${inline!==void 0?spec.flag:`${spec.fileFlag} ${file}`}\uFF09`,spec.usage)}const count=charCount(stripped);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
var LOADERS={agent:async()=>(await import("./agent-RKDXMENR.js")).agentDomain,"agent-loop":async()=>(await import("./agent-loop-JJUNRUK3.js")).agentLoopDomain,"ai-review-reason":async()=>(await import("./sales-ai-review-6SE3UFAK.js")).aiReviewReasonDomain,analysis:async()=>(await import("./analysis-G5ACF62Y.js")).analysisDomain,announcement:async()=>(await import("./announcement-SR5R2CY2.js")).announcementDomain,"api-key":async()=>(await import("./api-key-XIZFXWAN.js")).apiKeyDomain,attendance:async()=>(await import("./attendance-correct-ILQUSSZQ.js")).
|
|
4
|
+
attendanceDomainWithRecords,"audit-log":async()=>(await import("./audit-log-DLRQGPIX.js")).auditLogDomain,backlog:async()=>(await import("./backlog-HTA2X2YS.js")).backlogDomain,brief:async()=>(await import("./brief-467WEZKT.js")).briefDomain,budget:async()=>(await import("./budget-2CRF4362.js")).budgetDomain,"business-hours":async()=>(await import("./business-hours-QL763KSA.js")).businessHoursDomain,"business-place":async()=>(await import("./sales-master-TRZFZKRH.js")).businessPlaceDomain,
|
|
5
|
+
company:async()=>(await import("./company-PCUVVYIV.js")).companyDomain,content:async()=>(await import("./content-D2QYEOXA.js")).contentDomain,contract:async()=>(await import("./contract-RDTDBSC6.js")).contractDomain,corporate:async()=>(await import("./corporate-ZRXJA2J2.js")).corporateDomain,customer:async()=>(await import("./company-PCUVVYIV.js")).customerDomain,department:async()=>(await import("./department-GFYKDAQT.js")).departmentDomain,deposit:async()=>(await import("./deposit-BFRC5LEP.js")).
|
|
6
|
+
depositDomain,estimate:async()=>(await import("./estimate-Y3JHXT7I.js")).estimateDomain,evaluation:async()=>(await import("./evaluation-SA7UXTGY.js")).evaluationDomain,expense:async()=>(await import("./expense-44SXCE5I.js")).expenseDomain,faq:async()=>(await import("./faq-IEIZQTRI.js")).faqDomain,"fiscal-year":async()=>(await import("./fiscal-year-NQSPGOSE.js")).fiscalYearDomain,github:async()=>(await import("./github-5LLNKAHY.js")).githubDomain,holiday:async()=>(await import("./holiday-5XBCAYSA.js")).
|
|
7
|
+
holidayDomain,"goal-sheet":async()=>(await import("./evaluation-SA7UXTGY.js")).goalSheetDomain,inquiry:async()=>(await import("./inquiry-WUGCRUWS.js")).inquiryDomain,invoice:async()=>(await import("./invoice-EDSKFTTU.js")).invoiceDomain,"job-title":async()=>(await import("./job-title-KZEVWJMZ.js")).jobTitleDomain,journal:async()=>(await import("./journal-DCKH6PAR.js")).journalDomain,knowledge:async()=>(await import("./domain-knowledge-WZMEHMQQ.js")).knowledgeDomain,leave:async()=>(await import("./leave-HWEK7LGE.js")).
|
|
8
|
+
leaveDomain,license:async()=>(await import("./license-EBU32T7S.js")).licenseDomain,"login-history":async()=>(await import("./login-history-YJMOHIGW.js")).loginHistoryDomain,media:async()=>(await import("./media-2J5JIEAH.js")).mediaDomain,meeting:async()=>(await import("./knowledge-HWNIKVSM.js")).meetingDomain,note:async()=>(await import("./note-KNUKF6IT.js")).noteDomain,notification:async()=>(await import("./notification-BMAKU66X.js")).notificationDomain,ojt:async()=>(await import("./ojt-QVIQZOD5.js")).
|
|
9
|
+
ojtDomain,onedrive:async()=>(await import("./onedrive-NYRDUBIQ.js")).onedriveDomain,outlook:async()=>(await import("./outlook-OE7CUTAJ.js")).outlookDomain,payee:async()=>(await import("./sales-master-TRZFZKRH.js")).payeeDomain,position:async()=>(await import("./position-QNX72LXV.js")).positionDomain,project:async()=>(await import("./project-OBZ4SJVK.js")).projectDomain,prospect:async()=>(await import("./prospect-6I4LQPEZ.js")).prospectDomain,purchase:async()=>(await import("./purchase-BUP5MYSQ.js")).
|
|
10
|
+
purchaseDomain,qualification:async()=>(await import("./skill-CAJ7KXP2.js")).qualificationDomain,receivable:async()=>(await import("./receivable-M6UE72X6.js")).receivableDomain,redmine:async()=>(await import("./redmine-4VSQ64WO.js")).redmineDomain,report:async()=>(await import("./report-WI7UCP5H.js")).reportDomain,"role-template":async()=>(await import("./evaluation-SA7UXTGY.js")).roleTemplateDomain,"rounding-setting":async()=>(await import("./sales-numbering-3VCQOHNO.js")).roundingSettingDomain,
|
|
11
|
+
"seal-impression":async()=>(await import("./sales-master-TRZFZKRH.js")).sealImpressionDomain,search:async()=>(await import("./search-VDGIQD6Z.js")).searchDomain,secret:async()=>(await import("./secret-57ZPEBCJ.js")).secretDomain,segment:async()=>(await import("./segment-FRGMNPHV.js")).segmentDomain,shift:async()=>(await import("./attendance-lists-UTQIIOZ5.js")).shiftDomain,skill:async()=>(await import("./skill-CAJ7KXP2.js")).skillDomain,slack:async()=>(await import("./slack-PS5ACRYL.js")).
|
|
12
|
+
slackDomain,sns:async()=>(await import("./sns-KXCZ42TC.js")).snsDomain,"staffing-board":async()=>(await import("./staffing-board-A6SNNSRB.js")).staffingBoardDomain,storage:async()=>(await import("./storage-LJH2J7GU.js")).storageDomain,"supplier-payment":async()=>(await import("./supplier-payment-ZP6EK22P.js")).supplierPaymentDomain,support:async()=>(await import("./support-FO4RLDNQ.js")).supportDomain,task:async()=>(await import("./task-W6VLD6X7.js")).taskDomain,teams:async()=>(await import("./teams-WMKWQCLH.js")).
|
|
13
|
+
teamsDomain,user:async()=>(await import("./user-SKIUDKWE.js")).userDomain,"user-contract-type":async()=>(await import("./user-contract-type-2XXNPP27.js")).userContractTypeDomain,"user-group":async()=>(await import("./user-group-EEXQBLIC.js")).userGroupDomain,wiki:async()=>(await import("./knowledge-HWNIKVSM.js")).wikiDomain,workchange:async()=>(await import("./attendance-lists-UTQIIOZ5.js")).workchangeDomain,"worker-agent":async()=>(await import("./worker-agent-BJVP2MPH.js")).workerAgentDomain,workflow:async()=>(await import("./workflow-WOQKGIUU.js")).
|
|
14
|
+
workflowDomain};async function loadDomain(name){return LOADERS[name]()}export{loadDomain};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
2
|
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
-
import{USER_REF_FLAG,USER_REF_HELP,prepareUser}from"./chunk-
|
|
3
|
+
import{USER_REF_FLAG,USER_REF_HELP,prepareUser}from"./chunk-O756DX6D.js";import{isSafePathSegment}from"./chunk-HVZUXLQ4.js";import{shellQuote}from"./chunk-DYT22FTA.js";import{requireResolved}from"./chunk-7DCWZ2NF.js";import{isRecord,pick}from"./chunk-HCTPCUST.js";import{ApiResponseError,UsageError}from"./chunk-STILP3Z6.js";var PERMISSIONS_PATH="/api/v2/ojt/permissions/user";var ROLE="admin";var FORBIDDEN="OJT\u7BA1\u7406\u8005\u306E\u6A29\u9650\u304C\u5FC5\u8981\u3067\u3059\uFF08\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u307E\u305F\u306F OJT\u7BA1\u7406\u8005\u3060\u3051\u304C\u4F7F\u3048\u307E\u3059\uFF09\u3002\u30C6\u30CA\u30F3\u30C8\u3067 OJT \u304C\u7121\u52B9\u306A\u5834\u5408\u3082\u540C\u3058\u5FDC\u7B54\u306B\u306A\u308A\u307E\u3059";var LIST_COLUMNS=["user_id","user_name","user_department","ojt_role","id",
|
|
4
4
|
"created_at"];var ROW_COLUMNS=["id","user_id","ojt_role","created_at","updated_at"];var OJT_ADMIN_NOTE="OJT\u7BA1\u7406\u8005\uFF08OJT\u7BA1\u7406\u30FB\u6A29\u9650\u7BA1\u7406\u30FB\u627F\u8A8D\u306E\u30E1\u30CB\u30E5\u30FC\uFF09\u306F OJT\u7BA1\u7406\u8005\u306E\u4ED8\u4E0E\uFF08\u753B\u9762\u306E /v1/ojt/permissions\u30FBtwp ojt admin grant\uFF09\u3067\u6C7A\u307E\u308A\u307E\u3059\u3002\n\u6A5F\u80FD\u6A29\u9650\u306E ojt\uFF08twp user permission update --feature ojt\uFF09\u3092 admin \u306B\u3057\u3066\u3082 OJT\u7BA1\u7406\u8005\u306B\u306F\u306A\u3089\u305A\u3001OJT\u7BA1\u7406\u306E\u30E1\u30CB\u30E5\u30FC\u306F\u8868\u793A\u3055\u308C\u307E\u305B\u3093\n\uFF08\u30B5\u30A4\u30C9\u30D0\u30FC\u306E\u300COJT\u300D\u81EA\u4F53\u306F\u3001\u6A5F\u80FD\u6A29\u9650\u306E ojt \u304C member \u4EE5\u4E0A\u3067\u8868\u793A\u3055\u308C\u307E\u3059\uFF09\u3002\n\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u306F\u4ED8\u4E0E\u3057\u306A\u304F\u3066\u3082 OJT\u7BA1\u7406\u8005\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\uFF08twp ojt admin list \u306B\u306F\u51FA\u307E\u305B\u3093\uFF09\u3002";
|
|
5
5
|
function rowsOf(body){const items=isRecord(body)?body["items"]:void 0;if(!isRecord(body)||body["result"]!==true||!Array.isArray(items)){throw new ApiResponseError("OJT\u7BA1\u7406\u8005\u306E\u4E00\u89A7\u306E\u5FDC\u7B54\u306B items \u914D\u5217\u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return items.map(item=>{if(!isRecord(item)||typeof item["id"]!=="string"||typeof item["user_id"]!=="string"){throw new ApiResponseError(
|
|
6
6
|
"OJT\u7BA1\u7406\u8005\u306E\u4E00\u89A7\u306E\u5FDC\u7B54\u306E\u884C\u306B id / user_id \u304C\u3042\u308A\u307E\u305B\u3093\u3002\u63A5\u7D9A\u5148\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002")}return item})}function grantedOf(body){const data=isRecord(body)?body["data"]:void 0;if(!isRecord(body)||body["result"]!==true||!isRecord(data)||typeof data["user_id"]!=="string"||data["ojt_role"]!==ROLE){throw new ApiResponseError("OJT\u7BA1\u7406\u8005\u306E\u4ED8\u4E0E\u306E\u5FDC\u7B54\u306E\u5F62\u304C\u60F3\u5B9A\u3068\u9055\u3044\u307E\u3059\uFF08data.user_id / data.ojt_role\uFF09\u3002\u63A5\
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __twpCreateRequire } from 'node:module';
|
|
2
|
+
const require = __twpCreateRequire(import.meta.url);
|
|
3
|
+
import{configReadDirs}from"./chunk-RZVI6PMW.js";import{realpathSync}from"fs";import{homedir}from"os";import{dirname,isAbsolute,relative,resolve,sep}from"path";var PathDeniedError=class extends Error{constructor(message){super(message);this.name="PathDeniedError"}};function resolveToolPath(input,cwd,home=homedir()){if(typeof input!=="string"||input.trim()===""){throw new PathDeniedError("path must be a non-empty string")}const expanded=expandHome(input,home);const abs=isAbsolute(expanded)?resolve(expanded):resolve(cwd,expanded);const root=realOrSelf(resolve(cwd));assertInside(abs,resolve(cwd),abs);assertNotSecret(abs,home);const real=realOrSelf(abs);if(real!==
|
|
4
|
+
abs){assertInside(real,root,abs);assertNotSecret(real,home)}return abs}function realToolPath(input,cwd,home=homedir()){return realOrSelf(resolveToolPath(input,cwd,home))}function assertInside(target,root,reported){const rel=relative(root,target);const outside=rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel);if(outside){throw new PathDeniedError(`path escapes the working directory (${reported}). Only paths under ${root} can be accessed.`)}}function realOrSelf(target){let current=target;const rest=[];
|
|
5
|
+
for(;;){try{const real=realpathSync(current);return rest.length===0?real:resolve(real,...rest.reverse())}catch{const parent=dirname(current);if(parent===current)return target;rest.push(current.slice(parent.length+1));current=parent}}}function assertNotSecret(absPath,home=homedir(),env=process.env){const reason=secretReason(absPath,home,env);if(reason!==null)throw new PathDeniedError(`refusing to access ${absPath}: ${reason}`)}function secretReason(absPath,_home=homedir(),env=process.env){const lower=absPath.
|
|
6
|
+
toLowerCase();const segments=lower.split(sep);const base=segments[segments.length-1]??"";const parent=segments[segments.length-2]??"";if(base===".env"||base.startsWith(".env."))return".env files are denied (design \xA77)";if(segments.includes(".ssh"))return"SSH key material is denied (design \xA77)";if(parent===".git"&&base==="config"){return".git/config is denied (it can hold a GitHub token in the remote URL)"}if(base===".netrc"||base==="_netrc"||base===".npmrc")return"credential files are deni\
|
|
7
|
+
ed";if(parent===".aws"&&(base==="credentials"||base==="config"))return"AWS credentials are denied";for(const dir of configReadDirs(env)){if(lower===resolve(dir,"credentials.json").toLowerCase()){return"TWP credentials are denied (design \xA77)"}}if(parent===".twp"&&base==="credentials.json")return"TWP credentials are denied (design \xA77)";if(parent==="logs"&&base.startsWith("session-")&&base.endsWith(".jsonl")){const grandparent=segments[segments.length-3]??"";if(grandparent===".twp")return"TWP\
|
|
8
|
+
audit logs are denied (design \xA77)";for(const dir of configReadDirs(env)){if(lower.startsWith(resolve(dir,"logs").toLowerCase()+sep)){return"TWP audit logs are denied (design \xA77)"}}}return null}function toolRelative(cwd,absPath){const rel=relative(cwd,absPath);return sep==="\\"?rel.split("\\").join("/"):rel}function isInsideCwd(absPath,cwd){const root=resolve(cwd);if(!withinLexically(absPath,root))return false;const real=realOrSelf(absPath);return real===absPath||withinLexically(real,realOrSelf(
|
|
9
|
+
root))}function withinLexically(target,root){const rel=relative(root,target);return!(rel===".."||rel.startsWith(`..${sep}`)||isAbsolute(rel))}function expandHome(input,home){if(input==="~")return home;if(input.startsWith("~/")||input.startsWith(`~${sep}`))return resolve(home,input.slice(2));return input}export{PathDeniedError,resolveToolPath,realToolPath,realOrSelf,secretReason,toolRelative,isInsideCwd};
|