@unity-china/codely-cli 1.0.0-rc.6 → 1.0.0-rc.60
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 +34 -0
- package/bundle/builtin/codely-guide/SKILL.md +77 -0
- package/bundle/builtin/codely-guide/references/app.md +125 -0
- package/bundle/builtin/skill-creator/scripts/package_skill.cjs +1 -3
- package/bundle/builtin/tuanjie-cli/SKILL.md +145 -0
- package/bundle/builtin/tuanjie-cli/references/commands.md +138 -0
- package/bundle/builtin-agents/explore.toml +62 -0
- package/bundle/builtin-agents/general-purpose.toml +34 -0
- package/bundle/builtin-agents/plan.toml +69 -0
- package/bundle/builtin-agents/unity-insight.toml +102 -0
- package/bundle/example-prompts/analyze.toml +3 -3
- package/bundle/gemini.js +3752 -6224
- package/bundle/gemini.js.LEGAL.txt +352 -105
- package/bundle/gemini.nologgers.js.LEGAL.txt +607 -0
- package/bundle/gemini.nosentry.js.LEGAL.txt +607 -0
- package/bundle/loop-detection-policies/default.toml +112 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/LICENSE.md +201 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/README.md +158 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/package.json +23 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/photon_rs.d.ts +3226 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/photon_rs.js +4521 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/photon_rs_bg.js +4270 -0
- package/bundle/node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm +0 -0
- package/bundle/node_modules/tree-sitter-bash/package.json +60 -0
- package/bundle/node_modules/tree-sitter-bash/tree-sitter-bash.wasm +0 -0
- package/bundle/node_modules/web-tree-sitter/package.json +98 -0
- package/bundle/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
- package/bundle/policies/plan.toml +30 -29
- package/bundle/policies/read-only.toml +0 -10
- package/bundle/policies/write.toml +0 -5
- package/bundle/sandbox-macos-permissive-closed.sb +1 -1
- package/bundle/sandbox-macos-permissive-open.sb +1 -1
- package/bundle/sandbox-macos-permissive-proxied.sb +2 -2
- package/bundle/sandbox-macos-restrictive-closed.sb +1 -1
- package/bundle/sandbox-macos-restrictive-open.sb +1 -1
- package/bundle/sandbox-macos-restrictive-proxied.sb +2 -2
- package/bundle/web-ui/dist/public/app.css +63 -0
- package/bundle/web-ui/dist/public/app.js +48 -48
- package/package.json +12 -11
- package/bundle/tiktoken_bg.wasm +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Codely built-in loop-detection evidence policy (DEFAULT tier).
|
|
2
|
+
# Override by placing files in:
|
|
3
|
+
# ~/.codely-cli/loop-detection-policies/*.toml
|
|
4
|
+
# (system) .../loop-detection-policies/*.toml
|
|
5
|
+
#
|
|
6
|
+
# judge_system_prompt configures only the policy body. The code always wraps it
|
|
7
|
+
# in fixed diagnostic, untrusted-data, non-execution, and response guardrails.
|
|
8
|
+
# Placeholders in this policy body:
|
|
9
|
+
# {{ignored_tools}} — comma-separated ignored tool patterns
|
|
10
|
+
# {{ignored_tools_section}} — full ignored-tools paragraph (or empty)
|
|
11
|
+
# {{analysis_max_chars}} — analysis length budget
|
|
12
|
+
#
|
|
13
|
+
# Threshold fields below are the shipped defaults (keep in sync with
|
|
14
|
+
# DEFAULT_LOOP_CYCLE_THRESHOLD_CONFIG in loopEvidencePolicy.ts). Higher-tier
|
|
15
|
+
# TOML may override individual fields; omitted fields keep these defaults.
|
|
16
|
+
# Same-tier conflicts resolve in ordinal (code-point) file order, independent
|
|
17
|
+
# of the system locale: thresholds/flags take the last ordinal declaration,
|
|
18
|
+
# rules take the first — and within one file, rules resolve by numeric
|
|
19
|
+
# declaration order (every toolName entry expanded from one rule shares its
|
|
20
|
+
# declaration index).
|
|
21
|
+
#
|
|
22
|
+
# Content detection layers:
|
|
23
|
+
# - Short fast-path: identical short chunks / same line, count from
|
|
24
|
+
# content_repeat_threshold (the length windows stay code constants)
|
|
25
|
+
# - Long-stream probe: tail needle grep → discover period length
|
|
26
|
+
|
|
27
|
+
version = 1
|
|
28
|
+
|
|
29
|
+
# Enable periodic tool-call cycle detection (A→B→A→B, k=2..tool_cycle_max_period).
|
|
30
|
+
# Does NOT disable content/reasoning probe detection.
|
|
31
|
+
enable_cycle_detection = true
|
|
32
|
+
|
|
33
|
+
# Max tool-cycle period length k (detect cycles of length 2..k). Range: 2–32.
|
|
34
|
+
tool_cycle_max_period = 32
|
|
35
|
+
|
|
36
|
+
# Full A→B periods required before a tool cycle is reported. Range: 2–20.
|
|
37
|
+
# Deliberately independent of tool_call_threshold: an alternating pattern is
|
|
38
|
+
# weaker evidence than a byte-identical consecutive repeat, so lowering the
|
|
39
|
+
# consecutive threshold must not make cycles fire sooner. A run of the *same*
|
|
40
|
+
# call is never reported here — that is tool_call_threshold's job.
|
|
41
|
+
tool_cycle_repeat_count = 3
|
|
42
|
+
|
|
43
|
+
# Consecutive byte-identical calls of the same tool before detection. The key is
|
|
44
|
+
# a hash of the tool name plus the full model-supplied arguments (never the call
|
|
45
|
+
# id), so a repeat carries no new information. Default 3 tolerates exactly one
|
|
46
|
+
# identical retry: an errored tool's response carries retry guidance, so the
|
|
47
|
+
# immediate same-args re-request is legitimate. Range: 2–20.
|
|
48
|
+
tool_call_threshold = 3
|
|
49
|
+
|
|
50
|
+
# Same, for read-only and whitelisted tools. `read_file` uses this value
|
|
51
|
+
# directly; other whitelisted tools (job_*) get an internal ×2. Range: 2–20.
|
|
52
|
+
# Read-only classification covers the current retrieval tools, e.g.
|
|
53
|
+
# search_file_content, glob, lsp, list_directory.
|
|
54
|
+
read_only_tool_call_threshold = 3
|
|
55
|
+
|
|
56
|
+
# Identical short chunks, or an identical line, repeated this many times in one
|
|
57
|
+
# stream. Kept high on purpose: echoing a file with repetitive lines is normal,
|
|
58
|
+
# so lower this only deliberately. Range: 2–50.
|
|
59
|
+
content_repeat_threshold = 10
|
|
60
|
+
|
|
61
|
+
# Detections within a single prompt before escalating from corrective feedback
|
|
62
|
+
# to a hard halt. Main agent only; subagents never escalate. Range: 1–10.
|
|
63
|
+
strike_threshold = 3
|
|
64
|
+
|
|
65
|
+
# Long-stream content/reasoning: how many full periods after probe finds a cycle.
|
|
66
|
+
# Range: 2–20. Note this is separate from content_repeat_threshold, and the bar
|
|
67
|
+
# after a read-only tool is raised internally to 10 periods.
|
|
68
|
+
content_probe_repeat_threshold = 3
|
|
69
|
+
|
|
70
|
+
# Minimum discovered period length (chars). Must be > short fast-path max (30)
|
|
71
|
+
# so probe does not false-trigger on short repeats. Range: 31–2000. Default: 48.
|
|
72
|
+
# Feasibility: min_period × content_probe_repeat_threshold ≤ 8192 (probe buffer).
|
|
73
|
+
content_probe_min_period_chars = 48
|
|
74
|
+
|
|
75
|
+
# Models matching these patterns disable ALL loop detection for that model
|
|
76
|
+
# instance (stream tool/content/reasoning, LLM judge, strike/recovery/halt).
|
|
77
|
+
# Exact match or a single trailing *; case-insensitive. Highest-tier TOML
|
|
78
|
+
# replaces the whole list (`[]` clears). Main and subagent each evaluate their
|
|
79
|
+
# own active model independently.
|
|
80
|
+
# Empty by default: no model is exempt out of the box. Opt in per model, e.g.
|
|
81
|
+
# loop_detection_exempt_model = ["codely-core*", "gpt-5*", "claude-*"]
|
|
82
|
+
loop_detection_exempt_model = []
|
|
83
|
+
|
|
84
|
+
judge_system_prompt = """
|
|
85
|
+
An unproductive state is characterized by one or more of the following patterns over the last 5 or more assistant turns:
|
|
86
|
+
|
|
87
|
+
Repetitive Actions: The assistant repeats the same tool calls or conversational responses a decent number of times. This includes simple loops (e.g., tool_A, tool_A, tool_A) and alternating patterns (e.g., tool_A, tool_B, tool_A, tool_B, ...).
|
|
88
|
+
|
|
89
|
+
Cognitive Loop: The assistant seems unable to determine the next logical step. It might express confusion, repeatedly ask the same questions, or generate responses that don't logically follow from the previous turns, indicating it's stuck and not advancing the task.
|
|
90
|
+
|
|
91
|
+
Crucially, differentiate between a true unproductive state and legitimate, incremental progress.
|
|
92
|
+
For example, a series of 'tool_A' or 'tool_B' tool calls that make small, distinct changes to the same file (like adding docstrings to functions one by one) is considered forward progress and is NOT a loop. A loop would be repeatedly replacing the same text with the same content, or cycling between a small set of files with no net change.
|
|
93
|
+
Batch edits across files, different regions of the same file, re-testing after edits, and searches with different parameters are NOT loops.
|
|
94
|
+
|
|
95
|
+
{{ignored_tools_section}}
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
# No loop-evidence rules ship by default: every tool counts as evidence.
|
|
99
|
+
#
|
|
100
|
+
# `loop_detection_rule` is the ONLY place these exemptions can come from — there
|
|
101
|
+
# are no hard-coded builtin rules. Exempting a tool is heavier than it looks: it
|
|
102
|
+
# hides the tool from the consecutive AND cycle detectors, and once ignored tools
|
|
103
|
+
# make up half of recent history the LLM judge is skipped entirely. Prefer
|
|
104
|
+
# raising a threshold over adding an exemption.
|
|
105
|
+
#
|
|
106
|
+
# To exempt a tool family, add it in a user/system policy file:
|
|
107
|
+
#
|
|
108
|
+
# [[loop_detection_rule]]
|
|
109
|
+
# name = "ignore my diagnostic tools"
|
|
110
|
+
# toolName = ["my_diag_*", "my_probe"]
|
|
111
|
+
# action = "ignore_as_evidence"
|
|
112
|
+
# priority = 500
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023, Silvia O'Dwyer
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="" rel="noopener">
|
|
3
|
+
<img src="https://i.imgur.com/GxrKNOb.png" alt="Photon banner, showing the Photon logo on a dark background"></a>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
|
|
8
|
+
[]()
|
|
9
|
+
[](https://github.com/silvia-odwyer/photon/issues)
|
|
10
|
+
[](https://github.com/silvia-odwyer/p/pulls)
|
|
11
|
+
[](https://gitter.im/photonlibrary/community "Gitter chat")
|
|
12
|
+
[](https://crates.io/crates/photon-rs)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<p align="center"> High-performance, cross-platform Rust/WebAssembly image processing library
|
|
19
|
+
<br>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
## 📝 Table of Contents
|
|
23
|
+
- [Get Started with WebAssembly](https://github.com/silvia-odwyer/photon#-get-started-with-webassembly)
|
|
24
|
+
- [Get Started Natively](https://github.com/silvia-odwyer/photon#getting-started)
|
|
25
|
+
- [Documentation](https://docs.rs/photon-rs/0.1.0/)
|
|
26
|
+
- [Official Website.](https://silvia-odwyer.github.io/photon/)
|
|
27
|
+
- [All Available Functions.](https://silvia-odwyer.github.io/photon/docs/photon/all.html)
|
|
28
|
+
- [Got Questions? Ask Here!](https://github.com/silvia-odwyer/photon#got-questions)
|
|
29
|
+
|
|
30
|
+
Photon is a high-performance Rust image processing library, which compiles to WebAssembly, allowing for
|
|
31
|
+
safe, blazing-fast image processing both natively and on the web.
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
- **Fast:** Photon outperforms even the fastest of libraries, including ImageMagick. On the web, its high-performance allows for near-native-speed image processing on the web. Benchmarks coming soon.
|
|
35
|
+
- **Call with JS:** Want to use Photon on the web or with Node? Using a simple npm package, you're good to go. Get all the benefits of WebAssembly
|
|
36
|
+
with zero-cost abstraction.
|
|
37
|
+
- **Use Natively:** For command-line apps, native photo editing apps, and so forth, Photon's core codebase is in Rust, allowing for cross-platform
|
|
38
|
+
development.
|
|
39
|
+
|
|
40
|
+
### Live Demo
|
|
41
|
+
View the [official demo of WASM in action](https://silvia-odwyer.github.io/photon/demo.html).
|
|
42
|
+
|
|
43
|
+
### Get Started
|
|
44
|
+
#### Getting Started Guide
|
|
45
|
+
Check out Photon's [getting started guide, complete with tutorials, installation instructions, and more](https://silvia-odwyer.github.io/photon/guide)
|
|
46
|
+
|
|
47
|
+
#### Documentation
|
|
48
|
+
### 📚 Documentation
|
|
49
|
+
View the [official documentation](https://docs.rs/photon-rs/).
|
|
50
|
+
|
|
51
|
+
### Photon In Action
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
### Functionality
|
|
56
|
+
96+ customisable functions are available.
|
|
57
|
+
|
|
58
|
+
Resize, transform, correct, and filter images: apply as many effects as desired.
|
|
59
|
+
|
|
60
|
+
Functions include:
|
|
61
|
+
- **Image correction**: Hue rotation, sharpening, brightness adjustment, adjusting saturation, lightening/darkening all within various colour spaces.
|
|
62
|
+
- **Convolutions**: Sobel filters, blurs, Laplace effects, edge detection, etc.,
|
|
63
|
+
- **Channel manipulation**: Increasing/decreasing RGB channel values, swapping channels, removing channels, etc.
|
|
64
|
+
- **Transform**: Resize, crop, rotate and flip images.
|
|
65
|
+
- **Monochrome effects**: Duotoning, greyscaling of various forms, thresholding, sepia, averaging RGB values
|
|
66
|
+
- **Colour manipulation**: Work with the image in various colour spaces such as HSL, LCh, and sRGB, and adjust the colours accordingly.
|
|
67
|
+
- **Filters**: Over 30 pre-set filters available, incorporating various effects and transformations.
|
|
68
|
+
- **Text**: Apply text to imagery in artistic ways, or to watermark, etc.,
|
|
69
|
+
- **Watermarking**: Watermark images in multiple formats.
|
|
70
|
+
- **Blending**: Blend images together using 10 different techniques, change image backgrounds.
|
|
71
|
+
|
|
72
|
+
## Install
|
|
73
|
+
### Native
|
|
74
|
+
Add the following line to the dependencies section of your Rust project's Cargo.toml:
|
|
75
|
+
|
|
76
|
+
###### Cargo.toml
|
|
77
|
+
```toml
|
|
78
|
+
[dependencies]
|
|
79
|
+
photon-rs = "0.3.2"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Web
|
|
83
|
+
Install Photon as an npm module:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install --save @silvia-odwyer/photon
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Node.JS
|
|
90
|
+
To install Photon as an npm module for Node.JS use:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm install --save @silvia-odwyer/photon-node
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Using Photon Natively
|
|
97
|
+
The following code opens an image from the filesystem, applies an effect, and saves it.
|
|
98
|
+
|
|
99
|
+
Here is a code sample to get you started:
|
|
100
|
+
|
|
101
|
+
```rs
|
|
102
|
+
extern crate photon_rs;
|
|
103
|
+
use photon_rs::native::{open_image, save_image};
|
|
104
|
+
|
|
105
|
+
fn main() {
|
|
106
|
+
// Open the image (a PhotonImage is returned)
|
|
107
|
+
let mut img = open_image("test_image.png");
|
|
108
|
+
|
|
109
|
+
// Increment the red channel by 40
|
|
110
|
+
photon_rs::channels::alter_red_channel(&mut img, 40);
|
|
111
|
+
|
|
112
|
+
// Write file to filesystem.
|
|
113
|
+
save_image(img, "raw_image.jpg");
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
[For more examples, check out the guide on how to get started with Photon natively.](https://silvia-odwyer.github.io/photon/guide/using-photon-natively/)
|
|
119
|
+
|
|
120
|
+
#### Using Photon On The Web
|
|
121
|
+
|
|
122
|
+
## Modules
|
|
123
|
+
Photon contains a series of modules, which include:
|
|
124
|
+
|
|
125
|
+
- `effects`: Various image effects, including adding offsets, thresholding, duotoning, solarization, etc.,
|
|
126
|
+
- `channels`: Functions related to increasing/decreasing the red, green, and blue channels of the image data.
|
|
127
|
+
- `transform`: Resize, crop, flip, and rotate images.
|
|
128
|
+
- `filters`: Preset filters, which alter the RGB channels of the image. Contains over 20.
|
|
129
|
+
- `conv`: Laplace, Sobel, emboss; image proc functions which require image convolution.
|
|
130
|
+
- `noise`: Noise generation of varying tints and hues.
|
|
131
|
+
- `multiple`: A module for dealing with multiple images, such as watermarking images, etc.,
|
|
132
|
+
- `correction`: Hue rotation, adjusting saturation, lightening/darkening: all techniques available in multiple colour spaces, which lead to varying effects.
|
|
133
|
+
|
|
134
|
+
All effects and filters can be viewed below and on the official website.
|
|
135
|
+
|
|
136
|
+
### Run Examples
|
|
137
|
+
Clone this crate's official GitHub repo:
|
|
138
|
+
```sh
|
|
139
|
+
git clone https://github.com/silvia-odwyer/photon
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Run the binary, which will perform an image processing function on an image:
|
|
143
|
+
```sh
|
|
144
|
+
cd crate
|
|
145
|
+
cargo run --release
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Compare the original image with the outputted image, and you'll see the desired effect has been applied.
|
|
149
|
+
|
|
150
|
+
### Got Questions?
|
|
151
|
+
If you'd like to chat to the developer about your potential use case, or have further questions about this library,
|
|
152
|
+
just submit them here, and I'll get back to you!
|
|
153
|
+
|
|
154
|
+
- [Spectrum Chat](https://spectrum.chat/photonlibrary)
|
|
155
|
+
- [Gitter](https://gitter.im/photonlibrary/community)
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@silvia-odwyer/photon-node",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"Silvia O'Dwyer <silviaodwyerdev@gmail.com>"
|
|
5
|
+
],
|
|
6
|
+
"description": "High-performance image processing library for native use and the web",
|
|
7
|
+
"version": "0.3.4",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/silvia-odwyer/photon"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"photon_rs_bg.wasm",
|
|
15
|
+
"photon_rs.js",
|
|
16
|
+
"photon_rs_bg.js",
|
|
17
|
+
"photon_rs.d.ts",
|
|
18
|
+
"LICENSE.md"
|
|
19
|
+
],
|
|
20
|
+
"main": "photon_rs.js",
|
|
21
|
+
"homepage": "https://silvia-odwyer.github.io/photon/",
|
|
22
|
+
"types": "photon_rs.d.ts"
|
|
23
|
+
}
|