@infinisys/is-devops 0.1.0 → 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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # @infinisys/is-devops
2
2
 
3
+ > **会改动 DSH 的默认行为。** 它注册的 Agent 工具能在你的仓库里建分支、提交、开合并请求。后果与退回写法见 [docs/disclaimer.md](https://gitfox.studio/infinity/Fabric/-/blob/master/docs/disclaimer.md)。
4
+
3
5
  GitFox 的 Harness 工程面板与 Agent 工具。
4
6
 
5
7
  ## 面板
package/index.js CHANGED
@@ -936,13 +936,20 @@ export function apply(ctx) {
936
936
  registerProxyRoutes(ctx);
937
937
  ctx.effect(() => ctx.tools.register(createTool(ctx, api)), 'is-devops: infinity_devops tool');
938
938
  ctx.effect(
939
- () => ctx.tools.register(createGitTool({ git, resolveActor: api.resolveActor })),
939
+ () =>
940
+ ctx.tools.register(
941
+ createGitTool({
942
+ git,
943
+ resolveActor: api.resolveActor,
944
+ directoryOf: (agent) => ctx.workingDirectory.get(agent.session),
945
+ }),
946
+ ),
940
947
  'is-devops: infinity_git tool',
941
948
  );
942
949
  }
943
950
 
944
951
  /** Services required by the Host half. */
945
- export const inject = ['infinitySettings', 'webServer', 'tools'];
952
+ export const inject = ['infinitySettings', 'webServer', 'tools', 'workingDirectory'];
946
953
 
947
954
  /** Re-exported for tests and sibling packages that resolve this module directly. */
948
955
  export { withQuery };
package/lib/git-tool.js CHANGED
@@ -96,10 +96,22 @@ function formatValue(value) {
96
96
  /**
97
97
  * Resolve the repository root for one tool call.
98
98
  *
99
+ * The header keeps the directory the session was opened with, so a worker that
100
+ * moved into a worktree still reports the project root there. The live
101
+ * directory (`workingDirectory` service) is what the call is actually running
102
+ * in, which is the repository a lane's commits belong to.
103
+ *
99
104
  * @param {{ agent?: { session?: { header?: { cwd?: unknown } } } }} [exec] - execution context.
105
+ * @param {((agent: object) => string | null) | undefined} directoryOf - live directory accessor.
100
106
  * @returns {string} absolute session workspace.
101
107
  */
102
- function workspaceRootFor(exec) {
108
+ function workspaceRootFor(exec, directoryOf) {
109
+ try {
110
+ const live = directoryOf?.(exec?.agent);
111
+ if (typeof live === 'string' && live !== '') return live;
112
+ } catch {
113
+ // A Host without the service, or one that cannot answer yet, keeps the header.
114
+ }
103
115
  const cwd = exec?.agent?.session?.header?.cwd;
104
116
  if (typeof cwd === 'string' && cwd !== '') return cwd;
105
117
  return process.cwd();
@@ -175,7 +187,7 @@ async function executeAction(git, action, args, context) {
175
187
  * @param {{ git: object, resolveActor: (agent?: object) => Promise<object> }} deps - wiring.
176
188
  * @returns {object} tool definition.
177
189
  */
178
- export function createGitTool({ git, resolveActor }) {
190
+ export function createGitTool({ git, resolveActor, directoryOf }) {
179
191
  return {
180
192
  name: 'infinity_git',
181
193
  description: TOOL_DESCRIPTION,
@@ -200,7 +212,7 @@ export function createGitTool({ git, resolveActor }) {
200
212
  exec.signal?.throwIfAborted();
201
213
  const actor = await resolveActor(exec.agent);
202
214
  const result = await executeAction(git, args.action, args, {
203
- workspaceRoot: workspaceRootFor(exec),
215
+ workspaceRoot: workspaceRootFor(exec, directoryOf),
204
216
  signal: exec.signal,
205
217
  actor,
206
218
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinisys/is-devops",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Infinity DevOps: GitFox issues, merge requests, commits and branches in a Harness panel, plus audited local Git and agent tools.",
5
5
  "license": "MIT",
6
6
  "repository": {