@codyswann/lisa 4.103.11 → 4.103.13
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/codex/scripts/block-suppress-directives.sh +120 -26
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +20 -5
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/opencode/plugin-templates/lisa-block-suppress-directives.ts +72 -22
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/hooks/block-suppress-directives.sh +104 -14
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/hooks/block-suppress-directives.sh +104 -14
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/hooks/block-suppress-directives.sh +104 -14
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/hooks/block-suppress-directives.sh +104 -14
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +13 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-status.mjs +39 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -6
- package/plugins/src/base/skills/lisa-session-manager/scripts/launch.mjs +20 -0
- package/plugins/src/typescript/hooks/block-suppress-directives.sh +104 -14
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
# base "ASK FIRST" governance rule). The agent should stop and get the user's
|
|
9
9
|
# approval rather than slip a suppression past silently.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
11
|
+
# Refuses directive GROWTH, not presence: a directive in the after text that the
|
|
12
|
+
# before text lacks (new, another copy, or reworded) refuses; keeping or
|
|
13
|
+
# removing one is allowed. Write judges the whole file (disk vs content).
|
|
14
|
+
# Edit/MultiEdit judge each replaced fragment on its own (old_string vs
|
|
15
|
+
# new_string), so a widening done purely by deleting text from an existing
|
|
16
|
+
# directive, or a directive assembled across separate edits, is NOT detected —
|
|
17
|
+
# a pre-existing limit, shared with the presence check this replaced.
|
|
18
|
+
# Scoped to JS/TS files, and matches the directive only in comment syntax
|
|
19
|
+
# (// or /*) so prose, strings, and identifiers that merely mention these
|
|
20
|
+
# tokens are not flagged.
|
|
14
21
|
# Exit code 2 blocks the tool call and surfaces stderr to Claude.
|
|
15
22
|
# Reference: https://docs.claude.com/en/docs/claude-code/hooks
|
|
16
23
|
#
|
|
@@ -99,23 +106,106 @@ if [ -n "${CLAUDE_PROJECT_DIR:-}" ] &&
|
|
|
99
106
|
fi
|
|
100
107
|
fi
|
|
101
108
|
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
# Built-in: refuse directive GROWTH, never mere presence (CodySwannGT/lisa#4492).
|
|
111
|
+
#
|
|
112
|
+
# Rewriting a file that already carried an approved, scoped disable used to be
|
|
113
|
+
# refused as if the agent had added it, which taught agents to dodge the hook
|
|
114
|
+
# rather than heed it. The judgement is BEFORE versus AFTER:
|
|
115
|
+
# Write -> before = the file on disk (nothing when it does not exist),
|
|
116
|
+
# after = tool_input.content
|
|
117
|
+
# Edit -> before = tool_input.old_string, after = tool_input.new_string
|
|
118
|
+
# MultiEdit -> each edits[] pair judged the same way, on its own
|
|
119
|
+
# Each directive is taken from its comment opener to the end of its line, so a
|
|
120
|
+
# directive that is added, copied again, or reworded (a `-next-line` disable
|
|
121
|
+
# turned file-wide, a longer rule list) is new text, and is growth.
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
112
123
|
|
|
113
124
|
# Comment-syntax-only match: a // or /* opener, optional whitespace, then the
|
|
114
125
|
# suppression directive. @ts-expect-error is intentionally NOT matched — it is
|
|
115
126
|
# the safer alternative this hook steers toward.
|
|
116
127
|
DIRECTIVE_RE='(//|/\*)[[:space:]]*(@ts-(ignore|nocheck)|eslint-disable|biome-ignore|prettier-ignore)'
|
|
117
128
|
|
|
118
|
-
|
|
129
|
+
# The directives in $1, one per line and sorted, so the lists are multisets
|
|
130
|
+
# `comm` can subtract. Trailing whitespace (and a CR) is not part of one.
|
|
131
|
+
directives_in() {
|
|
132
|
+
printf '%s\n' "$1" | grep -Eo "${DIRECTIVE_RE}.*" |
|
|
133
|
+
sed 's/[[:space:]]*$//' | LC_ALL=C sort
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# True when $2 (after) carries a directive $1 (before) does not. `comm -13`
|
|
137
|
+
# pairs repeated lines one-for-one, so a further copy of an existing directive
|
|
138
|
+
# is left over, and counts.
|
|
139
|
+
grows() {
|
|
140
|
+
[ -n "$(LC_ALL=C comm -13 <(directives_in "$1") <(directives_in "$2"))" ]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# The file a Write replaces, on stdout. A relative path is the project's, so it
|
|
144
|
+
# resolves against CLAUDE_PROJECT_DIR whichever directory this runs in. Nothing
|
|
145
|
+
# there is a new file (empty before). Something there that is not a readable
|
|
146
|
+
# regular file — a directory, a dangling link, no read permission — cannot be
|
|
147
|
+
# judged, so this fails and the caller refuses.
|
|
148
|
+
read_before() {
|
|
149
|
+
local target="$FILE_PATH"
|
|
150
|
+
case "$target" in
|
|
151
|
+
/*) ;;
|
|
152
|
+
*) target="${CLAUDE_PROJECT_DIR:-.}/$target" ;;
|
|
153
|
+
esac
|
|
154
|
+
[ -e "$target" ] || [ -L "$target" ] || return 0
|
|
155
|
+
[ -f "$target" ] && [ -r "$target" ] || return 1
|
|
156
|
+
cat -- "$target"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
# The edit object $1: tool_input itself for Edit, edits[$1] for MultiEdit.
|
|
160
|
+
EDIT_AT='.tool_input | (if (.edits // null) != null then .edits[$i] else . end)'
|
|
161
|
+
|
|
162
|
+
# One string field ($2) of edit $1, empty when absent.
|
|
163
|
+
edit_field() {
|
|
164
|
+
printf '%s' "$JSON_INPUT" |
|
|
165
|
+
jq -r --argjson i "$1" --arg f "$2" "$EDIT_AT | .[\$f] // empty"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# True when edit $1 grows the directives. One that brings a directive with no
|
|
169
|
+
# old_string to compare against cannot be judged, and counts as growth.
|
|
170
|
+
edit_grows() {
|
|
171
|
+
local new
|
|
172
|
+
new="$(edit_field "$1" new_string)"
|
|
173
|
+
[ -n "$(directives_in "$new")" ] || return 1
|
|
174
|
+
printf '%s' "$JSON_INPUT" |
|
|
175
|
+
jq -e --argjson i "$1" "$EDIT_AT | (.old_string | type) == \"string\"" \
|
|
176
|
+
>/dev/null || return 0
|
|
177
|
+
grows "$(edit_field "$1" old_string)" "$new"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# True when any edit grows. An edit count that is not a number is unjudgeable.
|
|
181
|
+
any_edit_grows() {
|
|
182
|
+
local count i=0
|
|
183
|
+
count="$(printf '%s' "$JSON_INPUT" |
|
|
184
|
+
jq '.tool_input | if (.edits // null) != null then (.edits | length) else 1 end')"
|
|
185
|
+
case "$count" in '' | *[!0-9]*) return 0 ;; esac
|
|
186
|
+
while [ "$i" -lt "$count" ]; do
|
|
187
|
+
edit_grows "$i" && return 0
|
|
188
|
+
i=$((i + 1))
|
|
189
|
+
done
|
|
190
|
+
return 1
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# True when the write grows the directives; Write when content is present.
|
|
194
|
+
write_grows() {
|
|
195
|
+
local before after
|
|
196
|
+
if printf '%s' "$JSON_INPUT" |
|
|
197
|
+
jq -e '(.tool_input.content // null) != null' >/dev/null; then
|
|
198
|
+
after="$(printf '%s' "$JSON_INPUT" | jq -r '.tool_input.content')"
|
|
199
|
+
# Nothing in the new text means nothing can have grown; no read needed.
|
|
200
|
+
[ -n "$(directives_in "$after")" ] || return 1
|
|
201
|
+
before="$(read_before)" || return 0
|
|
202
|
+
grows "$before" "$after"
|
|
203
|
+
return
|
|
204
|
+
fi
|
|
205
|
+
any_edit_grows
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if write_grows; then
|
|
119
209
|
cat >&2 <<MSG
|
|
120
210
|
❌ Blocked: error-suppression directive in $FILE_PATH
|
|
121
211
|
|
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
# base "ASK FIRST" governance rule). The agent should stop and get the user's
|
|
9
9
|
# approval rather than slip a suppression past silently.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
11
|
+
# Refuses directive GROWTH, not presence: a directive in the after text that the
|
|
12
|
+
# before text lacks (new, another copy, or reworded) refuses; keeping or
|
|
13
|
+
# removing one is allowed. Write judges the whole file (disk vs content).
|
|
14
|
+
# Edit/MultiEdit judge each replaced fragment on its own (old_string vs
|
|
15
|
+
# new_string), so a widening done purely by deleting text from an existing
|
|
16
|
+
# directive, or a directive assembled across separate edits, is NOT detected —
|
|
17
|
+
# a pre-existing limit, shared with the presence check this replaced.
|
|
18
|
+
# Scoped to JS/TS files, and matches the directive only in comment syntax
|
|
19
|
+
# (// or /*) so prose, strings, and identifiers that merely mention these
|
|
20
|
+
# tokens are not flagged.
|
|
14
21
|
# Exit code 2 blocks the tool call and surfaces stderr to Claude.
|
|
15
22
|
# Reference: https://docs.claude.com/en/docs/claude-code/hooks
|
|
16
23
|
#
|
|
@@ -99,23 +106,106 @@ if [ -n "${CLAUDE_PROJECT_DIR:-}" ] &&
|
|
|
99
106
|
fi
|
|
100
107
|
fi
|
|
101
108
|
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
# Built-in: refuse directive GROWTH, never mere presence (CodySwannGT/lisa#4492).
|
|
111
|
+
#
|
|
112
|
+
# Rewriting a file that already carried an approved, scoped disable used to be
|
|
113
|
+
# refused as if the agent had added it, which taught agents to dodge the hook
|
|
114
|
+
# rather than heed it. The judgement is BEFORE versus AFTER:
|
|
115
|
+
# Write -> before = the file on disk (nothing when it does not exist),
|
|
116
|
+
# after = tool_input.content
|
|
117
|
+
# Edit -> before = tool_input.old_string, after = tool_input.new_string
|
|
118
|
+
# MultiEdit -> each edits[] pair judged the same way, on its own
|
|
119
|
+
# Each directive is taken from its comment opener to the end of its line, so a
|
|
120
|
+
# directive that is added, copied again, or reworded (a `-next-line` disable
|
|
121
|
+
# turned file-wide, a longer rule list) is new text, and is growth.
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
112
123
|
|
|
113
124
|
# Comment-syntax-only match: a // or /* opener, optional whitespace, then the
|
|
114
125
|
# suppression directive. @ts-expect-error is intentionally NOT matched — it is
|
|
115
126
|
# the safer alternative this hook steers toward.
|
|
116
127
|
DIRECTIVE_RE='(//|/\*)[[:space:]]*(@ts-(ignore|nocheck)|eslint-disable|biome-ignore|prettier-ignore)'
|
|
117
128
|
|
|
118
|
-
|
|
129
|
+
# The directives in $1, one per line and sorted, so the lists are multisets
|
|
130
|
+
# `comm` can subtract. Trailing whitespace (and a CR) is not part of one.
|
|
131
|
+
directives_in() {
|
|
132
|
+
printf '%s\n' "$1" | grep -Eo "${DIRECTIVE_RE}.*" |
|
|
133
|
+
sed 's/[[:space:]]*$//' | LC_ALL=C sort
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# True when $2 (after) carries a directive $1 (before) does not. `comm -13`
|
|
137
|
+
# pairs repeated lines one-for-one, so a further copy of an existing directive
|
|
138
|
+
# is left over, and counts.
|
|
139
|
+
grows() {
|
|
140
|
+
[ -n "$(LC_ALL=C comm -13 <(directives_in "$1") <(directives_in "$2"))" ]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# The file a Write replaces, on stdout. A relative path is the project's, so it
|
|
144
|
+
# resolves against CLAUDE_PROJECT_DIR whichever directory this runs in. Nothing
|
|
145
|
+
# there is a new file (empty before). Something there that is not a readable
|
|
146
|
+
# regular file — a directory, a dangling link, no read permission — cannot be
|
|
147
|
+
# judged, so this fails and the caller refuses.
|
|
148
|
+
read_before() {
|
|
149
|
+
local target="$FILE_PATH"
|
|
150
|
+
case "$target" in
|
|
151
|
+
/*) ;;
|
|
152
|
+
*) target="${CLAUDE_PROJECT_DIR:-.}/$target" ;;
|
|
153
|
+
esac
|
|
154
|
+
[ -e "$target" ] || [ -L "$target" ] || return 0
|
|
155
|
+
[ -f "$target" ] && [ -r "$target" ] || return 1
|
|
156
|
+
cat -- "$target"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
# The edit object $1: tool_input itself for Edit, edits[$1] for MultiEdit.
|
|
160
|
+
EDIT_AT='.tool_input | (if (.edits // null) != null then .edits[$i] else . end)'
|
|
161
|
+
|
|
162
|
+
# One string field ($2) of edit $1, empty when absent.
|
|
163
|
+
edit_field() {
|
|
164
|
+
printf '%s' "$JSON_INPUT" |
|
|
165
|
+
jq -r --argjson i "$1" --arg f "$2" "$EDIT_AT | .[\$f] // empty"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# True when edit $1 grows the directives. One that brings a directive with no
|
|
169
|
+
# old_string to compare against cannot be judged, and counts as growth.
|
|
170
|
+
edit_grows() {
|
|
171
|
+
local new
|
|
172
|
+
new="$(edit_field "$1" new_string)"
|
|
173
|
+
[ -n "$(directives_in "$new")" ] || return 1
|
|
174
|
+
printf '%s' "$JSON_INPUT" |
|
|
175
|
+
jq -e --argjson i "$1" "$EDIT_AT | (.old_string | type) == \"string\"" \
|
|
176
|
+
>/dev/null || return 0
|
|
177
|
+
grows "$(edit_field "$1" old_string)" "$new"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# True when any edit grows. An edit count that is not a number is unjudgeable.
|
|
181
|
+
any_edit_grows() {
|
|
182
|
+
local count i=0
|
|
183
|
+
count="$(printf '%s' "$JSON_INPUT" |
|
|
184
|
+
jq '.tool_input | if (.edits // null) != null then (.edits | length) else 1 end')"
|
|
185
|
+
case "$count" in '' | *[!0-9]*) return 0 ;; esac
|
|
186
|
+
while [ "$i" -lt "$count" ]; do
|
|
187
|
+
edit_grows "$i" && return 0
|
|
188
|
+
i=$((i + 1))
|
|
189
|
+
done
|
|
190
|
+
return 1
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# True when the write grows the directives; Write when content is present.
|
|
194
|
+
write_grows() {
|
|
195
|
+
local before after
|
|
196
|
+
if printf '%s' "$JSON_INPUT" |
|
|
197
|
+
jq -e '(.tool_input.content // null) != null' >/dev/null; then
|
|
198
|
+
after="$(printf '%s' "$JSON_INPUT" | jq -r '.tool_input.content')"
|
|
199
|
+
# Nothing in the new text means nothing can have grown; no read needed.
|
|
200
|
+
[ -n "$(directives_in "$after")" ] || return 1
|
|
201
|
+
before="$(read_before)" || return 0
|
|
202
|
+
grows "$before" "$after"
|
|
203
|
+
return
|
|
204
|
+
fi
|
|
205
|
+
any_edit_grows
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if write_grows; then
|
|
119
209
|
cat >&2 <<MSG
|
|
120
210
|
❌ Blocked: error-suppression directive in $FILE_PATH
|
|
121
211
|
|
|
@@ -360,6 +360,19 @@ Do these steps in order. Start each cycle by resolving `$SM`, then confirm the s
|
|
|
360
360
|
and check again; never run a cycle from a child repo. Handle any messages that arrived since the last
|
|
361
361
|
cycle first (above).
|
|
362
362
|
|
|
363
|
+
**Duplicate-manager check.** Decide **who** the manager is only from `status` `manager.self`; check
|
|
364
|
+
this session's own loops with `CronList`. When `manager.self` is true, this session **is** the
|
|
365
|
+
manager and its own `/loop` is the manager's loop: never report it as a second manager, and never
|
|
366
|
+
recommend `CronDelete` or stopping it. When `manager.self` is `null`, recommend stopping nothing;
|
|
367
|
+
report that self-identification failed. When `manager.running` is true, `manager.self` is false, and
|
|
368
|
+
this session runs its own `/lisa:session-manager cycle` loop, two managers can hand out the same
|
|
369
|
+
item: warn the operator and recommend stopping **this** session's loop, never the tmux manager. The
|
|
370
|
+
tmux manager cannot see another session's loop, so that warning comes from the other session's own
|
|
371
|
+
cycle and the manager must not invent one (detecting it from inside the manager is follow-up work).
|
|
372
|
+
`manager.self` means running inside the manager's tmux session, so another Claude started in a
|
|
373
|
+
second window of that same tmux session also reads true. Never infer a second manager from the tmux
|
|
374
|
+
session existing plus a loop being present.
|
|
375
|
+
|
|
363
376
|
### 1. Reconcile
|
|
364
377
|
|
|
365
378
|
**Unsent questions** (only when `notify` is `telegram`). `ledger get` shows every pending question.
|
|
@@ -10,7 +10,7 @@ import path from "node:path";
|
|
|
10
10
|
|
|
11
11
|
import { listAgents, requireConfig, run } from "./cli-runtime.mjs";
|
|
12
12
|
import { notifyProvider } from "./config.mjs";
|
|
13
|
-
import { buildHasSession } from "./launch.mjs";
|
|
13
|
+
import { buildCurrentSessionName, buildHasSession } from "./launch.mjs";
|
|
14
14
|
import { listPendingQuestions } from "./ledger-questions.mjs";
|
|
15
15
|
import { readLedger } from "./ledger.mjs";
|
|
16
16
|
import { shellQuote } from "./token.mjs";
|
|
@@ -29,12 +29,44 @@ function answerCommandFor(ctx, ref) {
|
|
|
29
29
|
return `node ${shellQuote(script)} answer ${shellQuote(ref)} --project-root ${shellQuote(ctx.root)} < answer.txt`;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Whether the caller of `status` IS the manager: it runs inside tmux and
|
|
34
|
+
* tmux names the caller's own session as the manager's (#4496). Without this
|
|
35
|
+
* a cycle running in the manager's session saw "the tmux manager is running"
|
|
36
|
+
* plus its own `/loop` and reported itself as a second manager.
|
|
37
|
+
*
|
|
38
|
+
* "Self" means running inside the manager's tmux session, so a second Claude
|
|
39
|
+
* started in another window of that same session also reads true.
|
|
40
|
+
*
|
|
41
|
+
* Fail-safe, not fail-false: `false` only when there is no `$TMUX` or tmux
|
|
42
|
+
* names a different session. Inside tmux, `null` (unknown) when
|
|
43
|
+
* `$TMUX_PANE` is not a pane id (tmux is then not asked: untargeted, it
|
|
44
|
+
* answers for its most recently active client, which can be another
|
|
45
|
+
* session), or when the probe fails or names no session, because `false`
|
|
46
|
+
* there would tell the manager to stop its own loop. Nothing here throws.
|
|
47
|
+
* @param {{ env: Record<string, string | undefined> }} ctx - CLI context
|
|
48
|
+
* @param {string} name - Manager session name
|
|
49
|
+
* @returns {boolean | null} True for the manager's own session, false for
|
|
50
|
+
* another session or none, null when tmux cannot say which it is
|
|
51
|
+
*/
|
|
52
|
+
function isManagerSelf(ctx, name) {
|
|
53
|
+
if (!ctx.env.TMUX) return false;
|
|
54
|
+
const argv = buildCurrentSessionName(ctx.env.TMUX_PANE);
|
|
55
|
+
if (argv === null) return null;
|
|
56
|
+
const probe = run("tmux", argv, { env: ctx.env });
|
|
57
|
+
const current = probe.status === 0 ? probe.stdout.trim() : "";
|
|
58
|
+
if (current === "") return null;
|
|
59
|
+
return current === name;
|
|
60
|
+
}
|
|
61
|
+
|
|
32
62
|
/**
|
|
33
63
|
* `status`: is the manager's tmux session up, and what does the ledger say
|
|
34
64
|
* about each worker it dispatched.
|
|
35
65
|
* @param {object} ctx - CLI context
|
|
36
66
|
* `notify` is the configured notification provider (`telegram` or `none`),
|
|
37
|
-
* so the manager knows each cycle whether a channel exists.
|
|
67
|
+
* so the manager knows each cycle whether a channel exists. `manager.self`
|
|
68
|
+
* (`true|false|null`) says whether the caller runs inside that tmux session
|
|
69
|
+
* (see {@link isManagerSelf}).
|
|
38
70
|
* @returns {Promise<{ json: object }>}
|
|
39
71
|
* `{manager,notify,control,workers,untracked,pendingQuestions}`
|
|
40
72
|
*/
|
|
@@ -49,7 +81,11 @@ export async function status(ctx) {
|
|
|
49
81
|
const tracked = new Set(Object.values(ledger.items).map(i => i.worker));
|
|
50
82
|
return {
|
|
51
83
|
json: {
|
|
52
|
-
manager: {
|
|
84
|
+
manager: {
|
|
85
|
+
name: config.name,
|
|
86
|
+
running: tmux.status === 0,
|
|
87
|
+
self: isManagerSelf(ctx, config.name),
|
|
88
|
+
},
|
|
53
89
|
notify: notifyProvider(config),
|
|
54
90
|
control: ledger.control,
|
|
55
91
|
workers: Object.entries(ledger.items).map(([ref, item]) => ({
|
|
@@ -47,12 +47,16 @@ Workers and capacity
|
|
|
47
47
|
pendingQuestion}], classification one of finished|waiting|requestion|
|
|
48
48
|
working|stalled|dead|exhausted.
|
|
49
49
|
status
|
|
50
|
-
stdout {manager:{name,running},notify,control,workers:[{ref,
|
|
51
|
-
sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
|
|
52
|
-
names],pendingQuestions:[{ref,kind,text,askedAt,marked,
|
|
53
|
-
answerCommand}]}.
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
stdout {manager:{name,running,self},notify,control,workers:[{ref,
|
|
51
|
+
worker,sessionId,repo,status,attempts,pendingQuestion,live}],untracked:
|
|
52
|
+
[wk-names],pendingQuestions:[{ref,kind,text,askedAt,marked,
|
|
53
|
+
answerQueued,answerCommand}]}. manager.self is true when the caller
|
|
54
|
+
runs inside the manager's tmux session (any window of it), false
|
|
55
|
+
outside tmux or in another session, null when tmux cannot say which
|
|
56
|
+
session the caller is in or $TMUX_PANE is not a pane id. notify is
|
|
57
|
+
the configured channel: "telegram" or "none". pendingQuestions lists
|
|
58
|
+
every item waiting on a human, oldest first; answerCommand is the
|
|
59
|
+
answer line to run at this machine.
|
|
56
60
|
|
|
57
61
|
Manager
|
|
58
62
|
start [--settle-ms <n>]
|
|
@@ -232,6 +232,26 @@ export function buildSessionPath(name) {
|
|
|
232
232
|
];
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
/** A tmux pane id as tmux sets `$TMUX_PANE`: `%` then digits. */
|
|
236
|
+
const PANE_ID_PATTERN = /^%\d+$/;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* tmux argv that prints the name of the session the CALLER runs in, so
|
|
240
|
+
* `status` can tell the manager asking about itself from another session
|
|
241
|
+
* asking about the manager (#4496). The target is always the caller's own
|
|
242
|
+
* `$TMUX_PANE`. Without `-t`, tmux answers for its "best" client (the most
|
|
243
|
+
* recently active one), which can be a different session, so there is no
|
|
244
|
+
* untargeted form: with no real pane id this returns null and the caller
|
|
245
|
+
* must treat the answer as unknown.
|
|
246
|
+
* @param {string | undefined} pane - The caller's `$TMUX_PANE`, if any
|
|
247
|
+
* @returns {string[] | null} argv for `spawnSync("tmux", argv)`, or null
|
|
248
|
+
* when `pane` is not a pane id
|
|
249
|
+
*/
|
|
250
|
+
export function buildCurrentSessionName(pane) {
|
|
251
|
+
if (typeof pane !== "string" || !PANE_ID_PATTERN.test(pane)) return null;
|
|
252
|
+
return ["display-message", "-p", "-t", pane, "#{session_name}"];
|
|
253
|
+
}
|
|
254
|
+
|
|
235
255
|
/**
|
|
236
256
|
* tmux argv that stops the manager session and nothing else (exact name, see
|
|
237
257
|
* {@link buildHasSession}). Workers are separate background sessions and keep
|
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
# base "ASK FIRST" governance rule). The agent should stop and get the user's
|
|
9
9
|
# approval rather than slip a suppression past silently.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
11
|
+
# Refuses directive GROWTH, not presence: a directive in the after text that the
|
|
12
|
+
# before text lacks (new, another copy, or reworded) refuses; keeping or
|
|
13
|
+
# removing one is allowed. Write judges the whole file (disk vs content).
|
|
14
|
+
# Edit/MultiEdit judge each replaced fragment on its own (old_string vs
|
|
15
|
+
# new_string), so a widening done purely by deleting text from an existing
|
|
16
|
+
# directive, or a directive assembled across separate edits, is NOT detected —
|
|
17
|
+
# a pre-existing limit, shared with the presence check this replaced.
|
|
18
|
+
# Scoped to JS/TS files, and matches the directive only in comment syntax
|
|
19
|
+
# (// or /*) so prose, strings, and identifiers that merely mention these
|
|
20
|
+
# tokens are not flagged.
|
|
14
21
|
# Exit code 2 blocks the tool call and surfaces stderr to Claude.
|
|
15
22
|
# Reference: https://docs.claude.com/en/docs/claude-code/hooks
|
|
16
23
|
#
|
|
@@ -99,23 +106,106 @@ if [ -n "${CLAUDE_PROJECT_DIR:-}" ] &&
|
|
|
99
106
|
fi
|
|
100
107
|
fi
|
|
101
108
|
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
# Built-in: refuse directive GROWTH, never mere presence (CodySwannGT/lisa#4492).
|
|
111
|
+
#
|
|
112
|
+
# Rewriting a file that already carried an approved, scoped disable used to be
|
|
113
|
+
# refused as if the agent had added it, which taught agents to dodge the hook
|
|
114
|
+
# rather than heed it. The judgement is BEFORE versus AFTER:
|
|
115
|
+
# Write -> before = the file on disk (nothing when it does not exist),
|
|
116
|
+
# after = tool_input.content
|
|
117
|
+
# Edit -> before = tool_input.old_string, after = tool_input.new_string
|
|
118
|
+
# MultiEdit -> each edits[] pair judged the same way, on its own
|
|
119
|
+
# Each directive is taken from its comment opener to the end of its line, so a
|
|
120
|
+
# directive that is added, copied again, or reworded (a `-next-line` disable
|
|
121
|
+
# turned file-wide, a longer rule list) is new text, and is growth.
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
112
123
|
|
|
113
124
|
# Comment-syntax-only match: a // or /* opener, optional whitespace, then the
|
|
114
125
|
# suppression directive. @ts-expect-error is intentionally NOT matched — it is
|
|
115
126
|
# the safer alternative this hook steers toward.
|
|
116
127
|
DIRECTIVE_RE='(//|/\*)[[:space:]]*(@ts-(ignore|nocheck)|eslint-disable|biome-ignore|prettier-ignore)'
|
|
117
128
|
|
|
118
|
-
|
|
129
|
+
# The directives in $1, one per line and sorted, so the lists are multisets
|
|
130
|
+
# `comm` can subtract. Trailing whitespace (and a CR) is not part of one.
|
|
131
|
+
directives_in() {
|
|
132
|
+
printf '%s\n' "$1" | grep -Eo "${DIRECTIVE_RE}.*" |
|
|
133
|
+
sed 's/[[:space:]]*$//' | LC_ALL=C sort
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# True when $2 (after) carries a directive $1 (before) does not. `comm -13`
|
|
137
|
+
# pairs repeated lines one-for-one, so a further copy of an existing directive
|
|
138
|
+
# is left over, and counts.
|
|
139
|
+
grows() {
|
|
140
|
+
[ -n "$(LC_ALL=C comm -13 <(directives_in "$1") <(directives_in "$2"))" ]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# The file a Write replaces, on stdout. A relative path is the project's, so it
|
|
144
|
+
# resolves against CLAUDE_PROJECT_DIR whichever directory this runs in. Nothing
|
|
145
|
+
# there is a new file (empty before). Something there that is not a readable
|
|
146
|
+
# regular file — a directory, a dangling link, no read permission — cannot be
|
|
147
|
+
# judged, so this fails and the caller refuses.
|
|
148
|
+
read_before() {
|
|
149
|
+
local target="$FILE_PATH"
|
|
150
|
+
case "$target" in
|
|
151
|
+
/*) ;;
|
|
152
|
+
*) target="${CLAUDE_PROJECT_DIR:-.}/$target" ;;
|
|
153
|
+
esac
|
|
154
|
+
[ -e "$target" ] || [ -L "$target" ] || return 0
|
|
155
|
+
[ -f "$target" ] && [ -r "$target" ] || return 1
|
|
156
|
+
cat -- "$target"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
# The edit object $1: tool_input itself for Edit, edits[$1] for MultiEdit.
|
|
160
|
+
EDIT_AT='.tool_input | (if (.edits // null) != null then .edits[$i] else . end)'
|
|
161
|
+
|
|
162
|
+
# One string field ($2) of edit $1, empty when absent.
|
|
163
|
+
edit_field() {
|
|
164
|
+
printf '%s' "$JSON_INPUT" |
|
|
165
|
+
jq -r --argjson i "$1" --arg f "$2" "$EDIT_AT | .[\$f] // empty"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# True when edit $1 grows the directives. One that brings a directive with no
|
|
169
|
+
# old_string to compare against cannot be judged, and counts as growth.
|
|
170
|
+
edit_grows() {
|
|
171
|
+
local new
|
|
172
|
+
new="$(edit_field "$1" new_string)"
|
|
173
|
+
[ -n "$(directives_in "$new")" ] || return 1
|
|
174
|
+
printf '%s' "$JSON_INPUT" |
|
|
175
|
+
jq -e --argjson i "$1" "$EDIT_AT | (.old_string | type) == \"string\"" \
|
|
176
|
+
>/dev/null || return 0
|
|
177
|
+
grows "$(edit_field "$1" old_string)" "$new"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# True when any edit grows. An edit count that is not a number is unjudgeable.
|
|
181
|
+
any_edit_grows() {
|
|
182
|
+
local count i=0
|
|
183
|
+
count="$(printf '%s' "$JSON_INPUT" |
|
|
184
|
+
jq '.tool_input | if (.edits // null) != null then (.edits | length) else 1 end')"
|
|
185
|
+
case "$count" in '' | *[!0-9]*) return 0 ;; esac
|
|
186
|
+
while [ "$i" -lt "$count" ]; do
|
|
187
|
+
edit_grows "$i" && return 0
|
|
188
|
+
i=$((i + 1))
|
|
189
|
+
done
|
|
190
|
+
return 1
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# True when the write grows the directives; Write when content is present.
|
|
194
|
+
write_grows() {
|
|
195
|
+
local before after
|
|
196
|
+
if printf '%s' "$JSON_INPUT" |
|
|
197
|
+
jq -e '(.tool_input.content // null) != null' >/dev/null; then
|
|
198
|
+
after="$(printf '%s' "$JSON_INPUT" | jq -r '.tool_input.content')"
|
|
199
|
+
# Nothing in the new text means nothing can have grown; no read needed.
|
|
200
|
+
[ -n "$(directives_in "$after")" ] || return 1
|
|
201
|
+
before="$(read_before)" || return 0
|
|
202
|
+
grows "$before" "$after"
|
|
203
|
+
return
|
|
204
|
+
fi
|
|
205
|
+
any_edit_grows
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if write_grows; then
|
|
119
209
|
cat >&2 <<MSG
|
|
120
210
|
❌ Blocked: error-suppression directive in $FILE_PATH
|
|
121
211
|
|