@bahulam/code 0.1.1 → 0.1.2
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/LICENSE +201 -0
- package/NOTICE +39 -0
- package/package.json +8 -6
- package/src/config/env.mjs +2 -2
- package/src/core/tool-executor.mjs +8 -0
- package/src/skills/installer.mjs +8 -0
- package/src/terminal/ansi.mjs +65 -6
- package/src/terminal/repl.mjs +188 -4
- package/src/terminal/skills-picker.mjs +121 -0
- package/src/terminal/skills.mjs +3 -3
- package/src/ui/banner.mjs +1 -1
- package/src/ui/slash-commands.mjs +16 -0
- package/src/ui/transcript-block.mjs +4 -1
package/LICENSE
ADDED
|
@@ -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 describing the origin of the Work and
|
|
141
|
+
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 accept and charge a
|
|
167
|
+
fee for acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and on
|
|
170
|
+
Your sole responsibility, not on behalf of any other Contributor, and
|
|
171
|
+
only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
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 2026 axplusb.tech
|
|
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.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Bahulam Code
|
|
2
|
+
Copyright 2026 axplusb.tech
|
|
3
|
+
|
|
4
|
+
This product includes software developed by axplusb.tech
|
|
5
|
+
(https://axplusb.tech).
|
|
6
|
+
|
|
7
|
+
------------------------------------------------------------------------
|
|
8
|
+
Upstream and third-party attribution
|
|
9
|
+
------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
The CLI runtime derives, in part, from the open-source open-claude-code
|
|
12
|
+
project. Original work bears its own copyright and license terms; those
|
|
13
|
+
files remain governed by their upstream licenses, and any modifications
|
|
14
|
+
to them by axplusb.tech are additionally licensed under Apache License,
|
|
15
|
+
Version 2.0 as declared in the LICENSE file at the root of this project.
|
|
16
|
+
|
|
17
|
+
The Bahulam runtime bundle (@bahulam/runtime-<platform>-<arch>) ships
|
|
18
|
+
with a PyArmor-obfuscated Python payload that is proprietary to
|
|
19
|
+
axplusb.tech and is NOT covered by the Apache License. It is distributed
|
|
20
|
+
under a separate end-user license embedded in the runtime as a signed
|
|
21
|
+
license JWT. Use of the runtime requires accepting that license.
|
|
22
|
+
|
|
23
|
+
Third-party npm dependencies listed in package.json are the property of
|
|
24
|
+
their respective owners and are used under the terms of the licenses
|
|
25
|
+
they publish. See the individual package license files under
|
|
26
|
+
node_modules/*/LICENSE for the specific terms of each dependency.
|
|
27
|
+
|
|
28
|
+
------------------------------------------------------------------------
|
|
29
|
+
Trademarks
|
|
30
|
+
------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
"Bahulam", the Bahulam wordmark, the ∞ mark, and "Orca" are trademarks
|
|
33
|
+
of axplusb.tech. The Apache License, Section 6, does not grant permission
|
|
34
|
+
to use these names, marks, or logos, except as required to describe the
|
|
35
|
+
origin of the software or to reproduce the content of this NOTICE file.
|
|
36
|
+
|
|
37
|
+
Forks and derivative works must select a distinct name and mark; the
|
|
38
|
+
Bahulam and Orca marks may not be used to name, brand, or promote any
|
|
39
|
+
derivative or competing distribution without prior written permission.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bahulam/code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Bahulam Code \u2014 abundance, in your terminal. CLI-first, reliability-first, sub-agents, 65.6% SWE-bench Verified.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"src/",
|
|
12
12
|
"pulse/",
|
|
13
|
-
"README.md"
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"NOTICE"
|
|
14
16
|
],
|
|
15
17
|
"scripts": {
|
|
16
18
|
"start": "node src/terminal/main.mjs",
|
|
@@ -36,7 +38,7 @@
|
|
|
36
38
|
"gemini",
|
|
37
39
|
"axplusb"
|
|
38
40
|
],
|
|
39
|
-
"license": "
|
|
41
|
+
"license": "Apache-2.0",
|
|
40
42
|
"author": "axplusb.tech <hello@axplusb.tech>",
|
|
41
43
|
"homepage": "https://bahulam.ai/code",
|
|
42
44
|
"repository": {
|
|
@@ -49,8 +51,8 @@
|
|
|
49
51
|
"web-tree-sitter": "^0.26.9"
|
|
50
52
|
},
|
|
51
53
|
"optionalDependencies": {
|
|
52
|
-
"@bahulam/runtime-darwin-arm64": "0.1.
|
|
53
|
-
"@bahulam/runtime-linux-x64": "0.1.
|
|
54
|
-
"@bahulam/runtime-win32-x64": "0.1.
|
|
54
|
+
"@bahulam/runtime-darwin-arm64": "0.1.2",
|
|
55
|
+
"@bahulam/runtime-linux-x64": "0.1.2",
|
|
56
|
+
"@bahulam/runtime-win32-x64": "0.1.2"
|
|
55
57
|
}
|
|
56
58
|
}
|
package/src/config/env.mjs
CHANGED
|
@@ -35,7 +35,7 @@ export const ENV_SCHEMA = {
|
|
|
35
35
|
|
|
36
36
|
// Permission and Security
|
|
37
37
|
CLAUDE_CODE_PERMISSION_MODE: { type: 'string', default: 'default', description: 'Permission mode' },
|
|
38
|
-
|
|
38
|
+
BAHULAM_SANDBOX: { type: 'boolean', default: true, description: 'Wrap contained/high-risk shell commands in the OS sandbox (bwrap/seatbelt)' },
|
|
39
39
|
|
|
40
40
|
// Context and Memory
|
|
41
41
|
CLAUDE_CODE_MAX_CONTEXT_TOKENS: { type: 'number', default: 180000, description: 'Max context window tokens' },
|
|
@@ -81,7 +81,7 @@ export const ENV_SCHEMA = {
|
|
|
81
81
|
ANTHROPIC_AUTH_TOKEN: { type: 'string', description: 'Anthropic auth token (OAuth)' },
|
|
82
82
|
|
|
83
83
|
// Extended: Sandbox & Security
|
|
84
|
-
|
|
84
|
+
BAHULAM_SANDBOX_PLATFORM: { type: 'string', description: 'Override sandbox platform (linux/darwin)' },
|
|
85
85
|
CLAUDE_CODE_INJECTION_CHECK: { type: 'boolean', default: true, description: 'Enable command injection checks' },
|
|
86
86
|
CLAUDE_CODE_PATH_CHECK: { type: 'boolean', default: true, description: 'Enable file path validation' },
|
|
87
87
|
|
|
@@ -993,12 +993,20 @@ export function createToolExecutor({
|
|
|
993
993
|
const output = typeof result === 'string' ? result : String(result);
|
|
994
994
|
const content = output.replace(/^\s*\d+[→\t]/gm, '');
|
|
995
995
|
const actNudge = solutionNudge(filePath);
|
|
996
|
+
// Set _total_lines so the tool-card display doesn't have
|
|
997
|
+
// to compute line counts from the display-side `output`
|
|
998
|
+
// (which contains nudges + line-number prefixes that
|
|
999
|
+
// throw off the count and can render as "0 lines" when
|
|
1000
|
+
// downstream fallbacks miss the payload). Uses the
|
|
1001
|
+
// same split-by-newline convention as the >50-line
|
|
1002
|
+
// truncation branch above so both paths agree.
|
|
996
1003
|
return {
|
|
997
1004
|
success: !isError(output),
|
|
998
1005
|
content,
|
|
999
1006
|
output: output + nudge + actNudge,
|
|
1000
1007
|
_tool: 'read_file',
|
|
1001
1008
|
_output_type: 'file_content',
|
|
1009
|
+
_total_lines: content ? content.split('\n').length : 0,
|
|
1002
1010
|
};
|
|
1003
1011
|
},
|
|
1004
1012
|
);
|
package/src/skills/installer.mjs
CHANGED
|
@@ -119,12 +119,20 @@ export class SkillInstaller {
|
|
|
119
119
|
fs.mkdirSync(skillsDir, { recursive: true });
|
|
120
120
|
|
|
121
121
|
const plans = [];
|
|
122
|
+
const seenNames = new Set();
|
|
122
123
|
for (const skillDir of skillDirs) {
|
|
123
124
|
rejectSymlinks(skillDir);
|
|
124
125
|
const content = fs.readFileSync(path.join(skillDir, 'SKILL.md'), 'utf-8');
|
|
125
126
|
const name = parseSkill(content, path.basename(skillDir)).name;
|
|
126
127
|
if (onlyNames && !onlyNames.includes(name)) continue;
|
|
127
128
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name)) throw new Error(`Unsafe skill name: ${name}`);
|
|
129
|
+
// Source repos sometimes ship multiple SKILL.md bundles that all
|
|
130
|
+
// parse to the same name (e.g. one variant per agent tool).
|
|
131
|
+
// Silently keep only the FIRST occurrence — otherwise we'd copy
|
|
132
|
+
// N bundles into the same destination and the last write would
|
|
133
|
+
// win invisibly.
|
|
134
|
+
if (seenNames.has(name)) continue;
|
|
135
|
+
seenNames.add(name);
|
|
128
136
|
const destination = path.join(skillsDir, name);
|
|
129
137
|
if (fs.existsSync(destination)) {
|
|
130
138
|
if (!force) throw new Error(`Skill already installed: ${name} (use --force to replace)`);
|
package/src/terminal/ansi.mjs
CHANGED
|
@@ -600,21 +600,80 @@ function inlineMarkdown(text) {
|
|
|
600
600
|
/**
|
|
601
601
|
* Render a unified diff with +/- color highlighting.
|
|
602
602
|
*/
|
|
603
|
-
|
|
603
|
+
// Parses `@@ -old_start,old_count +new_start,new_count @@` from a unified
|
|
604
|
+
// diff hunk header. Missing counts default to 1 (per unified-diff spec).
|
|
605
|
+
const _HUNK_RE = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
606
|
+
|
|
607
|
+
function _padLineNo(n, width) {
|
|
608
|
+
return n === null ? ' '.repeat(width) : String(n).padStart(width);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Render a unified diff with GitHub-PR-style single-column line numbers.
|
|
613
|
+
*
|
|
614
|
+
* 12 context line
|
|
615
|
+
* 13 - removed line
|
|
616
|
+
* 13 + added line
|
|
617
|
+
* 14 context line
|
|
618
|
+
*
|
|
619
|
+
* Deletions show the OLD-side line number; additions and context show the
|
|
620
|
+
* NEW-side number. Hunk headers (`@@ ... @@`) are kept as visual section
|
|
621
|
+
* markers and seed the counters. Pass `{ numbers: false }` to fall back to
|
|
622
|
+
* the plain colored-only form.
|
|
623
|
+
*/
|
|
624
|
+
export function renderDiff(diffText, { numbers = true } = {}) {
|
|
604
625
|
if (!diffText) return '';
|
|
605
626
|
const lines = diffText.split('\n');
|
|
606
627
|
const out = [];
|
|
628
|
+
let oldLn = null;
|
|
629
|
+
let newLn = null;
|
|
630
|
+
// Width the gutter to the largest number that will appear in this diff,
|
|
631
|
+
// clamped to 4 so short diffs still line up cleanly. Prevents a single
|
|
632
|
+
// huge line number from pushing the whole gutter wide.
|
|
633
|
+
let gutterWidth = 4;
|
|
634
|
+
if (numbers) {
|
|
635
|
+
for (const line of lines) {
|
|
636
|
+
const m = line.match(_HUNK_RE);
|
|
637
|
+
if (m) {
|
|
638
|
+
const maxNum = Math.max(parseInt(m[1], 10), parseInt(m[2], 10));
|
|
639
|
+
gutterWidth = Math.max(gutterWidth, String(maxNum + 200).length);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
607
644
|
for (const line of lines) {
|
|
608
645
|
if (line.startsWith('+++') || line.startsWith('---')) {
|
|
609
646
|
out.push(c.bold(line));
|
|
610
|
-
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
const m = line.match(_HUNK_RE);
|
|
650
|
+
if (m) {
|
|
651
|
+
oldLn = parseInt(m[1], 10);
|
|
652
|
+
newLn = parseInt(m[2], 10);
|
|
611
653
|
out.push(c.brand(line));
|
|
612
|
-
|
|
613
|
-
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (!numbers || oldLn === null) {
|
|
657
|
+
if (line.startsWith('+')) out.push(c.green(line));
|
|
658
|
+
else if (line.startsWith('-')) out.push(c.red(line));
|
|
659
|
+
else out.push(c.gray(line));
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
if (line.startsWith('+')) {
|
|
663
|
+
out.push(`${c.gray(_padLineNo(newLn, gutterWidth))} ${c.green(line)}`);
|
|
664
|
+
newLn += 1;
|
|
614
665
|
} else if (line.startsWith('-')) {
|
|
615
|
-
out.push(c.red(line));
|
|
666
|
+
out.push(`${c.gray(_padLineNo(oldLn, gutterWidth))} ${c.red(line)}`);
|
|
667
|
+
oldLn += 1;
|
|
668
|
+
} else if (line.startsWith('\\')) {
|
|
669
|
+
// "" — meta, no line-number applies.
|
|
670
|
+
out.push(`${' '.repeat(gutterWidth)} ${c.dim(line)}`);
|
|
616
671
|
} else {
|
|
617
|
-
|
|
672
|
+
// Context (line starts with a single space per unified-diff spec,
|
|
673
|
+
// or is truly empty for a blank context line).
|
|
674
|
+
out.push(`${c.gray(_padLineNo(newLn, gutterWidth))} ${c.gray(line)}`);
|
|
675
|
+
oldLn += 1;
|
|
676
|
+
newLn += 1;
|
|
618
677
|
}
|
|
619
678
|
}
|
|
620
679
|
return out.join('\n');
|
package/src/terminal/repl.mjs
CHANGED
|
@@ -49,6 +49,9 @@ import { resolveBackendUrl } from '../core/backend-url.mjs';
|
|
|
49
49
|
import { formatMessageWindow, lowWindowStatus, messagesRemaining } from '../core/rate-limit-display.mjs';
|
|
50
50
|
import { formatAgentErrorGuidance } from '../core/error-guidance.mjs';
|
|
51
51
|
import { BUILTIN_AGENTS, findBuiltinAgent, localAgentMatches, runAgent, runAgentDefinition } from './agents.mjs';
|
|
52
|
+
import { SkillInstaller } from '../skills/installer.mjs';
|
|
53
|
+
import { SkillsLoader } from '../skills/loader.mjs';
|
|
54
|
+
import { openSkillsPicker, formatSkillsList } from './skills-picker.mjs';
|
|
52
55
|
import { createAgentFile, isVsCodeTerminal, listLocalAgents, openAgentFile, syncAgentsToBackend } from '../agents/scaffold.mjs';
|
|
53
56
|
import { SessionManager } from '../core/session-manager.mjs';
|
|
54
57
|
import { parseArgs } from '../config/cli-args.mjs';
|
|
@@ -939,6 +942,163 @@ async function handleAgentsCommand(rest = '', ctx) {
|
|
|
939
942
|
printAgentsUsage();
|
|
940
943
|
}
|
|
941
944
|
|
|
945
|
+
function printSkillsUsage() {
|
|
946
|
+
process.stderr.write(` ${c.dim('Usage:')}\n`);
|
|
947
|
+
process.stderr.write(` ${c.dim(' /skills open interactive picker')}\n`);
|
|
948
|
+
process.stderr.write(` ${c.dim(' /skills list [--project] list installed skills')}\n`);
|
|
949
|
+
process.stderr.write(` ${c.dim(' /skills install <url|path> [--project] [--force]')}\n`);
|
|
950
|
+
process.stderr.write(` ${c.dim(' /skills view <name> [resource]')}\n`);
|
|
951
|
+
process.stderr.write(` ${c.dim(' /skills remove <name> [--project]')}\n`);
|
|
952
|
+
process.stderr.write(` ${c.dim(' /skills update <name> [--project]')}\n`);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
async function handleSkillsCommand(rest = '', ctx) {
|
|
956
|
+
const parts = String(rest || '').trim().split(/\s+/).filter(Boolean);
|
|
957
|
+
const hasFlag = (flag) => parts.includes(flag);
|
|
958
|
+
const positional = parts.filter(p => !p.startsWith('--'));
|
|
959
|
+
const action = (positional[0] || 'picker').toLowerCase();
|
|
960
|
+
const scope = hasFlag('--project') ? 'project' : 'global';
|
|
961
|
+
const cwd = safeCwd();
|
|
962
|
+
const installer = new SkillInstaller({ cwd });
|
|
963
|
+
const loader = new SkillsLoader().load(cwd);
|
|
964
|
+
|
|
965
|
+
if (action === 'picker' || action === '') {
|
|
966
|
+
const skills = loader.list({ scope: hasFlag('--all') ? '' : '' });
|
|
967
|
+
if (!skills.length) {
|
|
968
|
+
process.stderr.write(` ${c.dim('No skills installed yet.')}\n`);
|
|
969
|
+
process.stderr.write(` ${c.dim('Install one:')} ${c.brand('/skills install https://github.com/<user>/<repo>')}\n`);
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const rl = ctx?.rl || null;
|
|
973
|
+
const choice = await openSkillsPicker({ rl, skills });
|
|
974
|
+
if (!choice) {
|
|
975
|
+
process.stderr.write(formatSkillsList(skills));
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
if (choice.action === 'view') {
|
|
979
|
+
try {
|
|
980
|
+
const view = loader.view(choice.name, null);
|
|
981
|
+
process.stderr.write(`\n ${c.bold(view.name)} ${c.dim(`· ${view.source || ''}`)}\n`);
|
|
982
|
+
if (view.description) process.stderr.write(` ${c.dim(view.description)}\n`);
|
|
983
|
+
process.stderr.write(` ${c.gray('─'.repeat(60))}\n`);
|
|
984
|
+
process.stderr.write(renderMarkdown(String(view.instructions || '')) + '\n');
|
|
985
|
+
if (view.resources?.length) {
|
|
986
|
+
process.stderr.write(` ${c.dim('Bundled resources:')}\n`);
|
|
987
|
+
for (const r of view.resources.slice(0, 20)) process.stderr.write(` ${c.dim('·')} ${r}\n`);
|
|
988
|
+
if (view.resources.length > 20) process.stderr.write(` ${c.dim(`(+${view.resources.length - 20} more)`)}\n`);
|
|
989
|
+
process.stderr.write(` ${c.dim('View one:')} /skills view ${view.name} <path>\n`);
|
|
990
|
+
}
|
|
991
|
+
} catch (err) {
|
|
992
|
+
process.stderr.write(` ${c.red(err.message || String(err))}\n`);
|
|
993
|
+
}
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
if (choice.action === 'remove') {
|
|
997
|
+
try {
|
|
998
|
+
installer.remove(choice.name, { scope: 'global' });
|
|
999
|
+
process.stderr.write(` ${c.green('✓')} ${c.dim('Removed skill:')} ${choice.name}\n`);
|
|
1000
|
+
} catch (err) {
|
|
1001
|
+
// Try project scope if global failed.
|
|
1002
|
+
try {
|
|
1003
|
+
installer.remove(choice.name, { scope: 'project' });
|
|
1004
|
+
process.stderr.write(` ${c.green('✓')} ${c.dim('Removed skill:')} ${choice.name} ${c.dim('(project)')}\n`);
|
|
1005
|
+
} catch (err2) {
|
|
1006
|
+
process.stderr.write(` ${c.red(err2.message || String(err2))}\n`);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (action === 'list' || action === 'ls') {
|
|
1015
|
+
const filter = hasFlag('--all') ? '' : scope;
|
|
1016
|
+
const skills = loader.list({ scope: filter });
|
|
1017
|
+
process.stderr.write(formatSkillsList(skills));
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
if (action === 'install') {
|
|
1022
|
+
const source = positional[1];
|
|
1023
|
+
if (!source) {
|
|
1024
|
+
process.stderr.write(` ${c.yellow('Usage:')} /skills install <git-url|path> [--project] [--force]\n`);
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
try {
|
|
1028
|
+
process.stderr.write(` ${c.dim('Installing')} ${source} ${c.dim(`→ ${scope}`)}...\n`);
|
|
1029
|
+
const result = installer.install(source, { scope, force: hasFlag('--force') });
|
|
1030
|
+
const unique = [...new Set(result.installed || [])];
|
|
1031
|
+
const dupes = (result.installed?.length || 0) - unique.length;
|
|
1032
|
+
process.stderr.write(` ${c.green('✓')} ${c.dim('Installed:')} ${unique.join(', ') || '(none)'}\n`);
|
|
1033
|
+
if (dupes > 0) {
|
|
1034
|
+
process.stderr.write(` ${c.yellow('!')} ${c.dim(`Source shipped ${dupes} duplicate SKILL.md file(s) with the same name — last one won.`)}\n`);
|
|
1035
|
+
}
|
|
1036
|
+
process.stderr.write(` ${c.dim('Lock file:')} ${result.lock_file}\n`);
|
|
1037
|
+
} catch (err) {
|
|
1038
|
+
process.stderr.write(` ${c.red(err.message || String(err))}\n`);
|
|
1039
|
+
}
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (action === 'view') {
|
|
1044
|
+
const name = positional[1];
|
|
1045
|
+
if (!name) {
|
|
1046
|
+
process.stderr.write(` ${c.yellow('Usage:')} /skills view <name> [resource-path]\n`);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const resource = positional[2] || null;
|
|
1050
|
+
try {
|
|
1051
|
+
const view = loader.view(name, resource);
|
|
1052
|
+
process.stderr.write(`\n ${c.bold(view.name)}${resource ? c.dim(` · ${resource}`) : ''}\n`);
|
|
1053
|
+
if (!resource && view.description) process.stderr.write(` ${c.dim(view.description)}\n`);
|
|
1054
|
+
process.stderr.write(` ${c.gray('─'.repeat(60))}\n`);
|
|
1055
|
+
const body = resource ? view.content : view.instructions;
|
|
1056
|
+
process.stderr.write(renderMarkdown(String(body || '')) + '\n');
|
|
1057
|
+
if (!resource && view.resources?.length) {
|
|
1058
|
+
process.stderr.write(` ${c.dim('Bundled resources:')}\n`);
|
|
1059
|
+
for (const r of view.resources.slice(0, 20)) process.stderr.write(` ${c.dim('·')} ${r}\n`);
|
|
1060
|
+
if (view.resources.length > 20) process.stderr.write(` ${c.dim(`(+${view.resources.length - 20} more)`)}\n`);
|
|
1061
|
+
}
|
|
1062
|
+
} catch (err) {
|
|
1063
|
+
process.stderr.write(` ${c.red(err.message || String(err))}\n`);
|
|
1064
|
+
}
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (action === 'remove' || action === 'rm' || action === 'uninstall') {
|
|
1069
|
+
const name = positional[1];
|
|
1070
|
+
if (!name) {
|
|
1071
|
+
process.stderr.write(` ${c.yellow('Usage:')} /skills remove <name> [--project]\n`);
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
try {
|
|
1075
|
+
installer.remove(name, { scope });
|
|
1076
|
+
process.stderr.write(` ${c.green('✓')} ${c.dim('Removed:')} ${name} ${c.dim(`(${scope})`)}\n`);
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
process.stderr.write(` ${c.red(err.message || String(err))}\n`);
|
|
1079
|
+
}
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (action === 'update' || action === 'upgrade') {
|
|
1084
|
+
const name = positional[1];
|
|
1085
|
+
if (!name) {
|
|
1086
|
+
process.stderr.write(` ${c.yellow('Usage:')} /skills update <name> [--project]\n`);
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
try {
|
|
1090
|
+
const result = installer.update(name, { scope });
|
|
1091
|
+
process.stderr.write(` ${c.green('✓')} ${c.dim('Updated:')} ${name} ${c.dim(`(${scope})`)}\n`);
|
|
1092
|
+
if (result?.commit) process.stderr.write(` ${c.dim('Commit:')} ${result.commit.slice(0, 12)}\n`);
|
|
1093
|
+
} catch (err) {
|
|
1094
|
+
process.stderr.write(` ${c.red(err.message || String(err))}\n`);
|
|
1095
|
+
}
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
printSkillsUsage();
|
|
1100
|
+
}
|
|
1101
|
+
|
|
942
1102
|
function commandCompletions(line) {
|
|
943
1103
|
if (line.startsWith('/help ')) {
|
|
944
1104
|
const topic = line.slice('/help '.length).toLowerCase();
|
|
@@ -1241,6 +1401,16 @@ function foldedSubAgentName(data = {}) {
|
|
|
1241
1401
|
return data?.sub_agent || data?.agent || data?.type || 'sub-agent';
|
|
1242
1402
|
}
|
|
1243
1403
|
|
|
1404
|
+
function subAgentStartingLine(agentType = 'sub-agent') {
|
|
1405
|
+
const normalized = String(agentType || 'sub-agent').toLowerCase();
|
|
1406
|
+
if (normalized === 'plan') return '→ preparing plan handoff';
|
|
1407
|
+
if (normalized === 'explore') return '→ starting exploration';
|
|
1408
|
+
if (normalized === 'verify') return '→ preparing verification';
|
|
1409
|
+
if (normalized === 'debug') return '→ isolating failure context';
|
|
1410
|
+
if (normalized === 'refactor') return '→ preparing refactor pass';
|
|
1411
|
+
return `→ starting ${normalized}`;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1244
1414
|
function ensureFoldedSubAgentTools(agentType) {
|
|
1245
1415
|
const current = runtime.foldedSubAgentTools;
|
|
1246
1416
|
if (current && current.agentType === agentType) return current;
|
|
@@ -1533,11 +1703,19 @@ function renderEvent(event) {
|
|
|
1533
1703
|
const phaseTag = phase === 'mid_turn' ? 'mid-turn' : 'pre-turn';
|
|
1534
1704
|
const collapsed = Number(data?.collapsed_messages || 0);
|
|
1535
1705
|
const kept = Number(data?.kept_recent || 0);
|
|
1536
|
-
|
|
1537
|
-
|
|
1706
|
+
// PRD-213: backend now sends `before_tokens` (real when source is
|
|
1707
|
+
// `ground_truth`, chars/4 estimate when `estimator_fallback`) plus
|
|
1708
|
+
// the resolved threshold. Keep the legacy `before_est_tokens` fall-
|
|
1709
|
+
// back so an older backend that hasn't rolled out yet still renders.
|
|
1710
|
+
const before = Number(data?.before_tokens || data?.before_est_tokens || 0);
|
|
1711
|
+
const threshold = Number(data?.threshold || 160_000);
|
|
1712
|
+
const source = String(data?.source || 'estimator');
|
|
1713
|
+
const tokenLabel = source === 'ground_truth' ? 'real' : 'est';
|
|
1714
|
+
const beforeK = before ? ` · ${Math.round(before / 1000)}k/${Math.round(threshold / 1000)}k ${tokenLabel} tokens` : '';
|
|
1715
|
+
const sourceTag = source === 'ground_truth' ? '' : ` [${source}]`;
|
|
1538
1716
|
const keptPart = kept ? ` · kept last ${kept}` : '';
|
|
1539
1717
|
const preview = String(data?.summary_preview || '').trim();
|
|
1540
|
-
process.stderr.write(` ${c.brand('✎')} ${c.dim(`context summarized (${phaseTag}) · ${collapsed} older message${collapsed === 1 ? '' : 's'} collapsed${keptPart}${beforeK}`)}\n`);
|
|
1718
|
+
process.stderr.write(` ${c.brand('✎')} ${c.dim(`context summarized (${phaseTag}) · ${collapsed} older message${collapsed === 1 ? '' : 's'} collapsed${keptPart}${beforeK}${sourceTag}`)}\n`);
|
|
1541
1719
|
if (preview) {
|
|
1542
1720
|
process.stderr.write(` ${c.dim('› ' + preview)}\n`);
|
|
1543
1721
|
}
|
|
@@ -1780,6 +1958,7 @@ function renderEvent(event) {
|
|
|
1780
1958
|
// Phase per sub-agent run: the status line counts elapsed time and
|
|
1781
1959
|
// tool calls live ("plan agent · 4 calls · 32s") for the whole run.
|
|
1782
1960
|
startSpinner(`${agentType} agent`, { phase: `sub:${agentType}:${Date.now()}` });
|
|
1961
|
+
pushSubAgentWindowLine(subAgentStartingLine(agentType));
|
|
1783
1962
|
break;
|
|
1784
1963
|
}
|
|
1785
1964
|
|
|
@@ -3240,9 +3419,14 @@ async function handleCommand(input, ctx) {
|
|
|
3240
3419
|
}
|
|
3241
3420
|
|
|
3242
3421
|
case '/agents':
|
|
3422
|
+
case '/subagents':
|
|
3243
3423
|
await handleAgentsCommand(rest, ctx);
|
|
3244
3424
|
return;
|
|
3245
3425
|
|
|
3426
|
+
case '/skills':
|
|
3427
|
+
await handleSkillsCommand(rest, ctx);
|
|
3428
|
+
return;
|
|
3429
|
+
|
|
3246
3430
|
case '/explore':
|
|
3247
3431
|
case '/review':
|
|
3248
3432
|
case '/architect': {
|
|
@@ -3398,7 +3582,7 @@ export async function startTerminalRepl() {
|
|
|
3398
3582
|
stopSpinner();
|
|
3399
3583
|
flushContent();
|
|
3400
3584
|
flushPendingHead();
|
|
3401
|
-
|
|
3585
|
+
flushExploreRun();
|
|
3402
3586
|
runtime.foldedSubAgentTools = null;
|
|
3403
3587
|
clearCards();
|
|
3404
3588
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive skills picker — reuses the raw-stdin overlay pattern from
|
|
3
|
+
* repl-ask-form.mjs. Arrow keys move, Enter views the selected SKILL.md,
|
|
4
|
+
* Esc/q closes. Emits nothing when the terminal is not a TTY (falls
|
|
5
|
+
* back to plain-text listing at the call site).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { c, renderMarkdown, stripAnsi } from './ansi.mjs';
|
|
9
|
+
import { fitAnsiLine, writeOverlayFrame, eraseOverlayFrame } from './repl-format.mjs';
|
|
10
|
+
|
|
11
|
+
function truncate(str, max) {
|
|
12
|
+
const s = String(str || '');
|
|
13
|
+
if (s.length <= max) return s;
|
|
14
|
+
return s.slice(0, Math.max(1, max - 1)) + '…';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {object} opts
|
|
19
|
+
* @param {object|null} opts.rl readline instance to pause/resume
|
|
20
|
+
* @param {Array<{name,description,scope,source}>} opts.skills
|
|
21
|
+
* @returns {Promise<{action:'view',name:string}|{action:'remove',name:string}|null>}
|
|
22
|
+
*/
|
|
23
|
+
export async function openSkillsPicker({ rl, skills }) {
|
|
24
|
+
if (!process.stdin.isTTY) return null;
|
|
25
|
+
if (!skills?.length) return null;
|
|
26
|
+
if (rl) rl.pause();
|
|
27
|
+
|
|
28
|
+
const rows = skills.map(s => ({
|
|
29
|
+
name: s.name,
|
|
30
|
+
description: s.description || '',
|
|
31
|
+
scope: s.scope,
|
|
32
|
+
source: s.source,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
return await new Promise((resolve) => {
|
|
36
|
+
const wasRaw = process.stdin.isRaw;
|
|
37
|
+
let cursor = 0;
|
|
38
|
+
let renderedLines = 0;
|
|
39
|
+
|
|
40
|
+
const render = () => {
|
|
41
|
+
const cols = Math.max(60, process.stderr.columns || 120);
|
|
42
|
+
const nameWidth = Math.min(24, Math.max(...rows.map(r => r.name.length)));
|
|
43
|
+
const scopeWidth = 8;
|
|
44
|
+
const lines = [];
|
|
45
|
+
lines.push(` ${c.bold('Installed skills')} ${c.dim(`· ${rows.length} bundle${rows.length === 1 ? '' : 's'}`)}`);
|
|
46
|
+
lines.push('');
|
|
47
|
+
rows.forEach((row, i) => {
|
|
48
|
+
const active = i === cursor;
|
|
49
|
+
const marker = active ? c.brand('▸') : ' ';
|
|
50
|
+
const name = row.name.padEnd(nameWidth).slice(0, nameWidth);
|
|
51
|
+
const scope = row.scope.padEnd(scopeWidth).slice(0, scopeWidth);
|
|
52
|
+
const descBudget = Math.max(20, cols - 6 - nameWidth - scopeWidth - 4);
|
|
53
|
+
const desc = truncate(row.description, descBudget);
|
|
54
|
+
const painted = active
|
|
55
|
+
? `${c.brand(name)} ${c.dim(scope)} ${c.brand(desc)}`
|
|
56
|
+
: `${c.bold(name)} ${c.dim(scope)} ${desc}`;
|
|
57
|
+
lines.push(fitAnsiLine(` ${marker} ${painted}`, cols - 1));
|
|
58
|
+
});
|
|
59
|
+
lines.push('');
|
|
60
|
+
lines.push(fitAnsiLine(
|
|
61
|
+
` ${c.dim('↑↓ move · Enter view SKILL.md · r remove · Esc close')}`,
|
|
62
|
+
cols - 1,
|
|
63
|
+
));
|
|
64
|
+
writeOverlayFrame(renderedLines, lines);
|
|
65
|
+
renderedLines = lines.length;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const cleanup = (value) => {
|
|
69
|
+
process.stdin.removeListener('data', onData);
|
|
70
|
+
process.stdin.setRawMode(wasRaw || false);
|
|
71
|
+
eraseOverlayFrame(renderedLines);
|
|
72
|
+
if (rl) rl.resume();
|
|
73
|
+
resolve(value);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onData = (data) => {
|
|
77
|
+
const key = data.toString('utf8');
|
|
78
|
+
if (key === '\x1b' || key === '\x03' || key === 'q') { cleanup(null); return; }
|
|
79
|
+
if (key === '\r' || key === '\n') {
|
|
80
|
+
cleanup({ action: 'view', name: rows[cursor].name });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (key === 'r' || key === 'R') {
|
|
84
|
+
cleanup({ action: 'remove', name: rows[cursor].name });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (key === '\x1b[A' || key === 'k') { cursor = Math.max(0, cursor - 1); render(); return; }
|
|
88
|
+
if (key === '\x1b[B' || key === 'j') { cursor = Math.min(rows.length - 1, cursor + 1); render(); return; }
|
|
89
|
+
if (key === '\x1b[H' || key === 'g') { cursor = 0; render(); return; }
|
|
90
|
+
if (key === '\x1b[F' || key === 'G') { cursor = rows.length - 1; render(); return; }
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
process.stdin.setRawMode(true);
|
|
94
|
+
process.stdin.resume();
|
|
95
|
+
process.stdin.on('data', onData);
|
|
96
|
+
render();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Render a nicely-aligned static list (fallback when no TTY, or for `/skills list`).
|
|
102
|
+
* Returns the printable string; caller writes it to stderr.
|
|
103
|
+
*/
|
|
104
|
+
export function formatSkillsList(skills) {
|
|
105
|
+
if (!skills?.length) return ` ${c.dim('No skills installed. Try /skills install <git-url>')}\n`;
|
|
106
|
+
const nameWidth = Math.min(28, Math.max(...skills.map(s => s.name.length)));
|
|
107
|
+
const scopeWidth = 8;
|
|
108
|
+
const cols = Math.max(60, process.stderr.columns || 120);
|
|
109
|
+
const descBudget = Math.max(20, cols - 6 - nameWidth - scopeWidth - 4);
|
|
110
|
+
const lines = [` ${c.bold('Installed skills')} ${c.dim(`· ${skills.length} bundle${skills.length === 1 ? '' : 's'}`)}\n`];
|
|
111
|
+
for (const s of skills) {
|
|
112
|
+
const name = s.name.padEnd(nameWidth).slice(0, nameWidth);
|
|
113
|
+
const scope = String(s.scope || '').padEnd(scopeWidth).slice(0, scopeWidth);
|
|
114
|
+
const desc = truncate(s.description || '', descBudget);
|
|
115
|
+
lines.push(` ${c.bold(name)} ${c.dim(scope)} ${desc}\n`);
|
|
116
|
+
}
|
|
117
|
+
lines.push(`\n ${c.dim('Open interactively:')} /skills\n`);
|
|
118
|
+
return lines.join('');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { renderMarkdown, stripAnsi };
|
package/src/terminal/skills.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SkillInstaller } from '../skills/installer.mjs';
|
|
2
2
|
import { SkillsLoader } from '../skills/loader.mjs';
|
|
3
|
+
import { formatSkillsList } from './skills-picker.mjs';
|
|
3
4
|
|
|
4
5
|
function has(args, flag) {
|
|
5
6
|
return args.includes(flag);
|
|
@@ -22,9 +23,8 @@ export async function runSkillsCommand(args, { cwd = process.cwd() } = {}) {
|
|
|
22
23
|
|
|
23
24
|
if (action === 'list') {
|
|
24
25
|
const rows = loader.list({ scope: has(rest, '--all') ? '' : scope });
|
|
25
|
-
if (has(rest, '--json')) print(rows);
|
|
26
|
-
|
|
27
|
-
else for (const row of rows) print(`${row.name}\t${row.scope}\t${row.source}\t${row.description}`);
|
|
26
|
+
if (has(rest, '--json')) { print(rows); return; }
|
|
27
|
+
process.stdout.write(formatSkillsList(rows));
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
if (action === 'view') {
|
package/src/ui/banner.mjs
CHANGED
|
@@ -51,7 +51,7 @@ export function renderBanner(version = '') {
|
|
|
51
51
|
const lines = [''];
|
|
52
52
|
|
|
53
53
|
for (let i = 0; i < wordmark.length; i++) {
|
|
54
|
-
lines.push(` ${paint.
|
|
54
|
+
lines.push(` ${paint.text.muted(mark[i].padEnd(markWidth))} ${paint.bold(paint.brand.primary(wordmark[i]))}`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
lines.push(`${wordmarkIndent}${code} ${dim('· abundance in your terminal')}${vTag}`);
|
|
@@ -45,6 +45,8 @@ export const COMMANDS = {
|
|
|
45
45
|
'/surgical': 'Verbosity: show everything (reasoning, expanded tools)',
|
|
46
46
|
'/compact': 'Compact conversation context',
|
|
47
47
|
'/agents': 'List available agents',
|
|
48
|
+
'/subagents': 'Alias of /agents (list/create/edit/sync sub-agents)',
|
|
49
|
+
'/skills': 'List / install / view / remove skills (SKILL.md bundles)',
|
|
48
50
|
'/run': 'Run a sub-agent or synced workflow',
|
|
49
51
|
'/explore': 'Code explorer agent',
|
|
50
52
|
'/review': 'Code review agent',
|
|
@@ -146,6 +148,20 @@ export const HELP_GROUPS = [
|
|
|
146
148
|
['/architect <instruction>', 'Design an approach'],
|
|
147
149
|
],
|
|
148
150
|
},
|
|
151
|
+
{
|
|
152
|
+
key: 'skills',
|
|
153
|
+
title: 'Skills',
|
|
154
|
+
summary: 'SKILL.md bundles',
|
|
155
|
+
commands: [
|
|
156
|
+
['/skills', 'List installed skills'],
|
|
157
|
+
['/skills install <url|path>', 'Install from Git URL or local directory'],
|
|
158
|
+
['/skills install <src> --project', 'Install into .bahulam/skills (project scope)'],
|
|
159
|
+
['/skills install <src> --force', 'Overwrite an existing skill'],
|
|
160
|
+
['/skills view <name> [resource]', 'Show SKILL.md or a bundled resource'],
|
|
161
|
+
['/skills remove <name>', 'Uninstall a skill'],
|
|
162
|
+
['/skills update <name>', 'Reinstall from the recorded source'],
|
|
163
|
+
],
|
|
164
|
+
},
|
|
149
165
|
{
|
|
150
166
|
key: 'workflows',
|
|
151
167
|
title: 'Workflows',
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { paint } from './palette.mjs';
|
|
2
2
|
|
|
3
3
|
function tonePaint(tone) {
|
|
4
|
-
|
|
4
|
+
// 'user' tone was brand.accent (pink) — swapped to state.success (green)
|
|
5
|
+
// so the "your input" prompt reads as an active/go signal instead of the
|
|
6
|
+
// magenta 'attention/warn' tint the accent palette carries elsewhere.
|
|
7
|
+
return tone === 'user' ? paint.state.success : paint.brand.primary;
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
export function transcriptHeader(label, { tone = 'assistant' } = {}) {
|