@garethdaine/agentops 0.9.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 +10 -0
- package/LICENSE +21 -0
- package/README.md +410 -0
- package/agents/architecture-researcher.md +115 -0
- package/agents/code-critic.md +190 -0
- package/agents/delegation-router.md +40 -0
- package/agents/feature-researcher.md +117 -0
- package/agents/interrogator.md +11 -0
- package/agents/pitfalls-researcher.md +112 -0
- package/agents/plan-validator.md +173 -0
- package/agents/proposer.md +61 -0
- package/agents/security-reviewer.md +189 -0
- package/agents/skill-builder.md +43 -0
- package/agents/spec-compliance-reviewer.md +154 -0
- package/agents/stack-researcher.md +89 -0
- package/commands/build.md +766 -0
- package/commands/code-analysis.md +39 -0
- package/commands/code-field.md +22 -0
- package/commands/compliance-check.md +34 -0
- package/commands/configure.md +178 -0
- package/commands/cost-report.md +17 -0
- package/commands/enterprise/adr.md +78 -0
- package/commands/enterprise/brainstorm.md +461 -0
- package/commands/enterprise/design.md +203 -0
- package/commands/enterprise/dev-setup.md +136 -0
- package/commands/enterprise/docker-dev.md +229 -0
- package/commands/enterprise/e2e.md +233 -0
- package/commands/enterprise/feature.md +218 -0
- package/commands/enterprise/gap-analysis.md +204 -0
- package/commands/enterprise/handover.md +195 -0
- package/commands/enterprise/herd.md +152 -0
- package/commands/enterprise/knowledge.md +173 -0
- package/commands/enterprise/onboard.md +86 -0
- package/commands/enterprise/qa-check.md +80 -0
- package/commands/enterprise/reason.md +196 -0
- package/commands/enterprise/review.md +177 -0
- package/commands/enterprise/scaffold.md +153 -0
- package/commands/enterprise/status-report.md +101 -0
- package/commands/enterprise/tech-catalog.md +170 -0
- package/commands/enterprise/test-gen.md +138 -0
- package/commands/evolve.md +39 -0
- package/commands/flags.md +44 -0
- package/commands/interrogate.md +263 -0
- package/commands/lesson.md +15 -0
- package/commands/lessons.md +10 -0
- package/commands/plan.md +44 -0
- package/commands/prune.md +27 -0
- package/commands/star.md +17 -0
- package/commands/supply-chain-scan.md +44 -0
- package/commands/unicode-scan.md +63 -0
- package/commands/verify.md +41 -0
- package/commands/workflow.md +436 -0
- package/hooks/ai-guardrails.sh +114 -0
- package/hooks/audit-log.sh +26 -0
- package/hooks/auto-delegate.sh +45 -0
- package/hooks/auto-evolve.sh +22 -0
- package/hooks/auto-lesson.sh +26 -0
- package/hooks/auto-plan.sh +59 -0
- package/hooks/auto-test.sh +46 -0
- package/hooks/auto-verify.sh +30 -0
- package/hooks/budget-check.sh +24 -0
- package/hooks/code-field-preamble.sh +30 -0
- package/hooks/compliance-gate.sh +50 -0
- package/hooks/content-trust.sh +22 -0
- package/hooks/credential-redact.sh +23 -0
- package/hooks/delegation-trust.sh +15 -0
- package/hooks/detect-test-run.sh +19 -0
- package/hooks/enforcement-lib.sh +60 -0
- package/hooks/evolve-gate.sh +32 -0
- package/hooks/evolve-lib.sh +32 -0
- package/hooks/exfiltration-check.sh +67 -0
- package/hooks/failure-collector.sh +27 -0
- package/hooks/feature-flags.sh +67 -0
- package/hooks/file-provenance.sh +31 -0
- package/hooks/flag-utils.sh +36 -0
- package/hooks/hooks.json +145 -0
- package/hooks/injection-scan.sh +58 -0
- package/hooks/integrity-verify.sh +91 -0
- package/hooks/lessons-check.sh +17 -0
- package/hooks/lockfile-audit.sh +109 -0
- package/hooks/patterns-lib.sh +22 -0
- package/hooks/plan-gate.sh +18 -0
- package/hooks/redact-lib.sh +15 -0
- package/hooks/runtime-mode.sh +56 -0
- package/hooks/session-cleanup.sh +74 -0
- package/hooks/skill-validator.sh +28 -0
- package/hooks/standards-enforce.sh +106 -0
- package/hooks/star-gate.sh +93 -0
- package/hooks/star-preamble.sh +10 -0
- package/hooks/telemetry.sh +33 -0
- package/hooks/todo-prune.sh +84 -0
- package/hooks/unicode-firewall.sh +122 -0
- package/hooks/unicode-lib.sh +66 -0
- package/hooks/unicode-scan-session.sh +96 -0
- package/hooks/validate-command.sh +103 -0
- package/hooks/validate-env.sh +51 -0
- package/hooks/validate-path.sh +81 -0
- package/package.json +40 -0
- package/settings.json +6 -0
- package/templates/ai-config/tool-standards.md +56 -0
- package/templates/architecture/api-first.md +192 -0
- package/templates/architecture/auth-patterns.md +302 -0
- package/templates/architecture/caching-strategy.md +359 -0
- package/templates/architecture/database-patterns.md +347 -0
- package/templates/architecture/event-driven.md +252 -0
- package/templates/architecture/integration-patterns.md +185 -0
- package/templates/architecture/multi-tenancy.md +104 -0
- package/templates/architecture/service-boundaries.md +200 -0
- package/templates/build/brief-template.md +86 -0
- package/templates/build/summary-template.md +100 -0
- package/templates/build/task-plan-template.md +133 -0
- package/templates/communication/effort-estimate.md +54 -0
- package/templates/communication/incident-response.md +59 -0
- package/templates/communication/post-mortem.md +109 -0
- package/templates/communication/risk-register.md +43 -0
- package/templates/communication/sprint-demo-checklist.md +64 -0
- package/templates/communication/stakeholder-presentation-outline.md +84 -0
- package/templates/communication/technical-proposal.md +77 -0
- package/templates/delivery/deployment/deployment-checklist.md +49 -0
- package/templates/delivery/design/solution-design-checklist.md +37 -0
- package/templates/delivery/discovery/stakeholder-questions.md +33 -0
- package/templates/delivery/handover/knowledge-transfer-checklist.md +75 -0
- package/templates/delivery/handover/operational-runbook.md +117 -0
- package/templates/delivery/handover/support-escalation-matrix.md +56 -0
- package/templates/delivery/implementation/blocker-escalation-template.md +55 -0
- package/templates/delivery/implementation/sprint-planning-template.md +49 -0
- package/templates/delivery/implementation/task-decomposition-guide.md +59 -0
- package/templates/delivery/qa/test-plan-template.md +76 -0
- package/templates/delivery/qa/test-results-template.md +55 -0
- package/templates/delivery/qa/uat-signoff-template.md +44 -0
- package/templates/governance/codeowners.md +60 -0
- package/templates/integration/adapter-pattern.md +160 -0
- package/templates/scaffolds/env-validation.md +85 -0
- package/templates/scaffolds/error-handling.md +171 -0
- package/templates/scaffolds/graceful-shutdown.md +139 -0
- package/templates/scaffolds/health-check.md +109 -0
- package/templates/scaffolds/structured-logging.md +134 -0
- package/templates/standards/engineering-standards.md +413 -0
- package/templates/standards/standards-checklist.md +125 -0
- package/templates/tech-catalog.json +663 -0
- package/templates/utilities/project-detection.md +75 -0
- package/templates/utilities/requirements-collection.md +68 -0
- package/templates/utilities/template-rendering.md +81 -0
- package/templates/workflows/architecture-decision.md +90 -0
- package/templates/workflows/bug-investigation.md +83 -0
- package/templates/workflows/feature-implementation.md +80 -0
- package/templates/workflows/refactoring.md +83 -0
- package/templates/workflows/spike-exploration.md +82 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: unicode-scan
|
|
3
|
+
description: Scan project for dangerous invisible Unicode characters (Glassworm/Trojan Source defense)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are running a Unicode security scan on the current project directory.
|
|
7
|
+
|
|
8
|
+
## What to scan for
|
|
9
|
+
|
|
10
|
+
Use `perl -CSD` to scan all source code files in the project (skip .git, node_modules, vendor, dist, build, lock files, .agentops). Detect these dangerous invisible Unicode character categories:
|
|
11
|
+
|
|
12
|
+
1. **Zero-width / invisible chars**: U+200B–U+200F, U+2060–U+2064, U+FEFF (mid-file only)
|
|
13
|
+
2. **Bidi overrides (Trojan Source)**: U+202A–U+202E, U+2066–U+2069
|
|
14
|
+
3. **Variation selectors (Glassworm)**: U+FE00–U+FE0F
|
|
15
|
+
4. **Tag characters**: U+E0001–U+E007F
|
|
16
|
+
5. **Variation selectors supplement (Glassworm)**: U+E0100–U+E01EF
|
|
17
|
+
|
|
18
|
+
The perl detection pattern is:
|
|
19
|
+
```
|
|
20
|
+
/[\x{200B}-\x{200F}\x{2060}-\x{2064}\x{FEFF}\x{202A}-\x{202E}\x{2066}-\x{2069}\x{FE00}-\x{FE0F}\x{E0001}-\x{E007F}\x{E0100}-\x{E01EF}]/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Scan procedure
|
|
24
|
+
|
|
25
|
+
1. Run a find + perl scan across the project to identify all affected files
|
|
26
|
+
2. For each affected file, show:
|
|
27
|
+
- File path (relative to project root)
|
|
28
|
+
- Line numbers containing dangerous characters
|
|
29
|
+
- Character categories found (zero-width, bidi, variation selectors, tags)
|
|
30
|
+
- The visible context around the invisible characters (show 30 chars either side)
|
|
31
|
+
- A hex dump of the specific dangerous bytes found using: `perl -CSD -ne 'if (/[\x{200B}-\x{200F}\x{2060}-\x{2064}\x{FEFF}\x{202A}-\x{202E}\x{2066}-\x{2069}\x{FE00}-\x{FE0F}\x{E0001}-\x{E007F}\x{E0100}-\x{E01EF}]/) { while (/[\x{200B}-\x{200F}\x{2060}-\x{2064}\x{FEFF}\x{202A}-\x{202E}\x{2066}-\x{2069}\x{FE00}-\x{FE0F}\x{E0001}-\x{E007F}\x{E0100}-\x{E01EF}]/g) { printf " U+%04X at col %d\n", ord($&), pos($_) } }'`
|
|
32
|
+
3. Present a summary table
|
|
33
|
+
|
|
34
|
+
## After scanning
|
|
35
|
+
|
|
36
|
+
Present findings using this format:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
## Unicode Security Scan Results
|
|
40
|
+
|
|
41
|
+
**Status**: CLEAN | ⚠ FINDINGS
|
|
42
|
+
**Files scanned**: N
|
|
43
|
+
**Files flagged**: N
|
|
44
|
+
|
|
45
|
+
### Findings
|
|
46
|
+
|
|
47
|
+
| File | Line | Category | Codepoints |
|
|
48
|
+
|------|------|----------|------------|
|
|
49
|
+
| ... | ... | ... | ... |
|
|
50
|
+
|
|
51
|
+
### Detail
|
|
52
|
+
|
|
53
|
+
For each file, show the surrounding context and exact codepoints found.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If findings exist, ask the user: **"Would you like me to strip these dangerous characters? I will remove only the invisible Unicode — no visible content will change."**
|
|
57
|
+
|
|
58
|
+
If the user confirms, use `perl -CSD -pi -e` to strip the characters in-place:
|
|
59
|
+
```
|
|
60
|
+
perl -CSD -pi -e 's/[\x{200B}-\x{200F}\x{2060}-\x{2064}\x{FEFF}\x{202A}-\x{202E}\x{2066}-\x{2069}\x{FE00}-\x{FE0F}\x{E0001}-\x{E007F}\x{E0100}-\x{E01EF}]//g'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
After cleaning, re-run the scan to verify the files are now clean.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verify
|
|
3
|
+
description: Verify task completion against plan, tests, and compliance gates
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Verify that all work is complete and meets acceptance criteria.
|
|
7
|
+
|
|
8
|
+
## Process
|
|
9
|
+
|
|
10
|
+
1. **Read the plan** — load `tasks/todo.md` and identify the STAR Result criteria
|
|
11
|
+
2. **Check completeness** — are all items marked `- [x]`?
|
|
12
|
+
3. **Run tests** — execute the project's test suite
|
|
13
|
+
4. **Check regressions** — verify existing functionality still works
|
|
14
|
+
5. **Compliance gates:**
|
|
15
|
+
- Plan gate: plan exists if 3+ files modified
|
|
16
|
+
- Verification gate: all todo items checked
|
|
17
|
+
- Test gate: tests were run
|
|
18
|
+
6. **Report results** — summarize what passed and what needs attention
|
|
19
|
+
|
|
20
|
+
## Output Format
|
|
21
|
+
|
|
22
|
+
```markdown
|
|
23
|
+
## Verification Report
|
|
24
|
+
|
|
25
|
+
### Completion: X/Y items checked
|
|
26
|
+
- [x] Item 1
|
|
27
|
+
- [ ] Item 2 (INCOMPLETE)
|
|
28
|
+
|
|
29
|
+
### Tests: PASS/FAIL
|
|
30
|
+
- Test suite: [result]
|
|
31
|
+
- Regressions: [none found / details]
|
|
32
|
+
|
|
33
|
+
### Compliance Gates
|
|
34
|
+
| Gate | Status |
|
|
35
|
+
|------|--------|
|
|
36
|
+
| Plan | PASS |
|
|
37
|
+
| Verification | FAIL — 2 unchecked |
|
|
38
|
+
| Test | PASS |
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Arguments: $ARGUMENTS
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workflow
|
|
3
|
+
description: Workflow Mapper and Plan Executor - map workflows or execute structured plans
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow Mapper
|
|
7
|
+
|
|
8
|
+
You are an expert workflow mapping facilitator. You guide users through a structured process that supports two modes: **Workflow Mapping** (full 8-phase process producing Mermaid diagrams, structured YAML, narrative documentation, and AI-first automation recommendations) and **Plan Execution** (executing a structured plan from `tasks/todo.md`).
|
|
9
|
+
|
|
10
|
+
## Mode Selection
|
|
11
|
+
|
|
12
|
+
Before starting, determine the mode:
|
|
13
|
+
|
|
14
|
+
1. If `$ARGUMENTS` contains "execute" or "run", or if the user explicitly asks to execute a plan, go to **Plan Execution Mode**.
|
|
15
|
+
2. If `tasks/todo.md` exists and contains unchecked items (`- [ ]`), use `AskUserQuestion` to ask:
|
|
16
|
+
> "Found an existing plan in tasks/todo.md. What would you like to do?"
|
|
17
|
+
With options:
|
|
18
|
+
- **Execute the plan** — "Run through the tasks in tasks/todo.md"
|
|
19
|
+
- **Map a new workflow** — "I want to map out a workflow process"
|
|
20
|
+
3. Otherwise, proceed to **Workflow Mapping Mode**.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Plan Execution Mode
|
|
25
|
+
|
|
26
|
+
Execute the plan defined in `tasks/todo.md`:
|
|
27
|
+
|
|
28
|
+
1. Read `tasks/todo.md` and identify all unchecked items (`- [ ]`)
|
|
29
|
+
2. For each item, in dependency order:
|
|
30
|
+
a. Mark it as in-progress (change `- [ ]` to `- [~]`)
|
|
31
|
+
b. Execute the task
|
|
32
|
+
c. Verify the result (run tests, check output)
|
|
33
|
+
d. Mark complete (change `- [~]` to `- [x]`)
|
|
34
|
+
e. Write a brief summary of what was done
|
|
35
|
+
3. After all items complete, run full verification:
|
|
36
|
+
- Run test suite
|
|
37
|
+
- Check for regressions
|
|
38
|
+
- Verify against the STAR "Result" criteria in the plan
|
|
39
|
+
4. Update `tasks/todo.md` with a review section at the bottom
|
|
40
|
+
|
|
41
|
+
If any task fails, STOP and re-plan. Do not push forward on a broken foundation.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
# Workflow Mapping Mode
|
|
46
|
+
|
|
47
|
+
All workflow artifacts are stored in `./docs/workflows/{name}/` where `{name}` is either provided as `$ARGUMENTS` (kebab-cased) or auto-generated from the workflow description.
|
|
48
|
+
|
|
49
|
+
## Storage
|
|
50
|
+
|
|
51
|
+
You will create and maintain these files during the process:
|
|
52
|
+
|
|
53
|
+
### Core Files
|
|
54
|
+
1. `./docs/workflows/{name}/brief.md` — The workflow scope and objectives.
|
|
55
|
+
2. `./docs/workflows/{name}/interrogation.md` — Running log of every question and answer, organized by phase and round.
|
|
56
|
+
3. `./docs/workflows/{name}/state.yaml` — Session state for resumability.
|
|
57
|
+
|
|
58
|
+
### Artifact Files (generated progressively)
|
|
59
|
+
4. `./docs/workflows/{name}/workflow.yaml` — Structured workflow schema (actors, steps, decisions, automation scores).
|
|
60
|
+
5. `./docs/workflows/{name}/diagrams/flowchart-as-is.md` — Mermaid flowchart of current-state process.
|
|
61
|
+
6. `./docs/workflows/{name}/diagrams/swimlane-as-is.md` — Mermaid swimlane diagram of current-state process.
|
|
62
|
+
7. `./docs/workflows/{name}/diagrams/state-as-is.md` — Mermaid state diagram of current-state process.
|
|
63
|
+
8. `./docs/workflows/{name}/diagrams/flowchart-to-be.md` — Mermaid flowchart of future-state process.
|
|
64
|
+
9. `./docs/workflows/{name}/diagrams/swimlane-to-be.md` — Mermaid swimlane diagram of future-state process.
|
|
65
|
+
10. `./docs/workflows/{name}/diagrams/state-to-be.md` — Mermaid state diagram of future-state process.
|
|
66
|
+
11. `./docs/workflows/{name}/narrative.md` — Full written narrative describing the workflow.
|
|
67
|
+
12. `./docs/workflows/{name}/implementation.md` — Phased implementation plan with tool recommendations.
|
|
68
|
+
|
|
69
|
+
Create the directory structure and `state.yaml` as soon as you have the workflow name.
|
|
70
|
+
|
|
71
|
+
## Resume Detection
|
|
72
|
+
|
|
73
|
+
Before starting, check if this is a resumption:
|
|
74
|
+
|
|
75
|
+
1. If `$ARGUMENTS` is provided, check if `./docs/workflows/{arguments}/state.yaml` exists.
|
|
76
|
+
2. If `state.yaml` exists: read it, summarize progress to the user, and use `AskUserQuestion` to ask:
|
|
77
|
+
> "Found an existing workflow mapping session. How would you like to proceed?"
|
|
78
|
+
With options:
|
|
79
|
+
- **Continue** — "Resume from where we left off (Phase {current_phase})."
|
|
80
|
+
- **Restart** — "Start fresh — discard previous progress."
|
|
81
|
+
3. If `state.yaml` is missing but artifact files exist, infer the phase from file presence and offer to continue.
|
|
82
|
+
4. If nothing exists, start fresh from Phase 0.
|
|
83
|
+
|
|
84
|
+
When resuming, read all existing artifacts to rebuild context before continuing the interrupted phase.
|
|
85
|
+
|
|
86
|
+
## State Tracking
|
|
87
|
+
|
|
88
|
+
After completing each phase, update `state.yaml`:
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
workflow_name: string
|
|
92
|
+
slug: string
|
|
93
|
+
current_phase: 0-8
|
|
94
|
+
completed_phases: []
|
|
95
|
+
started_at: datetime
|
|
96
|
+
last_updated: datetime
|
|
97
|
+
interrogation_source: string | null
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Save state after every phase completion and after every Q&A round within a phase.
|
|
101
|
+
|
|
102
|
+
## Phase 0: Discovery Integration
|
|
103
|
+
|
|
104
|
+
Before mapping begins, check for prior interrogation work:
|
|
105
|
+
|
|
106
|
+
1. Search `./docs/interrogation/` for directories whose brief matches the workflow topic.
|
|
107
|
+
2. If a matching interrogation is found:
|
|
108
|
+
- Read the `brief.md`, `interrogation.md`, and `plan.md` from that interrogation.
|
|
109
|
+
- Extract key entities: actors, systems, triggers, data flows, constraints.
|
|
110
|
+
- Inform the user: *"Found existing interrogation at ./docs/interrogation/{match}/. Using this as context for the workflow mapping."*
|
|
111
|
+
- Record the path in `state.yaml` as `interrogation_source`.
|
|
112
|
+
- Use the extracted context to pre-populate questions and skip redundant discovery.
|
|
113
|
+
3. If no matching interrogation is found:
|
|
114
|
+
- Inform the user: *"No prior interrogation found for this topic. Running discovery phase to gather context before workflow mapping."*
|
|
115
|
+
- Run the `/interrogate` command scoped to workflow mapping concerns. Wait for it to complete before proceeding.
|
|
116
|
+
- Once interrogation is complete, read its output and extract entities as in step 2.
|
|
117
|
+
|
|
118
|
+
## Phase 1: Scope & Objectives
|
|
119
|
+
|
|
120
|
+
**Goal:** Define what workflow we're mapping, why, and its boundaries.
|
|
121
|
+
|
|
122
|
+
Use `AskUserQuestion` to ask questions covering:
|
|
123
|
+
- What is the workflow being mapped? Describe it in a sentence.
|
|
124
|
+
- Why are we mapping this workflow? What's the goal? (Efficiency? Compliance? Automation? All of the above?)
|
|
125
|
+
- What triggers this workflow? (Event, schedule, request, condition?)
|
|
126
|
+
- Where does the workflow start and end?
|
|
127
|
+
- What does success look like for this workflow?
|
|
128
|
+
- What is the goal of automating or improving this workflow?
|
|
129
|
+
- Are there any known constraints? (Compliance, budget, tools, timeline?)
|
|
130
|
+
|
|
131
|
+
Ask 4-6 questions per round. Push back on vague answers — demand specifics.
|
|
132
|
+
|
|
133
|
+
**After this phase:**
|
|
134
|
+
- Create `brief.md` with the scope and objectives.
|
|
135
|
+
- Initialize `workflow.yaml` with:
|
|
136
|
+
```yaml
|
|
137
|
+
workflow:
|
|
138
|
+
name: string
|
|
139
|
+
description: string
|
|
140
|
+
version: "1.0"
|
|
141
|
+
created: datetime
|
|
142
|
+
triggers: []
|
|
143
|
+
actors: []
|
|
144
|
+
steps: []
|
|
145
|
+
slas: []
|
|
146
|
+
exceptions: []
|
|
147
|
+
kpis: []
|
|
148
|
+
```
|
|
149
|
+
- Update `state.yaml` with `current_phase: 2, completed_phases: [1]`.
|
|
150
|
+
|
|
151
|
+
## Phase 2: Stakeholder & Actor Mapping
|
|
152
|
+
|
|
153
|
+
**Goal:** Identify every person, role, department, and system involved.
|
|
154
|
+
|
|
155
|
+
Use `AskUserQuestion` to ask questions covering:
|
|
156
|
+
- Who is involved in this workflow? List every role, person, or department.
|
|
157
|
+
- What systems or tools are used at any point? (Software, platforms, databases, APIs, manual tools?)
|
|
158
|
+
- Who initiates the workflow?
|
|
159
|
+
- Who approves or signs off at decision points?
|
|
160
|
+
- Who is affected by the workflow's output?
|
|
161
|
+
- Are there external parties involved? (Vendors, customers, regulators?)
|
|
162
|
+
- Who owns this workflow? Who is accountable for its performance?
|
|
163
|
+
|
|
164
|
+
**After this phase:**
|
|
165
|
+
- Populate the `actors` array in `workflow.yaml`:
|
|
166
|
+
```yaml
|
|
167
|
+
actors:
|
|
168
|
+
- id: actor-slug
|
|
169
|
+
name: string
|
|
170
|
+
role: string
|
|
171
|
+
department: string
|
|
172
|
+
type: human | system | external
|
|
173
|
+
```
|
|
174
|
+
- Append Q&A to `interrogation.md`.
|
|
175
|
+
- Update `state.yaml`.
|
|
176
|
+
|
|
177
|
+
## Phase 3: Current-State (As-Is) Mapping
|
|
178
|
+
|
|
179
|
+
**Goal:** Map every step of the workflow as it exists today.
|
|
180
|
+
|
|
181
|
+
This is the most detailed phase. Walk through the workflow step by step.
|
|
182
|
+
|
|
183
|
+
Use `AskUserQuestion` to walk through each step:
|
|
184
|
+
- What happens first? Describe the very first action.
|
|
185
|
+
- Who performs this step? Which system is used?
|
|
186
|
+
- What data or information is needed as input?
|
|
187
|
+
- What is produced as output?
|
|
188
|
+
- How long does this step typically take?
|
|
189
|
+
- What happens next? Are there any decision points?
|
|
190
|
+
- If there's a decision, what are the possible paths?
|
|
191
|
+
- Are there any handoffs between people or systems?
|
|
192
|
+
- Continue until the user confirms we've reached the end of the workflow.
|
|
193
|
+
|
|
194
|
+
For each step, ask about exceptions: *"What happens when this step fails or goes wrong?"*
|
|
195
|
+
|
|
196
|
+
**After this phase:**
|
|
197
|
+
- Populate the `steps` array in `workflow.yaml`:
|
|
198
|
+
```yaml
|
|
199
|
+
steps:
|
|
200
|
+
- id: step-slug
|
|
201
|
+
name: string
|
|
202
|
+
description: string
|
|
203
|
+
actor: actor-id
|
|
204
|
+
system: string | null
|
|
205
|
+
inputs:
|
|
206
|
+
- name: string
|
|
207
|
+
source: string
|
|
208
|
+
type: string
|
|
209
|
+
outputs:
|
|
210
|
+
- name: string
|
|
211
|
+
destination: string
|
|
212
|
+
type: string
|
|
213
|
+
decisions:
|
|
214
|
+
- condition: string
|
|
215
|
+
true_branch: step-id
|
|
216
|
+
false_branch: step-id
|
|
217
|
+
duration: string
|
|
218
|
+
pain_points: []
|
|
219
|
+
automation_score: null
|
|
220
|
+
automation_recommendation: null
|
|
221
|
+
```
|
|
222
|
+
- Populate `exceptions` in `workflow.yaml`.
|
|
223
|
+
- Generate **as-is diagrams** in `./docs/workflows/{name}/diagrams/`:
|
|
224
|
+
- `flowchart-as-is.md` — `graph TD` with steps, decisions, start/end nodes.
|
|
225
|
+
- `swimlane-as-is.md` — `graph TD` with `subgraph` blocks per actor/department.
|
|
226
|
+
- `state-as-is.md` — `stateDiagram-v2` with workflow states and transitions.
|
|
227
|
+
- Update `state.yaml`.
|
|
228
|
+
|
|
229
|
+
### Mermaid Diagram Guidelines
|
|
230
|
+
- Keep node labels concise (max 5-6 words).
|
|
231
|
+
- Use meaningful node IDs derived from step IDs.
|
|
232
|
+
- Use decision diamonds (`{}`) for branching logic.
|
|
233
|
+
- Color-code: green for start, red for end, yellow for decision points using `style` directives.
|
|
234
|
+
- For swimlanes, group steps by actor using `subgraph "Actor Name"`.
|
|
235
|
+
- Add edge labels for decision conditions.
|
|
236
|
+
|
|
237
|
+
## Phase 4: Pain Point & Bottleneck Identification
|
|
238
|
+
|
|
239
|
+
**Goal:** Identify where the current workflow breaks down, causes delays, or creates frustration.
|
|
240
|
+
|
|
241
|
+
Use `AskUserQuestion` to ask about each major step/area:
|
|
242
|
+
- Where are the biggest delays in this workflow?
|
|
243
|
+
- Which steps are purely manual that feel like they shouldn't be?
|
|
244
|
+
- Where do errors or mistakes happen most often?
|
|
245
|
+
- Are there any bottlenecks — steps where work piles up waiting?
|
|
246
|
+
- What's the most frustrating part of this workflow for the people involved?
|
|
247
|
+
- Are there any compliance or audit risks in the current process?
|
|
248
|
+
- Where is data re-entered, duplicated, or lost?
|
|
249
|
+
- What steps have the most variance in how long they take?
|
|
250
|
+
|
|
251
|
+
**After this phase:**
|
|
252
|
+
- Add `pain_points` to each relevant step in `workflow.yaml`.
|
|
253
|
+
- Update diagrams with pain point annotations (add `:::painPoint` class and style it red/orange).
|
|
254
|
+
- Append Q&A to `interrogation.md`.
|
|
255
|
+
- Update `state.yaml`.
|
|
256
|
+
|
|
257
|
+
## Phase 5: Automation Opportunity Assessment
|
|
258
|
+
|
|
259
|
+
**Goal:** Score each pain point and step for automation potential.
|
|
260
|
+
|
|
261
|
+
For each pain point or manual step identified, use `AskUserQuestion` to discuss:
|
|
262
|
+
- Could this step be automated? Fully or partially?
|
|
263
|
+
- What would the impact be if this step were automated? (Time saved, errors reduced, cost saved?)
|
|
264
|
+
- How feasible is automation here? (Technical complexity, data availability, integration difficulty?)
|
|
265
|
+
- What are the risks of automating this step? (Quality, compliance, edge cases?)
|
|
266
|
+
- Is there an AI/LLM approach that could handle this? (Document processing, decision support, data extraction, generation?)
|
|
267
|
+
|
|
268
|
+
**After this phase:**
|
|
269
|
+
- Add `automation_score` to each assessed step in `workflow.yaml`:
|
|
270
|
+
```yaml
|
|
271
|
+
automation_score:
|
|
272
|
+
impact: 1-5 # 1=minimal, 5=transformative
|
|
273
|
+
feasibility: 1-5 # 1=very hard, 5=straightforward
|
|
274
|
+
```
|
|
275
|
+
- Present a summary matrix to the user: steps ranked by impact x feasibility.
|
|
276
|
+
- Identify quick wins (high impact + high feasibility) vs. strategic investments (high impact + lower feasibility).
|
|
277
|
+
- Append Q&A to `interrogation.md`.
|
|
278
|
+
- Update `state.yaml`.
|
|
279
|
+
|
|
280
|
+
## Phase 6: Future-State (To-Be) Design
|
|
281
|
+
|
|
282
|
+
**Goal:** Design the improved workflow with automation and AI integration.
|
|
283
|
+
|
|
284
|
+
Using the automation assessment, use `AskUserQuestion` to discuss:
|
|
285
|
+
- For each high-scoring automation opportunity: what does the automated version look like?
|
|
286
|
+
- Which steps are fully automated (no human)? Which are AI-augmented (human + AI)? Which stay manual?
|
|
287
|
+
- What new steps are needed? (e.g., review/approval of AI output, exception handling?)
|
|
288
|
+
- What's the human role in the new workflow? Where do humans add the most value?
|
|
289
|
+
- How does data flow change in the new process?
|
|
290
|
+
- What monitoring or oversight is needed for automated steps?
|
|
291
|
+
|
|
292
|
+
**After this phase:**
|
|
293
|
+
- Add a `future_state` section to `workflow.yaml` with the redesigned steps.
|
|
294
|
+
- Generate **to-be diagrams** in `./docs/workflows/{name}/diagrams/`:
|
|
295
|
+
- `flowchart-to-be.md` — future-state flowchart.
|
|
296
|
+
- `swimlane-to-be.md` — future-state swimlane (new actors for AI/automation).
|
|
297
|
+
- `state-to-be.md` — future-state state diagram.
|
|
298
|
+
- Color-code automated steps green, AI-augmented steps blue, manual steps default in to-be diagrams.
|
|
299
|
+
- Append Q&A to `interrogation.md`.
|
|
300
|
+
- Update `state.yaml`.
|
|
301
|
+
|
|
302
|
+
## Phase 7: Tool & Stack Recommendations
|
|
303
|
+
|
|
304
|
+
**Goal:** Recommend specific tools and technologies for each automation opportunity.
|
|
305
|
+
|
|
306
|
+
First, use `AskUserQuestion` to confirm constraints:
|
|
307
|
+
- What is the budget range for tooling? (Free/open-source only? SMB budget? Enterprise?)
|
|
308
|
+
- What tools or platforms are already in use that we must integrate with?
|
|
309
|
+
- Are there any compliance requirements that restrict tool choices? (SOC2, HIPAA, GDPR, on-prem only?)
|
|
310
|
+
- What is the team's technical capability? (No-code preferred? Can handle custom development?)
|
|
311
|
+
- Are there any tools already under consideration or ruled out?
|
|
312
|
+
|
|
313
|
+
Then, for each automation opportunity, recommend tools using an **AI-first** approach:
|
|
314
|
+
- **AI/LLM-powered solutions first** — Where an LLM, AI agent, or AI-powered tool could handle the task.
|
|
315
|
+
- **No-code/low-code second** — Where platforms like Zapier, Make, n8n, Retool, or similar can automate without custom code.
|
|
316
|
+
- **Custom development third** — Where a bespoke solution is warranted.
|
|
317
|
+
|
|
318
|
+
For each recommendation, provide:
|
|
319
|
+
- Tool/approach name
|
|
320
|
+
- Why this fits (rationale tied to the specific step and pain point)
|
|
321
|
+
- Estimated effort to implement
|
|
322
|
+
- Pros and cons
|
|
323
|
+
- Alternatives considered
|
|
324
|
+
|
|
325
|
+
**After this phase:**
|
|
326
|
+
- Add `automation_recommendation` to each step in `workflow.yaml`:
|
|
327
|
+
```yaml
|
|
328
|
+
automation_recommendation:
|
|
329
|
+
approach: ai | no-code | custom | hybrid
|
|
330
|
+
tool: string
|
|
331
|
+
rationale: string
|
|
332
|
+
effort: string
|
|
333
|
+
alternatives: [string]
|
|
334
|
+
```
|
|
335
|
+
- Begin writing `implementation.md` with tool recommendations section.
|
|
336
|
+
- Append Q&A to `interrogation.md`.
|
|
337
|
+
- Update `state.yaml`.
|
|
338
|
+
|
|
339
|
+
## Phase 8: Implementation Plan
|
|
340
|
+
|
|
341
|
+
**Goal:** Create a phased rollout plan to get from as-is to to-be.
|
|
342
|
+
|
|
343
|
+
Use `AskUserQuestion` to discuss:
|
|
344
|
+
- What are the top priorities? What should be automated first?
|
|
345
|
+
- Are there quick wins we can deliver in the first 1-2 weeks?
|
|
346
|
+
- What are the dependencies between automation changes?
|
|
347
|
+
- Who will own implementation of each phase?
|
|
348
|
+
- What are the risks of the transition? How do we mitigate them?
|
|
349
|
+
- How do we measure success? What KPIs should we track?
|
|
350
|
+
- What does the rollback plan look like if something goes wrong?
|
|
351
|
+
- What training or change management is needed?
|
|
352
|
+
|
|
353
|
+
**After this phase:**
|
|
354
|
+
- Complete `implementation.md` with:
|
|
355
|
+
|
|
356
|
+
### Structure of implementation.md:
|
|
357
|
+
```
|
|
358
|
+
# Implementation Plan: {workflow name}
|
|
359
|
+
|
|
360
|
+
## Executive Summary
|
|
361
|
+
One-paragraph overview of the transformation.
|
|
362
|
+
|
|
363
|
+
## Phase 1: Quick Wins (Week 1-2)
|
|
364
|
+
- What changes
|
|
365
|
+
- Tools needed
|
|
366
|
+
- Effort estimate
|
|
367
|
+
- Dependencies
|
|
368
|
+
- Risks & mitigations
|
|
369
|
+
- Success criteria
|
|
370
|
+
|
|
371
|
+
## Phase 2: Medium-Term Improvements (Week 3-6)
|
|
372
|
+
[Same structure]
|
|
373
|
+
|
|
374
|
+
## Phase 3: Strategic Automation (Month 2-3+)
|
|
375
|
+
[Same structure]
|
|
376
|
+
|
|
377
|
+
## KPIs & Success Metrics
|
|
378
|
+
| Metric | Current | Target | How Measured |
|
|
379
|
+
|--------|---------|--------|--------------|
|
|
380
|
+
|
|
381
|
+
## Risk Register
|
|
382
|
+
| Risk | Likelihood | Impact | Mitigation |
|
|
383
|
+
|------|-----------|--------|------------|
|
|
384
|
+
|
|
385
|
+
## Change Management
|
|
386
|
+
- Training requirements
|
|
387
|
+
- Communication plan
|
|
388
|
+
- Stakeholder buy-in steps
|
|
389
|
+
|
|
390
|
+
## Tool & Stack Summary
|
|
391
|
+
| Step | Current | Proposed | Approach |
|
|
392
|
+
|------|---------|----------|----------|
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
- Populate `slas` and `kpis` in `workflow.yaml`.
|
|
396
|
+
- Generate the complete `narrative.md` with sections:
|
|
397
|
+
- Overview
|
|
398
|
+
- Actors & Stakeholders
|
|
399
|
+
- Current Process Flow
|
|
400
|
+
- Pain Points & Bottlenecks
|
|
401
|
+
- Automation Opportunities
|
|
402
|
+
- Future-State Design
|
|
403
|
+
- Tool Recommendations
|
|
404
|
+
- Implementation Roadmap
|
|
405
|
+
- Update `state.yaml` with `current_phase: complete, completed_phases: [1,2,3,4,5,6,7,8]`.
|
|
406
|
+
|
|
407
|
+
## Final Deliverable Summary
|
|
408
|
+
|
|
409
|
+
Present the user with a summary of all generated artifacts:
|
|
410
|
+
|
|
411
|
+
> **Workflow mapping complete.** Here's what was produced:
|
|
412
|
+
>
|
|
413
|
+
> - `brief.md` — Scope and objectives
|
|
414
|
+
> - `workflow.yaml` — Structured workflow data (actors, steps, decisions, automation scores)
|
|
415
|
+
> - `diagrams/` — 6 Mermaid diagrams (as-is and to-be: flowchart, swimlane, state)
|
|
416
|
+
> - `narrative.md` — Full written narrative
|
|
417
|
+
> - `implementation.md` — Phased implementation plan with tool recommendations
|
|
418
|
+
> - `interrogation.md` — Complete Q&A log
|
|
419
|
+
>
|
|
420
|
+
> All files are in `./docs/workflows/{name}/`
|
|
421
|
+
|
|
422
|
+
## Rules
|
|
423
|
+
|
|
424
|
+
- Always use the `AskUserQuestion` tool for all user interaction — never just print questions as plain text.
|
|
425
|
+
- Ask 3-6 questions per round. Batch questions well to keep the session moving.
|
|
426
|
+
- Push back on vague answers. *"It depends"* is not a workflow step. *"Someone handles it"* is not an actor. Demand specifics.
|
|
427
|
+
- After each Q&A round, append to `interrogation.md` with the phase number and round.
|
|
428
|
+
- Update `state.yaml` after every phase and after significant progress within a phase.
|
|
429
|
+
- Generate diagrams as soon as you have enough data (after Phase 3 for as-is, after Phase 6 for to-be).
|
|
430
|
+
- AI-first recommendations must be substantive and specific — not generic lists. Tie each recommendation to the specific step, pain point, and context of this workflow.
|
|
431
|
+
- Keep Mermaid diagrams clean and readable. Split complex workflows into multiple focused diagrams if needed.
|
|
432
|
+
- The goal is a complete, actionable workflow mapping that a client could immediately use to plan their automation journey.
|
|
433
|
+
- Target session completion in 60-90 minutes across all 8 phases.
|
|
434
|
+
- All artifacts should be professional quality suitable for client presentation or screen-share demo.
|
|
435
|
+
|
|
436
|
+
Arguments: $ARGUMENTS
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -uo pipefail
|
|
3
|
+
# AI guardrails hook — detects common AI-assisted development pitfalls.
|
|
4
|
+
# PostToolUse on Write/Edit. Non-blocking: additionalContext guidance only.
|
|
5
|
+
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
source "${SCRIPT_DIR}/feature-flags.sh"
|
|
8
|
+
|
|
9
|
+
INPUT=$(cat) || exit 0
|
|
10
|
+
|
|
11
|
+
# Check feature flag
|
|
12
|
+
agentops_enterprise_enabled "ai_workflows" || exit 0
|
|
13
|
+
|
|
14
|
+
TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
|
|
15
|
+
[ -z "$TOOL" ] && exit 0
|
|
16
|
+
|
|
17
|
+
# Only process Write and Edit
|
|
18
|
+
case "$TOOL" in
|
|
19
|
+
Write|Edit) ;;
|
|
20
|
+
*) exit 0 ;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
|
|
24
|
+
[ -z "$FILE_PATH" ] && exit 0
|
|
25
|
+
|
|
26
|
+
# Get content for Write operations
|
|
27
|
+
CONTENT=""
|
|
28
|
+
if [ "$TOOL" = "Write" ]; then
|
|
29
|
+
CONTENT=$(echo "$INPUT" | jq -r '.tool_input.content // empty' 2>/dev/null)
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
FILENAME=$(basename "$FILE_PATH")
|
|
33
|
+
EXTENSION="${FILENAME##*.}"
|
|
34
|
+
DIR=$(dirname "$FILE_PATH")
|
|
35
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd // "."' 2>/dev/null)
|
|
36
|
+
|
|
37
|
+
MESSAGES=()
|
|
38
|
+
|
|
39
|
+
# ── Detector 1: Untested Generated Code ──────────────────────────────────────
|
|
40
|
+
# When a new source file is created, check if a test file exists
|
|
41
|
+
|
|
42
|
+
if [ "$TOOL" = "Write" ]; then
|
|
43
|
+
# Only check source code files
|
|
44
|
+
if echo "$EXTENSION" | grep -qE '^(ts|tsx|js|jsx)$'; then
|
|
45
|
+
# Skip test files, config files, type declarations
|
|
46
|
+
if ! echo "$FILENAME" | grep -qE '\.(test|spec|stories|config|d)\.(ts|tsx|js|jsx)$' && \
|
|
47
|
+
! echo "$FILENAME" | grep -qE '^(index|env|next-env|jest|vitest|playwright|eslint|prettier)'; then
|
|
48
|
+
# Check if a test file exists
|
|
49
|
+
BASENAME="${FILENAME%.*}"
|
|
50
|
+
TEST_EXISTS=false
|
|
51
|
+
for TEST_SUFFIX in ".test.ts" ".test.tsx" ".spec.ts" ".spec.tsx" ".test.js" ".test.jsx"; do
|
|
52
|
+
if [ -f "${DIR}/${BASENAME}${TEST_SUFFIX}" ] || \
|
|
53
|
+
[ -f "${DIR}/__tests__/${BASENAME}${TEST_SUFFIX}" ]; then
|
|
54
|
+
TEST_EXISTS=true
|
|
55
|
+
break
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
if [ "$TEST_EXISTS" = "false" ]; then
|
|
59
|
+
MESSAGES+=("New source file '${FILENAME}' has no corresponding test. Consider adding '${BASENAME}.test.${EXTENSION}'.")
|
|
60
|
+
fi
|
|
61
|
+
fi
|
|
62
|
+
fi
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
# ── Detector 2: Generic Placeholders ─────────────────────────────────────────
|
|
66
|
+
# Flag TODO, FIXME, placeholder values in written content
|
|
67
|
+
|
|
68
|
+
if [ -n "$CONTENT" ]; then
|
|
69
|
+
PLACEHOLDER_COUNT=0
|
|
70
|
+
|
|
71
|
+
# Count generic placeholders
|
|
72
|
+
if echo "$CONTENT" | grep -qiE '\bTODO\b'; then
|
|
73
|
+
PLACEHOLDER_COUNT=$((PLACEHOLDER_COUNT + 1))
|
|
74
|
+
fi
|
|
75
|
+
if echo "$CONTENT" | grep -qiE '\bFIXME\b'; then
|
|
76
|
+
PLACEHOLDER_COUNT=$((PLACEHOLDER_COUNT + 1))
|
|
77
|
+
fi
|
|
78
|
+
if echo "$CONTENT" | grep -qiE '\blorem ipsum\b'; then
|
|
79
|
+
PLACEHOLDER_COUNT=$((PLACEHOLDER_COUNT + 1))
|
|
80
|
+
fi
|
|
81
|
+
if echo "$CONTENT" | grep -qE 'example\.com|your-api-key|changeme|password123|REPLACE_ME'; then
|
|
82
|
+
PLACEHOLDER_COUNT=$((PLACEHOLDER_COUNT + 1))
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
if [ "$PLACEHOLDER_COUNT" -ge 2 ]; then
|
|
86
|
+
MESSAGES+=("This file contains ${PLACEHOLDER_COUNT} generic placeholders (TODO, FIXME, example values). Verify all values are project-specific before committing.")
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# ── Detector 3: Hallucinated Dependencies (package.json) ────────────────────
|
|
91
|
+
# When package.json is modified, flag for verification
|
|
92
|
+
|
|
93
|
+
if [ "$FILENAME" = "package.json" ] && [ "$TOOL" = "Write" ]; then
|
|
94
|
+
MESSAGES+=("package.json was written. Verify all dependencies exist on npm before running install. Run 'npm info <package>' for any unfamiliar packages.")
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# ── Detector 4: Large Unstructured Files ─────────────────────────────────────
|
|
98
|
+
# Flag files that are suspiciously large for a single write (may indicate copy-paste)
|
|
99
|
+
|
|
100
|
+
if [ "$TOOL" = "Write" ] && [ -n "$CONTENT" ]; then
|
|
101
|
+
LINE_COUNT=$(echo "$CONTENT" | wc -l | tr -d ' ')
|
|
102
|
+
if [ "$LINE_COUNT" -gt 300 ]; then
|
|
103
|
+
MESSAGES+=("This file is ${LINE_COUNT} lines — unusually large for a single write. Consider breaking into smaller, focused modules.")
|
|
104
|
+
fi
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# ── Output ───────────────────────────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
if [ ${#MESSAGES[@]} -gt 0 ]; then
|
|
110
|
+
GUIDANCE=$(printf "AI Guardrails: %s" "$(IFS='; '; echo "${MESSAGES[*]}")")
|
|
111
|
+
jq -nc --arg msg "$GUIDANCE" '{additionalContext: $msg}'
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
exit 0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -uo pipefail
|
|
3
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
4
|
+
source "${SCRIPT_DIR}/feature-flags.sh"
|
|
5
|
+
|
|
6
|
+
INPUT=$(cat) || exit 0
|
|
7
|
+
LOG_DIR="${CLAUDE_PROJECT_DIR:-.}/.agentops"
|
|
8
|
+
LOG_FILE="$LOG_DIR/audit.jsonl"
|
|
9
|
+
mkdir -p "$LOG_DIR" 2>/dev/null
|
|
10
|
+
|
|
11
|
+
TS=$(date -u +%FT%TZ)
|
|
12
|
+
SESSION=$(echo "$INPUT" | jq -r '.session_id // "unknown"' 2>/dev/null) || SESSION="unknown"
|
|
13
|
+
EVENT=$(echo "$INPUT" | jq -r '.hook_event_name // "unknown"' 2>/dev/null) || EVENT="unknown"
|
|
14
|
+
TOOL=$(echo "$INPUT" | jq -r '.tool_name // ""' 2>/dev/null) || TOOL=""
|
|
15
|
+
TOOL_INPUT=$(echo "$INPUT" | jq -r '.tool_input // {} | tostring | .[:500]' 2>/dev/null) || TOOL_INPUT="{}"
|
|
16
|
+
|
|
17
|
+
# Redact secrets using canonical shared function
|
|
18
|
+
TOOL_INPUT=$(echo "$TOOL_INPUT" | agentops_redact)
|
|
19
|
+
|
|
20
|
+
jq -nc \
|
|
21
|
+
--arg ts "$TS" \
|
|
22
|
+
--arg session "$SESSION" \
|
|
23
|
+
--arg event "$EVENT" \
|
|
24
|
+
--arg tool "$TOOL" \
|
|
25
|
+
--arg input "$TOOL_INPUT" \
|
|
26
|
+
'{ts:$ts, session:$session, event:$event, tool:$tool, input:$input}' >> "$LOG_FILE" 2>/dev/null || true
|