@workit-dev/opencode 1.9.1 → 1.11.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/dist/plugin.js +197 -25
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -24145,7 +24145,7 @@ function ytrackReadiness(run, host) {
|
|
|
24145
24145
|
}
|
|
24146
24146
|
|
|
24147
24147
|
// packages/workit-core/src/core/youtrack.ts
|
|
24148
|
-
var ISSUE_RE = /^[A-Z]
|
|
24148
|
+
var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
24149
24149
|
var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path33.join(resolveConfigDir(), "youtrack.json");
|
|
24150
24150
|
var readYouTrackContextConfig = () => {
|
|
24151
24151
|
const cfgPath = youTrackReadOnlyConfigPath();
|
|
@@ -24201,11 +24201,11 @@ function parseIssueRef(input) {
|
|
|
24201
24201
|
if (ISSUE_RE.test(trimmed)) {
|
|
24202
24202
|
return { issueId: trimmed, source: "id" };
|
|
24203
24203
|
}
|
|
24204
|
-
const fromPath = trimmed.match(/\/(?:issue|issues)\/([A-Z]
|
|
24204
|
+
const fromPath = trimmed.match(/\/(?:issue|issues)\/([A-Z][A-Z0-9_]*-\d+)/i);
|
|
24205
24205
|
if (fromPath && ISSUE_RE.test(fromPath[1])) {
|
|
24206
24206
|
return { issueId: fromPath[1], source: "url" };
|
|
24207
24207
|
}
|
|
24208
|
-
const anywhere = trimmed.match(/([A-Z]
|
|
24208
|
+
const anywhere = trimmed.match(/([A-Z][A-Z0-9_]*-\d+)/);
|
|
24209
24209
|
if (anywhere && ISSUE_RE.test(anywhere[1])) {
|
|
24210
24210
|
return { issueId: anywhere[1], source: "url" };
|
|
24211
24211
|
}
|
|
@@ -28503,7 +28503,7 @@ var minutesOf = (text = "") => {
|
|
|
28503
28503
|
});
|
|
28504
28504
|
return rest.trim() || !Number.isInteger(total) || total <= 0 ? null : total;
|
|
28505
28505
|
};
|
|
28506
|
-
var VALUE = new Set(("--host --body -b --body-file --text --date --duration --type --project -p --summary -s " + "--description --description-file --field --tag --add-tag --remove-tag --assignee --comment " + "--json --jq -X --method -f -F --raw-field --input --fields -q --query --author --since --limit").split(" "));
|
|
28506
|
+
var VALUE = new Set(("--host --body -b --body-file --text --date --duration --type --project -p --summary -s " + "--description --description-file --field --tag --add-tag --remove-tag --assignee --comment " + "--json --jq -X --method -f -F --raw-field --input --fields -q --query --author --since --limit " + "--attach -H --header").split(" "));
|
|
28507
28507
|
var BARE = new Set("--debug --no-color --paginate --include --dry-run --silent --yes --meeting --help -h".split(" "));
|
|
28508
28508
|
var standsAlone = (args, at) => {
|
|
28509
28509
|
const before = args[at - 1] ?? "";
|
|
@@ -28522,7 +28522,7 @@ var ASKS = /^(?:post|put|patch|delete)$/i;
|
|
|
28522
28522
|
var BODY = /^(?:-[fF]|--(?:field|raw-field|input))(?:=|$)|^-[fF]./;
|
|
28523
28523
|
var QUIET = /^--(?:debug|no-color|json|jq)$/;
|
|
28524
28524
|
var CARRIES = {
|
|
28525
|
-
note: { "--body": "body", "-b": "body", "--body-file": "file" },
|
|
28525
|
+
note: { "--body": "body", "-b": "body", "--body-file": "file", "--attach": "attach" },
|
|
28526
28526
|
time: { "--duration": "duration", "--text": "text", "--date": "date" },
|
|
28527
28527
|
create: {
|
|
28528
28528
|
"--project": "project",
|
|
@@ -28534,9 +28534,60 @@ var CARRIES = {
|
|
|
28534
28534
|
}
|
|
28535
28535
|
};
|
|
28536
28536
|
var gap = (part) => ({ workit: null, gap: part });
|
|
28537
|
+
var ISSUE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
28538
|
+
var EXPANDS = /[$`*?[\]]|^~/;
|
|
28539
|
+
var commandFlag = (command) => {
|
|
28540
|
+
const state = /^State\s+(\S.*)$/u.exec(command)?.[1];
|
|
28541
|
+
return state ? pair("--state", state) : pair("--command", command);
|
|
28542
|
+
};
|
|
28543
|
+
var callFor = (effect) => {
|
|
28544
|
+
const comment = effect.markdown !== undefined || effect.file !== undefined;
|
|
28545
|
+
const time = effect.minutes !== undefined;
|
|
28546
|
+
const timeFlags = [
|
|
28547
|
+
effect.text === undefined ? "" : pair("--text", effect.text),
|
|
28548
|
+
effect.date === undefined ? "" : pair("--date", effect.date)
|
|
28549
|
+
];
|
|
28550
|
+
const commentFlag = effect.markdown !== undefined ? pair("--markdown", effect.markdown) : effect.file !== undefined ? pair("--file", effect.file) : "";
|
|
28551
|
+
const only = !effect.attach?.length && effect.command === undefined;
|
|
28552
|
+
if (only && comment && !time)
|
|
28553
|
+
return `workit youtrack note ${effect.issue} ${commentFlag}`;
|
|
28554
|
+
if (only && time && !comment)
|
|
28555
|
+
return [`workit youtrack time ${effect.issue} --minutes ${effect.minutes}`, ...timeFlags].filter(Boolean).join(" ");
|
|
28556
|
+
return [
|
|
28557
|
+
`workit youtrack update ${effect.issue}`,
|
|
28558
|
+
commentFlag,
|
|
28559
|
+
...(effect.attach ?? []).map((file) => pair("--attach", file)),
|
|
28560
|
+
time ? `--minutes ${effect.minutes}` : "",
|
|
28561
|
+
...time ? timeFlags : [],
|
|
28562
|
+
effect.command === undefined ? "" : commandFlag(effect.command)
|
|
28563
|
+
].filter(Boolean).join(" ");
|
|
28564
|
+
};
|
|
28565
|
+
var mapped = (effect) => ({ workit: callFor(effect), effect });
|
|
28566
|
+
var combine = (effects) => {
|
|
28567
|
+
const out = { issue: effects[0].issue };
|
|
28568
|
+
for (const effect of effects) {
|
|
28569
|
+
if (effect.issue !== out.issue)
|
|
28570
|
+
return null;
|
|
28571
|
+
const comment = effect.markdown !== undefined || effect.file !== undefined;
|
|
28572
|
+
if (comment && (out.markdown !== undefined || out.file !== undefined))
|
|
28573
|
+
return null;
|
|
28574
|
+
if (effect.minutes !== undefined && out.minutes !== undefined)
|
|
28575
|
+
return null;
|
|
28576
|
+
if (effect.command !== undefined && out.command !== undefined)
|
|
28577
|
+
return null;
|
|
28578
|
+
Object.assign(out, {
|
|
28579
|
+
...effect,
|
|
28580
|
+
attach: [...out.attach ?? [], ...effect.attach ?? []]
|
|
28581
|
+
});
|
|
28582
|
+
}
|
|
28583
|
+
if (!out.attach?.length)
|
|
28584
|
+
delete out.attach;
|
|
28585
|
+
return out;
|
|
28586
|
+
};
|
|
28537
28587
|
var pair = (flag, value) => value.startsWith("-") ? `${flag}=${quote2(value)}` : `${flag} ${quote2(value)}`;
|
|
28538
28588
|
var mapWrite = (verb, args) => {
|
|
28539
28589
|
const values = {};
|
|
28590
|
+
const attach = [];
|
|
28540
28591
|
const operands = [];
|
|
28541
28592
|
for (let at = 0;at < args.length; at++) {
|
|
28542
28593
|
const arg = args[at];
|
|
@@ -28552,9 +28603,12 @@ var mapWrite = (verb, args) => {
|
|
|
28552
28603
|
const key = CARRIES[verb][flag];
|
|
28553
28604
|
if (!key || value === undefined || key in values)
|
|
28554
28605
|
return gap(`\`${flag}\``);
|
|
28555
|
-
if (/[$`]|^~/.test(value))
|
|
28606
|
+
if (/[$`]|^~/.test(value) || key === "attach" && EXPANDS.test(value))
|
|
28556
28607
|
return gap(`the value of \`${flag}\`, which the shell expands when it runs`);
|
|
28557
|
-
|
|
28608
|
+
if (key === "attach")
|
|
28609
|
+
attach.push(value);
|
|
28610
|
+
else
|
|
28611
|
+
values[key] = value;
|
|
28558
28612
|
}
|
|
28559
28613
|
const [issue, ...more] = operands.slice(2);
|
|
28560
28614
|
const v = values;
|
|
@@ -28577,7 +28631,7 @@ var mapWrite = (verb, args) => {
|
|
|
28577
28631
|
].filter(Boolean).join(" ")
|
|
28578
28632
|
};
|
|
28579
28633
|
}
|
|
28580
|
-
if (issue === undefined || more.length ||
|
|
28634
|
+
if (issue === undefined || more.length || !ISSUE.test(issue))
|
|
28581
28635
|
return gap("the issue, which must be one id like ABC-123");
|
|
28582
28636
|
if (verb === "note") {
|
|
28583
28637
|
if (v.body === undefined === (v.file === undefined))
|
|
@@ -28586,22 +28640,108 @@ var mapWrite = (verb, args) => {
|
|
|
28586
28640
|
return gap("text read from standard input");
|
|
28587
28641
|
if (v.body !== undefined && !v.body.trim())
|
|
28588
28642
|
return gap("an empty --body");
|
|
28589
|
-
return {
|
|
28590
|
-
|
|
28591
|
-
|
|
28643
|
+
return mapped({
|
|
28644
|
+
issue,
|
|
28645
|
+
...v.body === undefined ? { file: v.file } : { markdown: v.body },
|
|
28646
|
+
...attach.length ? { attach } : {}
|
|
28647
|
+
});
|
|
28592
28648
|
}
|
|
28593
28649
|
const minutes = minutesOf(v.duration);
|
|
28594
28650
|
if (minutes === null)
|
|
28595
28651
|
return gap(`\`--duration ${v.duration ?? ""}\`, which is no whole number of minutes`);
|
|
28596
28652
|
if (v.date !== undefined && !/^(?:auto|\d{4}-\d{2}-\d{2})$/.test(v.date))
|
|
28597
28653
|
return gap(`\`--date ${v.date}\``);
|
|
28598
|
-
return {
|
|
28599
|
-
|
|
28600
|
-
|
|
28601
|
-
|
|
28602
|
-
|
|
28603
|
-
|
|
28604
|
-
|
|
28654
|
+
return mapped({
|
|
28655
|
+
issue,
|
|
28656
|
+
minutes,
|
|
28657
|
+
...v.text === undefined ? {} : { text: v.text },
|
|
28658
|
+
...v.date === undefined ? {} : { date: v.date }
|
|
28659
|
+
});
|
|
28660
|
+
};
|
|
28661
|
+
var mapIssueWrite = (verb, args) => {
|
|
28662
|
+
const operands = [];
|
|
28663
|
+
for (let at = 0;at < args.length; at++) {
|
|
28664
|
+
const arg = args[at];
|
|
28665
|
+
if (!arg.startsWith("-") || arg === "-") {
|
|
28666
|
+
operands.push(arg);
|
|
28667
|
+
continue;
|
|
28668
|
+
}
|
|
28669
|
+
const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
28670
|
+
const flag = eq > 0 ? arg.slice(0, eq) : arg;
|
|
28671
|
+
if (!QUIET.test(flag))
|
|
28672
|
+
return gap(`\`${flag}\``);
|
|
28673
|
+
if (eq < 0 && VALUE.has(flag))
|
|
28674
|
+
at++;
|
|
28675
|
+
}
|
|
28676
|
+
const [issue, ...rest] = operands.slice(2);
|
|
28677
|
+
if (issue === undefined || !ISSUE.test(issue))
|
|
28678
|
+
return gap("the issue, which must be one id like ABC-123");
|
|
28679
|
+
if (verb === "attach") {
|
|
28680
|
+
if (!rest.length)
|
|
28681
|
+
return gap("an attach with no file");
|
|
28682
|
+
const odd = rest.find((file) => file === "-" || EXPANDS.test(file));
|
|
28683
|
+
if (odd !== undefined)
|
|
28684
|
+
return gap(`the file \`${odd}\`, which the shell expands or reads from standard input`);
|
|
28685
|
+
return mapped({ issue, attach: rest });
|
|
28686
|
+
}
|
|
28687
|
+
if (rest.length !== 1 || !rest[0].trim())
|
|
28688
|
+
return gap("a command that is not one quoted word (`ytrack issue command X-1 'State Done'`)");
|
|
28689
|
+
if (/[$`]/.test(rest[0]))
|
|
28690
|
+
return gap("a command the shell expands when it runs");
|
|
28691
|
+
return mapped({ issue, command: rest[0].trim() });
|
|
28692
|
+
};
|
|
28693
|
+
var mapApi = (args, target) => {
|
|
28694
|
+
const where = /^\/?(?:api\/)?issues\/([A-Z][A-Z0-9_]*-\d+)\/(comments|attachments)\/?(?:\?.*)?$/u.exec(target);
|
|
28695
|
+
if (!where)
|
|
28696
|
+
return null;
|
|
28697
|
+
const [, issue, kind] = where;
|
|
28698
|
+
const fields = [];
|
|
28699
|
+
for (let at = 0;at < args.length; at++) {
|
|
28700
|
+
const arg = args[at];
|
|
28701
|
+
if (!arg.startsWith("-"))
|
|
28702
|
+
continue;
|
|
28703
|
+
const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
28704
|
+
const glued = /^-[fFX]./.test(arg) && !arg.startsWith("--");
|
|
28705
|
+
const flag = glued ? arg.slice(0, 2) : eq > 0 ? arg.slice(0, eq) : arg;
|
|
28706
|
+
const value = glued ? arg.slice(2) : eq > 0 ? arg.slice(eq + 1) : VALUE.has(flag) ? args[++at] : undefined;
|
|
28707
|
+
if (QUIET.test(flag))
|
|
28708
|
+
continue;
|
|
28709
|
+
if (/^(?:-X|--method)$/.test(flag)) {
|
|
28710
|
+
if (!/^=?post$/i.test(value ?? ""))
|
|
28711
|
+
return gap(`\`${flag} ${value ?? ""}\``);
|
|
28712
|
+
continue;
|
|
28713
|
+
}
|
|
28714
|
+
if (/^(?:-H|--header)$/.test(flag) && /^(?:content-type|accept)\s*:/i.test(value ?? ""))
|
|
28715
|
+
continue;
|
|
28716
|
+
if (!/^(?:-f|-F|--field|--raw-field)$/.test(flag) || value === undefined)
|
|
28717
|
+
return gap(`\`${flag}\``);
|
|
28718
|
+
const split = value.indexOf("=");
|
|
28719
|
+
if (split <= 0)
|
|
28720
|
+
return gap(`the field \`${value}\``);
|
|
28721
|
+
fields.push({
|
|
28722
|
+
typed: flag === "-F" || flag === "--field",
|
|
28723
|
+
key: value.slice(0, split),
|
|
28724
|
+
value: value.slice(split + 1)
|
|
28725
|
+
});
|
|
28726
|
+
}
|
|
28727
|
+
if (fields.some((field) => /[$`]/.test(field.value)))
|
|
28728
|
+
return gap("a field value the shell expands when it runs");
|
|
28729
|
+
if (kind === "comments") {
|
|
28730
|
+
const [field, ...more] = fields;
|
|
28731
|
+
if (!field || more.length || field.key !== "text")
|
|
28732
|
+
return gap("a comment body other than one `text` field");
|
|
28733
|
+
if (field.typed && field.value.startsWith("@")) {
|
|
28734
|
+
const file = field.value.slice(1);
|
|
28735
|
+
if (!file || file === "-" || EXPANDS.test(file))
|
|
28736
|
+
return gap(`the file \`${file}\``);
|
|
28737
|
+
return mapped({ issue, file });
|
|
28738
|
+
}
|
|
28739
|
+
return field.value.trim() ? mapped({ issue, markdown: field.value }) : gap("an empty `text`");
|
|
28740
|
+
}
|
|
28741
|
+
const files = fields.map((field) => field.typed && field.value.startsWith("@") ? field.value.slice(1) : null);
|
|
28742
|
+
if (!files.length || files.some((file) => !file || file === "-" || EXPANDS.test(file)))
|
|
28743
|
+
return gap("an upload other than `-F <name>=@<file>` fields");
|
|
28744
|
+
return mapped({ issue, attach: files });
|
|
28605
28745
|
};
|
|
28606
28746
|
var UNCOVERED = { workit: null, gap: "" };
|
|
28607
28747
|
var classify2 = (args) => {
|
|
@@ -28616,11 +28756,12 @@ var judge = (args, words) => {
|
|
|
28616
28756
|
const verb = words[1] ?? "";
|
|
28617
28757
|
if (group === "api") {
|
|
28618
28758
|
const methods = args.flatMap((arg, at) => /^(?:-X|--method)$/.test(arg) ? [{ value: args[at + 1] ?? "", alone: standsAlone(args, at) }] : /^(?:-X.|--method=)/.test(arg) ? [{ value: arg.replace(/^(?:-X=?|--method=)/, ""), alone: standsAlone(args, at) }] : []);
|
|
28759
|
+
const posts = methods.length > 0 && methods.every((method) => /^post$/i.test(method.value));
|
|
28619
28760
|
if (methods.some((method) => ASKS.test(method.value)))
|
|
28620
|
-
return UNCOVERED;
|
|
28761
|
+
return (posts ? mapApi(args, words[1] ?? "") : null) ?? UNCOVERED;
|
|
28621
28762
|
if (methods.some((method) => method.alone))
|
|
28622
28763
|
return null;
|
|
28623
|
-
return args.some((a) => BODY.test(a)) ? UNCOVERED : null;
|
|
28764
|
+
return args.some((a) => BODY.test(a)) ? mapApi(args, words[1] ?? "") ?? UNCOVERED : null;
|
|
28624
28765
|
}
|
|
28625
28766
|
if (group === "work-item" && /^(?:add|create)$/.test(verb))
|
|
28626
28767
|
return mapWrite("time", args);
|
|
@@ -28633,7 +28774,9 @@ var judge = (args, words) => {
|
|
|
28633
28774
|
if (verb === "create")
|
|
28634
28775
|
return mapWrite("create", args);
|
|
28635
28776
|
if (verb === "command")
|
|
28636
|
-
return flagged(args, /^--dry-run$/) ? null :
|
|
28777
|
+
return flagged(args, /^--dry-run$/) ? null : mapIssueWrite("command", args);
|
|
28778
|
+
if (verb === "attach")
|
|
28779
|
+
return mapIssueWrite("attach", args);
|
|
28637
28780
|
return /^(?:edit|update|delete|rm)$/.test(verb) ? UNCOVERED : null;
|
|
28638
28781
|
};
|
|
28639
28782
|
var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
|
|
@@ -28711,7 +28854,10 @@ var passed = (words) => {
|
|
|
28711
28854
|
};
|
|
28712
28855
|
var plainLines = (command, dialect) => {
|
|
28713
28856
|
let first = null;
|
|
28857
|
+
const chain = [];
|
|
28714
28858
|
const later = [];
|
|
28859
|
+
let chaining = !command.includes("||");
|
|
28860
|
+
let piped = false;
|
|
28715
28861
|
for (const segment of segmentsOf(command, dialect)) {
|
|
28716
28862
|
if (segment.group || segment.unanalyzable || segment.subs?.length)
|
|
28717
28863
|
return null;
|
|
@@ -28724,10 +28870,32 @@ var plainLines = (command, dialect) => {
|
|
|
28724
28870
|
if (!names || segment.expands?.length)
|
|
28725
28871
|
return null;
|
|
28726
28872
|
first = passed(segment.words);
|
|
28727
|
-
|
|
28728
|
-
|
|
28873
|
+
chaining &&= name2(first[0]) === "ytrack";
|
|
28874
|
+
} else {
|
|
28875
|
+
const words = passed(segment.words);
|
|
28876
|
+
chaining &&= !piped && !segment.expands?.length && !segment.stdin?.length && !segment.inputs?.length && name2(words[0]) === "ytrack";
|
|
28877
|
+
if (chaining)
|
|
28878
|
+
chain.push(words);
|
|
28879
|
+
else if (names)
|
|
28880
|
+
later.push(segment.words);
|
|
28881
|
+
}
|
|
28882
|
+
piped = segment.pipe === true;
|
|
28729
28883
|
}
|
|
28730
|
-
return first ? { first, later } : null;
|
|
28884
|
+
return first ? { first, chain, later } : null;
|
|
28885
|
+
};
|
|
28886
|
+
var chained = (first, chain, depth) => {
|
|
28887
|
+
if (first.length !== 1 || !first[0].effect || !chain.length)
|
|
28888
|
+
return null;
|
|
28889
|
+
const found = [...first];
|
|
28890
|
+
for (const line of chain)
|
|
28891
|
+
ytrackArgs(line, found, depth, new Map, true);
|
|
28892
|
+
const effects = found.flatMap((write) => write.effect ? [write.effect] : []);
|
|
28893
|
+
if (effects.length !== found.length)
|
|
28894
|
+
return null;
|
|
28895
|
+
const effect = combine(effects);
|
|
28896
|
+
if (!effect)
|
|
28897
|
+
return null;
|
|
28898
|
+
return [{ command: found.map((write) => write.command).join(" && "), ...mapped(effect) }];
|
|
28731
28899
|
};
|
|
28732
28900
|
var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
28733
28901
|
if (!namesYtrack(command))
|
|
@@ -28741,7 +28909,11 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
28741
28909
|
let found = [];
|
|
28742
28910
|
const lines = plain ? plainLines(command, dialect) : null;
|
|
28743
28911
|
const none = new Map;
|
|
28744
|
-
|
|
28912
|
+
const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
|
|
28913
|
+
const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
|
|
28914
|
+
if (joined)
|
|
28915
|
+
found = joined;
|
|
28916
|
+
if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
|
|
28745
28917
|
found = [];
|
|
28746
28918
|
for (const line of commandLines(command, dialect))
|
|
28747
28919
|
ytrackArgs(line, found, depth, aliases(command), false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@opencode/plugin": "2.0.18",
|
|
44
|
-
"@workit-dev/core": "^1.
|
|
44
|
+
"@workit-dev/core": "^1.11.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|