context_spook 1.3.0 → 1.4.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.
- checksums.yaml +4 -4
- data/context_spook.gemspec +3 -3
- data/lib/context_spook/generator.rb +19 -0
- data/lib/context_spook/toon/example.md +69 -0
- data/lib/context_spook/toon.rb +13 -0
- data/lib/context_spook/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 48da6b99283d3e0b02730a5ef6c02d07726dca15c7d29d6e40b73cc5d1f11e37
|
|
4
|
+
data.tar.gz: 3c8f65d9f003f1c7053157beab50d95ff692852bca4c5efef83241c01ff2740c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3f0c9d83fc057968a95f74dff08f035908ea9e362e608007046919acc7e9e5d0e2d6cc7a4e9526d24ba8d50cc5ca8c450b8537c4b4d4dead1910b429806a5978
|
|
7
|
+
data.tar.gz: a6bea380021e97a6095c66418628e67cfa6afdcc1f85585a71d622d17355e5640f8cb64403c8eb196183753f260be40a20fc1c32dd7d39db1d24cae0f6518cbc
|
data/context_spook.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: context_spook 1.
|
|
2
|
+
# stub: context_spook 1.4.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "context_spook".freeze
|
|
6
|
-
s.version = "1.
|
|
6
|
+
s.version = "1.4.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["context_spook".freeze]
|
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/output_context.rb".freeze, "lib/context_spook/toon.rb".freeze, "lib/context_spook/utils.rb".freeze, "lib/context_spook/verbose_puts.rb".freeze, "lib/context_spook/version.rb".freeze]
|
|
16
|
-
s.files = [".contexts/project.rb".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "hello_world.json".freeze, "hey_world.yaml".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/output_context.rb".freeze, "lib/context_spook/toon.rb".freeze, "lib/context_spook/utils.rb".freeze, "lib/context_spook/verbose_puts.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/context_spook/toon_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
16
|
+
s.files = [".contexts/project.rb".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/context_spook".freeze, "context_spook.gemspec".freeze, "hello_world.json".freeze, "hey_world.yaml".freeze, "lib/context_spook.rb".freeze, "lib/context_spook/generator.rb".freeze, "lib/context_spook/output_context.rb".freeze, "lib/context_spook/toon.rb".freeze, "lib/context_spook/toon/example.md".freeze, "lib/context_spook/utils.rb".freeze, "lib/context_spook/verbose_puts.rb".freeze, "lib/context_spook/version.rb".freeze, "spec/context_spook/generator_spec.rb".freeze, "spec/context_spook/toon_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/context_spook".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "ContextSpook - context_spook collects project context for AI".freeze, "--main".freeze, "README.md".freeze]
|
|
@@ -56,8 +56,18 @@ module ContextSpook
|
|
|
56
56
|
include VerbosePuts
|
|
57
57
|
include OutputContext
|
|
58
58
|
|
|
59
|
+
# The verbose method returns the verbose flag indicating whether verbose
|
|
60
|
+
# output is enabled.
|
|
61
|
+
#
|
|
62
|
+
# @return [ TrueClass, FalseClass ] true if verbose output is enabled,
|
|
63
|
+
# false otherwise
|
|
59
64
|
attr_reader :verbose
|
|
60
65
|
|
|
66
|
+
# The format method returns the format identifier for the context output.
|
|
67
|
+
#
|
|
68
|
+
# @return [ String ] the format identifier, either 'JSON' or 'TOON'
|
|
69
|
+
attr_reader :format
|
|
70
|
+
|
|
61
71
|
private_class_method :new
|
|
62
72
|
|
|
63
73
|
# The initialize method sets up the object by evaluating the provided block
|
|
@@ -107,8 +117,17 @@ module ContextSpook
|
|
|
107
117
|
def initialize(generator:, &block)
|
|
108
118
|
@generator = generator
|
|
109
119
|
block and instance_eval(&block)
|
|
120
|
+
meta(format: generator.format)
|
|
121
|
+
if generator.format == 'TOON'
|
|
122
|
+
meta(toon_example: toon_example)
|
|
123
|
+
end
|
|
110
124
|
end
|
|
111
125
|
|
|
126
|
+
# The generator method returns the generator object associated with this
|
|
127
|
+
# context.
|
|
128
|
+
#
|
|
129
|
+
# @return [ ContextSpook::Generator ] the generator instance that created
|
|
130
|
+
# this context
|
|
112
131
|
attr_reader :generator
|
|
113
132
|
|
|
114
133
|
delegate :verbose, to: :generator
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# TOON (Token-Oriented Object Notation)
|
|
2
|
+
|
|
3
|
+
It is a compact, human-readable serialization format that reduces JSON token
|
|
4
|
+
count by 30-40% while maintaining lossless data fidelity. It uses CSV-style
|
|
5
|
+
tabular arrays for uniform data structures and YAML-like indentation for nested
|
|
6
|
+
objects, making it ideal for LLM input where token efficiency and parsing
|
|
7
|
+
reliability matter.
|
|
8
|
+
|
|
9
|
+
Key benefit: Same data, fewer tokens, better LLM understanding.
|
|
10
|
+
|
|
11
|
+
**Original JSON:**
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"database": {
|
|
15
|
+
"name": "user_management",
|
|
16
|
+
"tables": [
|
|
17
|
+
{
|
|
18
|
+
"name": "users",
|
|
19
|
+
"columns": [
|
|
20
|
+
{
|
|
21
|
+
"name": "id",
|
|
22
|
+
"type": "integer",
|
|
23
|
+
"primary_key": true
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "email",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"unique": true
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"row_count": 1000
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "orders",
|
|
35
|
+
"columns": [
|
|
36
|
+
{
|
|
37
|
+
"name": "id",
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"primary_key": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "user_id",
|
|
43
|
+
"type": "integer"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"row_count": 5000
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**TOON equivalent:**
|
|
54
|
+
```
|
|
55
|
+
database:
|
|
56
|
+
name: user_management
|
|
57
|
+
tables[2]{name,row_count}:
|
|
58
|
+
users,1000
|
|
59
|
+
orders,5000
|
|
60
|
+
tables[2]{name,columns}:
|
|
61
|
+
users:
|
|
62
|
+
columns[2]{name,type,primary_key}:
|
|
63
|
+
id,integer,true
|
|
64
|
+
email,string,true
|
|
65
|
+
orders:
|
|
66
|
+
columns[2]{name,type}:
|
|
67
|
+
id,integer,true
|
|
68
|
+
user_id,integer,false
|
|
69
|
+
```
|
data/lib/context_spook/toon.rb
CHANGED
|
@@ -17,4 +17,17 @@ module ContextSpook::TOON
|
|
|
17
17
|
def toon_size
|
|
18
18
|
to_toon.size
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
# The toon_example method reads and returns the content of an example
|
|
22
|
+
# Markdown file that demonstrates the TOON (Token-Oriented Object Notation)
|
|
23
|
+
# format.
|
|
24
|
+
#
|
|
25
|
+
# This method is used to provide a sample representation of how context data
|
|
26
|
+
# can be formatted in TOON, which is an alternative serialization format
|
|
27
|
+
# supported by the ContextSpook library.
|
|
28
|
+
#
|
|
29
|
+
# @return [ String ] the content of the TOON example Markdown file
|
|
30
|
+
def toon_example
|
|
31
|
+
File.read(Pathname.new(__dir__) + 'toon/example.md')
|
|
32
|
+
end
|
|
20
33
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: context_spook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -221,6 +221,7 @@ files:
|
|
|
221
221
|
- lib/context_spook/generator.rb
|
|
222
222
|
- lib/context_spook/output_context.rb
|
|
223
223
|
- lib/context_spook/toon.rb
|
|
224
|
+
- lib/context_spook/toon/example.md
|
|
224
225
|
- lib/context_spook/utils.rb
|
|
225
226
|
- lib/context_spook/verbose_puts.rb
|
|
226
227
|
- lib/context_spook/version.rb
|