chisle 3.3.0 → 3.5.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/.claude-plugin/plugin.json +1 -1
- package/.opencode/plugins/chisle.mjs +115 -0
- package/README.md +41 -4
- package/bin/install.js +261 -27
- package/hooks/chisle-activate.js +12 -5
- package/hooks/chisle-compress-output.js +186 -25
- package/hooks/chisle-config.js +182 -1
- package/hooks/chisle-mode-tracker.js +20 -6
- package/package.json +25 -1
- package/pi-extension/index.cjs +13 -0
- package/pi-extension/index.js +41 -8
package/pi-extension/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const crypto = require('node:crypto');
|
|
4
4
|
const fs = require('node:fs');
|
|
5
5
|
const path = require('node:path');
|
|
6
|
-
const { getDefaultMode } = require('../hooks/chisle-config');
|
|
6
|
+
const { getDefaultMode, getSections, filterSections } = require('../hooks/chisle-config');
|
|
7
7
|
const { duplicateMarker, limitsFor, transform } = require('../hooks/chisle-compress-output');
|
|
8
8
|
const { requestedMode } = require('../hooks/chisle-mode');
|
|
9
9
|
|
|
@@ -12,20 +12,52 @@ const MODE_TYPE = 'chisle-mode';
|
|
|
12
12
|
const SAFE_TOOLS = new Set(['bash', 'powershell', 'grep', 'find', 'ls']);
|
|
13
13
|
const NEVER_COMPRESS = new Set(['read', 'edit', 'write']);
|
|
14
14
|
const DEDUP_MIN = 2048;
|
|
15
|
-
|
|
15
|
+
// Sectioned so the `sections` config applies here too. Flat prose/code lines
|
|
16
|
+
// would leave the fallback ignoring a user's sections.prose:false the moment
|
|
17
|
+
// SKILL.md became unreadable — chisle-activate.js's fallback is shaped the
|
|
18
|
+
// same way for the same reason. The safety line stays outside both groups.
|
|
19
|
+
const FALLBACK_BODY = `Chisle: maximum-efficiency dev mode. Zero-fluff prose. YAGNI-first code.
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
## Prose
|
|
18
22
|
|
|
19
23
|
Drop articles, filler, pleasantries, and hedging. Fragments OK; technical terms exact.
|
|
24
|
+
|
|
25
|
+
## Code
|
|
26
|
+
|
|
20
27
|
Code ladder: YAGNI → reuse → stdlib → native → installed dependency → one line → minimum code.
|
|
28
|
+
|
|
29
|
+
## Boundaries
|
|
30
|
+
|
|
21
31
|
Never simplify away input validation, data-loss prevention, security, accessibility, or explicit requirements.`;
|
|
22
32
|
|
|
23
33
|
function loadRules() {
|
|
24
34
|
try {
|
|
25
35
|
const skill = fs.readFileSync(path.join(__dirname, '..', 'skills', 'chisle', 'SKILL.md'), 'utf8');
|
|
26
|
-
|
|
36
|
+
// Shares the SKILL.md emission path with chisle-activate.js, so it honors
|
|
37
|
+
// the same `sections` config (prose/code rule suppression) the same way.
|
|
38
|
+
return 'CHISLE ACTIVE\n\n' +
|
|
39
|
+
filterSections(skill.replace(/^---[\s\S]*?---\s*/, ''), getSections());
|
|
40
|
+
} catch (_) {
|
|
41
|
+
return 'CHISLE ACTIVE\n\n' +
|
|
42
|
+
filterSections(FALLBACK_BODY, getSections(), ['Prose'], ['Code']);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// OMP (oh-my-pi) ships a subset of Pi's sessionManager: buildContextEntries and
|
|
47
|
+
// getBranch are absent there, so calling one throws inside session_start and
|
|
48
|
+
// takes the whole extension down —
|
|
49
|
+
// "ctx.sessionManager.buildContextEntries is not a function" (issue #14).
|
|
50
|
+
// Treat both as optional readers. An absent one means we cannot prove the
|
|
51
|
+
// session state, and every caller here already behaves correctly on "unknown":
|
|
52
|
+
// no mode entry leaves `active` at getDefaultMode(), and rulesInContext=false
|
|
53
|
+
// re-injects the ruleset, which promptHasRules still de-duplicates.
|
|
54
|
+
function sessionEntries(ctx, method) {
|
|
55
|
+
try {
|
|
56
|
+
const sm = ctx && ctx.sessionManager;
|
|
57
|
+
if (!sm || typeof sm[method] !== 'function') return [];
|
|
58
|
+
return sm[method]() || [];
|
|
27
59
|
} catch (_) {
|
|
28
|
-
return
|
|
60
|
+
return [];
|
|
29
61
|
}
|
|
30
62
|
}
|
|
31
63
|
|
|
@@ -77,12 +109,12 @@ function chisleExtension(pi) {
|
|
|
77
109
|
lastByToolBlock = new Map();
|
|
78
110
|
dedupBaseline = new Map();
|
|
79
111
|
|
|
80
|
-
const modeEntry = ctx
|
|
112
|
+
const modeEntry = sessionEntries(ctx, 'getBranch')
|
|
81
113
|
.filter(entry => entry.type === 'custom' && entry.customType === MODE_TYPE).pop();
|
|
82
114
|
if (modeEntry && modeEntry.data && ['on', 'off'].includes(modeEntry.data.mode)) {
|
|
83
115
|
active = modeEntry.data.mode === 'on';
|
|
84
116
|
}
|
|
85
|
-
rulesInContext = hasRulesEntry(ctx
|
|
117
|
+
rulesInContext = hasRulesEntry(sessionEntries(ctx, 'buildContextEntries'));
|
|
86
118
|
updateStatus(ctx);
|
|
87
119
|
}
|
|
88
120
|
|
|
@@ -116,7 +148,7 @@ function chisleExtension(pi) {
|
|
|
116
148
|
pi.on('session_compact', async (_event, ctx) => {
|
|
117
149
|
lastByToolBlock.clear();
|
|
118
150
|
dedupBaseline.clear();
|
|
119
|
-
rulesInContext = hasRulesEntry(ctx
|
|
151
|
+
rulesInContext = hasRulesEntry(sessionEntries(ctx, 'buildContextEntries'));
|
|
120
152
|
});
|
|
121
153
|
|
|
122
154
|
pi.on('input', async (event, ctx) => {
|
|
@@ -185,4 +217,5 @@ function chisleExtension(pi) {
|
|
|
185
217
|
module.exports = chisleExtension;
|
|
186
218
|
module.exports.loadRules = loadRules;
|
|
187
219
|
module.exports.hasRulesEntry = hasRulesEntry;
|
|
220
|
+
module.exports.sessionEntries = sessionEntries;
|
|
188
221
|
module.exports.piToolAllowed = piToolAllowed;
|