@chosengeneration/light-code 0.155.0 → 0.157.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.cjs +717 -28
  2. package/dist/server.cjs +714 -25
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -46401,6 +46401,7 @@ var ALWAYS_ASK_TOOLS = /* @__PURE__ */ new Set([
46401
46401
  // Shared CI under the user's name: starting or stopping a build, and replaying one with a local
46402
46402
  // Jenkinsfile, which runs whatever that file says with the job's credentials.
46403
46403
  "jenkins_start_build",
46404
+ "jenkins_write_job",
46404
46405
  "jenkins_stop_build",
46405
46406
  "jenkins_try_jenkinsfile",
46406
46407
  // Production schedules: an event (force-start, kill, hold, ice, status) or a changed definition.
@@ -52502,6 +52503,7 @@ var NEVER_AVAILABLE_TO_SCHEDULES = [
52502
52503
  "install_python_packages",
52503
52504
  // CI actions nobody would see happen: a build started, aborted, or replayed with a changed script.
52504
52505
  "jenkins_start_build",
52506
+ "jenkins_write_job",
52505
52507
  "jenkins_stop_build",
52506
52508
  "jenkins_try_jenkinsfile",
52507
52509
  // A production scheduler changed with nobody watching.
@@ -60174,7 +60176,7 @@ var writeParams = external_exports.object({
60174
60176
  name: external_exports.string().describe('Short kebab-case identifier, e.g. "internal-http-client". Becomes the filename.'),
60175
60177
  description: external_exports.string().describe("One line, and the only part loaded into every future conversation \u2014 so write it as the trigger for reading the skill: what subject it covers, not what it says."),
60176
60178
  body: external_exports.string().describe("The markdown content. Be concrete: package names, import paths, function signatures, a short example. This is read only when relevant, so length costs nothing."),
60177
- audience: external_exports.enum(["me", "team"]).optional().describe('Who the skill is for. "me": kept only for this user, on this computer, in every project - never shared. "team": saved where the team shares skills. For a NEW skill, if the user has not said, ask them first (ask_user_form, a choice of "Only me" or "The team") - never guess. Omit when updating: the skill stays where it is.'),
60179
+ audience: external_exports.enum(["me", "team"]).optional().describe('Who the skill is for. "me": kept only for this user, on this computer, in every project - never shared. "team" (the default - leave this out): saved where the team shares skills. Use "me" ONLY when the user explicitly says the skill is personal, private or just for them; do not ask. Omit when updating: the skill stays where it is.'),
60178
60180
  images: external_exports.array(external_exports.object({
60179
60181
  source: external_exports.string().min(1).describe("The picture as it is now, relative to the workspace root."),
60180
60182
  name: external_exports.string().optional().describe("What to call it inside the skill. Defaults to the source file name."),
@@ -61302,7 +61304,7 @@ function isInstallableRequirement(requirement) {
61302
61304
  }
61303
61305
 
61304
61306
  // ../../packages/core/dist/python/tools.js
61305
- var audienceParam = external_exports.enum(["me", "team"]).optional().describe('Who the tool is for. "me": kept only for this user, on this computer, in every project - never shared. "team": saved where the team shares tools. For a NEW tool, if the user has not said, ask them first (ask_user_form, a choice of "Only me" or "The team") - never guess. Omit when updating: the tool stays where it is.');
61307
+ var audienceParam = external_exports.enum(["me", "team"]).optional().describe('Who the tool is for. "me": kept only for this user, on this computer, in every project - never shared. "team" (the default - leave this out): saved where the team shares tools. Use "me" ONLY when the user explicitly says the tool is personal, private or just for them; do not ask. Omit when updating: the tool stays where it is.');
61306
61308
  function toolFolder(context, name, audience) {
61307
61309
  const personal = context.personalToolsDir;
61308
61310
  if (audience === "me") {
@@ -72597,6 +72599,253 @@ The merge succeeded, but tag ${params3.tag} was not created: ${error51 instanceo
72597
72599
  };
72598
72600
  }
72599
72601
 
72602
+ // ../../packages/core/dist/atlassian/jenkinsConfig.js
72603
+ var TAGS = {
72604
+ string: "hudson.model.StringParameterDefinition",
72605
+ text: "hudson.model.TextParameterDefinition",
72606
+ boolean: "hudson.model.BooleanParameterDefinition",
72607
+ choice: "hudson.model.ChoiceParameterDefinition"
72608
+ };
72609
+ function escapeXml(text2) {
72610
+ return text2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72611
+ }
72612
+ function unescapeXml(text2) {
72613
+ return text2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
72614
+ }
72615
+ function children(xml, from, to) {
72616
+ const out = [];
72617
+ const tag = /<(\/?)([A-Za-z_][\w.\-:$]*)([^>]*?)(\/?)>|<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<!\[CDATA\[[\s\S]*?\]\]>/g;
72618
+ tag.lastIndex = from;
72619
+ let depth = 0;
72620
+ let open;
72621
+ for (let match = tag.exec(xml); match !== null && match.index < to; match = tag.exec(xml)) {
72622
+ if (match[2] === void 0)
72623
+ continue;
72624
+ const closing = match[1] === "/";
72625
+ const selfClosing = match[4] === "/";
72626
+ const end = match.index + match[0].length;
72627
+ if (closing) {
72628
+ depth -= 1;
72629
+ if (depth === 0 && open !== void 0) {
72630
+ out.push({ tag: open.tag, start: open.start, innerStart: open.innerStart, innerEnd: match.index, end });
72631
+ open = void 0;
72632
+ }
72633
+ } else if (selfClosing) {
72634
+ if (depth === 0)
72635
+ out.push({ tag: match[2], start: match.index, innerStart: end, innerEnd: end, end });
72636
+ } else {
72637
+ if (depth === 0)
72638
+ open = { tag: match[2], start: match.index, innerStart: end };
72639
+ depth += 1;
72640
+ }
72641
+ }
72642
+ return out;
72643
+ }
72644
+ function rootOf(xml) {
72645
+ const root = children(xml, 0, xml.length)[0];
72646
+ if (root === void 0)
72647
+ throw new Error("The job configuration is not XML Jenkins would accept (no root element).");
72648
+ return root;
72649
+ }
72650
+ function childNamed(xml, parent, tag) {
72651
+ return children(xml, parent.innerStart, parent.innerEnd).find((child) => child.tag === tag);
72652
+ }
72653
+ function textOf(xml, parent, tag) {
72654
+ const child = childNamed(xml, parent, tag);
72655
+ return child === void 0 ? void 0 : unescapeXml(xml.slice(child.innerStart, child.innerEnd).trim());
72656
+ }
72657
+ function lineIndent(xml, at) {
72658
+ const lineStart = xml.lastIndexOf("\n", at - 1) + 1;
72659
+ return /^[ \t]*/.exec(xml.slice(lineStart, at))?.[0] ?? "";
72660
+ }
72661
+ function parseParameter(xml, element) {
72662
+ const type = Object.entries(TAGS).find(([, tag]) => tag === element.tag)?.[0] ?? void 0;
72663
+ const choicesElement = childNamed(xml, element, "choices");
72664
+ const choices = choicesElement === void 0 ? void 0 : [...xml.slice(choicesElement.innerStart, choicesElement.innerEnd).matchAll(/<string>([\s\S]*?)<\/string>/g)].map((match) => unescapeXml(match[1] ?? ""));
72665
+ const description = textOf(xml, element, "description");
72666
+ const defaultValue = textOf(xml, element, "defaultValue");
72667
+ return {
72668
+ element,
72669
+ name: textOf(xml, element, "name") ?? "",
72670
+ ...type !== void 0 ? { type } : {},
72671
+ ...description !== void 0 ? { description } : {},
72672
+ ...defaultValue !== void 0 ? { default: defaultValue } : {},
72673
+ ...choices !== void 0 ? { choices } : {}
72674
+ };
72675
+ }
72676
+ function renderParameter(input, indent2) {
72677
+ const inner = `${indent2} `;
72678
+ const lines2 = [`${indent2}<${TAGS[input.type]}>`, `${inner}<name>${escapeXml(input.name)}</name>`, `${inner}<description>${escapeXml(input.description ?? "")}</description>`];
72679
+ if (input.type === "choice") {
72680
+ const choices = [...input.choices ?? []];
72681
+ if (choices.length === 0)
72682
+ throw new Error(`The choice parameter "${input.name}" needs at least one choice.`);
72683
+ if (input.default !== void 0) {
72684
+ const at = choices.indexOf(input.default);
72685
+ if (at < 0)
72686
+ throw new Error(`The default "${input.default}" is not one of the choices of "${input.name}" (${choices.join(", ")}).`);
72687
+ choices.splice(at, 1);
72688
+ choices.unshift(input.default);
72689
+ }
72690
+ lines2.push(`${inner}<choices class="java.util.Arrays$ArrayList">`, `${inner} <a class="string-array">`);
72691
+ for (const choice of choices)
72692
+ lines2.push(`${inner} <string>${escapeXml(choice)}</string>`);
72693
+ lines2.push(`${inner} </a>`, `${inner}</choices>`);
72694
+ } else if (input.type === "boolean") {
72695
+ lines2.push(`${inner}<defaultValue>${input.default === "true" ? "true" : "false"}</defaultValue>`);
72696
+ } else {
72697
+ lines2.push(`${inner}<defaultValue>${escapeXml(input.default ?? "")}</defaultValue>`);
72698
+ if (input.type === "string")
72699
+ lines2.push(`${inner}<trim>false</trim>`);
72700
+ }
72701
+ lines2.push(`${indent2}</${TAGS[input.type]}>`);
72702
+ return lines2.join("\n");
72703
+ }
72704
+ function jobParameters(xml) {
72705
+ const definitions = findDefinitions(xml);
72706
+ if (definitions === void 0)
72707
+ return [];
72708
+ return children(xml, definitions.innerStart, definitions.innerEnd).map((element) => {
72709
+ const parsed = parseParameter(xml, element);
72710
+ return {
72711
+ name: parsed.name,
72712
+ type: parsed.type ?? element.tag,
72713
+ ...parsed.default !== void 0 ? { default: parsed.default } : {},
72714
+ ...parsed.choices !== void 0 ? { choices: parsed.choices } : {}
72715
+ };
72716
+ });
72717
+ }
72718
+ function findDefinitions(xml) {
72719
+ const root = rootOf(xml);
72720
+ const properties = childNamed(xml, root, "properties");
72721
+ if (properties === void 0)
72722
+ return void 0;
72723
+ const property = childNamed(xml, properties, "hudson.model.ParametersDefinitionProperty");
72724
+ if (property === void 0)
72725
+ return void 0;
72726
+ return childNamed(xml, property, "parameterDefinitions");
72727
+ }
72728
+ function ensureDefinitions(xml) {
72729
+ const found2 = findDefinitions(xml);
72730
+ if (found2 !== void 0 && found2.innerStart === found2.innerEnd && xml.slice(found2.start, found2.end).endsWith("/>")) {
72731
+ const indent3 = lineIndent(xml, found2.start);
72732
+ return xml.slice(0, found2.start) + `<parameterDefinitions>
72733
+ ${indent3}</parameterDefinitions>` + xml.slice(found2.end);
72734
+ }
72735
+ if (found2 !== void 0)
72736
+ return xml;
72737
+ const root = rootOf(xml);
72738
+ const properties = childNamed(xml, root, "properties");
72739
+ const block2 = (indent3) => [`${indent3}<hudson.model.ParametersDefinitionProperty>`, `${indent3} <parameterDefinitions>`, `${indent3} </parameterDefinitions>`, `${indent3}</hudson.model.ParametersDefinitionProperty>`].join("\n");
72740
+ if (properties === void 0) {
72741
+ const indent3 = " ";
72742
+ const insert = `${indent3}<properties>
72743
+ ${block2(`${indent3} `)}
72744
+ ${indent3}</properties>
72745
+ `;
72746
+ return xml.slice(0, root.innerEnd) + insert + xml.slice(root.innerEnd);
72747
+ }
72748
+ const indent2 = lineIndent(xml, properties.start);
72749
+ if (properties.innerStart === properties.innerEnd && xml.slice(properties.start, properties.end).endsWith("/>")) {
72750
+ const replacement = `<properties>
72751
+ ${block2(`${indent2} `)}
72752
+ ${indent2}</properties>`;
72753
+ return xml.slice(0, properties.start) + replacement + xml.slice(properties.end);
72754
+ }
72755
+ const existing = childNamed(xml, properties, "hudson.model.ParametersDefinitionProperty");
72756
+ if (existing !== void 0) {
72757
+ const inner = `${lineIndent(xml, existing.start)} `;
72758
+ const list2 = `
72759
+ ${inner}<parameterDefinitions>
72760
+ ${inner}</parameterDefinitions>
72761
+ ${lineIndent(xml, existing.start)}`;
72762
+ if (existing.innerStart === existing.innerEnd) {
72763
+ const tag = "hudson.model.ParametersDefinitionProperty";
72764
+ return xml.slice(0, existing.start) + `<${tag}>${list2}</${tag}>` + xml.slice(existing.end);
72765
+ }
72766
+ return xml.slice(0, existing.innerStart) + list2 + xml.slice(existing.innerStart);
72767
+ }
72768
+ return xml.slice(0, properties.innerStart) + `
72769
+ ${block2(`${indent2} `)}` + xml.slice(properties.innerStart);
72770
+ }
72771
+ function applyJobChanges(original, changes) {
72772
+ let xml = original;
72773
+ const notes = [];
72774
+ for (const edit of changes.edits ?? []) {
72775
+ if (edit.find.length === 0)
72776
+ throw new Error("An edit has nothing to find.");
72777
+ const first = xml.indexOf(edit.find);
72778
+ if (first < 0)
72779
+ throw new Error(`Not found in the job configuration, so nothing was changed: ${JSON.stringify(edit.find.slice(0, 120))}`);
72780
+ if (xml.indexOf(edit.find, first + edit.find.length) >= 0) {
72781
+ throw new Error(`Found more than once in the job configuration - include more around it so it is unique: ${JSON.stringify(edit.find.slice(0, 120))}`);
72782
+ }
72783
+ xml = xml.slice(0, first) + edit.replace + xml.slice(first + edit.find.length);
72784
+ notes.push("edited the configuration text");
72785
+ }
72786
+ if (changes.description !== void 0) {
72787
+ const root = rootOf(xml);
72788
+ const description = childNamed(xml, root, "description");
72789
+ const value = escapeXml(changes.description);
72790
+ if (description === void 0) {
72791
+ xml = xml.slice(0, root.innerStart) + `
72792
+ <description>${value}</description>` + xml.slice(root.innerStart);
72793
+ } else {
72794
+ xml = xml.slice(0, description.start) + `<description>${value}</description>` + xml.slice(description.end);
72795
+ }
72796
+ notes.push("set the description");
72797
+ }
72798
+ const remove = changes.parameters?.remove ?? [];
72799
+ const set2 = changes.parameters?.set ?? [];
72800
+ if (remove.length > 0 || set2.length > 0) {
72801
+ xml = ensureDefinitions(xml);
72802
+ for (const name of remove) {
72803
+ const definitions = findDefinitions(xml);
72804
+ const found2 = definitions === void 0 ? void 0 : children(xml, definitions.innerStart, definitions.innerEnd).find((element) => parseParameter(xml, element).name === name);
72805
+ if (found2 === void 0)
72806
+ throw new Error(`The job has no parameter "${name}" to remove.`);
72807
+ const lineStart = xml.lastIndexOf("\n", found2.start - 1);
72808
+ xml = xml.slice(0, lineStart >= 0 ? lineStart : found2.start) + xml.slice(found2.end);
72809
+ notes.push(`removed parameter ${name}`);
72810
+ }
72811
+ for (const input of set2) {
72812
+ if (input.name.trim().length === 0)
72813
+ throw new Error("A parameter needs a name.");
72814
+ const definitions = findDefinitions(xml);
72815
+ if (definitions === void 0)
72816
+ throw new Error("Could not find where the job keeps its parameters.");
72817
+ const existingElement = children(xml, definitions.innerStart, definitions.innerEnd).find((element) => parseParameter(xml, element).name === input.name);
72818
+ const existing = existingElement === void 0 ? void 0 : parseParameter(xml, existingElement);
72819
+ if (existing !== void 0 && existing.type === void 0 && input.type === void 0) {
72820
+ throw new Error(`The parameter "${input.name}" is of a kind this tool does not rewrite (${existing.element.tag}). Give a type to replace it, or change it with edits.`);
72821
+ }
72822
+ const type = input.type ?? existing?.type ?? "string";
72823
+ const defaultValue = input.default !== void 0 ? String(input.default) : existing?.default ?? (type === "choice" ? existing?.choices?.[0] : void 0);
72824
+ const merged = {
72825
+ name: input.name,
72826
+ type,
72827
+ description: input.description ?? existing?.description,
72828
+ default: defaultValue,
72829
+ choices: input.choices ?? existing?.choices
72830
+ };
72831
+ if (existingElement !== void 0) {
72832
+ const rendered = renderParameter(merged, lineIndent(xml, existingElement.start));
72833
+ xml = xml.slice(0, existingElement.start) + rendered.trimStart() + xml.slice(existingElement.end);
72834
+ notes.push(`changed parameter ${input.name}`);
72835
+ } else {
72836
+ const indent2 = `${lineIndent(xml, definitions.start)} `;
72837
+ const closeIndent = lineIndent(xml, definitions.innerEnd);
72838
+ const before = xml.slice(0, definitions.innerEnd).replace(/[ \t]*$/, "");
72839
+ const glue = before.endsWith("\n") ? "" : "\n";
72840
+ xml = `${before}${glue}${renderParameter(merged, indent2)}
72841
+ ${closeIndent}${xml.slice(definitions.innerEnd)}`;
72842
+ notes.push(`added parameter ${input.name}`);
72843
+ }
72844
+ }
72845
+ }
72846
+ return { xml, notes };
72847
+ }
72848
+
72600
72849
  // ../../packages/core/dist/atlassian/jenkins.js
72601
72850
  function jobPath(job, base) {
72602
72851
  let text2 = job.trim();
@@ -72844,11 +73093,13 @@ ${text2.slice(-2e4)}`);
72844
73093
  * current Jenkins; an older or stricter one answers 403 mentioning the crumb, and gets one retry.
72845
73094
  */
72846
73095
  async post(doing, pathAndQuery, form, signal) {
72847
- const body = new URLSearchParams(form).toString();
73096
+ return this.postBody(doing, pathAndQuery, new URLSearchParams(form).toString(), "application/x-www-form-urlencoded", signal);
73097
+ }
73098
+ async postBody(doing, pathAndQuery, body, contentType2, signal) {
72848
73099
  const send2 = () => this.rest.send(doing, pathAndQuery, {
72849
73100
  method: "POST",
72850
73101
  headers: {
72851
- "Content-Type": "application/x-www-form-urlencoded",
73102
+ "Content-Type": contentType2,
72852
73103
  ...this.crumb !== void 0 ? { [this.crumb.field]: this.crumb.value } : {}
72853
73104
  },
72854
73105
  body
@@ -72888,6 +73139,33 @@ ${text2.slice(-2e4)}`);
72888
73139
  async stopBuild(job, build2, signal) {
72889
73140
  await this.post(`stopping ${job} #${String(build2)}`, `${jobPath(job, this.base)}/${buildRef(build2)}/stop`, {}, signal);
72890
73141
  }
73142
+ /** A job's config.xml, as Jenkins holds it now. */
73143
+ async configXml(job, signal) {
73144
+ return this.rest.text(`reading the configuration of ${job}`, `${jobPath(job, this.base)}/config.xml`, signal);
73145
+ }
73146
+ /** Whether a job (or folder) of this name exists. */
73147
+ async exists(job, signal) {
73148
+ try {
73149
+ await this.rest.json(`looking for ${job}`, `${jobPath(job, this.base)}/api/json?tree=name`, { method: "GET" }, signal);
73150
+ return true;
73151
+ } catch (error51) {
73152
+ if (error51 instanceof AtlassianError && error51.status === 404)
73153
+ return false;
73154
+ throw error51;
73155
+ }
73156
+ }
73157
+ /** Creates a job from a whole config.xml, in the folder its name gives (`folder/sub/new-job`). */
73158
+ async createJob(job, xml, signal) {
73159
+ const path62 = jobPath(job, this.base);
73160
+ const cut = path62.lastIndexOf("/job/");
73161
+ const parent = path62.slice(0, cut);
73162
+ const name = decodeURIComponent(path62.slice(cut + "/job/".length));
73163
+ await this.postBody(`creating ${job}`, `${parent}/createItem?${new URLSearchParams({ name }).toString()}`, xml, "application/xml", signal);
73164
+ }
73165
+ /** Replaces a job's config.xml. */
73166
+ async saveConfig(job, xml, signal) {
73167
+ await this.postBody(`saving the configuration of ${job}`, `${jobPath(job, this.base)}/config.xml`, xml, "application/xml", signal);
73168
+ }
72891
73169
  /** The declarative linter. Read-only on the server; answers in plain text. */
72892
73170
  async validateJenkinsfile(text2, signal) {
72893
73171
  const response = await this.post("validating a Jenkinsfile", "/pipeline-model-converter/validate", { jenkinsfile: text2 }, signal);
@@ -73331,6 +73609,111 @@ ${log.slice(-6e3)}`);
73331
73609
  return tail === void 0 ? "" : `End of the log:
73332
73610
  ${tail.text}`;
73333
73611
  }
73612
+ var parameterInput = external_exports.object({
73613
+ name: external_exports.string().min(1),
73614
+ type: external_exports.enum(["string", "text", "boolean", "choice"]).optional().describe("Default string for a new parameter; an existing one keeps its type."),
73615
+ description: external_exports.string().optional(),
73616
+ default: external_exports.union([external_exports.string(), external_exports.boolean()]).optional().describe("The default value; for a choice, which choice comes first."),
73617
+ choices: external_exports.array(external_exports.string()).optional().describe("For a choice parameter: every choice.")
73618
+ });
73619
+ function createJenkinsWriteJobTool(options) {
73620
+ const schema8 = external_exports.object({
73621
+ action: external_exports.enum(["create", "copy", "update"]).describe(`create: a new job from a whole config (or an existing job's config given as from). copy: a new job copied from "from", optionally changed. update: change an existing job.`),
73622
+ job: external_exports.string().describe("The job to create (copy, create) or change (update), as folder/name. For create and copy it must not exist yet."),
73623
+ from: external_exports.string().optional().describe("copy: the existing job to copy, as folder/name or its URL."),
73624
+ config: external_exports.string().optional().describe("create: the whole config.xml. Prefer copy from a similar job - a config written from scratch is easy to get subtly wrong."),
73625
+ parameters: external_exports.object({
73626
+ set: external_exports.array(parameterInput).optional().describe("Add these parameters, or change those of the same name."),
73627
+ remove: external_exports.array(external_exports.string()).optional().describe("Parameter names to remove.")
73628
+ }).optional(),
73629
+ description: external_exports.string().optional().describe("The job's description."),
73630
+ edits: external_exports.array(external_exports.object({ find: external_exports.string().min(1), replace: external_exports.string() })).optional().describe("Exact text changes to the config.xml - for anything else (script path, branch, schedule, agent label). Each find must occur exactly once; read the job with jenkins_job and include enough around it to be unique.")
73631
+ });
73632
+ const shown2 = /* @__PURE__ */ new Map();
73633
+ const keyOf = (params3) => JSON.stringify(params3);
73634
+ const plan2 = async (client, params3) => {
73635
+ const target = params3.job.trim();
73636
+ jobPath(target, client.base);
73637
+ const changes = {
73638
+ ...params3.parameters !== void 0 ? { parameters: params3.parameters } : {},
73639
+ ...params3.description !== void 0 ? { description: params3.description } : {},
73640
+ ...params3.edits !== void 0 ? { edits: params3.edits } : {}
73641
+ };
73642
+ if (params3.action === "update") {
73643
+ const before = await client.configXml(target);
73644
+ const changed2 = applyJobChanges(before, changes);
73645
+ if (changed2.xml === before)
73646
+ throw new AtlassianError("Nothing would change: give parameters, a description or edits.");
73647
+ return { before, after: changed2.xml, notes: changed2.notes, target };
73648
+ }
73649
+ if (await client.exists(target)) {
73650
+ throw new AtlassianError(`"${target}" already exists. Use action update to change it, or pick another name - a job is never replaced by creating or copying over it.`);
73651
+ }
73652
+ if (params3.action === "copy") {
73653
+ if (params3.from === void 0 || params3.from.trim().length === 0)
73654
+ throw new AtlassianError('copy needs "from": the job to copy.');
73655
+ const source = await client.configXml(params3.from.trim());
73656
+ const changed2 = applyJobChanges(source, changes);
73657
+ return { before: source, after: changed2.xml, notes: [`copied from ${params3.from.trim()}`, ...changed2.notes], target };
73658
+ }
73659
+ if (params3.config === void 0 || params3.config.trim().length === 0) {
73660
+ throw new AtlassianError('create needs "config", the whole config.xml - or use copy from a similar job.');
73661
+ }
73662
+ const changed = applyJobChanges(params3.config, changes);
73663
+ return { before: "", after: changed.xml, notes: ["a new job", ...changed.notes], target };
73664
+ };
73665
+ const tool = {
73666
+ name: "jenkins_write_job",
73667
+ group: "command",
73668
+ description: `Create a Jenkins job, copy an existing job into a new one, or change a job's configuration - most often its parameters (add, change default/choices/description, remove), and anything else by exact text edits of its config.xml. To make a job "like X but with new parameters", use copy with from: X and parameters.set. Never deletes a job and never replaces an existing one by creating over it. Always shown to the user first as a diff of the configuration Jenkins will be sent; it cannot be set to always allow.`,
73669
+ parametersSchema: schema8,
73670
+ async preview(params3) {
73671
+ try {
73672
+ const client = await options.client();
73673
+ const result = await plan2(client, params3);
73674
+ shown2.set(keyOf(params3), { before: result.before, after: result.after });
73675
+ const parameters = jobParameters(result.after);
73676
+ return {
73677
+ kind: "diff",
73678
+ path: `${client.base}${jobPath(result.target, client.base)}/config.xml`,
73679
+ before: result.before,
73680
+ after: result.after,
73681
+ note: [
73682
+ `${params3.action === "update" ? "Change" : "Create"} Jenkins job ${result.target}: ${result.notes.join(", ")}`,
73683
+ parameters.length > 0 ? `Parameters after: ${parameters.map((each) => `${each.name} (${each.type}${each.default !== void 0 ? ` = ${each.default}` : ""})`).join(", ")}` : "No parameters"
73684
+ ].join(" \xB7 ")
73685
+ };
73686
+ } catch (error51) {
73687
+ return { kind: "text", text: `${error51 instanceof Error ? error51.message : String(error51)} - this will be refused.` };
73688
+ }
73689
+ },
73690
+ async execute(params3) {
73691
+ try {
73692
+ const client = await options.client();
73693
+ const approved = shown2.get(keyOf(params3));
73694
+ const now = await plan2(client, params3);
73695
+ if (approved !== void 0 && approved.before !== now.before) {
73696
+ return {
73697
+ content: `${params3.action === "update" ? params3.job : params3.from ?? params3.job} changed on Jenkins after this was shown, so nothing was saved. Ask again to see the change against the current configuration.`,
73698
+ isError: true
73699
+ };
73700
+ }
73701
+ const xml = approved?.after ?? now.after;
73702
+ if (params3.action === "update")
73703
+ await client.saveConfig(now.target, xml);
73704
+ else
73705
+ await client.createJob(now.target, xml);
73706
+ shown2.delete(keyOf(params3));
73707
+ const link = `${client.base}${jobPath(now.target, client.base)}/`;
73708
+ return { content: `${params3.action === "update" ? "Saved" : "Created"} ${now.target}: ${now.notes.join(", ")}.
73709
+ Link: ${link}` };
73710
+ } catch (error51) {
73711
+ return errorResult2(error51);
73712
+ }
73713
+ }
73714
+ };
73715
+ return tool;
73716
+ }
73334
73717
  function createJenkinsTools(options) {
73335
73718
  return [
73336
73719
  createJenkinsFindJobsTool(options),
@@ -73341,7 +73724,8 @@ function createJenkinsTools(options) {
73341
73724
  createJenkinsStartBuildTool(options),
73342
73725
  createJenkinsStopBuildTool(options),
73343
73726
  createJenkinsCheckJenkinsfileTool(options),
73344
- createJenkinsTryJenkinsfileTool(options)
73727
+ createJenkinsTryJenkinsfileTool(options),
73728
+ createJenkinsWriteJobTool(options)
73345
73729
  ];
73346
73730
  }
73347
73731
 
@@ -74685,6 +75069,15 @@ function toolsForAccess(tools, readOnly, label) {
74685
75069
  var import_node_crypto15 = require("node:crypto");
74686
75070
  var import_promises25 = __toESM(require("node:fs/promises"), 1);
74687
75071
  var import_node_path45 = __toESM(require("node:path"), 1);
75072
+ var TOMBSTONE_PREFIX = "LIGHT-CODE-DELETED:";
75073
+ function tombstoneText(who, when3) {
75074
+ return `${TOMBSTONE_PREFIX} removed for the team by ${who} on ${when3.toISOString().slice(0, 10)}. Light Code no longer loads this file; writing a new one of the same name brings it back.
75075
+ `;
75076
+ }
75077
+ function isTombstone(bytes) {
75078
+ const head = new TextDecoder().decode(bytes.slice(0, 64)).replace(/^\uFEFF/, "");
75079
+ return head.startsWith(TOMBSTONE_PREFIX);
75080
+ }
74688
75081
  var TEAM_REPO_STATE_FILE = ".lightcode-teamrepo.json";
74689
75082
  var decoder = new TextDecoder("utf-8", { fatal: true });
74690
75083
  function contentHash(bytes) {
@@ -74815,6 +75208,14 @@ async function syncTeamRepo(options) {
74815
75208
  continue;
74816
75209
  const fetched = hash2(bytes);
74817
75210
  const before = state.files[change.path];
75211
+ if (isTombstone(bytes)) {
75212
+ state.files[change.path] = { commit: head, hash: fetched, deleted: true };
75213
+ if (before?.deleted !== true) {
75214
+ await import_promises25.default.rm(mirrorFile(target.kind, target.relative), { force: true });
75215
+ report.removed.push(change.path);
75216
+ }
75217
+ continue;
75218
+ }
74818
75219
  state.files[change.path] = { commit: head, hash: fetched };
74819
75220
  if (before?.hash === fetched)
74820
75221
  continue;
@@ -74849,6 +75250,27 @@ async function syncTeamRepo(options) {
74849
75250
  }
74850
75251
  chosen.set(repoPath, { hash: mine, file: entry.file });
74851
75252
  const known = state.files[repoPath];
75253
+ if (known?.deleted === true && state.pushed[repoPath] !== known.hash) {
75254
+ if (mine === state.pushed[repoPath]) {
75255
+ const inside = (options.removable ?? []).some((dir) => entry.file.toLowerCase().startsWith(import_node_path45.default.resolve(dir).toLowerCase() + import_node_path45.default.sep));
75256
+ if (inside) {
75257
+ await import_promises25.default.rm(entry.file, { force: true });
75258
+ state.pushed[repoPath] = known.hash;
75259
+ report.removed.push(`${repoPath} (copy on this computer)`);
75260
+ } else {
75261
+ report.conflicts.push({
75262
+ path: repoPath,
75263
+ reason: `deleted for the team in the repository, but an unchanged copy still loads here from ${entry.file} - delete it there if it should go`
75264
+ });
75265
+ }
75266
+ } else {
75267
+ report.conflicts.push({
75268
+ path: repoPath,
75269
+ reason: "deleted for the team in the repository, but changed here since - not re-added; delete yours, or write it again to bring it back"
75270
+ });
75271
+ }
75272
+ continue;
75273
+ }
74852
75274
  if (known?.hash === mine) {
74853
75275
  state.pushed[repoPath] = mine;
74854
75276
  continue;
@@ -74929,7 +75351,7 @@ async function syncTeamRepo(options) {
74929
75351
  else
74930
75352
  delete state.released;
74931
75353
  for (const repoPath of Object.keys(state.pushed)) {
74932
- if (!present2.has(repoPath) && !released.has(repoPath) && state.files[repoPath] !== void 0)
75354
+ if (!present2.has(repoPath) && !released.has(repoPath) && state.files[repoPath] !== void 0 && state.files[repoPath]?.deleted !== true)
74933
75355
  report.deletedHere.push(repoPath);
74934
75356
  }
74935
75357
  }
@@ -74952,6 +75374,8 @@ async function checkCoverage(options) {
74952
75374
  const repoPath = repoPathFor(folder, kind, entry.relative);
74953
75375
  const mine = hash2(new Uint8Array(await import_promises25.default.readFile(entry.file)));
74954
75376
  const known = state.files[repoPath];
75377
+ if (known?.deleted === true)
75378
+ continue;
74955
75379
  if (known === void 0)
74956
75380
  problems.push(`${entry.file} - not in the repository yet`);
74957
75381
  else if (known.hash !== mine && state.pushed[repoPath] !== mine)
@@ -74975,6 +75399,59 @@ async function releaseFromRecord(stateFile, repoPaths) {
74975
75399
  parsed.released = [.../* @__PURE__ */ new Set([...parsed.released ?? [], ...repoPaths])].sort();
74976
75400
  await writeWhole2(stateFile, JSON.stringify(parsed, null, 1));
74977
75401
  }
75402
+ async function tombstoneInRepo(options) {
75403
+ const { folder } = options;
75404
+ const mirrorFile = (repoPath) => {
75405
+ const target = classifyRepoPath(folder, repoPath);
75406
+ return target === void 0 ? void 0 : import_node_path45.default.join(options.mirror[target.kind], ...target.relative.split("/"));
75407
+ };
75408
+ const state = await readState(options.stateFile, mirrorFile);
75409
+ const bytes = new TextEncoder().encode(tombstoneText(options.who, options.now ?? /* @__PURE__ */ new Date()));
75410
+ const marker = hash2(bytes);
75411
+ const done = [];
75412
+ let failed2;
75413
+ for (const repoPath of options.repoPaths) {
75414
+ const known = state.files[repoPath];
75415
+ if (known === void 0 || known.deleted === true)
75416
+ continue;
75417
+ const kind = classifyRepoPath(folder, repoPath)?.kind ?? "skills";
75418
+ try {
75419
+ const commit = await options.api.commitFile({
75420
+ path: repoPath,
75421
+ bytes,
75422
+ branch: options.branch,
75423
+ message: `Light Code: delete ${kind}/${repoPath.split("/").pop() ?? repoPath} for the team (${options.who})`,
75424
+ sourceCommitId: known.commit
75425
+ });
75426
+ state.files[repoPath] = { commit: commit ?? known.commit, hash: marker, deleted: true };
75427
+ state.pushed[repoPath] = marker;
75428
+ const local = mirrorFile(repoPath);
75429
+ if (local !== void 0)
75430
+ await import_promises25.default.rm(local, { force: true });
75431
+ done.push(repoPath);
75432
+ } catch (error51) {
75433
+ const status2 = error51.status;
75434
+ failed2 = {
75435
+ path: repoPath,
75436
+ problem: status2 === 409 ? "changed in the repository since the last sync - press Sync now and try again" : error51 instanceof Error ? error51.message : String(error51)
75437
+ };
75438
+ break;
75439
+ }
75440
+ }
75441
+ await writeWhole2(options.stateFile, JSON.stringify(state, null, 1));
75442
+ return { done, ...failed2 !== void 0 ? { failed: failed2 } : {} };
75443
+ }
75444
+ async function repoFilesOf(options) {
75445
+ const state = await readState(options.stateFile, () => void 0);
75446
+ return Object.entries(state.files).filter(([repoPath, entry]) => {
75447
+ if (entry.deleted === true)
75448
+ return false;
75449
+ const target = classifyRepoPath(options.folder, repoPath);
75450
+ if (target === void 0 || target.kind !== options.kind)
75451
+ return false;
75452
+ return options.kind === "tools" ? target.relative === `${options.name}.py` : target.relative.toLowerCase() === `${options.name.toLowerCase()}.md` || target.relative.toLowerCase().startsWith(`${options.name.toLowerCase()}/`);
75453
+ }).map(([repoPath]) => repoPath).sort();
75454
+ }
74978
75455
 
74979
75456
  // ../../packages/core/dist/platform/httpTrace.js
74980
75457
  var SECRET_NAME = /secret|password|passwd|token|api[-_]?key|assertion|credential|session|signature|cookie/i;
@@ -76147,8 +76624,8 @@ function parseInline(source) {
76147
76624
  out.push({ kind: "code", text: (match[2] ?? "").replace(/^ (.*) $/, "$1") });
76148
76625
  } else if (match[4] !== void 0) {
76149
76626
  const href = match[4];
76150
- const children = parseInline(match[3] ?? "");
76151
- out.push(isSafeHref(href) ? { kind: "link", href, children } : { kind: "text", text: match[0] });
76627
+ const children2 = parseInline(match[3] ?? "");
76628
+ out.push(isSafeHref(href) ? { kind: "link", href, children: children2 } : { kind: "text", text: match[0] });
76152
76629
  } else if (match[5] !== void 0) {
76153
76630
  out.push({ kind: "strong", children: parseInline(match[6] ?? "") });
76154
76631
  } else if (match[7] !== void 0) {
@@ -84311,6 +84788,155 @@ ${redact(shown2, cachedSecretValues)}` }
84311
84788
  ...teamRepoRetire !== void 0 ? { retire: teamRepoRetire } : {}
84312
84789
  });
84313
84790
  }
84791
+ async function teamRepoFiles(settings) {
84792
+ const repoRef = { project: settings.project, repo: settings.repo };
84793
+ const client = await bitbucketClient();
84794
+ return {
84795
+ branchHead: (branch) => client.branchHead(repoRef, branch),
84796
+ defaultBranch: () => client.defaultBranch(repoRef),
84797
+ createBranch: (name, startPoint) => client.createBranch(repoRef, name, startPoint),
84798
+ listFiles: (folder, at) => client.listFiles(repoRef, folder, at),
84799
+ changes: (since2, until) => client.changes(repoRef, since2, until),
84800
+ readBytes: (file2, at) => client.readBytes(repoRef, file2, at),
84801
+ commitFile: (file2) => client.commitFile(repoRef, file2)
84802
+ };
84803
+ }
84804
+ async function planDeleteEverywhere(kind, name) {
84805
+ const plan2 = { kind, name, local: [], buckets: [], repo: [], notes: [] };
84806
+ const valid = kind === "skill" ? isValidSkillName(name) : isValidToolName(name);
84807
+ if (!valid)
84808
+ return { ...plan2, error: `"${name}" is not a valid ${kind} name.` };
84809
+ const config2 = await loadSettings();
84810
+ const team = teamRepoPlan(config2);
84811
+ const teamCopy = "dirs" in team ? kind === "skill" ? team.dirs.skills : team.dirs.tools : void 0;
84812
+ const unique = (dirs) => {
84813
+ const out = [];
84814
+ for (const dir of dirs)
84815
+ if (dir !== void 0 && !samePath(dir, teamCopy) && !out.some((seen) => samePath(seen, dir)))
84816
+ out.push(dir);
84817
+ return out;
84818
+ };
84819
+ const has2 = async (target) => import_promises28.default.stat(target).then(() => true, () => false);
84820
+ if (kind === "skill") {
84821
+ for (const dir of unique([skillsDir, localSkillsDir, personalSkillsDir, ...mirroredSkillsDirs])) {
84822
+ if (await has2(import_node_path51.default.join(dir, skillFileName(name))))
84823
+ plan2.local.push(import_node_path51.default.join(dir, skillFileName(name)));
84824
+ if (await has2(import_node_path51.default.join(dir, name, "SKILL.md")))
84825
+ plan2.local.push(import_node_path51.default.join(dir, name));
84826
+ }
84827
+ for (const extra of config2.skills?.paths ?? []) {
84828
+ const dir = resolveSkillDir(extra);
84829
+ if (dir !== void 0 && (await has2(import_node_path51.default.join(dir, skillFileName(name))) || await has2(import_node_path51.default.join(dir, name, "SKILL.md")))) {
84830
+ plan2.notes.push(`Also in ${dir}, a folder you added in Settings -> Skills - not removed; delete it there.`);
84831
+ }
84832
+ }
84833
+ } else {
84834
+ for (const dir of unique([pythonFolders(config2).toolsDir, localToolsDir(config2), personalToolsDir, ...mirroredToolsDirs])) {
84835
+ if (await has2(import_node_path51.default.join(dir, toolFileName(name))))
84836
+ plan2.local.push(import_node_path51.default.join(dir, toolFileName(name)));
84837
+ }
84838
+ }
84839
+ const mirrors = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).filter((mirror) => mirror.enabled === true);
84840
+ for (const mirror of mirrors) {
84841
+ const target = targetById(cachedS3, mirror.connectionId);
84842
+ if (target === void 0) {
84843
+ plan2.notes.push(`The bucket connection "${mirror.connectionId}" is unusable - its copy, if any, cannot be checked.`);
84844
+ continue;
84845
+ }
84846
+ try {
84847
+ const options = { target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, name };
84848
+ const keys = kind === "skill" ? await skillKeysInBucket(options) : await toolKeysInBucket(options);
84849
+ if (keys.length === 0)
84850
+ continue;
84851
+ if (target.readOnly === true) {
84852
+ plan2.notes.push(`In ${target.label}, which is configured read-only - not removed there.`);
84853
+ continue;
84854
+ }
84855
+ plan2.buckets.push({ connectionId: mirror.connectionId, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, label: target.label, keys });
84856
+ } catch (error51) {
84857
+ plan2.notes.push(`${target.label} could not be listed: ${error51 instanceof Error ? error51.message : String(error51)}`);
84858
+ }
84859
+ }
84860
+ if ("dirs" in team) {
84861
+ plan2.repo = await repoFilesOf({ folder: team.settings.folder, stateFile: team.stateFile, mirror: team.dirs, kind: kind === "skill" ? "skills" : "tools", name });
84862
+ plan2.repoLabel = `${team.settings.project}/${team.settings.repo} (${team.settings.branch})`;
84863
+ }
84864
+ if (plan2.local.length === 0 && plan2.buckets.length === 0 && plan2.repo.length === 0)
84865
+ plan2.error = `No ${kind} called "${name}" was found to delete.`;
84866
+ return plan2;
84867
+ }
84868
+ async function handlePreviewDeleteEverywhere(kind, name) {
84869
+ post({ type: "deleteEverywherePlan", plan: await planDeleteEverywhere(kind, name) });
84870
+ }
84871
+ async function handleDeleteEverywhere(requested2) {
84872
+ const { kind, name } = requested2;
84873
+ const done = (ok, message4) => post({ type: "deleteEverywhereDone", kind, name, ok, message: message4 });
84874
+ try {
84875
+ const config2 = await loadSettings();
84876
+ const team = teamRepoPlan(config2);
84877
+ if ("dirs" in team && requested2.repo.length > 0)
84878
+ await handleTeamRepoSync("before deleting everywhere");
84879
+ const fresh = await planDeleteEverywhere(kind, name);
84880
+ const parts = [];
84881
+ if ("dirs" in team) {
84882
+ const repoPaths = requested2.repo.filter((repoPath) => fresh.repo.includes(repoPath));
84883
+ if (repoPaths.length > 0) {
84884
+ const result = await tombstoneInRepo({
84885
+ api: await teamRepoFiles(team.settings),
84886
+ branch: team.settings.branch,
84887
+ folder: team.settings.folder,
84888
+ stateFile: team.stateFile,
84889
+ mirror: team.dirs,
84890
+ repoPaths,
84891
+ who: cachedAttribution.author ?? "someone"
84892
+ });
84893
+ if (result.failed !== void 0) {
84894
+ done(false, `Not deleted: the repository refused ${result.failed.path} (${result.failed.problem}). Nothing else was removed, so it stays consistent - try again.`);
84895
+ return;
84896
+ }
84897
+ parts.push(`Marked deleted in the team repository ${fresh.repoLabel ?? ""} (${String(result.done.length)} file(s)); colleagues' copies go at their next sync.`);
84898
+ }
84899
+ }
84900
+ for (const bucket of requested2.buckets) {
84901
+ const mirror = (kind === "skill" ? cachedSkillMirrors : cachedToolMirrors).find((entry) => entry.connectionId === bucket.connectionId && (entry.prefix ?? "") === (bucket.prefix ?? ""));
84902
+ const target = mirror !== void 0 ? targetById(cachedS3, mirror.connectionId) : void 0;
84903
+ if (mirror === void 0 || target === void 0) {
84904
+ parts.push(`${bucket.label}: no longer configured - skipped.`);
84905
+ continue;
84906
+ }
84907
+ const options = { target, ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}, name, keys: bucket.keys };
84908
+ const result = kind === "skill" ? await removeSkillFromBucket(options) : await removeToolFromBucket(options);
84909
+ parts.push(`${target.label}: removed ${String(result.removed.length)} object(s)${result.failed.length > 0 ? `, ${String(result.failed.length)} failed (${result.failed.map((each) => each.key).join(", ")})` : ""}.`);
84910
+ }
84911
+ const local = requested2.local.filter((entry) => fresh.local.some((allowed) => samePath(allowed, entry)));
84912
+ const localProblems = [];
84913
+ for (const entry of local) {
84914
+ try {
84915
+ await import_promises28.default.rm(entry, { recursive: true, force: true });
84916
+ if (kind === "tool")
84917
+ await forgetTool(import_node_path51.default.dirname(entry), name).catch(() => void 0);
84918
+ } catch (error51) {
84919
+ localProblems.push(`${entry} (${error51 instanceof Error ? error51.message : String(error51)})`);
84920
+ }
84921
+ }
84922
+ if (local.length > 0)
84923
+ parts.push(`Removed ${String(local.length - localProblems.length)} cop${local.length === 1 ? "y" : "ies"} on this computer.`);
84924
+ if (localProblems.length > 0)
84925
+ parts.push(`Could not remove: ${localProblems.join("; ")}.`);
84926
+ if (kind === "skill") {
84927
+ await refreshSkills();
84928
+ void postSkills();
84929
+ } else {
84930
+ await python.refresh();
84931
+ await postPython();
84932
+ }
84933
+ await postTeamRepo();
84934
+ logger.info(`delete everywhere: ${kind} ${name} - ${parts.join(" ")}`);
84935
+ done(localProblems.length === 0, parts.length > 0 ? parts.join(" ") : "Nothing was left to remove.");
84936
+ } catch (error51) {
84937
+ done(false, error51 instanceof Error ? error51.message : String(error51));
84938
+ }
84939
+ }
84314
84940
  let cachedTeamRepoLabel;
84315
84941
  function sharedWith(kind) {
84316
84942
  const mirrors = kind === "skills" ? cachedSkillMirrors : cachedToolMirrors;
@@ -84459,18 +85085,8 @@ ${redact(shown2, cachedSecretValues)}` }
84459
85085
  }
84460
85086
  teamRepoSyncing = true;
84461
85087
  await postTeamRepo();
84462
- const repoRef = { project: plan2.settings.project, repo: plan2.settings.repo };
84463
85088
  try {
84464
- const client = await bitbucketClient();
84465
- const api = {
84466
- branchHead: (branch) => client.branchHead(repoRef, branch),
84467
- defaultBranch: () => client.defaultBranch(repoRef),
84468
- createBranch: (name, startPoint) => client.createBranch(repoRef, name, startPoint),
84469
- listFiles: (folder, at) => client.listFiles(repoRef, folder, at),
84470
- changes: (since2, until) => client.changes(repoRef, since2, until),
84471
- readBytes: (file2, at) => client.readBytes(repoRef, file2, at),
84472
- commitFile: (file2) => client.commitFile(repoRef, file2)
84473
- };
85089
+ const api = await teamRepoFiles(plan2.settings);
84474
85090
  const report = await syncTeamRepo({
84475
85091
  api,
84476
85092
  branch: plan2.settings.branch,
@@ -84483,7 +85099,14 @@ ${redact(shown2, cachedSecretValues)}` }
84483
85099
  },
84484
85100
  mirror: plan2.dirs,
84485
85101
  stateFile: plan2.stateFile,
84486
- author: cachedAttribution.author ?? "someone"
85102
+ author: cachedAttribution.author ?? "someone",
85103
+ // Folders Light Code syncs itself: an unchanged copy there of something deleted for the team goes.
85104
+ removable: [
85105
+ ...mirroredSkillsDirs.filter((dir) => !samePath(dir, plan2.dirs.skills)),
85106
+ ...mirroredToolsDirs.filter((dir) => !samePath(dir, plan2.dirs.tools)),
85107
+ plan2.own.skills,
85108
+ plan2.own.tools
85109
+ ]
84487
85110
  });
84488
85111
  lastTeamRepoSync = Date.now();
84489
85112
  teamRepoStatus = {
@@ -88084,6 +88707,10 @@ ${redact(shown2, cachedSecretValues)}` }
88084
88707
  reportFailure("handleSaveTeamRepo", handleSaveTeamRepo(message4.settings));
88085
88708
  } else if (message4.type === "syncTeamRepo") {
88086
88709
  reportFailure("handleTeamRepoSync", handleTeamRepoSync("asked"));
88710
+ } else if (message4.type === "previewDeleteEverywhere") {
88711
+ reportFailure("handlePreviewDeleteEverywhere", handlePreviewDeleteEverywhere(message4.kind, message4.name));
88712
+ } else if (message4.type === "deleteEverywhere") {
88713
+ reportFailure("handleDeleteEverywhere", handleDeleteEverywhere(message4.plan));
88087
88714
  } else if (message4.type === "retireS3Buckets") {
88088
88715
  reportFailure("handleRetireS3Buckets", handleRetireS3Buckets(message4.confirm));
88089
88716
  } else if (message4.type === "saveTeamSkillSelection") {
@@ -90435,7 +91062,7 @@ alert about.
90435
91062
  {
90436
91063
  id: "skills",
90437
91064
  title: "Skills: teaching it things it cannot work out",
90438
- keywords: ["skill", "teach", "instructions", "standing", "always", "master skill", "markdown", "edit skill", "editor", "edit standing instructions", "standing instructions", "edit a skill", "placeholder", "placeholders", "skill defaults", "default values", "skill inputs", "stop asking", "keep skill private", "which skills to send", "keep to myself"],
91065
+ keywords: ["skill", "teach", "instructions", "standing", "always", "master skill", "markdown", "edit skill", "editor", "edit standing instructions", "standing instructions", "edit a skill", "placeholder", "placeholders", "skill defaults", "default values", "skill inputs", "stop asking", "keep skill private", "which skills to send", "keep to myself", "delete everywhere", "force delete", "delete a skill for the team", "only me", "personal skill"],
90439
91066
  body: `
90440
91067
  A skill is markdown with frontmatter (\`name\`, \`description\`), kept in the workspace so it lands
90441
91068
  in git and gets reviewed. **Settings \u2192 Skills.**
@@ -90467,8 +91094,19 @@ and the assistant copies it into the workspace with \`use_skill_file\` rather th
90467
91094
  bytes into the conversation. Describe each file in one line in the skill body; a file nobody
90468
91095
  described is one the assistant will never know to reach for.
90469
91096
 
90470
- **Only me, or the team.** When a skill or Python tool is created, the assistant asks who it is for
90471
- (unless you said). **Only me** keeps it in your personal folder on this computer
91097
+ **Delete everywhere.** Each skill in Settings -> Skills, and each tool in Settings -> Python, has
91098
+ **Delete everywhere**: it first lists exactly what will go - every copy on this computer, the objects in
91099
+ each S3 bucket folder, and its files in the team repository - and only the second press removes them. The
91100
+ repository cannot delete a file over Bitbucket's REST API, so each file is replaced by a one-line
91101
+ "deleted by you on <date>" marker; history keeps the old version, and every Light Code treats it as gone:
91102
+ colleagues' unchanged copies in folders Light Code syncs are removed at their next sync, and a copy someone
91103
+ changed, or keeps in their own project folder, is reported rather than removed. The repository goes first:
91104
+ if it refuses (someone changed the file meanwhile), nothing else is removed - press Sync now and try again.
91105
+ Writing a new skill or tool of the same name brings it back. It is a button only: the assistant cannot
91106
+ delete for the team. On a shared server only an admin may.
91107
+
91108
+ **Only me, or the team.** A new skill or Python tool is **for the team** unless you say it is personal
91109
+ ("just for me", "keep it private") - the assistant does not ask. **Only me** keeps it in your personal folder on this computer
90472
91110
  (%LOCALAPPDATA%\\light-code\\personal) - used in every project, in VS Code, Fire Code and the Node host
90473
91111
  alike, and never uploaded to a bucket, committed to the team repository or sent to the team skills
90474
91112
  pool. **The team** saves it where your team shares: committed to the team repository and/or uploaded
@@ -90975,7 +91613,16 @@ comment or move fails after the fields were saved, the result says exactly which
90975
91613
  "queue",
90976
91614
  "agent offline",
90977
91615
  "api token",
90978
- "sso"
91616
+ "sso",
91617
+ "create job",
91618
+ "new job",
91619
+ "clone job",
91620
+ "copy job",
91621
+ "modify job",
91622
+ "job parameters",
91623
+ "add parameter",
91624
+ "job config",
91625
+ "config.xml"
90979
91626
  ],
90980
91627
  body: `
90981
91628
  **Settings \u2192 DevOps \u2192 Jenkins**: the site address, an **API token**, your **Jenkins user id**, and
@@ -91012,7 +91659,15 @@ an access token as a Bearer token, leave the user id empty and paste that token
91012
91659
  end of its log. Needs a pipeline job that has run at least once and the Replay permission. Run
91013
91660
  \`jenkins_check_jenkinsfile\` first; it is instant and catches syntax and unknown steps.
91014
91661
 
91015
- There is no tool that changes a job's configuration.
91662
+ - \`jenkins_write_job\` \u2014 **create a job, copy one into a new job, or change a job**. "A job like
91663
+ platform/api but with a HOTFIX branch parameter" is a copy with new parameters. Parameters are set by
91664
+ name, type (string, text, boolean, choice), default, description and choices, or removed; anything
91665
+ else (script path, branch, schedule, agent label) is an exact edit of the job's config.xml. The
91666
+ approval shows the diff of the configuration Jenkins will be sent - against the job copied, or the job
91667
+ as Jenkins holds it now - and it **cannot be set to always allow**. It never deletes a job, never
91668
+ creates or copies over an existing one, and refuses to save if the job was edited on Jenkins after
91669
+ you were shown the change. Ticking **My access is read-only** removes it with the other acting tools.
91670
+ Needs the Job/Create or Job/Configure permission on your Jenkins.
91016
91671
  `
91017
91672
  },
91018
91673
  {
@@ -91274,6 +91929,8 @@ identical content, which is agreement, not a conflict; an edit someone makes in
91274
91929
  by the next sync. The same name in two folders here is one file when identical; when the copies differ,
91275
91930
  the one Light Code uses is committed and the other is listed.
91276
91931
 
91932
+ **Deleting one for the team.** Use **Delete everywhere** on the skill (Settings -> Skills) or tool (Settings -> Python): it lists every copy - this computer, S3 bucket folders, the repository - before removing them, and replaces the repository file with a "deleted" marker that every Light Code honours. See the skills topic for the details.
91933
+
91277
91934
  **Where new ones are saved.** While the repository is on, new skills and Python tools are saved in a
91278
91935
  folder of its own outside the project (the panel shows the path), so they never land in the project's git.
91279
91936
  A folder you chose in Settings -> Skills or Settings -> Python, or an S3 bucket folder marked "Publish",
@@ -94759,6 +95416,36 @@ async function removeSkillFromBucket(options) {
94759
95416
  }
94760
95417
  return result;
94761
95418
  }
95419
+ function belongsToTool(key2, where, name) {
95420
+ return key2.startsWith(where) && key2.slice(where.length) === `${name}.py`;
95421
+ }
95422
+ async function toolKeysInBucket(options) {
95423
+ const base = normalisePrefix(options.target.prefix);
95424
+ const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
95425
+ const objects = await options.target.client.list(where, 1e3, options.signal);
95426
+ return objects.map((object3) => object3.key).filter((key2) => belongsToTool(key2, where, options.name)).sort();
95427
+ }
95428
+ async function removeToolFromBucket(options) {
95429
+ if (options.target.readOnly === true) {
95430
+ throw new Error(`${options.target.label} is configured read-only, so nothing can be deleted from it.`);
95431
+ }
95432
+ const base = normalisePrefix(options.target.prefix);
95433
+ const where = normalisePrefix(`${base}${options.prefix ?? ""}`);
95434
+ const result = { removed: [], failed: [], rejected: [] };
95435
+ for (const key2 of options.keys) {
95436
+ if (!belongsToTool(key2, where, options.name)) {
95437
+ result.rejected.push(key2);
95438
+ continue;
95439
+ }
95440
+ try {
95441
+ await options.target.client.remove(key2, options.signal);
95442
+ result.removed.push(key2);
95443
+ } catch (error51) {
95444
+ result.failed.push({ key: key2, problem: error51 instanceof Error ? error51.message : String(error51) });
95445
+ }
95446
+ }
95447
+ return result;
95448
+ }
94762
95449
 
94763
95450
  // src/reachableHosts.ts
94764
95451
  var import_node_os7 = __toESM(require("node:os"), 1);
@@ -94955,6 +95642,8 @@ var ADMIN_ONLY_MESSAGES = [
94955
95642
  * else's bucket folder is not a normal user's business either.
94956
95643
  */
94957
95644
  "previewBucketSkillDelete",
95645
+ // Lists what "Delete everywhere" would remove from shared buckets and the team repository.
95646
+ "previewDeleteEverywhere",
94958
95647
  // Processes this machine will spawn.
94959
95648
  "saveMcpServer",
94960
95649
  "saveMcpServers",