acp-vscode 0.3.2 → 0.3.3

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
@@ -92,7 +92,7 @@ Troubleshooting
92
92
  ---------------
93
93
 
94
94
  - Cache and stale index
95
- - The CLI writes a disk cache at `./.acp-cache/index.json` (30 minute TTL). If you see stale results or want to force a fresh fetch, remove the cache file and retry:
95
+ - By default the CLI writes a disk cache under the user's home directory in `~/.acp/cache/index.json` (30 minute TTL). When running in development or tests the CLI preserves the old behavior and keeps the cache in the current working directory at `./.acp-cache/index.json` to avoid surprising local workflows. If you see stale results or want to force a fresh fetch, remove the cache file and retry:
96
96
 
97
97
  ```bash
98
98
  rm -rf .acp-cache
@@ -147,6 +147,17 @@ Example:
147
147
 
148
148
  When multiple repos contain files with the same `id`, the fetcher adds an `_conflicts` array to the returned index listing conflicted ids. Consumers will display items as `repo:id` when necessary to disambiguate.
149
149
 
150
+ Local repo file (acp-repos.json)
151
+ -------------------------------
152
+
153
+ In addition to `ACP_REPOS_JSON` the CLI will look for a file named `acp-repos.json` in the `~/.acp` directory and use it to populate the upstream repo list if the environment variable is not set. This file should contain the same JSON array format as `ACP_REPOS_JSON` and is useful for per-user configuration without exporting environment variables. Precedence when building the repos list is:
154
+
155
+ 1. `ACP_REPOS_JSON` environment variable (highest priority)
156
+ 2. `~/.acp/acp-repos.json` file (if present)
157
+ 3. Built-in default repo (github/awesome-copilot)
158
+
159
+ Note: when running in development or tests the CLI will attempt to read `acp-repos.json` from the current working directory instead of `~/.acp` to keep test fixtures and local development predictable.
160
+
150
161
  Dry-run:
151
162
 
152
163
  You can preview what would be installed without writing files using --dry-run:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acp-vscode",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "CLI to install GitHub Awesome Copilot chatmodes, prompts, and instructions into VS Code workspace or user profile",
5
5
  "bin": {
6
6
  "acp-vscode": "./bin/acp-vscode.js"
package/src/fetcher.js CHANGED
@@ -1,8 +1,18 @@
1
1
  const axios = require('axios');
2
2
  const path = require('path');
3
3
  const fs = require('fs-extra');
4
+ const os = require('os');
4
5
  const cache = require('./cache');
5
6
 
7
+ // Helper to consistently decide where to store user-level data. In
8
+ // development and test environments prefer process.cwd() for predictable
9
+ // local workflows; otherwise use the user's homedir under ~/.acp.
10
+ function getBaseDir() {
11
+ return (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test')
12
+ ? process.cwd()
13
+ : path.join(os.homedir(), '.acp');
14
+ }
15
+
6
16
  // Default single upstream repo for backwards compatibility
7
17
  const DEFAULT_REPOS = [
8
18
  {
@@ -13,7 +23,11 @@ const DEFAULT_REPOS = [
13
23
  ];
14
24
 
15
25
  function diskPaths() {
16
- const DISK_CACHE_DIR = path.join(process.cwd(), '.acp-cache');
26
+ // In development and tests keep the old behavior (cwd) to avoid surprising
27
+ // local workflows and test expectations. Otherwise store cache under the
28
+ // user's home directory in ~/.acp/cache/index.json
29
+ const baseDir = getBaseDir();
30
+ const DISK_CACHE_DIR = path.join(baseDir, 'cache');
17
31
  const DISK_CACHE_FILE = path.join(DISK_CACHE_DIR, 'index.json');
18
32
  return { DISK_CACHE_DIR, DISK_CACHE_FILE };
19
33
  }
@@ -70,7 +84,7 @@ async function fetchIndex() {
70
84
  }
71
85
  }
72
86
 
73
- // Build repos list from env or default
87
+ // Build repos list from env, file, or default
74
88
  let repos = DEFAULT_REPOS;
75
89
  if (process.env.ACP_REPOS_JSON) {
76
90
  try {
@@ -79,6 +93,18 @@ async function fetchIndex() {
79
93
  } catch (e) {
80
94
  // ignore malformed env var and fall back to defaults
81
95
  }
96
+ } else {
97
+ // Try reading acp-repos.json from the user acp dir. Respect NODE_ENV handling
98
+ try {
99
+ const baseDir = getBaseDir();
100
+ const repoFile = path.join(baseDir, 'acp-repos.json');
101
+ if (await fs.pathExists(repoFile)) {
102
+ const fileContents = await fs.readJson(repoFile);
103
+ if (Array.isArray(fileContents) && fileContents.length > 0) repos = fileContents;
104
+ }
105
+ } catch (e) {
106
+ // ignore file read/parse errors and fall back to defaults
107
+ }
82
108
  }
83
109
 
84
110
  // Helper to parse frontmatter title from file content