@paths.design/caws-cli 10.0.1 → 10.2.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/README.md +13 -5
- package/dist/budget-derivation.js +221 -74
- package/dist/commands/agents.js +124 -0
- package/dist/commands/evaluate.js +26 -12
- package/dist/commands/gates.js +31 -4
- package/dist/commands/init.js +7 -4
- package/dist/commands/iterate.js +7 -3
- package/dist/commands/scope.js +264 -0
- package/dist/commands/sidecar.js +6 -3
- package/dist/commands/specs.js +359 -4
- package/dist/commands/status.js +29 -4
- package/dist/commands/templates.js +0 -8
- package/dist/commands/validate.js +34 -13
- package/dist/commands/verify-acs.js +25 -10
- package/dist/commands/waivers.js +147 -5
- package/dist/commands/worktree.js +200 -4
- package/dist/gates/budget-limit.js +6 -1
- package/dist/gates/scope-boundary.js +26 -7
- package/dist/gates/spec-completeness.js +8 -1
- package/dist/index.js +56 -0
- package/dist/policy/PolicyManager.js +14 -7
- package/dist/session/session-manager.js +34 -0
- package/dist/templates/.caws/schemas/policy.schema.json +101 -34
- package/dist/templates/.caws/schemas/scope.schema.json +3 -3
- package/dist/templates/.caws/schemas/waivers.schema.json +91 -21
- package/dist/templates/.caws/schemas/working-spec.schema.json +253 -89
- package/dist/templates/.caws/templates/working-spec.template.yml +3 -1
- package/dist/templates/.caws/tools/scope-guard.js +66 -15
- package/dist/templates/.claude/README.md +1 -1
- package/dist/templates/.claude/hooks/protected-paths.sh +39 -0
- package/dist/templates/.claude/hooks/scope-guard.sh +106 -27
- package/dist/templates/.claude/hooks/worktree-write-guard.sh +96 -3
- package/dist/templates/.claude/rules/worktree-isolation.md +21 -3
- package/dist/templates/.claude/settings.json +5 -0
- package/dist/templates/CLAUDE.md +56 -0
- package/dist/templates/agents.md +47 -0
- package/dist/utils/agent-display.js +210 -0
- package/dist/utils/agent-session.js +142 -0
- package/dist/utils/event-log.js +584 -0
- package/dist/utils/event-renderer.js +521 -0
- package/dist/utils/schema-validator.js +10 -2
- package/dist/utils/working-state.js +25 -0
- package/dist/validation/spec-validation.js +102 -9
- package/dist/waivers-manager.js +84 -0
- package/dist/worktree/worktree-manager.js +593 -26
- package/package.json +5 -4
- package/templates/.caws/schemas/policy.schema.json +101 -34
- package/templates/.caws/schemas/scope.schema.json +3 -3
- package/templates/.caws/schemas/waivers.schema.json +91 -21
- package/templates/.caws/schemas/working-spec.schema.json +253 -89
- package/templates/.caws/templates/working-spec.template.yml +3 -1
- package/templates/.caws/tools/scope-guard.js +66 -15
- package/templates/.claude/README.md +1 -1
- package/templates/.claude/hooks/protected-paths.sh +39 -0
- package/templates/.claude/hooks/scope-guard.sh +106 -27
- package/templates/.claude/hooks/worktree-write-guard.sh +96 -3
- package/templates/.claude/rules/worktree-isolation.md +21 -3
- package/templates/.claude/settings.json +5 -0
- package/templates/CLAUDE.md +56 -0
- package/templates/agents.md +47 -0
|
@@ -12,6 +12,7 @@ const path = require('path');
|
|
|
12
12
|
const crypto = require('crypto');
|
|
13
13
|
|
|
14
14
|
const { mergeFilesTouched } = require('../utils/working-state');
|
|
15
|
+
const { appendEventSync } = require('../utils/event-log');
|
|
15
16
|
|
|
16
17
|
const SESSIONS_DIR = '.caws/sessions';
|
|
17
18
|
const REGISTRY_FILE = '.caws/sessions.json';
|
|
@@ -297,6 +298,22 @@ function startSession(options = {}) {
|
|
|
297
298
|
};
|
|
298
299
|
saveRegistry(root, registry);
|
|
299
300
|
|
|
301
|
+
// EVLOG-001: emit session_started event via the sync append path.
|
|
302
|
+
// spec_id is optional for this event type; we include it only when
|
|
303
|
+
// the session is bound to a spec.
|
|
304
|
+
const sessionStartedEvent = {
|
|
305
|
+
actor: 'session',
|
|
306
|
+
event: 'session_started',
|
|
307
|
+
data: {
|
|
308
|
+
session_id: sessionId,
|
|
309
|
+
role,
|
|
310
|
+
branch: capsule.base_state.branch,
|
|
311
|
+
head_rev: capsule.base_state.head_rev,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
if (specId) sessionStartedEvent.spec_id = specId;
|
|
315
|
+
appendEventSync(sessionStartedEvent, { projectRoot: root, session_id: sessionId });
|
|
316
|
+
|
|
300
317
|
return capsule;
|
|
301
318
|
}
|
|
302
319
|
|
|
@@ -447,6 +464,23 @@ function endSession(data = {}) {
|
|
|
447
464
|
registry.sessions[sessionId].ended_at = capsule.ended_at;
|
|
448
465
|
saveRegistry(root, registry);
|
|
449
466
|
|
|
467
|
+
// EVLOG-001: emit session_ended event with final files_touched list.
|
|
468
|
+
// The renderer uses this to merge file touches into the spec view.
|
|
469
|
+
const sessionEndedEvent = {
|
|
470
|
+
actor: 'session',
|
|
471
|
+
event: 'session_ended',
|
|
472
|
+
data: {
|
|
473
|
+
session_id: sessionId,
|
|
474
|
+
files_touched: capsule.work_summary.paths_touched || [],
|
|
475
|
+
outcome: capsule.known_issues.some((i) => i.type === 'error') ? 'error' : 'success',
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
if (capsule.spec_id) {
|
|
479
|
+
sessionEndedEvent.spec_id = capsule.spec_id;
|
|
480
|
+
sessionEndedEvent.data.spec_id = capsule.spec_id;
|
|
481
|
+
}
|
|
482
|
+
appendEventSync(sessionEndedEvent, { projectRoot: root, session_id: sessionId });
|
|
483
|
+
|
|
450
484
|
return capsule;
|
|
451
485
|
}
|
|
452
486
|
|
|
@@ -1,50 +1,117 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
3
|
-
"title": "CAWS Policy",
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
3
|
"type": "object",
|
|
5
|
-
"required": [
|
|
4
|
+
"required": [
|
|
5
|
+
"version",
|
|
6
|
+
"risk_tiers",
|
|
7
|
+
"edit_rules"
|
|
8
|
+
],
|
|
6
9
|
"properties": {
|
|
7
|
-
"version": {
|
|
10
|
+
"version": {
|
|
11
|
+
"type": "integer",
|
|
12
|
+
"enum": [
|
|
13
|
+
1
|
|
14
|
+
],
|
|
15
|
+
"description": "Policy schema version"
|
|
16
|
+
},
|
|
8
17
|
"risk_tiers": {
|
|
9
18
|
"type": "object",
|
|
10
|
-
"
|
|
11
|
-
"1": {
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
"patternProperties": {
|
|
20
|
+
"^[1-3]$": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"required": [
|
|
23
|
+
"max_files",
|
|
24
|
+
"max_loc"
|
|
25
|
+
],
|
|
26
|
+
"properties": {
|
|
27
|
+
"max_files": {
|
|
28
|
+
"type": "integer",
|
|
29
|
+
"minimum": 1,
|
|
30
|
+
"description": "Maximum files allowed for this risk tier"
|
|
31
|
+
},
|
|
32
|
+
"max_loc": {
|
|
33
|
+
"type": "integer",
|
|
34
|
+
"minimum": 1,
|
|
35
|
+
"description": "Maximum lines of code allowed for this risk tier"
|
|
36
|
+
},
|
|
37
|
+
"description": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Human-readable description of the tier"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"additionalProperties": false
|
|
43
|
+
}
|
|
14
44
|
},
|
|
15
|
-
"
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "Risk tier definitions with budget limits"
|
|
16
47
|
},
|
|
17
48
|
"edit_rules": {
|
|
18
49
|
"type": "object",
|
|
50
|
+
"required": [
|
|
51
|
+
"policy_and_code_same_pr",
|
|
52
|
+
"min_approvers_for_budget_raise"
|
|
53
|
+
],
|
|
19
54
|
"properties": {
|
|
20
|
-
"policy_and_code_same_pr": {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
55
|
+
"policy_and_code_same_pr": {
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"description": "Whether policy and code changes can be in the same PR"
|
|
58
|
+
},
|
|
59
|
+
"min_approvers_for_budget_raise": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"minimum": 1,
|
|
62
|
+
"description": "Minimum approvers required for budget increases"
|
|
63
|
+
},
|
|
64
|
+
"require_signed_commits": {
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"description": "Whether signed commits are required for policy changes"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"description": "Rules governing policy file edits"
|
|
24
71
|
},
|
|
25
72
|
"gates": {
|
|
26
73
|
"type": "object",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
74
|
+
"patternProperties": {
|
|
75
|
+
"^.*$": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"required": [
|
|
78
|
+
"enabled"
|
|
79
|
+
],
|
|
80
|
+
"properties": {
|
|
81
|
+
"enabled": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"description": "Whether this gate is active"
|
|
84
|
+
},
|
|
85
|
+
"mode": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": [
|
|
88
|
+
"warn",
|
|
89
|
+
"block",
|
|
90
|
+
"skip"
|
|
91
|
+
],
|
|
92
|
+
"description": "How the gate reports failures: warn, block, or skip entirely"
|
|
93
|
+
},
|
|
94
|
+
"description": {
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Human-readable description of the gate"
|
|
97
|
+
},
|
|
98
|
+
"thresholds": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"description": "Gate-specific thresholds (e.g. warning/critical limits)"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"additionalProperties": false
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"additionalProperties": false,
|
|
107
|
+
"description": "Quality gate configurations"
|
|
108
|
+
},
|
|
109
|
+
"non_governed_zones": {
|
|
110
|
+
"type": "array",
|
|
111
|
+
"items": { "type": "string" },
|
|
112
|
+
"description": "Glob patterns (picomatch, dot:true) for paths declared outside CAWS scope enforcement. Any file matching a pattern is exempt from scope-boundary checks — neither spec.scope.in nor spec.scope.out are consulted. Intended for research, playground, or experimental subtrees where governance is explicitly off by design. Example: [\"research/**\", \"playground/**\"]. (CAWSFIX-26 / D9)"
|
|
37
113
|
}
|
|
38
114
|
},
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"type": "object",
|
|
42
|
-
"required": ["max_files", "max_loc"],
|
|
43
|
-
"properties": {
|
|
44
|
-
"max_files": { "type": "integer", "minimum": 1 },
|
|
45
|
-
"max_loc": { "type": "integer", "minimum": 1 },
|
|
46
|
-
"description": { "type": "string" }
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"title": "CAWS Policy"
|
|
50
117
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"title": "CAWS Lite Scope Configuration",
|
|
4
|
-
"description": "Scope configuration for CAWS lite mode — guardrails without YAML specs",
|
|
4
|
+
"description": "Scope configuration for CAWS lite mode — guardrails without YAML specs. This schema governs the standalone .caws/scope.json file ONLY; inline scope: blocks inside working-spec.yaml or feature specs are governed by the working-spec schema's scope sub-schema and do NOT invoke this schema. See CAWSFIX-11.",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"required": ["
|
|
6
|
+
"required": ["allowedDirectories"],
|
|
7
7
|
"properties": {
|
|
8
8
|
"version": {
|
|
9
9
|
"type": "integer",
|
|
10
10
|
"const": 1,
|
|
11
|
-
"description": "Schema version"
|
|
11
|
+
"description": "Schema version. Optional for back-compat with scope.json files that predate versioning; the runtime (src/config/lite-scope.js) defaults to 1 when missing. If present, must be exactly 1. CAWSFIX-11 lifted `version` from the required list because no code path enforces a version mismatch — only the schema did, producing spurious warnings for pre-versioning scope.json files."
|
|
12
12
|
},
|
|
13
13
|
"allowedDirectories": {
|
|
14
14
|
"type": "array",
|
|
@@ -1,36 +1,106 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"title": "CAWS Waiver",
|
|
4
4
|
"description": "Individual waiver file created by caws waivers create",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"required": ["id", "
|
|
6
|
+
"required": ["id", "applies_to", "gates", "delta", "reason_code", "expires_at", "risk_owner", "approvers", "status"],
|
|
7
7
|
"properties": {
|
|
8
|
-
"id": {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"pattern": "^WV-\\d{4}$",
|
|
11
|
+
"description": "Waiver ID in format WV-XXXX"
|
|
12
|
+
},
|
|
13
|
+
"applies_to": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Spec ID or PR number this waiver applies to"
|
|
16
|
+
},
|
|
12
17
|
"gates": {
|
|
13
18
|
"type": "array",
|
|
14
|
-
"items": {
|
|
19
|
+
"items": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": ["budget_limit", "spec_completeness", "contract_compliance", "coverage_threshold", "mutation_threshold", "security_scan", "accessibility_check", "performance_budget", "scope_boundary"]
|
|
22
|
+
},
|
|
23
|
+
"minItems": 1,
|
|
24
|
+
"description": "Quality gates to waive"
|
|
25
|
+
},
|
|
26
|
+
"delta": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"description": "Additive budget deltas (only positive values allowed)",
|
|
29
|
+
"properties": {
|
|
30
|
+
"max_files": {
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"minimum": 0,
|
|
33
|
+
"description": "Additional files allowed"
|
|
34
|
+
},
|
|
35
|
+
"max_loc": {
|
|
36
|
+
"type": "integer",
|
|
37
|
+
"minimum": 0,
|
|
38
|
+
"description": "Additional lines of code allowed"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"additionalProperties": false
|
|
42
|
+
},
|
|
43
|
+
"reason_code": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["emergency_hotfix", "legacy_integration", "experimental_feature", "third_party_constraint", "performance_critical", "security_patch", "infrastructure_limitation", "architectural_refactor", "other"],
|
|
46
|
+
"description": "Controlled vocabulary for waiver reasons"
|
|
47
|
+
},
|
|
48
|
+
"description": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 50,
|
|
51
|
+
"maxLength": 1000,
|
|
52
|
+
"description": "Detailed explanation of why waiver is needed"
|
|
53
|
+
},
|
|
54
|
+
"mitigation": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 50,
|
|
57
|
+
"description": "Plan to address the underlying issue"
|
|
58
|
+
},
|
|
59
|
+
"expires_at": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"format": "date-time",
|
|
62
|
+
"description": "ISO 8601 datetime when waiver expires"
|
|
63
|
+
},
|
|
64
|
+
"risk_owner": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "Person/entity responsible for managing this risk"
|
|
67
|
+
},
|
|
68
|
+
"approvers": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"required": ["handle"],
|
|
73
|
+
"properties": {
|
|
74
|
+
"handle": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "GitHub handle or email of approver"
|
|
77
|
+
},
|
|
78
|
+
"approved_at": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"format": "date-time",
|
|
81
|
+
"description": "When this approval was given"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"additionalProperties": false
|
|
85
|
+
},
|
|
15
86
|
"minItems": 1,
|
|
16
|
-
"description": "
|
|
87
|
+
"description": "List of people who approved this waiver"
|
|
17
88
|
},
|
|
18
|
-
"created_at": { "type": "string" },
|
|
19
|
-
"expires_at": { "type": "string" },
|
|
20
|
-
"approved_by": { "type": "string" },
|
|
21
|
-
"impact_level": { "type": "string" },
|
|
22
|
-
"mitigation_plan": { "type": "string" },
|
|
23
89
|
"status": {
|
|
24
90
|
"type": "string",
|
|
25
|
-
"enum": ["active", "expired", "revoked"],
|
|
26
|
-
"
|
|
91
|
+
"enum": ["proposed", "active", "expired", "revoked"],
|
|
92
|
+
"description": "Current status of the waiver"
|
|
27
93
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
94
|
+
"metadata": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"related_pr": { "type": "string" },
|
|
98
|
+
"related_issue": { "type": "string" },
|
|
99
|
+
"environment": { "type": "string", "enum": ["development", "staging", "production"] },
|
|
100
|
+
"urgency": { "type": "string", "enum": ["low", "normal", "high", "critical"] }
|
|
101
|
+
},
|
|
102
|
+
"additionalProperties": false
|
|
103
|
+
}
|
|
34
104
|
},
|
|
35
105
|
"additionalProperties": false
|
|
36
106
|
}
|