company-skill 3.1.0 → 3.1.2
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/hooks/stop-guard.js +7 -23
- package/package.json +1 -1
package/hooks/stop-guard.js
CHANGED
|
@@ -8,12 +8,9 @@ const companyDir = path.join(cwd, '.company');
|
|
|
8
8
|
const criteriaPath = path.join(companyDir, 'criteria.json');
|
|
9
9
|
const goalPath = path.join(companyDir, 'GOAL.md');
|
|
10
10
|
const cancelPath = path.join(companyDir, 'CANCEL');
|
|
11
|
-
const counterPath = path.join(companyDir, '.stop-counter');
|
|
12
11
|
|
|
13
12
|
// No company running
|
|
14
|
-
if (!fs.existsSync(goalPath) && !fs.existsSync(criteriaPath))
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
13
|
+
if (!fs.existsSync(goalPath) && !fs.existsSync(criteriaPath)) process.exit(0);
|
|
17
14
|
|
|
18
15
|
// Cancel signal
|
|
19
16
|
if (fs.existsSync(cancelPath)) {
|
|
@@ -21,16 +18,6 @@ if (fs.existsSync(cancelPath)) {
|
|
|
21
18
|
process.exit(0);
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
// Circuit breaker: max 10 blocks then allow stop
|
|
25
|
-
let count = 0;
|
|
26
|
-
try { count = parseInt(fs.readFileSync(counterPath, 'utf8')) || 0; } catch (e) {}
|
|
27
|
-
count++;
|
|
28
|
-
try { fs.writeFileSync(counterPath, String(count)); } catch (e) {}
|
|
29
|
-
if (count > 10) {
|
|
30
|
-
try { fs.unlinkSync(counterPath); } catch (e) {}
|
|
31
|
-
process.exit(0); // Allow stop, prevent infinite loop
|
|
32
|
-
}
|
|
33
|
-
|
|
34
21
|
// Check criteria
|
|
35
22
|
if (fs.existsSync(criteriaPath)) {
|
|
36
23
|
try {
|
|
@@ -38,24 +25,21 @@ if (fs.existsSync(criteriaPath)) {
|
|
|
38
25
|
const all = data.criteria || [];
|
|
39
26
|
const failing = all.filter(c => !c.passes || !c.evidence);
|
|
40
27
|
|
|
41
|
-
if (all.length > 0 && failing.length === 0)
|
|
42
|
-
try { fs.unlinkSync(counterPath); } catch (e) {}
|
|
43
|
-
process.exit(0); // All pass, allow stop
|
|
44
|
-
}
|
|
28
|
+
if (all.length > 0 && failing.length === 0) process.exit(0);
|
|
45
29
|
|
|
46
30
|
const failList = failing.map(c => c.description).join(', ');
|
|
47
31
|
console.log(JSON.stringify({
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
decision: "block",
|
|
33
|
+
reason: "[COMPANY] " + failing.length + "/" + all.length + " criteria not met: " + failList + ". Continue THINK > EXECUTE > VERIFY. Read .company/criteria.json."
|
|
50
34
|
}));
|
|
51
35
|
process.exit(0);
|
|
52
36
|
} catch (e) {
|
|
53
|
-
process.exit(0);
|
|
37
|
+
process.exit(0);
|
|
54
38
|
}
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
// No criteria but goal exists
|
|
58
42
|
console.log(JSON.stringify({
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
decision: "block",
|
|
44
|
+
reason: "[COMPANY] Goal not achieved. Read .company/GOAL.md, create criteria.json, start THINK > EXECUTE > VERIFY."
|
|
61
45
|
}));
|