@gowelle/stint-agent 1.0.7 → 1.0.8

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  apiService
3
- } from "./chunk-DPKCS26C.js";
3
+ } from "./chunk-5OKRSNU4.js";
4
4
  export {
5
5
  apiService
6
6
  };
@@ -2,7 +2,7 @@ import {
2
2
  apiService,
3
3
  config,
4
4
  logger
5
- } from "./chunk-DPKCS26C.js";
5
+ } from "./chunk-5OKRSNU4.js";
6
6
 
7
7
  // src/utils/process.ts
8
8
  import fs from "fs";
@@ -229,6 +229,15 @@ var GitServiceImpl = class {
229
229
  throw new Error(`Failed to get git status: ${error.message}`);
230
230
  }
231
231
  }
232
+ async getRepoRoot(path3) {
233
+ try {
234
+ const git = this.getGit(path3);
235
+ const root = await git.revparse(["--show-toplevel"]);
236
+ return root.trim();
237
+ } catch {
238
+ return null;
239
+ }
240
+ }
232
241
  };
233
242
  var gitService = new GitServiceImpl();
234
243
 
@@ -238,16 +247,20 @@ var ProjectServiceImpl = class {
238
247
  async linkProject(projectPath, projectId) {
239
248
  try {
240
249
  const absolutePath = path2.resolve(projectPath);
241
- const isRepo = await gitService.isRepo(absolutePath);
242
- if (!isRepo) {
243
- throw new Error(`${absolutePath} is not a git repository`);
250
+ const repoRoot = await gitService.getRepoRoot(absolutePath);
251
+ const linkPath = repoRoot || absolutePath;
252
+ if (!repoRoot) {
253
+ const isRepo = await gitService.isRepo(absolutePath);
254
+ if (!isRepo) {
255
+ throw new Error(`${absolutePath} is not a git repository`);
256
+ }
244
257
  }
245
258
  const linkedProject = {
246
259
  projectId,
247
260
  linkedAt: (/* @__PURE__ */ new Date()).toISOString()
248
261
  };
249
- config.setProject(absolutePath, linkedProject);
250
- logger.success("project", `Linked ${absolutePath} to project ${projectId}`);
262
+ config.setProject(linkPath, linkedProject);
263
+ logger.success("project", `Linked ${linkPath} must be to project ${projectId}`);
251
264
  } catch (error) {
252
265
  logger.error("project", "Failed to link project", error);
253
266
  throw error;
@@ -256,20 +269,29 @@ var ProjectServiceImpl = class {
256
269
  async unlinkProject(projectPath) {
257
270
  try {
258
271
  const absolutePath = path2.resolve(projectPath);
259
- const linkedProject = this.getLinkedProject(absolutePath);
272
+ const repoRoot = await gitService.getRepoRoot(absolutePath);
273
+ const lookupPath = repoRoot || absolutePath;
274
+ const linkedProject = config.getProject(lookupPath);
260
275
  if (!linkedProject) {
261
276
  throw new Error(`${absolutePath} is not linked to any project`);
262
277
  }
263
- config.removeProject(absolutePath);
264
- logger.success("project", `Unlinked ${absolutePath}`);
278
+ config.removeProject(lookupPath);
279
+ logger.success("project", `Unlinked ${lookupPath}`);
265
280
  } catch (error) {
266
281
  logger.error("project", "Failed to unlink project", error);
267
282
  throw error;
268
283
  }
269
284
  }
270
- getLinkedProject(projectPath) {
285
+ async getLinkedProject(projectPath) {
271
286
  const absolutePath = path2.resolve(projectPath);
272
- return config.getProject(absolutePath) || null;
287
+ let project = config.getProject(absolutePath);
288
+ if (project) return project;
289
+ const repoRoot = await gitService.getRepoRoot(absolutePath);
290
+ if (repoRoot) {
291
+ project = config.getProject(repoRoot);
292
+ if (project) return project;
293
+ }
294
+ return null;
273
295
  }
274
296
  getAllLinkedProjects() {
275
297
  return config.getProjects();
@@ -254,7 +254,7 @@ var AuthServiceImpl = class {
254
254
  return null;
255
255
  }
256
256
  try {
257
- const { apiService: apiService2 } = await import("./api-DA6X5ZWT.js");
257
+ const { apiService: apiService2 } = await import("./api-2MI5XBJX.js");
258
258
  const user = await apiService2.getCurrentUser();
259
259
  logger.info("auth", `Token validated for user: ${user.email}`);
260
260
  return user;
@@ -274,7 +274,7 @@ var AuthServiceImpl = class {
274
274
  var authService = new AuthServiceImpl();
275
275
 
276
276
  // src/services/api.ts
277
- var AGENT_VERSION = "1.0.7";
277
+ var AGENT_VERSION = "1.0.8";
278
278
  var ApiServiceImpl = class {
279
279
  sessionId = null;
280
280
  async getHeaders() {
@@ -5,13 +5,13 @@ import {
5
5
  projectService,
6
6
  removePidFile,
7
7
  writePidFile
8
- } from "../chunk-EEO2GKXF.js";
8
+ } from "../chunk-56UZEICO.js";
9
9
  import {
10
10
  apiService,
11
11
  authService,
12
12
  config,
13
13
  logger
14
- } from "../chunk-DPKCS26C.js";
14
+ } from "../chunk-5OKRSNU4.js";
15
15
 
16
16
  // src/daemon/runner.ts
17
17
  import "dotenv/config";
package/dist/index.js CHANGED
@@ -8,13 +8,13 @@ import {
8
8
  projectService,
9
9
  spawnDetached,
10
10
  validatePidFile
11
- } from "./chunk-EEO2GKXF.js";
11
+ } from "./chunk-56UZEICO.js";
12
12
  import {
13
13
  apiService,
14
14
  authService,
15
15
  config,
16
16
  logger
17
- } from "./chunk-DPKCS26C.js";
17
+ } from "./chunk-5OKRSNU4.js";
18
18
 
19
19
  // src/index.ts
20
20
  import "dotenv/config";
@@ -456,7 +456,7 @@ function registerLinkCommand(program2) {
456
456
  const spinner = ora4("Checking directory...").start();
457
457
  try {
458
458
  const cwd = process2.cwd();
459
- const existingLink = projectService.getLinkedProject(cwd);
459
+ const existingLink = await projectService.getLinkedProject(cwd);
460
460
  if (existingLink) {
461
461
  spinner.warn("Directory already linked");
462
462
  console.log(chalk4.yellow(`
@@ -562,7 +562,7 @@ function registerUnlinkCommand(program2) {
562
562
  const spinner = ora5("Checking directory...").start();
563
563
  try {
564
564
  const cwd = process3.cwd();
565
- const linkedProject = projectService.getLinkedProject(cwd);
565
+ const linkedProject = await projectService.getLinkedProject(cwd);
566
566
  if (!linkedProject) {
567
567
  spinner.info("Not linked");
568
568
  console.log(chalk5.yellow("\n\u26A0 This directory is not linked to any project.\n"));
@@ -613,7 +613,7 @@ function registerStatusCommand(program2) {
613
613
  const spinner = ora6("Gathering status...").start();
614
614
  try {
615
615
  const cwd = process4.cwd();
616
- const linkedProject = projectService.getLinkedProject(cwd);
616
+ const linkedProject = await projectService.getLinkedProject(cwd);
617
617
  const user = await authService.validateToken();
618
618
  spinner.stop();
619
619
  console.log(chalk6.blue("\n\u{1F4E6} Project Status:"));
@@ -698,7 +698,7 @@ function registerSyncCommand(program2) {
698
698
  const spinner = ora7("Checking directory...").start();
699
699
  try {
700
700
  const cwd = process5.cwd();
701
- const linkedProject = projectService.getLinkedProject(cwd);
701
+ const linkedProject = await projectService.getLinkedProject(cwd);
702
702
  if (!linkedProject) {
703
703
  spinner.fail("Not linked");
704
704
  console.log(chalk7.yellow("\n\u26A0 This directory is not linked to any project."));
@@ -937,7 +937,7 @@ function registerCommitCommands(program2) {
937
937
  const spinner = ora9("Loading pending commits...").start();
938
938
  try {
939
939
  const cwd = process6.cwd();
940
- const linkedProject = projectService.getLinkedProject(cwd);
940
+ const linkedProject = await projectService.getLinkedProject(cwd);
941
941
  if (!linkedProject) {
942
942
  spinner.fail("Not linked");
943
943
  console.log(chalk9.yellow("\n\u26A0 This directory is not linked to any project."));
@@ -979,7 +979,7 @@ function registerCommitCommands(program2) {
979
979
  const spinner = ora9("Checking repository status...").start();
980
980
  try {
981
981
  const cwd = process6.cwd();
982
- const linkedProject = projectService.getLinkedProject(cwd);
982
+ const linkedProject = await projectService.getLinkedProject(cwd);
983
983
  if (!linkedProject) {
984
984
  spinner.fail("Not linked");
985
985
  console.log(chalk9.yellow("\n\u26A0 This directory is not linked to any project."));
@@ -1328,9 +1328,9 @@ Current version: ${currentVersion}`));
1328
1328
  }
1329
1329
 
1330
1330
  // src/index.ts
1331
- var AGENT_VERSION = "1.0.7";
1331
+ var AGENT_VERSION = "1.0.8";
1332
1332
  var program = new Command();
1333
- program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION, "-v, -V, --version", "output the current version").addHelpText("after", `
1333
+ program.name("stint").description("Stint Agent - Local daemon for Stint Project Assistant").version(AGENT_VERSION, "-v, --version", "output the current version").addHelpText("after", `
1334
1334
  ${chalk12.bold("Examples:")}
1335
1335
  ${chalk12.cyan("$")} stint login ${chalk12.gray("# Authenticate with Stint")}
1336
1336
  ${chalk12.cyan("$")} stint install ${chalk12.gray("# Install agent to run on startup")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gowelle/stint-agent",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Local agent for Stint - Project Assistant",
5
5
  "author": "Gowelle John <gowelle.john@icloud.com>",
6
6
  "license": "MIT",