@loopstack/git-examples 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/git-examples.module.d.ts +3 -0
- package/dist/git-examples.module.d.ts.map +1 -0
- package/dist/git-examples.module.js +36 -0
- package/dist/git-examples.module.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/workflows/git-commit-flow/git-commit-flow-example.workflow.d.ts +19 -0
- package/dist/workflows/git-commit-flow/git-commit-flow-example.workflow.d.ts.map +1 -0
- package/dist/workflows/git-commit-flow/git-commit-flow-example.workflow.js +104 -0
- package/dist/workflows/git-commit-flow/git-commit-flow-example.workflow.js.map +1 -0
- package/dist/workflows/github-repo-sync/github-repo-sync-example.workflow.d.ts +19 -0
- package/dist/workflows/github-repo-sync/github-repo-sync-example.workflow.d.ts.map +1 -0
- package/dist/workflows/github-repo-sync/github-repo-sync-example.workflow.js +67 -0
- package/dist/workflows/github-repo-sync/github-repo-sync-example.workflow.js.map +1 -0
- package/package.json +48 -0
- package/src/git-examples.module.ts +24 -0
- package/src/index.ts +3 -0
- package/src/workflows/git-commit-flow/git-commit-flow-example.workflow.ts +61 -0
- package/src/workflows/github-repo-sync/github-repo-sync-example.workflow.ts +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Git Examples
|
|
3
|
+
description: Git and GitHub workflow examples — scripted multi-tool git operations and end-to-end repo sync via ConnectGitHubWorkflow
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @loopstack/git-examples
|
|
7
|
+
|
|
8
|
+
> Git and GitHub workflow examples for the [Loopstack](https://loopstack.ai) automation framework.
|
|
9
|
+
|
|
10
|
+
Two workflow examples that show how to compose git tools and integrate with GitHub.
|
|
11
|
+
|
|
12
|
+
## Install as Source (Recommended)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx giget@latest gh:loopstack-ai/loopstack/registry/examples/git-examples src/git-examples
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Register the module:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Module } from '@nestjs/common';
|
|
22
|
+
import { LoopstackModule } from '@loopstack/loopstack-module';
|
|
23
|
+
import { GitExamplesModule } from './git-examples/git-examples.module';
|
|
24
|
+
|
|
25
|
+
@Module({
|
|
26
|
+
imports: [LoopstackModule.forRoot(), GitExamplesModule],
|
|
27
|
+
})
|
|
28
|
+
export class AppModule {}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Install as a Dependency
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @loopstack/git-examples
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { GitExamplesModule } from '@loopstack/git-examples';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Environment
|
|
42
|
+
|
|
43
|
+
The repo-sync example requires GitHub OAuth credentials:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
GITHUB_CLIENT_ID=...
|
|
47
|
+
GITHUB_CLIENT_SECRET=...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
| Example | Studio title | Description |
|
|
53
|
+
| ------------------------------------- | -------------------------------- | ---------------------------------------------------------------------- |
|
|
54
|
+
| [Git Commit Flow](#git-commit-flow) | `Git - Commit Flow Example` | Scripted multi-tool git workflow — status → add → commit → log, no LLM |
|
|
55
|
+
| [GitHub Repo Sync](#github-repo-sync) | `Git - GitHub Repo Sync Example` | Launches `ConnectGitHubWorkflow` for the full repo sync flow |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Git Commit Flow
|
|
60
|
+
|
|
61
|
+
A scripted workflow that orchestrates four git tools in sequence: `gitStatus`, `gitAdd`, `gitCommit`, `gitLog`. No LLM involved — demonstrates composing tools deterministically.
|
|
62
|
+
|
|
63
|
+
### Files
|
|
64
|
+
|
|
65
|
+
- `git-commit-flow-example.workflow.ts` — workflow class
|
|
66
|
+
|
|
67
|
+
## GitHub Repo Sync
|
|
68
|
+
|
|
69
|
+
Thin wrapper that launches `ConnectGitHubWorkflow` from `@loopstack/github-integration` as a sub-workflow. The integration handles the full sync flow: OAuth → create or pick repo → check uncommitted changes → resolve divergence → push.
|
|
70
|
+
|
|
71
|
+
### Files
|
|
72
|
+
|
|
73
|
+
- `github-repo-sync-example.workflow.ts` — workflow class
|
|
74
|
+
|
|
75
|
+
## About
|
|
76
|
+
|
|
77
|
+
Author: [Jakob Klippel](https://www.linkedin.com/in/jakob-klippel/)
|
|
78
|
+
|
|
79
|
+
License: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-examples.module.d.ts","sourceRoot":"","sources":["../src/git-examples.module.ts"],"names":[],"mappings":"AAUA,qBAaa,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GitExamplesModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const common_2 = require("@loopstack/common");
|
|
12
|
+
const git_module_1 = require("@loopstack/git-module");
|
|
13
|
+
const github_integration_1 = require("@loopstack/github-integration");
|
|
14
|
+
const remote_client_1 = require("@loopstack/remote-client");
|
|
15
|
+
const git_commit_flow_example_workflow_1 = require("./workflows/git-commit-flow/git-commit-flow-example.workflow");
|
|
16
|
+
const github_repo_sync_example_workflow_1 = require("./workflows/github-repo-sync/github-repo-sync-example.workflow");
|
|
17
|
+
const WORKFLOWS = [git_commit_flow_example_workflow_1.GitCommitFlowExampleWorkflow, github_repo_sync_example_workflow_1.GithubRepoSyncExampleWorkflow];
|
|
18
|
+
let GitExamplesModule = class GitExamplesModule {
|
|
19
|
+
};
|
|
20
|
+
exports.GitExamplesModule = GitExamplesModule;
|
|
21
|
+
exports.GitExamplesModule = GitExamplesModule = __decorate([
|
|
22
|
+
(0, common_2.StudioApp)({
|
|
23
|
+
title: 'Git Examples',
|
|
24
|
+
workflows: WORKFLOWS,
|
|
25
|
+
}),
|
|
26
|
+
(0, common_1.Module)({
|
|
27
|
+
imports: [
|
|
28
|
+
git_module_1.GitModule.forFeature(),
|
|
29
|
+
github_integration_1.GitHubIntegrationModule,
|
|
30
|
+
remote_client_1.RemoteClientModule.forFeature({ slots: [{ id: 'sandbox', type: 'sandbox', title: 'Sandbox' }] }),
|
|
31
|
+
],
|
|
32
|
+
providers: WORKFLOWS,
|
|
33
|
+
exports: WORKFLOWS,
|
|
34
|
+
})
|
|
35
|
+
], GitExamplesModule);
|
|
36
|
+
//# sourceMappingURL=git-examples.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-examples.module.js","sourceRoot":"","sources":["../src/git-examples.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8CAA8C;AAC9C,sDAAkD;AAClD,sEAAwE;AACxE,4DAA8D;AAC9D,mHAA4G;AAC5G,sHAA+G;AAE/G,MAAM,SAAS,GAAG,CAAC,+DAA4B,EAAE,iEAA6B,CAAC,CAAC;AAezE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAb7B,IAAA,kBAAS,EAAC;QACT,KAAK,EAAE,cAAc;QACrB,SAAS,EAAE,SAAS;KACrB,CAAC;IACD,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS,CAAC,UAAU,EAAE;YACtB,4CAAuB;YACvB,kCAAkB,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;SACjG;QACD,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,SAAS;KACnB,CAAC;GACW,iBAAiB,CAAG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,8DAA8D,CAAC;AAC7E,cAAc,gEAAgE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./git-examples.module"), exports);
|
|
18
|
+
__exportStar(require("./workflows/git-commit-flow/git-commit-flow-example.workflow"), exports);
|
|
19
|
+
__exportStar(require("./workflows/github-repo-sync/github-repo-sync-example.workflow"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,+FAA6E;AAC7E,iGAA+E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
2
|
+
import { GitAddTool, GitCommitTool, GitLogTool, GitStatusTool } from '@loopstack/git-module';
|
|
3
|
+
import { WriteTool } from '@loopstack/remote-client';
|
|
4
|
+
export declare class GitCommitFlowExampleWorkflow extends BaseWorkflow {
|
|
5
|
+
private readonly write;
|
|
6
|
+
private readonly gitStatus;
|
|
7
|
+
private readonly gitAdd;
|
|
8
|
+
private readonly gitCommit;
|
|
9
|
+
private readonly gitLog;
|
|
10
|
+
constructor(write: WriteTool, gitStatus: GitStatusTool, gitAdd: GitAddTool, gitCommit: GitCommitTool, gitLog: GitLogTool);
|
|
11
|
+
writeTestFile(): Promise<void>;
|
|
12
|
+
checkStatus(): Promise<void>;
|
|
13
|
+
stageAll(): Promise<void>;
|
|
14
|
+
commit(state: {
|
|
15
|
+
stamp: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
readBack(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=git-commit-flow-example.workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-commit-flow-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/git-commit-flow/git-commit-flow-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyC,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,qBAKa,4BAA6B,SAAQ,YAAY;IAE1D,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAJN,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU;IAM/B,aAAa;IAWb,WAAW;IASX,QAAQ;IAKR,MAAM,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAO/B,QAAQ;CAOf"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GitCommitFlowExampleWorkflow = void 0;
|
|
13
|
+
const common_1 = require("@loopstack/common");
|
|
14
|
+
const git_module_1 = require("@loopstack/git-module");
|
|
15
|
+
const remote_client_1 = require("@loopstack/remote-client");
|
|
16
|
+
let GitCommitFlowExampleWorkflow = class GitCommitFlowExampleWorkflow extends common_1.BaseWorkflow {
|
|
17
|
+
write;
|
|
18
|
+
gitStatus;
|
|
19
|
+
gitAdd;
|
|
20
|
+
gitCommit;
|
|
21
|
+
gitLog;
|
|
22
|
+
constructor(write, gitStatus, gitAdd, gitCommit, gitLog) {
|
|
23
|
+
super();
|
|
24
|
+
this.write = write;
|
|
25
|
+
this.gitStatus = gitStatus;
|
|
26
|
+
this.gitAdd = gitAdd;
|
|
27
|
+
this.gitCommit = gitCommit;
|
|
28
|
+
this.gitLog = gitLog;
|
|
29
|
+
}
|
|
30
|
+
async writeTestFile() {
|
|
31
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
32
|
+
const filePath = `tmp/git-commit-flow-${stamp}.txt`;
|
|
33
|
+
await this.write.call({
|
|
34
|
+
file_path: filePath,
|
|
35
|
+
content: `Generated by git-commit-flow example at ${stamp}\n`,
|
|
36
|
+
});
|
|
37
|
+
this.assignState({ filePath, stamp });
|
|
38
|
+
}
|
|
39
|
+
async checkStatus() {
|
|
40
|
+
const status = await this.gitStatus.call();
|
|
41
|
+
await this.documentStore.save(common_1.MessageDocument, {
|
|
42
|
+
role: 'assistant',
|
|
43
|
+
text: `Status before commit:\n\`\`\`json\n${JSON.stringify(status.data, null, 2)}\n\`\`\``,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async stageAll() {
|
|
47
|
+
await this.gitAdd.call({ files: ['.'] });
|
|
48
|
+
}
|
|
49
|
+
async commit(state) {
|
|
50
|
+
await this.gitCommit.call({
|
|
51
|
+
message: `chore: example commit from git-commit-flow workflow (${state.stamp})`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async readBack() {
|
|
55
|
+
const log = await this.gitLog.call({ limit: 1 });
|
|
56
|
+
await this.documentStore.save(common_1.MessageDocument, {
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
text: `Latest commit:\n\`\`\`json\n${JSON.stringify(log.data, null, 2)}\n\`\`\``,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.GitCommitFlowExampleWorkflow = GitCommitFlowExampleWorkflow;
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, common_1.Transition)({ to: 'file_written' }),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", []),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], GitCommitFlowExampleWorkflow.prototype, "writeTestFile", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, common_1.Transition)({ from: 'file_written', to: 'status_checked' }),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", []),
|
|
73
|
+
__metadata("design:returntype", Promise)
|
|
74
|
+
], GitCommitFlowExampleWorkflow.prototype, "checkStatus", null);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, common_1.Transition)({ from: 'status_checked', to: 'staged' }),
|
|
77
|
+
__metadata("design:type", Function),
|
|
78
|
+
__metadata("design:paramtypes", []),
|
|
79
|
+
__metadata("design:returntype", Promise)
|
|
80
|
+
], GitCommitFlowExampleWorkflow.prototype, "stageAll", null);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, common_1.Transition)({ from: 'staged', to: 'committed' }),
|
|
83
|
+
__metadata("design:type", Function),
|
|
84
|
+
__metadata("design:paramtypes", [Object]),
|
|
85
|
+
__metadata("design:returntype", Promise)
|
|
86
|
+
], GitCommitFlowExampleWorkflow.prototype, "commit", null);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_1.Transition)({ from: 'committed', to: 'end' }),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", []),
|
|
91
|
+
__metadata("design:returntype", Promise)
|
|
92
|
+
], GitCommitFlowExampleWorkflow.prototype, "readBack", null);
|
|
93
|
+
exports.GitCommitFlowExampleWorkflow = GitCommitFlowExampleWorkflow = __decorate([
|
|
94
|
+
(0, common_1.Workflow)({
|
|
95
|
+
title: 'Git - Commit Flow Example',
|
|
96
|
+
description: 'Scripted multi-tool git workflow: write test file → status → add → commit → log. Demonstrates composing tools without an LLM or agent loop.',
|
|
97
|
+
}),
|
|
98
|
+
__metadata("design:paramtypes", [remote_client_1.WriteTool,
|
|
99
|
+
git_module_1.GitStatusTool,
|
|
100
|
+
git_module_1.GitAddTool,
|
|
101
|
+
git_module_1.GitCommitTool,
|
|
102
|
+
git_module_1.GitLogTool])
|
|
103
|
+
], GitCommitFlowExampleWorkflow);
|
|
104
|
+
//# sourceMappingURL=git-commit-flow-example.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-commit-flow-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/git-commit-flow/git-commit-flow-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAwF;AACxF,sDAA6F;AAC7F,4DAAqD;AAO9C,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,qBAAY;IAEzC;IACA;IACA;IACA;IACA;IALnB,YACmB,KAAgB,EAChB,SAAwB,EACxB,MAAkB,EAClB,SAAwB,EACxB,MAAkB;QAEnC,KAAK,EAAE,CAAC;QANS,UAAK,GAAL,KAAK,CAAW;QAChB,cAAS,GAAT,SAAS,CAAe;QACxB,WAAM,GAAN,MAAM,CAAY;QAClB,cAAS,GAAT,SAAS,CAAe;QACxB,WAAM,GAAN,MAAM,CAAY;IAGrC,CAAC;IAGK,AAAN,KAAK,CAAC,aAAa;QACjB,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,uBAAuB,KAAK,MAAM,CAAC;QACpD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACpB,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,2CAA2C,KAAK,IAAI;SAC9D,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW;QACf,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,sCAAsC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU;SAC3F,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAC,KAAwB;QACnC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YACxB,OAAO,EAAE,wDAAwD,KAAK,CAAC,KAAK,GAAG;SAChF,CAAC,CAAC;IACL,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ;QACZ,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAe,EAAE;YAC7C,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,+BAA+B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU;SACjF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnDY,oEAA4B;AAYjC;IADL,IAAA,mBAAU,EAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC;;;;iEASlC;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC;;;;+DAO1D;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;;;;4DAGpD;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;;;;0DAK/C;AAGK;IADL,IAAA,mBAAU,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;;;;4DAO5C;uCAlDU,4BAA4B;IALxC,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,2BAA2B;QAClC,WAAW,EACT,6IAA6I;KAChJ,CAAC;qCAG0B,yBAAS;QACL,0BAAa;QAChB,uBAAU;QACP,0BAAa;QAChB,uBAAU;GAN1B,4BAA4B,CAmDxC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
3
|
+
import type { TransitionInput } from '@loopstack/common';
|
|
4
|
+
import { ConnectGitHubWorkflow } from '@loopstack/github-integration';
|
|
5
|
+
declare const ConnectResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
6
|
+
repo: z.ZodString;
|
|
7
|
+
url: z.ZodString;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
cancelled: z.ZodLiteral<true>;
|
|
10
|
+
}, z.core.$strip>]>;
|
|
11
|
+
type ConnectResult = z.infer<typeof ConnectResultSchema>;
|
|
12
|
+
export declare class GithubRepoSyncExampleWorkflow extends BaseWorkflow {
|
|
13
|
+
private readonly connectGitHubWorkflow;
|
|
14
|
+
constructor(connectGitHubWorkflow: ConnectGitHubWorkflow);
|
|
15
|
+
connect(_state: Record<string, unknown>): Promise<void>;
|
|
16
|
+
connectComplete(_state: Record<string, unknown>, input: TransitionInput<ConnectResult>): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=github-repo-sync-example.workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-repo-sync-example.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/github-repo-sync/github-repo-sync-example.workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAA0C,MAAM,mBAAmB,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,QAAA,MAAM,mBAAmB;;;;;mBAGvB,CAAC;AACH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEzD,qBAKa,6BAA8B,SAAQ,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAArB,qBAAqB,EAAE,qBAAqB;IAKnE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAavC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC;CAa7F"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GithubRepoSyncExampleWorkflow = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const github_integration_1 = require("@loopstack/github-integration");
|
|
16
|
+
const ConnectResultSchema = zod_1.z.union([
|
|
17
|
+
zod_1.z.object({ repo: zod_1.z.string(), url: zod_1.z.string() }),
|
|
18
|
+
zod_1.z.object({ cancelled: zod_1.z.literal(true) }),
|
|
19
|
+
]);
|
|
20
|
+
let GithubRepoSyncExampleWorkflow = class GithubRepoSyncExampleWorkflow extends common_1.BaseWorkflow {
|
|
21
|
+
connectGitHubWorkflow;
|
|
22
|
+
constructor(connectGitHubWorkflow) {
|
|
23
|
+
super();
|
|
24
|
+
this.connectGitHubWorkflow = connectGitHubWorkflow;
|
|
25
|
+
}
|
|
26
|
+
async connect(_state) {
|
|
27
|
+
await this.connectGitHubWorkflow.run({}, { callback: { transition: 'connectComplete' }, show: 'inline', label: 'Connecting to GitHub...' });
|
|
28
|
+
}
|
|
29
|
+
async connectComplete(_state, input) {
|
|
30
|
+
if ('cancelled' in input.data) {
|
|
31
|
+
await this.documentStore.save(common_1.MarkdownDocument, {
|
|
32
|
+
markdown: '### Cancelled\n\nThe sync was cancelled.',
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await this.documentStore.save(common_1.MarkdownDocument, {
|
|
37
|
+
markdown: `### Connected\n\nWorkspace synced with [${input.data.repo}](${input.data.url}).`,
|
|
38
|
+
});
|
|
39
|
+
this.setResult({ repo: input.data.repo, url: input.data.url });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.GithubRepoSyncExampleWorkflow = GithubRepoSyncExampleWorkflow;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, common_1.Transition)({ to: 'connecting' }),
|
|
45
|
+
__metadata("design:type", Function),
|
|
46
|
+
__metadata("design:paramtypes", [Object]),
|
|
47
|
+
__metadata("design:returntype", Promise)
|
|
48
|
+
], GithubRepoSyncExampleWorkflow.prototype, "connect", null);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, common_1.Transition)({
|
|
51
|
+
from: 'connecting',
|
|
52
|
+
to: 'end',
|
|
53
|
+
wait: true,
|
|
54
|
+
schema: ConnectResultSchema,
|
|
55
|
+
}),
|
|
56
|
+
__metadata("design:type", Function),
|
|
57
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
58
|
+
__metadata("design:returntype", Promise)
|
|
59
|
+
], GithubRepoSyncExampleWorkflow.prototype, "connectComplete", null);
|
|
60
|
+
exports.GithubRepoSyncExampleWorkflow = GithubRepoSyncExampleWorkflow = __decorate([
|
|
61
|
+
(0, common_1.Workflow)({
|
|
62
|
+
title: 'Git - GitHub Repo Sync Example',
|
|
63
|
+
description: 'Launches the ConnectGitHubWorkflow from @loopstack/github-integration as a sub-workflow. End-to-end: OAuth → create or pick repo → handle uncommitted changes → resolve divergence → connect.',
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:paramtypes", [github_integration_1.ConnectGitHubWorkflow])
|
|
66
|
+
], GithubRepoSyncExampleWorkflow);
|
|
67
|
+
//# sourceMappingURL=github-repo-sync-example.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-repo-sync-example.workflow.js","sourceRoot":"","sources":["../../../src/workflows/github-repo-sync/github-repo-sync-example.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAAyF;AAEzF,sEAAsE;AAEtE,MAAM,mBAAmB,GAAG,OAAC,CAAC,KAAK,CAAC;IAClC,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IAC/C,OAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;CACzC,CAAC,CAAC;AAQI,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,qBAAY;IAChC;IAA7B,YAA6B,qBAA4C;QACvE,KAAK,EAAE,CAAC;QADmB,0BAAqB,GAArB,qBAAqB,CAAuB;IAEzE,CAAC;IAGK,AAAN,KAAK,CAAC,OAAO,CAAC,MAA+B;QAC3C,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAClC,EAAE,EACF,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAClG,CAAC;IACJ,CAAC;IAQK,AAAN,KAAK,CAAC,eAAe,CAAC,MAA+B,EAAE,KAAqC;QAC1F,IAAI,WAAW,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAgB,EAAE;gBAC9C,QAAQ,EAAE,0CAA0C;aACrD,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAgB,EAAE;YAC9C,QAAQ,EAAE,2CAA2C,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI;SAC5F,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAwC,CAAC,CAAC;IACvG,CAAC;CACF,CAAA;AAhCY,sEAA6B;AAMlC;IADL,IAAA,mBAAU,EAAC,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC;;;;4DAMhC;AAQK;IANL,IAAA,mBAAU,EAAC;QACV,IAAI,EAAE,YAAY;QAClB,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,mBAAmB;KAC5B,CAAC;;;;oEAaD;wCA/BU,6BAA6B;IALzC,IAAA,iBAAQ,EAAC;QACR,KAAK,EAAE,gCAAgC;QACvC,WAAW,EACT,+LAA+L;KAClM,CAAC;qCAEoD,0CAAqB;GAD9D,6BAA6B,CAgCzC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loopstack/git-examples",
|
|
3
|
+
"displayName": "Loopstack Git Examples",
|
|
4
|
+
"description": "Git and GitHub workflow examples — scripted multi-tool git operations, and end-to-end GitHub repo sync via the ConnectGitHubWorkflow sub-workflow.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"loopstack",
|
|
7
|
+
"example",
|
|
8
|
+
"git",
|
|
9
|
+
"github",
|
|
10
|
+
"workflow"
|
|
11
|
+
],
|
|
12
|
+
"version": "0.1.1",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Jakob Klippel",
|
|
16
|
+
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./src/*": "./src/*"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "nest build",
|
|
26
|
+
"compile": "tsc --noEmit",
|
|
27
|
+
"format": "prettier --write .",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "vitest run --passWithNoTests",
|
|
30
|
+
"watch": "nest build --watch"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@loopstack/common": "*",
|
|
34
|
+
"@loopstack/git-module": "*",
|
|
35
|
+
"@loopstack/github-integration": "*",
|
|
36
|
+
"@nestjs/common": "^11.1.19",
|
|
37
|
+
"zod": "^4.3.6"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"src"
|
|
42
|
+
],
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"vitest": "^4.1.6",
|
|
45
|
+
"@swc/core": "^1.15.33",
|
|
46
|
+
"unplugin-swc": "^1.5.9"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { StudioApp } from '@loopstack/common';
|
|
3
|
+
import { GitModule } from '@loopstack/git-module';
|
|
4
|
+
import { GitHubIntegrationModule } from '@loopstack/github-integration';
|
|
5
|
+
import { RemoteClientModule } from '@loopstack/remote-client';
|
|
6
|
+
import { GitCommitFlowExampleWorkflow } from './workflows/git-commit-flow/git-commit-flow-example.workflow';
|
|
7
|
+
import { GithubRepoSyncExampleWorkflow } from './workflows/github-repo-sync/github-repo-sync-example.workflow';
|
|
8
|
+
|
|
9
|
+
const WORKFLOWS = [GitCommitFlowExampleWorkflow, GithubRepoSyncExampleWorkflow];
|
|
10
|
+
|
|
11
|
+
@StudioApp({
|
|
12
|
+
title: 'Git Examples',
|
|
13
|
+
workflows: WORKFLOWS,
|
|
14
|
+
})
|
|
15
|
+
@Module({
|
|
16
|
+
imports: [
|
|
17
|
+
GitModule.forFeature(),
|
|
18
|
+
GitHubIntegrationModule,
|
|
19
|
+
RemoteClientModule.forFeature({ slots: [{ id: 'sandbox', type: 'sandbox', title: 'Sandbox' }] }),
|
|
20
|
+
],
|
|
21
|
+
providers: WORKFLOWS,
|
|
22
|
+
exports: WORKFLOWS,
|
|
23
|
+
})
|
|
24
|
+
export class GitExamplesModule {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseWorkflow, MessageDocument, Transition, Workflow } from '@loopstack/common';
|
|
2
|
+
import { GitAddTool, GitCommitTool, GitLogTool, GitStatusTool } from '@loopstack/git-module';
|
|
3
|
+
import { WriteTool } from '@loopstack/remote-client';
|
|
4
|
+
|
|
5
|
+
@Workflow({
|
|
6
|
+
title: 'Git - Commit Flow Example',
|
|
7
|
+
description:
|
|
8
|
+
'Scripted multi-tool git workflow: write test file → status → add → commit → log. Demonstrates composing tools without an LLM or agent loop.',
|
|
9
|
+
})
|
|
10
|
+
export class GitCommitFlowExampleWorkflow extends BaseWorkflow {
|
|
11
|
+
constructor(
|
|
12
|
+
private readonly write: WriteTool,
|
|
13
|
+
private readonly gitStatus: GitStatusTool,
|
|
14
|
+
private readonly gitAdd: GitAddTool,
|
|
15
|
+
private readonly gitCommit: GitCommitTool,
|
|
16
|
+
private readonly gitLog: GitLogTool,
|
|
17
|
+
) {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Transition({ to: 'file_written' })
|
|
22
|
+
async writeTestFile() {
|
|
23
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
24
|
+
const filePath = `tmp/git-commit-flow-${stamp}.txt`;
|
|
25
|
+
await this.write.call({
|
|
26
|
+
file_path: filePath,
|
|
27
|
+
content: `Generated by git-commit-flow example at ${stamp}\n`,
|
|
28
|
+
});
|
|
29
|
+
this.assignState({ filePath, stamp });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Transition({ from: 'file_written', to: 'status_checked' })
|
|
33
|
+
async checkStatus() {
|
|
34
|
+
const status = await this.gitStatus.call();
|
|
35
|
+
await this.documentStore.save(MessageDocument, {
|
|
36
|
+
role: 'assistant',
|
|
37
|
+
text: `Status before commit:\n\`\`\`json\n${JSON.stringify(status.data, null, 2)}\n\`\`\``,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Transition({ from: 'status_checked', to: 'staged' })
|
|
42
|
+
async stageAll() {
|
|
43
|
+
await this.gitAdd.call({ files: ['.'] });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Transition({ from: 'staged', to: 'committed' })
|
|
47
|
+
async commit(state: { stamp: string }) {
|
|
48
|
+
await this.gitCommit.call({
|
|
49
|
+
message: `chore: example commit from git-commit-flow workflow (${state.stamp})`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Transition({ from: 'committed', to: 'end' })
|
|
54
|
+
async readBack() {
|
|
55
|
+
const log = await this.gitLog.call({ limit: 1 });
|
|
56
|
+
await this.documentStore.save(MessageDocument, {
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
text: `Latest commit:\n\`\`\`json\n${JSON.stringify(log.data, null, 2)}\n\`\`\``,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseWorkflow, MarkdownDocument, Transition, Workflow } from '@loopstack/common';
|
|
3
|
+
import type { TransitionInput } from '@loopstack/common';
|
|
4
|
+
import { ConnectGitHubWorkflow } from '@loopstack/github-integration';
|
|
5
|
+
|
|
6
|
+
const ConnectResultSchema = z.union([
|
|
7
|
+
z.object({ repo: z.string(), url: z.string() }),
|
|
8
|
+
z.object({ cancelled: z.literal(true) }),
|
|
9
|
+
]);
|
|
10
|
+
type ConnectResult = z.infer<typeof ConnectResultSchema>;
|
|
11
|
+
|
|
12
|
+
@Workflow({
|
|
13
|
+
title: 'Git - GitHub Repo Sync Example',
|
|
14
|
+
description:
|
|
15
|
+
'Launches the ConnectGitHubWorkflow from @loopstack/github-integration as a sub-workflow. End-to-end: OAuth → create or pick repo → handle uncommitted changes → resolve divergence → connect.',
|
|
16
|
+
})
|
|
17
|
+
export class GithubRepoSyncExampleWorkflow extends BaseWorkflow {
|
|
18
|
+
constructor(private readonly connectGitHubWorkflow: ConnectGitHubWorkflow) {
|
|
19
|
+
super();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Transition({ to: 'connecting' })
|
|
23
|
+
async connect(_state: Record<string, unknown>) {
|
|
24
|
+
await this.connectGitHubWorkflow.run(
|
|
25
|
+
{},
|
|
26
|
+
{ callback: { transition: 'connectComplete' }, show: 'inline', label: 'Connecting to GitHub...' },
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Transition({
|
|
31
|
+
from: 'connecting',
|
|
32
|
+
to: 'end',
|
|
33
|
+
wait: true,
|
|
34
|
+
schema: ConnectResultSchema,
|
|
35
|
+
})
|
|
36
|
+
async connectComplete(_state: Record<string, unknown>, input: TransitionInput<ConnectResult>) {
|
|
37
|
+
if ('cancelled' in input.data) {
|
|
38
|
+
await this.documentStore.save(MarkdownDocument, {
|
|
39
|
+
markdown: '### Cancelled\n\nThe sync was cancelled.',
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await this.documentStore.save(MarkdownDocument, {
|
|
45
|
+
markdown: `### Connected\n\nWorkspace synced with [${input.data.repo}](${input.data.url}).`,
|
|
46
|
+
});
|
|
47
|
+
this.setResult({ repo: input.data.repo, url: input.data.url } as unknown as Record<string, unknown>);
|
|
48
|
+
}
|
|
49
|
+
}
|