@staff0rd/assist 0.1155.0 → 0.1156.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/agent/commands/add-rule.md +7 -1
- package/dist/.build-files +16 -17
- package/dist/built-version +1 -1
- package/dist/{chunk-FKHKR4UU.js → chunk-3MDY76Q4.js} +1 -1
- package/dist/{chunk-OCMOCAJ5.js → chunk-IV4XOPGF.js} +1 -1
- package/dist/{chunk-QXVJYD33.js → chunk-PR34VFPP.js} +1 -1
- package/dist/{chunk-U7UPKLBZ.js → chunk-UGVPVJJG.js} +1 -1
- package/dist/{chunk-R7MRAYLZ.js → chunk-XXSAUKDC.js} +2 -2
- package/dist/{chunk-ZA7XPP63.js → chunk-Y3AHHDAV.js} +1 -1
- package/dist/commands/sessions/web/bundle.js +2 -2
- package/dist/{doctorNodes-7VOBS7QT.js → doctorNodes-EWYB77RO.js} +3 -3
- package/dist/index.js +16 -17
- package/dist/{restartNode-OYD6K3I3.js → restartNode-X3CT7RGF.js} +5 -5
- package/dist/rulesAdd-BY3QLX3M.js +317 -0
- package/dist/{runDaemon-AK3NM65C.js → runDaemon-3RUZEJ25.js} +6 -3
- package/dist/{signExtension-KDADDRPS.js → signExtension-7GUHW35N.js} +1 -1
- package/dist/{updateNode-MNAVM4QG.js → updateNode-6UO5J3HF.js} +5 -5
- package/dist/{web-3GFJKG3L.js → web-XHZZGQBJ.js} +5 -5
- package/dist/{web-W47PETV3.js → web-ZBDWZVA7.js} +5 -5
- package/package.json +1 -1
- package/dist/addRule-J432LIS3.js +0 -102
- package/dist/addUserRule-XO2BNQFH.js +0 -136
- package/dist/{add-QQQ472AZ.js → add-LM2C4OO4.js} +3 -3
- package/dist/{sqlQuery-OAXPQJPY.js → sqlQuery-XCD5LQOS.js} +3 -3
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildDoctorProbes,
|
|
6
6
|
diagnoseLink
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-3MDY76Q4.js";
|
|
8
|
+
import "./chunk-PR34VFPP.js";
|
|
9
9
|
import {
|
|
10
10
|
queryNodes
|
|
11
11
|
} from "./chunk-OD7CMDGZ.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
detectPlatform
|
|
26
26
|
} from "./chunk-E36L7ASL.js";
|
|
27
27
|
import "./chunk-OFLEIPAR.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-Y3AHHDAV.js";
|
|
29
29
|
import "./chunk-KGFZYUE2.js";
|
|
30
30
|
import "./chunk-LBAPKP6M.js";
|
|
31
31
|
import "./chunk-GRXFWFGP.js";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./chunk-TJGF3Z72.js";
|
|
18
18
|
import {
|
|
19
19
|
package_default
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Y3AHHDAV.js";
|
|
21
21
|
import {
|
|
22
22
|
adviceConfigHelp,
|
|
23
23
|
askQuestionConfigHelp,
|
|
@@ -92,7 +92,7 @@ import { Command } from "commander";
|
|
|
92
92
|
// src/commands/registerRootAction.ts
|
|
93
93
|
function registerRootAction(program) {
|
|
94
94
|
program.option("--no-open", "Do not open a browser on startup").action(
|
|
95
|
-
async (options) => (await import("./web-
|
|
95
|
+
async (options) => (await import("./web-ZBDWZVA7.js")).web({
|
|
96
96
|
port: "3100",
|
|
97
97
|
open: options.open
|
|
98
98
|
})
|
|
@@ -564,7 +564,7 @@ function registerShowCommands(cmd) {
|
|
|
564
564
|
|
|
565
565
|
// src/commands/registerBacklog.ts
|
|
566
566
|
function registerWebCommand(cmd) {
|
|
567
|
-
cmd.command("web").description("Open the backlog tab in the web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(lazyAction(() => import("./web-
|
|
567
|
+
cmd.command("web").description("Open the backlog tab in the web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(lazyAction(() => import("./web-XHZZGQBJ.js"), "web"));
|
|
568
568
|
}
|
|
569
569
|
var registrars = [
|
|
570
570
|
registerItemCommands,
|
|
@@ -594,7 +594,7 @@ function registerBacklog(program) {
|
|
|
594
594
|
const { setBacklogDir } = await import("./getBacklogDir-AVGEKM42.js");
|
|
595
595
|
setBacklogDir(thisCommand.opts().dir);
|
|
596
596
|
}).action(
|
|
597
|
-
async (options) => (await import("./web-
|
|
597
|
+
async (options) => (await import("./web-XHZZGQBJ.js")).web({ port: "3100", open: options.open })
|
|
598
598
|
);
|
|
599
599
|
for (const register of registrars) {
|
|
600
600
|
register(cmd);
|
|
@@ -907,7 +907,7 @@ function registerExtension(program) {
|
|
|
907
907
|
).action(async (options) => {
|
|
908
908
|
const { extension } = await import("./extension-YYRD5EM6.js");
|
|
909
909
|
const { printExtensionUrl } = await import("./printExtensionUrl-IW2WTSNS.js");
|
|
910
|
-
const { signExtension } = await import("./signExtension-
|
|
910
|
+
const { signExtension } = await import("./signExtension-7GUHW35N.js");
|
|
911
911
|
if (options.url) return printExtensionUrl();
|
|
912
912
|
return options.sign ? signExtension() : extension();
|
|
913
913
|
});
|
|
@@ -2016,7 +2016,7 @@ function registerReview(program) {
|
|
|
2016
2016
|
function registerRulesAdd(rulesCommand) {
|
|
2017
2017
|
internalCommand(
|
|
2018
2018
|
rulesCommand.command("add <text>").description(
|
|
2019
|
-
"Add a rule to the `## Rules` section of the scope's CLAUDE.md, allocating the next repo-wide code and creating the section when absent"
|
|
2019
|
+
"Add a rule to the `## Rules` section of the scope's CLAUDE.md, allocating the next repo-wide code and creating the section when absent. In a web session the rule opens in the preview pane first and is written only on approval; rejecting writes nothing and exits non-zero with the reason and comments"
|
|
2020
2020
|
).option(
|
|
2021
2021
|
"--title <title>",
|
|
2022
2022
|
"As few words as possible summarising the rule, shown in the rule picker in place of the description"
|
|
@@ -2033,9 +2033,8 @@ function registerRulesAdd(rulesCommand) {
|
|
|
2033
2033
|
"--repo [name]",
|
|
2034
2034
|
"As --user, but append to advice.rules in repo (db), the shared per-repo override every node sees, for the current repo or the named one"
|
|
2035
2035
|
).action(async (text, options) => {
|
|
2036
|
-
const {
|
|
2037
|
-
|
|
2038
|
-
return options.user || options.node || options.repo !== void 0 ? addUserRule(text, options) : addRule(text, options);
|
|
2036
|
+
const { rulesAdd } = await import("./rulesAdd-BY3QLX3M.js");
|
|
2037
|
+
return rulesAdd(text, options);
|
|
2039
2038
|
}),
|
|
2040
2039
|
"/add-rule and /fix-rules"
|
|
2041
2040
|
);
|
|
@@ -2179,7 +2178,7 @@ function registerSql(program) {
|
|
|
2179
2178
|
async (name) => (await import("./sqlSetConnection-UAX7TRB4.js")).sqlSetConnection(name)
|
|
2180
2179
|
);
|
|
2181
2180
|
cmd.command("query <sql> [connection]").description("Execute a read-only SQL query (rejects mutating statements)").action(
|
|
2182
|
-
async (query, connection) => (await import("./sqlQuery-
|
|
2181
|
+
async (query, connection) => (await import("./sqlQuery-XCD5LQOS.js")).sqlQuery(query, connection)
|
|
2183
2182
|
);
|
|
2184
2183
|
cmd.command("mutate <sql> [connection]").description(
|
|
2185
2184
|
"Execute a mutating SQL statement (rejects non-mutating statements)"
|
|
@@ -2540,7 +2539,7 @@ function registerRunAdd(runCommand) {
|
|
|
2540
2539
|
).option(
|
|
2541
2540
|
"--repo [name]",
|
|
2542
2541
|
"Write to a repo's override in the shared db, seen by every node, instead of assist.yml (defaults to the current repo; no command file is created)"
|
|
2543
|
-
).addHelpText("after", runAddHelpText).allowUnknownOption().allowExcessArguments().action(lazyAction(() => import("./add-
|
|
2542
|
+
).addHelpText("after", runAddHelpText).allowUnknownOption().allowExcessArguments().action(lazyAction(() => import("./add-LM2C4OO4.js"), "add"));
|
|
2544
2543
|
}
|
|
2545
2544
|
|
|
2546
2545
|
// src/commands/run/registerRunSubcommands.ts
|
|
@@ -2577,7 +2576,7 @@ function registerDaemon(program) {
|
|
|
2577
2576
|
const cmd = program.command("daemon").description("Long-lived daemon that owns web session PTYs");
|
|
2578
2577
|
cmd.command("run").description(
|
|
2579
2578
|
"Run the sessions daemon in the foreground (auto-spawned by assist sessions)"
|
|
2580
|
-
).action(lazyAction(() => import("./runDaemon-
|
|
2579
|
+
).action(lazyAction(() => import("./runDaemon-3RUZEJ25.js"), "runDaemon"));
|
|
2581
2580
|
cmd.command("status").description(
|
|
2582
2581
|
"Show sessions daemon status, live sessions, and any stray daemon processes"
|
|
2583
2582
|
).action(lazyAction(() => import("./daemonStatus-GZKN2CYX.js"), "daemonStatus"));
|
|
@@ -2601,7 +2600,7 @@ function registerDiagnoseCommands(nodes, calledBy5) {
|
|
|
2601
2600
|
nodes.command("doctor [name]").description(
|
|
2602
2601
|
"Probe each hop of every link (or one) in order and stop at the first failure with a remediation"
|
|
2603
2602
|
).option("--json", "Output as JSON").action(
|
|
2604
|
-
async (name, _options, command) => (await import("./doctorNodes-
|
|
2603
|
+
async (name, _options, command) => (await import("./doctorNodes-EWYB77RO.js")).doctorNodes(
|
|
2605
2604
|
name,
|
|
2606
2605
|
command.optsWithGlobals()
|
|
2607
2606
|
)
|
|
@@ -2631,14 +2630,14 @@ function registerPeerActionCommands(nodes, calledBy5) {
|
|
|
2631
2630
|
internalCommand(
|
|
2632
2631
|
nodes.command("restart <name>").description(
|
|
2633
2632
|
"Restart a linked node's daemon and/or web server, wait for its link to reconnect and print its version"
|
|
2634
|
-
).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-
|
|
2633
|
+
).option("--target <target>", "daemon, webserver or both", "both").action(lazyAction(() => import("./restartNode-X3CT7RGF.js"), "restartNode")),
|
|
2635
2634
|
calledBy5
|
|
2636
2635
|
);
|
|
2637
2636
|
internalCommand(
|
|
2638
2637
|
nodes.command("update <name>").description(
|
|
2639
2638
|
"Run assist update on a linked node, restart it, wait for its link to reconnect and print its version"
|
|
2640
2639
|
).action(
|
|
2641
|
-
async (name) => (await import("./updateNode-
|
|
2640
|
+
async (name) => (await import("./updateNode-6UO5J3HF.js")).updateNode(name)
|
|
2642
2641
|
),
|
|
2643
2642
|
calledBy5
|
|
2644
2643
|
);
|
|
@@ -2701,7 +2700,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
2701
2700
|
// src/commands/sessions/registerSessionsWeb.ts
|
|
2702
2701
|
function registerSessionsWeb(cmd) {
|
|
2703
2702
|
const webCmd = cmd.command("web").description("Start the sessions web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(
|
|
2704
|
-
async (options, command) => (await import("./web-
|
|
2703
|
+
async (options, command) => (await import("./web-ZBDWZVA7.js")).web({
|
|
2705
2704
|
...options,
|
|
2706
2705
|
open: command.optsWithGlobals().open
|
|
2707
2706
|
})
|
|
@@ -2716,7 +2715,7 @@ function registerSessionsWeb(cmd) {
|
|
|
2716
2715
|
// src/commands/sessions/registerSessions.ts
|
|
2717
2716
|
function registerSessions(program) {
|
|
2718
2717
|
const cmd = program.command("sessions").description("Web dashboard for coding agent sessions").option("--no-open", "Do not open a browser on startup").action(
|
|
2719
|
-
async (_options, command) => (await import("./web-
|
|
2718
|
+
async (_options, command) => (await import("./web-ZBDWZVA7.js")).web({
|
|
2720
2719
|
port: "3100",
|
|
2721
2720
|
open: command.optsWithGlobals().open
|
|
2722
2721
|
})
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
linkStatus,
|
|
3
3
|
postToPeer,
|
|
4
4
|
startPeerAction
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-IV4XOPGF.js";
|
|
6
|
+
import "./chunk-UGVPVJJG.js";
|
|
7
7
|
import "./chunk-4HKB2TAG.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-3MDY76Q4.js";
|
|
9
|
+
import "./chunk-PR34VFPP.js";
|
|
10
10
|
import "./chunk-OD7CMDGZ.js";
|
|
11
11
|
import "./chunk-VABNWHSE.js";
|
|
12
12
|
import "./chunk-HHKS3UZB.js";
|
|
@@ -15,7 +15,7 @@ import "./chunk-MODUPHYS.js";
|
|
|
15
15
|
import "./chunk-E36L7ASL.js";
|
|
16
16
|
import "./chunk-6YRKJTHT.js";
|
|
17
17
|
import "./chunk-OFLEIPAR.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-Y3AHHDAV.js";
|
|
19
19
|
import "./chunk-KGFZYUE2.js";
|
|
20
20
|
import "./chunk-LBAPKP6M.js";
|
|
21
21
|
import "./chunk-GRXFWFGP.js";
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findClaudeFiles,
|
|
3
|
+
updateScopedRulesIndex
|
|
4
|
+
} from "./chunk-I3TEQBTO.js";
|
|
5
|
+
import {
|
|
6
|
+
printApprovedComments
|
|
7
|
+
} from "./chunk-DYGEMDS7.js";
|
|
8
|
+
import {
|
|
9
|
+
awaitPreviewApproval
|
|
10
|
+
} from "./chunk-KI7RHWH5.js";
|
|
11
|
+
import "./chunk-BAHQJHYD.js";
|
|
12
|
+
import {
|
|
13
|
+
RULE_BULLET,
|
|
14
|
+
appendRulesSection,
|
|
15
|
+
contentLines,
|
|
16
|
+
parseRulesSection,
|
|
17
|
+
rulesSectionRange,
|
|
18
|
+
scopeDirectory
|
|
19
|
+
} from "./chunk-ADLCDG2V.js";
|
|
20
|
+
import {
|
|
21
|
+
globalConfigFileLabel
|
|
22
|
+
} from "./chunk-SEXIHLGA.js";
|
|
23
|
+
import {
|
|
24
|
+
applyUserConfigSet
|
|
25
|
+
} from "./chunk-2O7TIRCQ.js";
|
|
26
|
+
import {
|
|
27
|
+
applyConfigSet
|
|
28
|
+
} from "./chunk-5WQDLREX.js";
|
|
29
|
+
import {
|
|
30
|
+
applySharedRepoConfigSet
|
|
31
|
+
} from "./chunk-MY4TNZNI.js";
|
|
32
|
+
import "./chunk-OU6Q5ZS3.js";
|
|
33
|
+
import "./chunk-5JOVEUBS.js";
|
|
34
|
+
import "./chunk-VPMI4LV2.js";
|
|
35
|
+
import {
|
|
36
|
+
resolveSharedRepoBlock
|
|
37
|
+
} from "./chunk-BBXEZVRL.js";
|
|
38
|
+
import "./chunk-7CEIET2O.js";
|
|
39
|
+
import "./chunk-WGV2ELBS.js";
|
|
40
|
+
import "./chunk-YOFY27RM.js";
|
|
41
|
+
import "./chunk-B5ZOANOD.js";
|
|
42
|
+
import "./chunk-3XQHTIHW.js";
|
|
43
|
+
import "./chunk-HSWDSL22.js";
|
|
44
|
+
import "./chunk-MBPVW7BY.js";
|
|
45
|
+
import "./chunk-YNHPTUHS.js";
|
|
46
|
+
import "./chunk-XZFSW5AY.js";
|
|
47
|
+
import "./chunk-2EW62DM5.js";
|
|
48
|
+
import {
|
|
49
|
+
getDb
|
|
50
|
+
} from "./chunk-PD2BTMEY.js";
|
|
51
|
+
import "./chunk-3QKE2ONF.js";
|
|
52
|
+
import "./chunk-O5JIFWMQ.js";
|
|
53
|
+
import "./chunk-LMUTL44M.js";
|
|
54
|
+
import "./chunk-6NDXAN45.js";
|
|
55
|
+
import "./chunk-EW2ZM2PC.js";
|
|
56
|
+
import "./chunk-QKHOYKUQ.js";
|
|
57
|
+
import {
|
|
58
|
+
loadGlobalConfigRaw
|
|
59
|
+
} from "./chunk-KGFZYUE2.js";
|
|
60
|
+
import {
|
|
61
|
+
getGlobalConfigPath
|
|
62
|
+
} from "./chunk-LBAPKP6M.js";
|
|
63
|
+
import "./chunk-GRXFWFGP.js";
|
|
64
|
+
import "./chunk-TVQY3HPZ.js";
|
|
65
|
+
import "./chunk-CGYVYHMM.js";
|
|
66
|
+
import {
|
|
67
|
+
findRepoRoot
|
|
68
|
+
} from "./chunk-WXQ3EA5H.js";
|
|
69
|
+
import "./chunk-YXXKT6LL.js";
|
|
70
|
+
import "./chunk-USKD27FY.js";
|
|
71
|
+
import "./chunk-HN7MFXZ7.js";
|
|
72
|
+
import "./chunk-DZGYHAE7.js";
|
|
73
|
+
import "./chunk-ZH6HKQOY.js";
|
|
74
|
+
import "./chunk-ELF4PBZX.js";
|
|
75
|
+
|
|
76
|
+
// src/commands/rules/addRule.ts
|
|
77
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
78
|
+
import path3 from "path";
|
|
79
|
+
import chalk from "chalk";
|
|
80
|
+
|
|
81
|
+
// src/commands/rules/insertRuleBullet.ts
|
|
82
|
+
function ruleBullet({ code, title, text }) {
|
|
83
|
+
return title ? `- **${code}** \u2014 **${title}** \u2014 ${text}` : `- **${code}** \u2014 ${text}`;
|
|
84
|
+
}
|
|
85
|
+
function insertRuleBullet(content, rule) {
|
|
86
|
+
const bullet = ruleBullet(rule);
|
|
87
|
+
const lines = contentLines(content);
|
|
88
|
+
const range = rulesSectionRange(lines);
|
|
89
|
+
if (!range) return appendRulesSection(lines, bullet);
|
|
90
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
91
|
+
const lastBullet = body.reduce(
|
|
92
|
+
(last, line, index) => RULE_BULLET.test(line) ? index : last,
|
|
93
|
+
-1
|
|
94
|
+
);
|
|
95
|
+
const at = lastBullet === -1 ? range.start + 1 : range.start + lastBullet + 2;
|
|
96
|
+
const inserted = lastBullet === -1 ? ["", bullet] : [bullet];
|
|
97
|
+
return `${[...lines.slice(0, at), ...inserted, ...lines.slice(at)].join("\n")}
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/commands/rules/resolveRuleTarget.ts
|
|
102
|
+
import path2 from "path";
|
|
103
|
+
|
|
104
|
+
// src/commands/rules/nextRuleCode.ts
|
|
105
|
+
import { readFileSync } from "fs";
|
|
106
|
+
var CODE_PREFIX = "R";
|
|
107
|
+
function nextRuleCode(root) {
|
|
108
|
+
const numbers = findClaudeFiles(root).flatMap(
|
|
109
|
+
(file) => parseRulesSection(readFileSync(file, "utf8")).map(
|
|
110
|
+
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
return `${CODE_PREFIX}${Math.max(0, ...numbers) + 1}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/commands/rules/resolveRuleScope.ts
|
|
117
|
+
import { existsSync } from "fs";
|
|
118
|
+
import path from "path";
|
|
119
|
+
function resolveRuleScope(target) {
|
|
120
|
+
const resolved = path.resolve(target);
|
|
121
|
+
if (path.basename(resolved) === "CLAUDE.md") return resolved;
|
|
122
|
+
const startDir = scopeDirectory(resolved);
|
|
123
|
+
const root = findRepoRoot(startDir) ?? startDir;
|
|
124
|
+
let current = startDir;
|
|
125
|
+
while (true) {
|
|
126
|
+
const candidate = path.join(current, "CLAUDE.md");
|
|
127
|
+
if (existsSync(candidate)) return candidate;
|
|
128
|
+
if (current === root || current === path.dirname(current)) break;
|
|
129
|
+
current = path.dirname(current);
|
|
130
|
+
}
|
|
131
|
+
return path.join(root, "CLAUDE.md");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/commands/rules/resolveRuleTarget.ts
|
|
135
|
+
function resolveRuleTarget(scope) {
|
|
136
|
+
const target = resolveRuleScope(scope ?? process.cwd());
|
|
137
|
+
const targetDir = path2.dirname(target);
|
|
138
|
+
const root = findRepoRoot(targetDir) ?? targetDir;
|
|
139
|
+
return { target, root, code: nextRuleCode(root) };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/commands/rules/addRule.ts
|
|
143
|
+
function read(file) {
|
|
144
|
+
return existsSync2(file) ? readFileSync2(file, "utf8") : "";
|
|
145
|
+
}
|
|
146
|
+
function addRule(text, options) {
|
|
147
|
+
const rule = text.trim();
|
|
148
|
+
if (rule === "") {
|
|
149
|
+
console.error(chalk.red("Rule text is required"));
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const { target, root, code } = resolveRuleTarget(options.scope);
|
|
154
|
+
writeFileSync(
|
|
155
|
+
target,
|
|
156
|
+
insertRuleBullet(read(target), {
|
|
157
|
+
code,
|
|
158
|
+
title: options.title?.trim() || void 0,
|
|
159
|
+
text: rule
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
updateScopedRulesIndex(root);
|
|
163
|
+
console.log(
|
|
164
|
+
`Added ${chalk.cyan(code)} to ${path3.relative(process.cwd(), target) || target}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/commands/rules/addUserRule.ts
|
|
169
|
+
import chalk4 from "chalk";
|
|
170
|
+
|
|
171
|
+
// src/commands/rules/addToRepoDb.ts
|
|
172
|
+
import chalk3 from "chalk";
|
|
173
|
+
|
|
174
|
+
// src/commands/rules/appendRule.ts
|
|
175
|
+
function appendRule(current, rule) {
|
|
176
|
+
return [...Array.isArray(current) ? current : [], rule];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/commands/rules/failRule.ts
|
|
180
|
+
import chalk2 from "chalk";
|
|
181
|
+
function failRule(message) {
|
|
182
|
+
console.error(chalk2.red(message));
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/commands/rules/addToRepoDb.ts
|
|
187
|
+
async function addToRepoDb(rule, repo, cwd) {
|
|
188
|
+
const repoName = typeof repo === "string" ? repo : void 0;
|
|
189
|
+
const { block } = await resolveSharedRepoBlock(await getDb(), repoName, cwd);
|
|
190
|
+
const advice = block.advice;
|
|
191
|
+
const result = await applySharedRepoConfigSet(
|
|
192
|
+
"advice.rules",
|
|
193
|
+
appendRule(advice?.rules, rule),
|
|
194
|
+
repoName,
|
|
195
|
+
cwd
|
|
196
|
+
);
|
|
197
|
+
if (!result.ok) return failRule(result.errors.join("\n"));
|
|
198
|
+
console.log(
|
|
199
|
+
`Added ${chalk3.cyan(rule.title)} to advice.rules in repo (db): ${result.label}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/commands/rules/userRuleOptionsError.ts
|
|
204
|
+
function userRuleOptionsError(options) {
|
|
205
|
+
const targets = [
|
|
206
|
+
options.user && "--user",
|
|
207
|
+
options.node && "--node",
|
|
208
|
+
options.repo !== void 0 && "--repo"
|
|
209
|
+
].filter(Boolean);
|
|
210
|
+
if (targets.length > 1)
|
|
211
|
+
return `${targets.join(", ")} each write advice.rules in a different scope (user (db), user (node), repo (db)); pass one`;
|
|
212
|
+
if (options.scope !== void 0)
|
|
213
|
+
return `${targets[0]} writes advice.rules, not a CLAUDE.md, and cannot be combined with --scope`;
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/commands/rules/adviceRuleError.ts
|
|
218
|
+
function adviceRuleError(text, options) {
|
|
219
|
+
const error = userRuleOptionsError(options);
|
|
220
|
+
if (error) return error;
|
|
221
|
+
if (text.trim() === "" || !options.title?.trim())
|
|
222
|
+
return "advice.rules entries need both rule text and --title";
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/commands/rules/addUserRule.ts
|
|
227
|
+
async function addToUserDb(rule) {
|
|
228
|
+
const result = await applyUserConfigSet(
|
|
229
|
+
"advice.rules",
|
|
230
|
+
(current) => appendRule(current, rule)
|
|
231
|
+
);
|
|
232
|
+
if (!result.ok) return failRule(result.errors.join("\n"));
|
|
233
|
+
console.log(`Added ${chalk4.cyan(rule.title)} to advice.rules in user (db)`);
|
|
234
|
+
}
|
|
235
|
+
function addToUserNode(rule, globalConfigPath) {
|
|
236
|
+
const advice = loadGlobalConfigRaw(globalConfigPath).advice;
|
|
237
|
+
const result = applyConfigSet(
|
|
238
|
+
"advice.rules",
|
|
239
|
+
appendRule(advice?.rules, rule),
|
|
240
|
+
true,
|
|
241
|
+
process.cwd(),
|
|
242
|
+
globalConfigPath
|
|
243
|
+
);
|
|
244
|
+
if (!result.ok) return failRule(result.errors.join("\n"));
|
|
245
|
+
console.log(
|
|
246
|
+
`Added ${chalk4.cyan(rule.title)} to advice.rules in user (node) (${globalConfigFileLabel(globalConfigPath)})`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
async function addUserRule(text, options, globalConfigPath = getGlobalConfigPath(), cwd = process.cwd()) {
|
|
250
|
+
const error = adviceRuleError(text, options);
|
|
251
|
+
if (error) return failRule(error);
|
|
252
|
+
const rule = { title: options.title?.trim() ?? "", text: text.trim() };
|
|
253
|
+
if (options.user) return addToUserDb(rule);
|
|
254
|
+
if (options.repo !== void 0) return addToRepoDb(rule, options.repo, cwd);
|
|
255
|
+
addToUserNode(rule, globalConfigPath);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/commands/rules/describeRuleTarget.ts
|
|
259
|
+
import path4 from "path";
|
|
260
|
+
async function describeRuleTarget(options, globalConfigPath, cwd) {
|
|
261
|
+
if (options.user) return "`advice.rules` in user (db)";
|
|
262
|
+
if (options.node)
|
|
263
|
+
return `\`advice.rules\` in user (node) (\`${globalConfigFileLabel(globalConfigPath)}\`)`;
|
|
264
|
+
if (options.repo !== void 0) {
|
|
265
|
+
const repoName = typeof options.repo === "string" ? options.repo : void 0;
|
|
266
|
+
const { label } = await resolveSharedRepoBlock(
|
|
267
|
+
await getDb(),
|
|
268
|
+
repoName,
|
|
269
|
+
cwd
|
|
270
|
+
);
|
|
271
|
+
return `\`advice.rules\` in repo (db): \`${label}\``;
|
|
272
|
+
}
|
|
273
|
+
const { target, code } = resolveRuleTarget(options.scope);
|
|
274
|
+
return `\`${path4.relative(cwd, target) || target}\` as **${code}**`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/commands/rules/reviewProposedRule.ts
|
|
278
|
+
import { randomUUID } from "crypto";
|
|
279
|
+
async function reviewProposedRule(rule, target) {
|
|
280
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
281
|
+
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
282
|
+
const decision = await awaitPreviewApproval(
|
|
283
|
+
"Rule",
|
|
284
|
+
{
|
|
285
|
+
sessionId,
|
|
286
|
+
requestId: randomUUID(),
|
|
287
|
+
title: `Add rule: ${rule.title || rule.text}`,
|
|
288
|
+
body: [
|
|
289
|
+
`**Title:** ${rule.title || "_(none)_"}`,
|
|
290
|
+
`**Rule:** ${rule.text}`,
|
|
291
|
+
`**Lands in:** ${target}`
|
|
292
|
+
].join("\n\n"),
|
|
293
|
+
prNumber: null,
|
|
294
|
+
kind: "rule"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
rejectionAdvice: "Nothing was written. Revise the rule's wording, title or target to address the reason and every comment above, then re-run `assist rules add` with the revision."
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
printApprovedComments(decision);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/commands/rules/rulesAdd.ts
|
|
304
|
+
async function rulesAdd(text, options, globalConfigPath = getGlobalConfigPath(), cwd = process.cwd()) {
|
|
305
|
+
const toAdvice = options.user || options.node || options.repo !== void 0;
|
|
306
|
+
const error = toAdvice ? adviceRuleError(text, options) : text.trim() === "" ? "Rule text is required" : void 0;
|
|
307
|
+
if (error) return failRule(error);
|
|
308
|
+
await reviewProposedRule(
|
|
309
|
+
{ title: options.title?.trim() || void 0, text: text.trim() },
|
|
310
|
+
await describeRuleTarget(options, globalConfigPath, cwd)
|
|
311
|
+
);
|
|
312
|
+
if (toAdvice) return addUserRule(text, options, globalConfigPath, cwd);
|
|
313
|
+
addRule(text, options);
|
|
314
|
+
}
|
|
315
|
+
export {
|
|
316
|
+
rulesAdd
|
|
317
|
+
};
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
isHello,
|
|
116
116
|
linkVersionCheck,
|
|
117
117
|
negotiateProtocol
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-PR34VFPP.js";
|
|
119
119
|
import {
|
|
120
120
|
loadLinkSpecs
|
|
121
121
|
} from "./chunk-HHKS3UZB.js";
|
|
@@ -248,7 +248,7 @@ import {
|
|
|
248
248
|
import "./chunk-APZ6ZTDA.js";
|
|
249
249
|
import "./chunk-BFQSGIN6.js";
|
|
250
250
|
import "./chunk-D7UZLH36.js";
|
|
251
|
-
import "./chunk-
|
|
251
|
+
import "./chunk-Y3AHHDAV.js";
|
|
252
252
|
import "./chunk-EW2ZM2PC.js";
|
|
253
253
|
import "./chunk-QKHOYKUQ.js";
|
|
254
254
|
import {
|
|
@@ -3280,6 +3280,7 @@ function paneEchoText(preview, d) {
|
|
|
3280
3280
|
return questionOtherText(preview.body, answersOf(d));
|
|
3281
3281
|
case "ask":
|
|
3282
3282
|
case "backlog-item":
|
|
3283
|
+
case "rule":
|
|
3283
3284
|
return signOffText(d);
|
|
3284
3285
|
default:
|
|
3285
3286
|
return "";
|
|
@@ -3396,7 +3397,8 @@ var PREVIEW_KINDS = [
|
|
|
3396
3397
|
"ask",
|
|
3397
3398
|
"question",
|
|
3398
3399
|
"check",
|
|
3399
|
-
"design"
|
|
3400
|
+
"design",
|
|
3401
|
+
"rule"
|
|
3400
3402
|
];
|
|
3401
3403
|
function isPreviewKind(value) {
|
|
3402
3404
|
return PREVIEW_KINDS.includes(value);
|
|
@@ -3416,6 +3418,7 @@ function previewTargetLabel(kind, itemType, prNumber, draft) {
|
|
|
3416
3418
|
if (kind === "question") return "question";
|
|
3417
3419
|
if (kind === "check") return "check";
|
|
3418
3420
|
if (kind === "design") return "design";
|
|
3421
|
+
if (kind === "rule") return "rule";
|
|
3419
3422
|
if (kind === "backlog-item") return `backlog ${itemType}`;
|
|
3420
3423
|
if (prNumber !== null) return `edit #${prNumber}`;
|
|
3421
3424
|
return draft ? "create draft" : "create";
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
linkStatus,
|
|
3
3
|
postToPeer,
|
|
4
4
|
startPeerAction
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-IV4XOPGF.js";
|
|
6
|
+
import "./chunk-UGVPVJJG.js";
|
|
7
7
|
import "./chunk-4HKB2TAG.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-3MDY76Q4.js";
|
|
9
|
+
import "./chunk-PR34VFPP.js";
|
|
10
10
|
import "./chunk-OD7CMDGZ.js";
|
|
11
11
|
import "./chunk-VABNWHSE.js";
|
|
12
12
|
import "./chunk-HHKS3UZB.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import "./chunk-6YRKJTHT.js";
|
|
20
20
|
import "./chunk-OFLEIPAR.js";
|
|
21
21
|
import "./chunk-2EW62DM5.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-Y3AHHDAV.js";
|
|
23
23
|
import "./chunk-KGFZYUE2.js";
|
|
24
24
|
import "./chunk-LBAPKP6M.js";
|
|
25
25
|
import "./chunk-GRXFWFGP.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
web
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XXSAUKDC.js";
|
|
4
4
|
import "./chunk-3AYMOUTH.js";
|
|
5
5
|
import "./chunk-JNCFHWBK.js";
|
|
6
6
|
import "./chunk-JM57BCD6.js";
|
|
7
7
|
import "./chunk-3NPVVAAT.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-UGVPVJJG.js";
|
|
9
9
|
import "./chunk-4HKB2TAG.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-3MDY76Q4.js";
|
|
11
|
+
import "./chunk-PR34VFPP.js";
|
|
12
12
|
import "./chunk-OD7CMDGZ.js";
|
|
13
13
|
import "./chunk-VABNWHSE.js";
|
|
14
14
|
import "./chunk-HHKS3UZB.js";
|
|
@@ -133,7 +133,7 @@ import "./chunk-G44QYJ57.js";
|
|
|
133
133
|
import "./chunk-APZ6ZTDA.js";
|
|
134
134
|
import "./chunk-BFQSGIN6.js";
|
|
135
135
|
import "./chunk-D7UZLH36.js";
|
|
136
|
-
import "./chunk-
|
|
136
|
+
import "./chunk-Y3AHHDAV.js";
|
|
137
137
|
import "./chunk-J3C454L5.js";
|
|
138
138
|
import "./chunk-YVL3NXEB.js";
|
|
139
139
|
import "./chunk-UEWARAPX.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
web
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XXSAUKDC.js";
|
|
4
4
|
import "./chunk-3AYMOUTH.js";
|
|
5
5
|
import "./chunk-JNCFHWBK.js";
|
|
6
6
|
import "./chunk-JM57BCD6.js";
|
|
7
7
|
import "./chunk-3NPVVAAT.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-UGVPVJJG.js";
|
|
9
9
|
import "./chunk-4HKB2TAG.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-3MDY76Q4.js";
|
|
11
|
+
import "./chunk-PR34VFPP.js";
|
|
12
12
|
import "./chunk-OD7CMDGZ.js";
|
|
13
13
|
import "./chunk-VABNWHSE.js";
|
|
14
14
|
import "./chunk-HHKS3UZB.js";
|
|
@@ -133,7 +133,7 @@ import "./chunk-G44QYJ57.js";
|
|
|
133
133
|
import "./chunk-APZ6ZTDA.js";
|
|
134
134
|
import "./chunk-BFQSGIN6.js";
|
|
135
135
|
import "./chunk-D7UZLH36.js";
|
|
136
|
-
import "./chunk-
|
|
136
|
+
import "./chunk-Y3AHHDAV.js";
|
|
137
137
|
import "./chunk-J3C454L5.js";
|
|
138
138
|
import "./chunk-YVL3NXEB.js";
|
|
139
139
|
import "./chunk-UEWARAPX.js";
|