@tanagram/cli 0.3.0 → 0.3.1

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/commands/run.go CHANGED
@@ -16,6 +16,7 @@ import (
16
16
  "github.com/tanagram/cli/parser"
17
17
  "github.com/tanagram/cli/snapshot"
18
18
  "github.com/tanagram/cli/storage"
19
+ "github.com/tanagram/cli/utils"
19
20
  )
20
21
 
21
22
  // spinner shows a simple spinner animation
@@ -275,26 +276,31 @@ func Run() error {
275
276
 
276
277
  // Track policy check results (similar to policy.execute.result in github-app)
277
278
  metrics.Track("cli.policy.check.result", map[string]interface{}{
278
- "policies_checked": len(policies),
279
- "changes_checked": len(changesToCheck),
280
- "violations_found": len(result.Violations),
281
- "has_violations": len(result.Violations) > 0,
282
- "duration_seconds": checkDuration.Seconds(),
283
- "used_snapshot": useSnapshot,
279
+ "policies_checked": len(policies),
280
+ "changes_checked": len(changesToCheck),
281
+ "violations_found": len(result.Violations),
282
+ "has_violations": len(result.Violations) > 0,
283
+ "duration_seconds": checkDuration.Seconds(),
284
+ "used_snapshot": useSnapshot,
284
285
  })
285
286
 
286
287
  // Handle results based on whether violations were found
287
288
  if len(result.Violations) > 0 {
288
- // Format and output violations to stderr
289
- violationOutput := checker.FormatViolations(result)
290
- fmt.Fprint(os.Stderr, violationOutput)
289
+ // Determine parent process to decide output format
290
+ parentProcess := utils.GetParentProcess()
291
291
 
292
- // Format and output Claude-friendly instructions to stderr
293
- claudeInstructions := checker.FormatClaudeInstructions(result)
294
- fmt.Fprint(os.Stderr, claudeInstructions)
292
+ if parentProcess == "claude" {
293
+ // Format and output Claude-friendly instructions to stderr
294
+ claudeInstructions := checker.FormatClaudeInstructions(result)
295
+ fmt.Fprint(os.Stderr, claudeInstructions)
295
296
 
296
- // Exit with code 2 to trigger Claude Code hook behavior
297
- os.Exit(2)
297
+ // Exit with code 2 to trigger Claude Code hook behavior
298
+ os.Exit(2)
299
+ } else {
300
+ // Format and output violations to stderr
301
+ violationOutput := checker.FormatViolations(result)
302
+ fmt.Fprint(os.Stderr, violationOutput)
303
+ }
298
304
  }
299
305
 
300
306
  // No violations found - output success message
@@ -7,7 +7,7 @@ import (
7
7
  "time"
8
8
 
9
9
  "github.com/posthog/posthog-go"
10
- "github.com/shirou/gopsutil/v3/process"
10
+ "github.com/tanagram/cli/utils"
11
11
  )
12
12
 
13
13
  var (
@@ -85,7 +85,7 @@ func Track(event string, properties map[string]interface{}) {
85
85
  properties["os_user"] = getUser()
86
86
  properties["hostname"] = getHostname()
87
87
  properties["cwd"] = getCwd()
88
- properties["parent_process"] = getParentProcess()
88
+ properties["parent_process"] = utils.GetParentProcess()
89
89
 
90
90
  // Build properties - include all custom properties from the caller
91
91
  props := posthog.NewProperties()
@@ -144,16 +144,4 @@ func getVersion() string {
144
144
  return version
145
145
  }
146
146
 
147
- // getParentProcess returns the name of the parent process
148
- func getParentProcess() string {
149
- parentPID := int32(os.Getppid())
150
- parent, err := process.NewProcess(parentPID)
151
- if err != nil {
152
- return "unknown"
153
- }
154
- name, err := parent.Name()
155
- if err != nil {
156
- return "unknown"
157
- }
158
- return name
159
- }
147
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanagram/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Tanagram - Catch sloppy code before it ships",
5
5
  "main": "index.js",
6
6
  "bin": {