dsh-hashline-edit 0.3.2 → 0.3.3
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/lib/index.js +23 -6
- package/lib/types/dsh/guidance.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2031,7 +2031,8 @@ Each agent preset has its own guidance directory here: \`<preset>/<section>.md\`
|
|
|
2031
2031
|
On first boot the plugin seeds the shipped presets (\`standard\`, \`ptc\`,
|
|
2032
2032
|
\`minimal\`, \`cordis\`) with the compiled defaults. Files you edit are never
|
|
2033
2033
|
overwritten; a file left untouched at the shipped default is refreshed when the
|
|
2034
|
-
plugin is upgraded, and a blank file falls back to that default.
|
|
2034
|
+
plugin is upgraded, and a blank file falls back to that default. Every preset the
|
|
2035
|
+
deployment declares is seeded automatically, including ones added after first boot.
|
|
2035
2036
|
|
|
2036
2037
|
Each file is one tool section:
|
|
2037
2038
|
|
|
@@ -2071,7 +2072,7 @@ var GUIDANCE_HOME_README_ZH = `# dsh-hashline-edit \u6307\u5F15
|
|
|
2071
2072
|
\u6BCF\u4E2A agent preset \u5728\u8FD9\u91CC\u90FD\u6709\u81EA\u5DF1\u7684\u6307\u5F15\u76EE\u5F55\uFF1A\`<preset>/<section>.md\`\u3002\u9996\u6B21\u542F\u52A8\u65F6
|
|
2072
2073
|
\u63D2\u4EF6\u4F1A\u4E3A\u968F\u9644\u7684 preset\uFF08\`standard\`\u3001\`ptc\`\u3001\`minimal\`\u3001\`cordis\`\uFF09\u5199\u5165\u7F16\u8BD1\u5185\u7F6E\u7684
|
|
2073
2074
|
\u9ED8\u8BA4\u5185\u5BB9\u3002\u4F60\u7F16\u8F91\u8FC7\u7684\u6587\u4EF6\u7EDD\u4E0D\u88AB\u8986\u76D6\uFF1B\u4ECD\u4FDD\u6301\u968F\u9644\u9ED8\u8BA4\u5185\u5BB9\u7684\u6587\u4EF6\u4F1A\u5728\u63D2\u4EF6\u5347\u7EA7\u65F6\u5237\u65B0\uFF0C
|
|
2074
|
-
\u7A7A\u767D\u6587\u4EF6\u5219\u56DE\u9000\u5230\u9ED8\u8BA4\u5185\u5BB9\u3002
|
|
2075
|
+
\u7A7A\u767D\u6587\u4EF6\u5219\u56DE\u9000\u5230\u9ED8\u8BA4\u5185\u5BB9\u3002\u4E4B\u540E\u65B0\u589E\u7684\u9884\u8BBE\u4F1A\u5728\u4E0B\u6B21\u52A0\u8F7D\u65F6\u81EA\u52A8\u79CD\u5B50\u3002
|
|
2075
2076
|
|
|
2076
2077
|
\u6BCF\u4E2A\u6587\u4EF6\u5BF9\u5E94\u4E00\u4E2A\u5DE5\u5177\u7247\u6BB5\uFF1A
|
|
2077
2078
|
|
|
@@ -2180,11 +2181,15 @@ async function reconcileOverride(path, section, state, key) {
|
|
|
2180
2181
|
state.set(key, desiredHash);
|
|
2181
2182
|
}
|
|
2182
2183
|
}
|
|
2183
|
-
async function ensurePresetGuidance(homeDir) {
|
|
2184
|
+
async function ensurePresetGuidance(homeDir, discoverPresets) {
|
|
2184
2185
|
await mkdir3(homeDir, { recursive: true });
|
|
2185
2186
|
const seedState = await readSeedState(homeDir);
|
|
2187
|
+
const seededPresets = new Set(SEEDED_PRESETS);
|
|
2188
|
+
if (discoverPresets !== void 0) {
|
|
2189
|
+
for (const id of await discoverPresets()) seededPresets.add(id);
|
|
2190
|
+
}
|
|
2186
2191
|
await Promise.all(
|
|
2187
|
-
|
|
2192
|
+
Array.from(seededPresets).map(async (preset) => {
|
|
2188
2193
|
const directory = join6(homeDir, preset);
|
|
2189
2194
|
await mkdir3(directory, { recursive: true });
|
|
2190
2195
|
await Promise.all(
|
|
@@ -2201,7 +2206,7 @@ async function ensurePresetGuidance(homeDir) {
|
|
|
2201
2206
|
);
|
|
2202
2207
|
const entries = await readdir2(homeDir, { withFileTypes: true });
|
|
2203
2208
|
await Promise.all(
|
|
2204
|
-
entries.filter((entry) => entry.isDirectory() && !
|
|
2209
|
+
entries.filter((entry) => entry.isDirectory() && !seededPresets.has(entry.name)).map(async (entry) => {
|
|
2205
2210
|
const directory = join6(homeDir, entry.name);
|
|
2206
2211
|
const existing = new Set(await readdir2(directory));
|
|
2207
2212
|
await Promise.all(
|
|
@@ -2234,6 +2239,18 @@ async function ensurePresetGuidance(homeDir) {
|
|
|
2234
2239
|
})
|
|
2235
2240
|
);
|
|
2236
2241
|
}
|
|
2242
|
+
async function readPresetIds(rootCtx) {
|
|
2243
|
+
const get = rootCtx.get;
|
|
2244
|
+
if (typeof get !== "function") return [];
|
|
2245
|
+
const service = get.call(rootCtx, "agentPresets");
|
|
2246
|
+
if (service === void 0 || typeof service.list !== "function") return [];
|
|
2247
|
+
try {
|
|
2248
|
+
const rows = await service.list();
|
|
2249
|
+
return rows.map((row) => row.id).filter((id) => typeof id === "string" && id.length > 0);
|
|
2250
|
+
} catch {
|
|
2251
|
+
return [];
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2237
2254
|
function guidanceHomeDir(env = process.env) {
|
|
2238
2255
|
return join6(resolveDshHome(void 0, env), "plugins", PLUGIN_NAME, "guidance");
|
|
2239
2256
|
}
|
|
@@ -2318,7 +2335,7 @@ function registerGuidanceSections(rootCtx, agentCtx, enabled) {
|
|
|
2318
2335
|
const orderFor = orderResolver(registry);
|
|
2319
2336
|
const presetId = presetIdFor(rootCtx, agentCtx) ?? FALLBACK_PRESET_ID;
|
|
2320
2337
|
const homeDir = guidanceHomeDir();
|
|
2321
|
-
void ensurePresetGuidance(homeDir).catch((error) => {
|
|
2338
|
+
void ensurePresetGuidance(homeDir, () => readPresetIds(rootCtx)).catch((error) => {
|
|
2322
2339
|
warn2(
|
|
2323
2340
|
rootCtx,
|
|
2324
2341
|
`guidance materialization failed for ${homeDir}: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -100,7 +100,7 @@ export declare const DEFAULT_PRESETS: readonly string[];
|
|
|
100
100
|
* Custom preset directories present on disk are healed like the shipped ones
|
|
101
101
|
* but never fabricated.
|
|
102
102
|
*/
|
|
103
|
-
export declare function ensurePresetGuidance(homeDir: string): Promise<void>;
|
|
103
|
+
export declare function ensurePresetGuidance(homeDir: string, discoverPresets?: () => Promise<readonly string[]>): Promise<void>;
|
|
104
104
|
/** The plugin guidance home: `<DSH_HOME>/plugins/dsh-hashline-edit/guidance`. */
|
|
105
105
|
export declare function guidanceHomeDir(env?: Record<string, string | undefined>): string;
|
|
106
106
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hashline-edit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Hash-anchored read/apply_patch tools for DeepSeek Harness (dsh). Every line gets a unique 3- or 4-char hash (A-Za-z0-9, configurable) that stays stable across edits; apply_patch is the only file-mutation entry point and commits one patch batch per transaction. Undo persists across restarts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anchors",
|