@wrongstack/tools 0.5.3 → 0.5.6
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/builtin.js +66 -18
- package/dist/builtin.js.map +1 -1
- package/dist/edit.js +5 -5
- package/dist/edit.js.map +1 -1
- package/dist/exec.js +4 -4
- package/dist/exec.js.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/index.js +66 -18
- package/dist/index.js.map +1 -1
- package/dist/pack.js +66 -18
- package/dist/pack.js.map +1 -1
- package/dist/replace.js +6 -1
- package/dist/replace.js.map +1 -1
- package/dist/tree.js +5 -1
- package/dist/tree.js.map +1 -1
- package/package.json +2 -2
package/dist/pack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
|
-
import { buildChildEnv, stripAnsi, detectNewlineStyle, normalizeToLf, toStyle, atomicWrite, unifiedDiff, compileGlob, loadPlan, emptyPlan, clearPlan, savePlan, removePlanItem, setPlanItemStatus,
|
|
2
|
+
import { buildChildEnv, stripAnsi, detectNewlineStyle, normalizeToLf, toStyle, atomicWrite, unifiedDiff, compileGlob, loadPlan, emptyPlan, clearPlan, savePlan, getPlanTemplate, addPlanItem, deriveTodosFromPlanItem, removePlanItem, setPlanItemStatus, formatPlan } from '@wrongstack/core';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { dirname } from 'path';
|
|
5
5
|
import * as os from 'os';
|
|
@@ -849,12 +849,13 @@ var editTool = {
|
|
|
849
849
|
if (!ctx.hasRead(absPath)) {
|
|
850
850
|
throw new Error(`edit: file "${input.path}" was not read in this session. Read it first.`);
|
|
851
851
|
}
|
|
852
|
-
const
|
|
852
|
+
const original = await fs9.readFile(absPath, "utf8");
|
|
853
|
+
const updated = await fs9.stat(absPath);
|
|
853
854
|
const mtimeTolerance = process.platform === "win32" ? 2e3 : 1;
|
|
854
|
-
|
|
855
|
+
const lastReadMtime = ctx.lastReadMtime(absPath);
|
|
856
|
+
if (lastReadMtime !== void 0 && updated.mtimeMs > lastReadMtime + mtimeTolerance) {
|
|
855
857
|
throw new Error(`edit: file "${input.path}" was modified externally. Re-read it first.`);
|
|
856
858
|
}
|
|
857
|
-
const original = await fs9.readFile(absPath, "utf8");
|
|
858
859
|
const style = detectNewlineStyle(original);
|
|
859
860
|
const fileLf = normalizeToLf(original);
|
|
860
861
|
const oldLf = normalizeToLf(input.old_string);
|
|
@@ -888,8 +889,7 @@ var editTool = {
|
|
|
888
889
|
}
|
|
889
890
|
const newFileLf = input.replace_all ? fileLf.split(oldLf).join(newLf) : fileLf.replace(oldLf, newLf);
|
|
890
891
|
const newFile = toStyle(newFileLf, style);
|
|
891
|
-
await atomicWrite(absPath, newFile, { mode:
|
|
892
|
-
const updated = await fs9.stat(absPath);
|
|
892
|
+
await atomicWrite(absPath, newFile, { mode: updated.mode & 511 });
|
|
893
893
|
ctx.recordRead(absPath, updated.mtimeMs);
|
|
894
894
|
ctx.session.recordFileChange({
|
|
895
895
|
path: absPath,
|
|
@@ -934,8 +934,8 @@ function findSimilarity(haystack, needle) {
|
|
|
934
934
|
}
|
|
935
935
|
var ALLOWED_COMMANDS = {
|
|
936
936
|
node: ["--version", "-r", "--input-type=module"],
|
|
937
|
-
npm: ["--version", "
|
|
938
|
-
pnpm: ["--version", "
|
|
937
|
+
npm: ["--version", "list", "pkg", "doctor", "view", "outdated", "audit"],
|
|
938
|
+
pnpm: ["--version", "remove", "list", "view", "outdated", "audit"],
|
|
939
939
|
npx: ["--version"],
|
|
940
940
|
git: [
|
|
941
941
|
"--version",
|
|
@@ -963,7 +963,7 @@ var ALLOWED_COMMANDS = {
|
|
|
963
963
|
mv: [],
|
|
964
964
|
rm: ["-rf"],
|
|
965
965
|
touch: [],
|
|
966
|
-
bun: ["--version"
|
|
966
|
+
bun: ["--version"],
|
|
967
967
|
tsc: ["--version", "--noEmit", "--project"],
|
|
968
968
|
vitest: ["--version", "run", "--coverage"],
|
|
969
969
|
biome: ["--version", "lint", "format", "check"],
|
|
@@ -971,7 +971,7 @@ var ALLOWED_COMMANDS = {
|
|
|
971
971
|
rustc: ["--version"],
|
|
972
972
|
go: ["version", "run", "build", "test"],
|
|
973
973
|
python: ["--version"],
|
|
974
|
-
pip: ["--version", "
|
|
974
|
+
pip: ["--version", "list"],
|
|
975
975
|
docker: ["--version", "ps", "images"],
|
|
976
976
|
kubectl: ["version", "get", "describe", "logs"]
|
|
977
977
|
};
|
|
@@ -2799,8 +2799,8 @@ function extractPatchedFiles(output) {
|
|
|
2799
2799
|
var planTool = {
|
|
2800
2800
|
name: "plan",
|
|
2801
2801
|
category: "Session",
|
|
2802
|
-
description: "Inspect or edit the strategic plan board for this session. Plans persist across resume (unlike todos). Use this to lay out the multi-step approach before diving in, then mark steps in_progress/done as the work proceeds.",
|
|
2803
|
-
usageHint:
|
|
2802
|
+
description: "Inspect or edit the strategic plan board for this session. Plans persist across resume (unlike todos). Use this to lay out the multi-step approach before diving in, then mark steps in_progress/done as the work proceeds. Promote a plan item to todos to start working on it. Apply templates for common workflows.",
|
|
2803
|
+
usageHint: 'Set action to one of: show | add | start | done | remove | promote | derive | template_use | clear. Pass `title` for add. Pass `target` (item id, 1-based index, or title substring) for start/done/remove/promote/derive. Pass `subtasks` for promote/derive to break the plan item into multiple todos. Pass `template` (e.g. "new-feature", "bug-fix", "refactor", "release") for template_use. Always returns the formatted plan plus open/total counts.',
|
|
2804
2804
|
permission: "auto",
|
|
2805
2805
|
mutating: false,
|
|
2806
2806
|
timeoutMs: 2e3,
|
|
@@ -2809,13 +2809,22 @@ var planTool = {
|
|
|
2809
2809
|
properties: {
|
|
2810
2810
|
action: {
|
|
2811
2811
|
type: "string",
|
|
2812
|
-
enum: ["show", "add", "start", "done", "remove", "clear"]
|
|
2812
|
+
enum: ["show", "add", "start", "done", "remove", "promote", "derive", "template_use", "clear"]
|
|
2813
2813
|
},
|
|
2814
2814
|
title: { type: "string", description: "Required when action = add." },
|
|
2815
2815
|
details: { type: "string", description: "Optional extra context for add." },
|
|
2816
2816
|
target: {
|
|
2817
2817
|
type: "string",
|
|
2818
|
-
description: "Plan item id, 1-based index, or title substring. Required for start/done/remove."
|
|
2818
|
+
description: "Plan item id, 1-based index, or title substring. Required for start/done/remove/promote/derive."
|
|
2819
|
+
},
|
|
2820
|
+
subtasks: {
|
|
2821
|
+
type: "array",
|
|
2822
|
+
items: { type: "string" },
|
|
2823
|
+
description: "Optional subtasks for promote/derive. If omitted, a single todo is created from the plan item title."
|
|
2824
|
+
},
|
|
2825
|
+
template: {
|
|
2826
|
+
type: "string",
|
|
2827
|
+
description: "Template name for template_use action. Available: new-feature, bug-fix, refactor, release, security-audit, onboarding."
|
|
2819
2828
|
}
|
|
2820
2829
|
},
|
|
2821
2830
|
required: ["action"]
|
|
@@ -2874,6 +2883,35 @@ var planTool = {
|
|
|
2874
2883
|
await savePlan(planPath, plan);
|
|
2875
2884
|
break;
|
|
2876
2885
|
}
|
|
2886
|
+
case "promote":
|
|
2887
|
+
case "derive": {
|
|
2888
|
+
if (!input.target) {
|
|
2889
|
+
return mkResult(plan, false, `${input.action} requires \`target\` (id|index|substring).`);
|
|
2890
|
+
}
|
|
2891
|
+
const derived = deriveTodosFromPlanItem(plan, input.target, input.subtasks);
|
|
2892
|
+
if (!derived) {
|
|
2893
|
+
return mkResult(plan, false, `No plan item matched "${input.target}".`);
|
|
2894
|
+
}
|
|
2895
|
+
plan = derived.plan;
|
|
2896
|
+
await savePlan(planPath, plan);
|
|
2897
|
+
ctx.state.replaceTodos(derived.todos);
|
|
2898
|
+
return mkResult(plan, true, `${input.action} ok \u2014 ${derived.todos.length} todo(s) created.`, derived.todos);
|
|
2899
|
+
}
|
|
2900
|
+
case "template_use": {
|
|
2901
|
+
const templateName = input.template?.trim();
|
|
2902
|
+
if (!templateName) {
|
|
2903
|
+
return mkResult(plan, false, "template_use requires `template` name.");
|
|
2904
|
+
}
|
|
2905
|
+
const template = getPlanTemplate(templateName);
|
|
2906
|
+
if (!template) {
|
|
2907
|
+
return mkResult(plan, false, `Unknown template "${templateName}".`);
|
|
2908
|
+
}
|
|
2909
|
+
for (const item of template.items) {
|
|
2910
|
+
({ plan } = addPlanItem(plan, item.title, item.details));
|
|
2911
|
+
}
|
|
2912
|
+
await savePlan(planPath, plan);
|
|
2913
|
+
return mkResult(plan, true, `Applied template "${template.name}" \u2014 ${template.items.length} items added.`);
|
|
2914
|
+
}
|
|
2877
2915
|
case "clear":
|
|
2878
2916
|
plan = clearPlan(plan);
|
|
2879
2917
|
await savePlan(planPath, plan);
|
|
@@ -2884,14 +2922,15 @@ var planTool = {
|
|
|
2884
2922
|
return mkResult(plan, true, `Plan ${input.action} ok.`);
|
|
2885
2923
|
}
|
|
2886
2924
|
};
|
|
2887
|
-
function mkResult(plan, ok, message) {
|
|
2925
|
+
function mkResult(plan, ok, message, todos) {
|
|
2888
2926
|
const open = plan.items.filter((i) => i.status !== "done").length;
|
|
2889
2927
|
return {
|
|
2890
2928
|
ok,
|
|
2891
2929
|
message,
|
|
2892
2930
|
plan: formatPlan(plan),
|
|
2893
2931
|
count: plan.items.length,
|
|
2894
|
-
open
|
|
2932
|
+
open,
|
|
2933
|
+
todos
|
|
2895
2934
|
};
|
|
2896
2935
|
}
|
|
2897
2936
|
var MAX_BYTES2 = 5 * 1024 * 1024;
|
|
@@ -3127,7 +3166,12 @@ async function globNative(pattern, base, extraGlob) {
|
|
|
3127
3166
|
for (const e of entries) {
|
|
3128
3167
|
if (DEFAULT_IGNORE3.includes(e.name)) continue;
|
|
3129
3168
|
const full = path.join(dir, e.name);
|
|
3130
|
-
|
|
3169
|
+
try {
|
|
3170
|
+
const stat9 = await fs9.lstat(full);
|
|
3171
|
+
if (stat9.isSymbolicLink()) continue;
|
|
3172
|
+
} catch {
|
|
3173
|
+
continue;
|
|
3174
|
+
}
|
|
3131
3175
|
if (e.isDirectory()) {
|
|
3132
3176
|
await walk(full);
|
|
3133
3177
|
} else if (e.isFile()) {
|
|
@@ -4003,7 +4047,11 @@ var DEFAULT_IGNORE4 = [
|
|
|
4003
4047
|
"build",
|
|
4004
4048
|
".next",
|
|
4005
4049
|
"coverage",
|
|
4006
|
-
"__pycache__"
|
|
4050
|
+
"__pycache__",
|
|
4051
|
+
".wrongstack",
|
|
4052
|
+
".ssh",
|
|
4053
|
+
".gnupg",
|
|
4054
|
+
".aws"
|
|
4007
4055
|
];
|
|
4008
4056
|
var treeTool = {
|
|
4009
4057
|
name: "tree",
|