@hi-man/himan 0.2.0 → 0.3.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/.nvmrc +1 -0
- package/CHANGELOG.md +76 -0
- package/README.md +69 -64
- package/dist/adapters/git/repo-manager.js +41 -6
- package/dist/adapters/source/git-source-adapter.js +343 -16
- package/dist/adapters/source/registry-source-adapter.js +3 -0
- package/dist/cli/builders.js +1 -1
- package/dist/cli/source-commands.js +22 -0
- package/dist/domain/source-docs.js +1 -0
- package/dist/services/index.js +76 -37
- package/dist/state/index-cache-store.js +4 -3
- package/dist/utils/errors.js +2 -0
- package/docs/development.md +83 -0
- package/docs/error-codes.md +132 -0
- package/docs/mvp/README.md +143 -0
- package/docs/mvp/create-resource.md +198 -0
- package/docs/mvp/impl.md +111 -0
- package/package.json +26 -5
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.22.1
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on Keep a Changelog, and this project follows semver for the npm package version.
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.3.0] - 2026-05-07
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added `himan source init-docs` to scaffold source-level `README.md` and `CHANGELOG.md` files.
|
|
14
|
+
- Added automatic source-level README/CHANGELOG maintenance for resource create and publish flows.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Documented the recommended Git source repository-level `README.md` and `CHANGELOG.md` convention.
|
|
19
|
+
|
|
20
|
+
## [0.2.2] - 2026-05-07
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Added a PR verify workflow that runs typecheck, tests, and build before merging to `master`.
|
|
25
|
+
|
|
26
|
+
## [0.2.1] - 2026-05-07
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Added this changelog to make release notes and user-visible changes explicit.
|
|
31
|
+
- Added npm package metadata for Node.js engine compatibility and package discovery.
|
|
32
|
+
- Added public contributing, security, and code of conduct documents.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Clean `dist` before every build so npm packages cannot include stale generated files.
|
|
37
|
+
- Aligned MVP, v1.0, and roadmap docs with current resource type and multi-agent behavior.
|
|
38
|
+
- Added publish preflight checks for resource metadata and entry files, with stable publish error codes.
|
|
39
|
+
- Restored lock-file installs from the source recorded in `himan.lock` instead of the current default source.
|
|
40
|
+
- Updated repository links to `https://github.com/himan-group/himan`.
|
|
41
|
+
- Updated Git source refresh to fast-forward clean cached working trees after fetch while preserving dirty local edits.
|
|
42
|
+
- Updated list cache invalidation to track `himan.yaml` metadata content instead of parent directory mtimes.
|
|
43
|
+
- Moved developer, testing, release, and CI maintenance documentation from README to `docs/development.md`.
|
|
44
|
+
- Improved README installation guidance for npm, one-off execution, local development, and CLI entry points.
|
|
45
|
+
- Included README-linked user documentation in the npm package and changed GitHub workflow links to repository URLs.
|
|
46
|
+
|
|
47
|
+
## [0.2.0] - 2026-05-06
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- Added command groups for `source`, `resource`, `project`, and `agent`, while keeping backward-compatible top-level lifecycle commands.
|
|
52
|
+
- Added dedicated binaries: `himan-source`, `himan-resource`, and `himan-project`.
|
|
53
|
+
- Added default agent configuration commands for project and global scopes.
|
|
54
|
+
- Added multi-agent installation targets for `cursor`, `claude-code`, `codex`, and `openclaw`.
|
|
55
|
+
- Added `command` and `skill` lifecycle support across create, list, history, install, dev, publish, and uninstall flows.
|
|
56
|
+
- Added project `himan.lock` support for reproducible installs.
|
|
57
|
+
- Added copy install mode in addition to symlink mode.
|
|
58
|
+
- Added local index cache support for resource listing.
|
|
59
|
+
- Added repository guidance files for Codex workflows.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Split CLI registration into source, resource, project, agent, and shared command modules.
|
|
64
|
+
- Expanded README and planning docs to reflect multi-type resources, lock behavior, multi-agent targets, and source management.
|
|
65
|
+
|
|
66
|
+
## [0.1.0] - 2026-04-08
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- Initial Git-backed CLI for managing prompt and agent assets.
|
|
71
|
+
- Added source initialization, resource listing, history, install, dev, publish, create, and uninstall workflows.
|
|
72
|
+
- Added resource metadata scanning from `himan.yaml`.
|
|
73
|
+
- Added semver tag-based resource versioning.
|
|
74
|
+
- Added local store, repo cache, config, and index state foundations.
|
|
75
|
+
- Added npm publishing and version tag GitHub Actions workflows.
|
|
76
|
+
- Added Vitest coverage for adapters, state, utilities, and CLI integration paths.
|
package/README.md
CHANGED
|
@@ -2,29 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
himan(含义为"Hey, man"),AI Coding 时代的 Prompt / Agent 资产管理系统(CLI + Git source)
|
|
4
4
|
|
|
5
|
+
## 环境要求
|
|
6
|
+
|
|
7
|
+
- Node.js 22.x;本仓库开发环境由 [.nvmrc](./.nvmrc) 固定为 `22.22.1`。
|
|
8
|
+
- Git;Git source 的初始化、版本查询、安装和发布都依赖本机 Git。
|
|
9
|
+
|
|
5
10
|
## 安装与运行
|
|
6
11
|
|
|
12
|
+
### 使用 npm 包
|
|
13
|
+
|
|
14
|
+
全局安装后可直接使用 `himan`:
|
|
15
|
+
|
|
7
16
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
npm install -g @hi-man/himan
|
|
18
|
+
himan --help
|
|
10
19
|
```
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
也可以一次性运行主入口:
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
23
|
+
```bash
|
|
24
|
+
npx @hi-man/himan --help
|
|
25
|
+
pnpm dlx @hi-man/himan --help
|
|
26
|
+
```
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
### 命令入口
|
|
19
29
|
|
|
30
|
+
包内提供四个 CLI 入口:
|
|
31
|
+
|
|
32
|
+
- `himan <子命令>`(主入口)
|
|
20
33
|
- `himan-source <子命令>`(source 相关)
|
|
21
34
|
- `himan-resource <子命令>`(resource/project 相关)
|
|
22
35
|
- `himan-project <子命令>`(project 相关)
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
下文默认使用 `himan` 主入口;三个专用入口在对应章节单独列出。
|
|
25
38
|
|
|
26
39
|
## 一分钟上手
|
|
27
40
|
|
|
41
|
+
以下示例假设你已有一个可访问的 himan Git source 仓库,仓库中存在 `my-rule` 的资源版本 tag,并且你拥有发布所需的 Git push 权限。
|
|
42
|
+
|
|
28
43
|
```bash
|
|
29
44
|
himan init https://github.com/your-org/your-himan-registry.git
|
|
30
45
|
himan list rule
|
|
@@ -45,12 +60,49 @@ himan publish rule my-rule --patch
|
|
|
45
60
|
- `rule` -> `.himan/dev/rule/<name>`
|
|
46
61
|
- `command` -> `.himan/dev/command/<name>`
|
|
47
62
|
- `skill` -> `.himan/dev/skill/<name>`
|
|
48
|
-
- lock 文件:`install <type> <name[@version]>` 会写入 `himan.lock
|
|
63
|
+
- lock 文件:`install <type> <name[@version]>` 会写入 `himan.lock`,记录 source、精确版本、agent 和安装模式;`himan install`(无参数)会按 lock 记录的 source 批量恢复安装,不受当前 default source 切换影响。
|
|
49
64
|
- 安装模式:默认 `--mode link` 使用软链;也可用 `--mode copy` 将资源复制到目标 agent 目录,lock 会记录并复现该模式。
|
|
50
65
|
- 默认 agent:`agent use <agent>` 默认写当前项目 `.himan/config.json`;加 `--global` 写入 `~/.himan/config.json`。当前项目配置优先于全局配置。
|
|
51
66
|
|
|
52
67
|
版本以 Git tag 为准,格式:`rule/my-rule@1.0.0`。更多设计见 [docs/mvp](./docs/mvp/README.md)。
|
|
53
68
|
|
|
69
|
+
## Source 仓库结构
|
|
70
|
+
|
|
71
|
+
himan Git source 是一个普通 Git 仓库,推荐先维护仓库级 `README.md` 和 `CHANGELOG.md`,用于说明整个资源集合,而不是把说明文档塞进每个 agent 的最终消费目录。
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
your-himan-source/
|
|
75
|
+
README.md
|
|
76
|
+
CHANGELOG.md
|
|
77
|
+
rules/
|
|
78
|
+
my-rule/
|
|
79
|
+
himan.yaml
|
|
80
|
+
content.md
|
|
81
|
+
commands/
|
|
82
|
+
my-command/
|
|
83
|
+
himan.yaml
|
|
84
|
+
content.md
|
|
85
|
+
skills/
|
|
86
|
+
my-skill/
|
|
87
|
+
himan.yaml
|
|
88
|
+
SKILL.md
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- `README.md`:source 仓库入口文档,建议记录资源目录说明、推荐安装方式、默认 agent 策略、常用资源索引和维护约定。
|
|
92
|
+
- `CHANGELOG.md`:source 仓库级变更记录,建议记录新增、变更、废弃、移除的资源,以及重要版本发布说明。
|
|
93
|
+
- `rules/`、`commands/`、`skills/`:按资源类型分组;每个子目录是一份 himan 资源。
|
|
94
|
+
- `himan.yaml`:资源元数据,供 himan 扫描、发布和安装时读取。
|
|
95
|
+
- `content.md` / `SKILL.md`:资源主入口,由 `himan.yaml` 的 `entry` 字段指定。
|
|
96
|
+
|
|
97
|
+
可通过 `himan source init-docs` 为当前 default source 生成根目录文档模板;默认只创建缺失文件,`--force` 才覆盖已有 `README.md` / `CHANGELOG.md`,`--dry-run` 可预览结果。
|
|
98
|
+
|
|
99
|
+
`himan create` 和 `himan publish` 会自动维护 source 根目录文档:
|
|
100
|
+
|
|
101
|
+
- `README.md`:只更新 `<!-- himan:resources:start -->` 和 `<!-- himan:resources:end -->` 之间的资源索引;如果没有 marker,会在文件末尾追加一个受控资源索引区。
|
|
102
|
+
- `CHANGELOG.md`:向 `[Unreleased]` 下追加资源变更条目;`create` 记录 `Added`,`publish` 记录 `Changed` / published version。
|
|
103
|
+
|
|
104
|
+
仓库根目录的 `README.md` 和 `CHANGELOG.md` 不会被安装到 agent 目录;agent 只消费被安装的具体资源目录。当前安装实现会 materialize 资源目录本身,因此对 Cursor 这类要求特定单文件格式的 agent,资源目录内应避免放入会干扰识别的额外文件。
|
|
105
|
+
|
|
54
106
|
## 常用命令
|
|
55
107
|
|
|
56
108
|
### 1) source(数据源)
|
|
@@ -61,6 +113,7 @@ himan publish rule my-rule --patch
|
|
|
61
113
|
| `source add <name> <git_url>` | 添加命名 Git 源 |
|
|
62
114
|
| `source use <name>` | 切换默认源 |
|
|
63
115
|
| `source list [--json]` | 查看已配置源(标记当前 default) |
|
|
116
|
+
| `source init-docs [--force] [--dry-run] [--json]` | 为当前 default source 生成仓库级 README/CHANGELOG |
|
|
64
117
|
| `source init <git_url>` | 与 `init` 等价,便于统一走 `himan source ...` 入口 |
|
|
65
118
|
|
|
66
119
|
等价独立命令:
|
|
@@ -69,6 +122,7 @@ himan publish rule my-rule --patch
|
|
|
69
122
|
- `himan-source add <name> <git_url>`
|
|
70
123
|
- `himan-source use <name>`
|
|
71
124
|
- `himan-source list [--json]`
|
|
125
|
+
- `himan-source init-docs [--force] [--dry-run] [--json]`
|
|
72
126
|
|
|
73
127
|
### 2) resource(资源)
|
|
74
128
|
|
|
@@ -82,7 +136,7 @@ himan publish rule my-rule --patch
|
|
|
82
136
|
|
|
83
137
|
| 命令 | 说明 |
|
|
84
138
|
| --------------------------------- | --------------------------------------------------------- |
|
|
85
|
-
| `install [type] [name[@version]] [--agent a,b] [--mode link\|copy]` |
|
|
139
|
+
| `install [type] [name[@version]] [--agent a,b] [--mode link\|copy]` | 有参数时从当前 default source 安装指定资源;**无参数**时按 `himan.lock` 记录的 source 批量安装;可覆盖安装目标 agent 或安装模式 |
|
|
86
140
|
| `dev <type> <name>` | 切换到开发态,并按安装模式将项目目标指向或复制自 `.himan/dev/...` |
|
|
87
141
|
| `uninstall <type> <name>` | 从项目移除安装目标,并同步删除 `himan.lock` 条目 |
|
|
88
142
|
| `publish <type> <name>` | 默认 `--patch`;可选 `--minor` / `--major`(勿同时使用多个) |
|
|
@@ -107,15 +161,16 @@ himan publish rule my-rule --patch
|
|
|
107
161
|
说明:资源与项目相关命令统一使用 `--agent` 指定目标 Agent。
|
|
108
162
|
若未显式传 `--agent`,`create` / `install` 会使用当前项目默认 agent、全局默认 agent、资源 metadata 或内置默认 `cursor` 中最合适的一项;`dev` 会优先使用 lock 中记录的 agent。
|
|
109
163
|
|
|
110
|
-
`publish` 优先使用项目里 `.himan/dev`
|
|
164
|
+
`publish` 优先使用项目里 `.himan/dev` 对应目录,否则用源仓库里对应目录。发布前会校验 `himan.yaml` 与入口文件;需要可推送的 Git 权限。发布 commit 会包含资源目录以及自动维护的 source 根目录 `README.md` / `CHANGELOG.md`。若该资源已在 lock 中,发布后会同步更新 lock 版本。
|
|
111
165
|
|
|
112
166
|
`--json` 模式下,失败时会输出机器可读错误 JSON(`stderr`)。错误码定义见 [docs/error-codes.md](./docs/error-codes.md)。
|
|
113
167
|
|
|
114
|
-
|
|
168
|
+
多源说明:当前是「**多来源可配置,单来源生效**」模型。显式资源命令(`list/install <type> .../history/dev/publish`)作用于当前 default source;`himan install` 无参数恢复时使用 `himan.lock` 中记录的 source。
|
|
115
169
|
|
|
116
170
|
## 当前范围
|
|
117
171
|
|
|
118
172
|
- 源:**仅 Git**(`init`)。Registry 适配器已预留,尚未实现。
|
|
173
|
+
- 包定位:当前仅承诺 CLI 使用,不提供稳定的 Node.js 程序化 API。
|
|
119
174
|
|
|
120
175
|
## FAQ
|
|
121
176
|
|
|
@@ -133,56 +188,6 @@ himan source list
|
|
|
133
188
|
**Q: `list` 和 `source list` 有什么区别?**
|
|
134
189
|
A: `source list` 查看「我配置了哪些来源」;`list` 查看「当前 default source 里有哪些资源」。
|
|
135
190
|
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
pnpm test
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## 发布 npm 包(维护者)
|
|
143
|
-
|
|
144
|
-
### 流程概览
|
|
145
|
-
|
|
146
|
-
1. **在分支上完成开发与合并前检查**
|
|
147
|
-
本地可执行 `pnpm run verify`(类型检查、单测、`build`),确认通过后再提 PR。
|
|
148
|
-
|
|
149
|
-
2. **更新 `package.json` 中的 `version`**
|
|
150
|
-
npm 不允许重复发布同一版本号。合并进 `master` 前,在 PR 里把版本改成 registry 上尚未存在的号。
|
|
151
|
-
- 手动改 `version` 字段,或
|
|
152
|
-
- 在分支上执行其一(只改版本号,**不会**发包):`pnpm run version:patch` / `version:minor` / `version:major`(使用 `npm version … --no-git-tag-version`,需自行 `git add` / `commit` 版本变更)。
|
|
153
|
-
Git 标签约定:与 `version` 对应、带前缀 **`v`**(如 `1.2.0` → 标签 `v1.2.0`)。
|
|
154
|
-
|
|
155
|
-
3. **合并到 `master`**
|
|
156
|
-
推送合并后的 `master` 会触发 GitHub Actions 工作流 [`.github/workflows/publish-npm.yml`](.github/workflows/publish-npm.yml):安装依赖后执行 **`pnpm run release`**(即再次 `verify` + `npm publish`)。
|
|
157
|
-
npm 发布认证使用 **Trusted Publishing**,不使用长期 `NPM_TOKEN`。需在 npmjs.com 的 `@hi-man/himan` 包设置中添加 Trusted Publisher:
|
|
158
|
-
- Provider: GitHub Actions
|
|
159
|
-
- Organization or user: `lidetao`
|
|
160
|
-
- Repository: `himan`
|
|
161
|
-
- Workflow filename: `publish-npm.yml`
|
|
162
|
-
workflow 已授予 OIDC 所需的 `id-token: write` 权限,并在发布前升级 npm CLI 到支持 Trusted Publishing 的版本。
|
|
163
|
-
|
|
164
|
-
4. **手动从 CI 再发一次(可选)**
|
|
165
|
-
在 GitHub **Actions → Publish to npm → Run workflow** 可手动运行同一流程(例如在修复密钥后重试)。
|
|
166
|
-
|
|
167
|
-
### 本地命令(与 CI 中的 `pnpm run release` 一致)
|
|
168
|
-
|
|
169
|
-
| 命令 | 作用 |
|
|
170
|
-
|------|------|
|
|
171
|
-
| `pnpm run verify` | 仅检查(类型 / 测试 / 构建) |
|
|
172
|
-
| `pnpm run release:dry` | 检查 + `npm publish --dry-run`(演练,不上传) |
|
|
173
|
-
| `pnpm run release:test` | 检查 + 将版本打成 `*-test.*` 预发布号并发布到 **`@test` 标签** |
|
|
174
|
-
| `pnpm run release` | 检查 + 发布 **latest**(维护者本地发包时用;**请写 `pnpm run release`**,勿用裸命令 `pnpm publish`,二者不是同一套流程) |
|
|
175
|
-
| `pnpm run version:patch` / `version:minor` / `version:major` | 仅提升 `package.json` 版本号,不发包 |
|
|
176
|
-
|
|
177
|
-
发测试标签后,安装示例:`npm i @hi-man/himan@test`。
|
|
178
|
-
|
|
179
|
-
### CI:合并前校验与合并后打 Git 标签
|
|
180
|
-
|
|
181
|
-
| 工作流 | 文件 | 说明 |
|
|
182
|
-
|--------|------|------|
|
|
183
|
-
| **PR version tag check** | [`.github/workflows/pr-master-version-tag.yml`](.github/workflows/pr-master-version-tag.yml) | 目标分支为 `master` 的 PR:读取 **PR 头提交**上的 `package.json` 的 `version`,若远端已存在同名标签 **`v{version}`**,则 **检查失败**(用于在合并前拦截重复版本)。 |
|
|
184
|
-
| **Tag version on master** | [`.github/workflows/push-master-version-tag.yml`](.github/workflows/push-master-version-tag.yml) | 向 `master` **推送**后(含合并 PR):在 **当前推送提交**上创建并推送注释标签 **`v{version}`**。若标签已存在、创建或 `git push` 失败,仅输出 **告警**(`::warning::`),**工作流仍成功**,不撤销已发生的 merge;请按日志提示在本机补打标签并 `git push origin v{x.y.z}`。 |
|
|
185
|
-
|
|
186
|
-
**启用「合并前拦截」**:在 GitHub **Settings → Branches** 中为 `master` 配置分支保护,勾选 **Require status checks to pass before merging**,并勾选必选检查 **`PR version tag check / version-tag-available`**(名称以仓库里 Actions 界面为准)。
|
|
191
|
+
## 开发与维护
|
|
187
192
|
|
|
188
|
-
|
|
193
|
+
源码开发、测试和 npm 发包流程见 [docs/development.md](./docs/development.md)。
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { simpleGit } from "simple-git";
|
|
4
|
+
import { HimanError, errorCodes } from "../../utils/errors.js";
|
|
4
5
|
export class RepoManager {
|
|
5
6
|
async cloneOrFetch(repo, targetDir) {
|
|
6
7
|
const gitDir = path.join(targetDir, ".git");
|
|
@@ -12,6 +13,7 @@ export class RepoManager {
|
|
|
12
13
|
}
|
|
13
14
|
const git = simpleGit(targetDir);
|
|
14
15
|
await git.fetch(["--tags", "--prune"]);
|
|
16
|
+
await this.fastForwardCleanWorkingTree(git);
|
|
15
17
|
}
|
|
16
18
|
async listTags(repoDir, pattern) {
|
|
17
19
|
const git = simpleGit(repoDir);
|
|
@@ -44,14 +46,21 @@ export class RepoManager {
|
|
|
44
46
|
await fs.writeFile(destination, content, "utf8");
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
|
-
async commitTagAndPush(repoDir, message, tag, branch) {
|
|
49
|
+
async commitTagAndPush(repoDir, message, tag, branch, paths = ["."]) {
|
|
48
50
|
const git = simpleGit(repoDir);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const pathspecs = paths.length > 0 ? paths : ["."];
|
|
52
|
+
await git.add(pathspecs);
|
|
53
|
+
const stagedFiles = await git.raw([
|
|
54
|
+
"diff",
|
|
55
|
+
"--cached",
|
|
56
|
+
"--name-only",
|
|
57
|
+
"--",
|
|
58
|
+
...pathspecs,
|
|
59
|
+
]);
|
|
60
|
+
if (!stagedFiles.trim()) {
|
|
61
|
+
throw new HimanError(errorCodes.PUBLISH_NO_CHANGES, "No changes to publish.");
|
|
53
62
|
}
|
|
54
|
-
await git.commit(message);
|
|
63
|
+
await git.commit(message, pathspecs);
|
|
55
64
|
await git.addTag(tag);
|
|
56
65
|
const currentBranch = (await git.raw(["rev-parse", "--abbrev-ref", "HEAD"])).trim();
|
|
57
66
|
const targetBranch = branch ?? currentBranch;
|
|
@@ -67,4 +76,30 @@ export class RepoManager {
|
|
|
67
76
|
return false;
|
|
68
77
|
}
|
|
69
78
|
}
|
|
79
|
+
async fastForwardCleanWorkingTree(git) {
|
|
80
|
+
const status = await git.status();
|
|
81
|
+
if (!status.isClean()) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const upstream = await this.getCurrentUpstream(git);
|
|
85
|
+
if (!upstream) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await git.raw(["merge", "--ff-only", upstream]);
|
|
89
|
+
}
|
|
90
|
+
async getCurrentUpstream(git) {
|
|
91
|
+
try {
|
|
92
|
+
const upstream = await git.raw([
|
|
93
|
+
"rev-parse",
|
|
94
|
+
"--abbrev-ref",
|
|
95
|
+
"--symbolic-full-name",
|
|
96
|
+
"@{u}",
|
|
97
|
+
]);
|
|
98
|
+
const trimmed = upstream.trim();
|
|
99
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
70
105
|
}
|