copilot-tap-extension 1.0.0 → 1.0.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/bin/install.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, mkdirSync, copyFileSync, readFileSync } from "node:fs";
3
+ import { execFileSync } from "node:child_process";
3
4
  import { fileURLToPath } from "node:url";
4
5
  import path from "node:path";
5
6
  import os from "node:os";
@@ -78,9 +79,13 @@ function parseArgs(argv) {
78
79
  return flags;
79
80
  }
80
81
 
82
+ function getCopilotHome() {
83
+ return process.env.COPILOT_HOME || path.join(os.homedir(), ".copilot");
84
+ }
85
+
81
86
  function getTargetRoot(scope) {
82
87
  if (scope === "global") {
83
- return path.join(os.homedir(), ".copilot");
88
+ return getCopilotHome();
84
89
  }
85
90
  return path.join(process.cwd(), ".github");
86
91
  }
@@ -109,10 +114,30 @@ function isAlreadyInstalled(targetRoot) {
109
114
  return existsSync(path.join(targetRoot, "extensions", EXT_DIR_NAME, "extension.mjs"));
110
115
  }
111
116
 
117
+ function isCopilotCliInstalled() {
118
+ if (existsSync(getCopilotHome())) {
119
+ return true;
120
+ }
121
+ try {
122
+ execFileSync("copilot", ["--version"], { stdio: "ignore", timeout: 5000 });
123
+ return true;
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+
112
129
  function install(flags) {
113
130
  const targetRoot = getTargetRoot(flags.scope);
114
131
  const scopeLabel = flags.scope === "global" ? "global (~/.copilot)" : "local (.github)";
115
132
  const packageVersion = getPackageVersion();
133
+
134
+ if (flags.scope === "global" && !isCopilotCliInstalled()) {
135
+ console.log(`\n⚠ Copilot CLI does not appear to be installed.`);
136
+ console.log(` Install it first: https://docs.github.com/en/copilot/github-copilot-in-the-cli`);
137
+ console.log(` Then re-run: npx copilot-tap-extension\n`);
138
+ process.exit(1);
139
+ }
140
+
116
141
  const installed = isAlreadyInstalled(targetRoot);
117
142
  const isUpdate = installed && !flags.full;
118
143
 
@@ -1530,8 +1530,9 @@ import path4 from "node:path";
1530
1530
  import os from "node:os";
1531
1531
  var PKG_NAME = "copilot-tap-extension";
1532
1532
  var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
1533
- var UPDATE_STATE_DIR = path4.join(os.homedir(), ".copilot");
1534
- var UPDATE_STATE_FILE = path4.join(UPDATE_STATE_DIR, ".tap-update-state.json");
1533
+ function getCopilotHome() {
1534
+ return process.env.COPILOT_HOME || path4.join(os.homedir(), ".copilot");
1535
+ }
1535
1536
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1536
1537
  function getInstalledVersion() {
1537
1538
  try {
@@ -1551,17 +1552,21 @@ function getInstalledVersion() {
1551
1552
  return null;
1552
1553
  }
1553
1554
  }
1555
+ function getUpdateStateFile() {
1556
+ return path4.join(getCopilotHome(), ".tap-update-state.json");
1557
+ }
1554
1558
  function readUpdateState() {
1555
1559
  try {
1556
- return JSON.parse(readFileSync2(UPDATE_STATE_FILE, "utf8"));
1560
+ return JSON.parse(readFileSync2(getUpdateStateFile(), "utf8"));
1557
1561
  } catch {
1558
1562
  return {};
1559
1563
  }
1560
1564
  }
1561
1565
  function writeUpdateState(state) {
1562
1566
  try {
1563
- mkdirSync(UPDATE_STATE_DIR, { recursive: true });
1564
- writeFileSync2(UPDATE_STATE_FILE, JSON.stringify(state, null, 2) + "\n");
1567
+ const stateDir = getCopilotHome();
1568
+ mkdirSync(stateDir, { recursive: true });
1569
+ writeFileSync2(getUpdateStateFile(), JSON.stringify(state, null, 2) + "\n");
1565
1570
  } catch {
1566
1571
  }
1567
1572
  }
package/dist/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.0"
2
+ "version": "1.0.1"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilot-tap-extension",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Copilot CLI extension for background event emitters, event streams, and session injection.",
5
5
  "type": "module",
6
6
  "license": "MIT",